Problem with data reception after iBus

Post here first, or if you can't find a relevant section!
Post Reply
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

Problem with data reception after iBus

Post by nawasaqi »

Hi all,
I have such a problem, namely I want to receive data via iBus from the flysky ia6b receiver.
The problem is that I get all 0 instead of specific values.
The same code uploaded to ArduinoMega works without a problem and with stm32 it does not want.
I tried on the STM32F411 / F401 blackpill, NUCLEO-F401RE plates and all the time I have only zeros.
  • Ch0: 0 ---- Ch1: 0 ---- Ch2: 0 ---- Ch3: 0 ---- Ch4: 0 ---- Ch5: 0 ---- Ch6: 0 ---- Ch7: 0 ---- Ch8: 0 ---- Ch9: 0 ---- Ch10: 0 ---- Ch11: 0 ---- Ch12: 0 ---- Ch13: 0 ---- Next
    Ch0: 0 ---- Ch1: 0 ---- Ch2: 0 ---- Ch3: 0 ---- Ch4: 0 ---- Ch5: 0 ---- Ch6: 0 ---- Ch7: 0 ---- Ch8: 0 ---- Ch9: 0 ---- Ch10: 0 ---- Ch11: 0 ---- Ch12: 0 ---- Ch13: 0 ---- Next
    Ch0: 0 ---- Ch1: 0 ---- Ch2: 0 ---- Ch3: 0 ---- Ch4: 0 ---- Ch5: 0 ---- Ch6: 0 ---- Ch7: 0 ---- Ch8: 0 ---- Ch9: 0 ---- Ch10: 0 ---- Ch11: 0 ---- Ch12: 0 ---- Ch13: 0 ---- Next
    Ch0: 0 ---- Ch1: 0 ---- Ch2: 0 ---- Ch3: 0 ---- Ch4: 0 ---- Ch5: 0 ---- Ch6: 0 ---- Ch7: 0 ---- Ch8: 0 ---- Ch9: 0 ---- Ch10: 0 ---- Ch11: 0 ---- Ch12: 0 ---- Ch13: 0 ---- Next
    Ch0: 0 ---- Ch1: 0 ---- Ch2: 0 ---- Ch3: 0 ---- Ch4: 0 ---- Ch5: 0 ---- Ch6: 0 ---- Ch7: 0 ---- Ch8: 0 ---- Ch9: 0 ---- Ch10: 0 ---- Ch11: 0 ---- Ch12: 0 ---- Ch13: 0 ---- Next

Code: Select all

#include <IBusBM.h>



IBusBM IBusServo;

//Arduino Mega
//HardwareSerial Serial2(17,16); 

//                      RX    TX
//HardwareSerial Serial2(PA3, PA2);
  
void setup() {
  Serial.begin(115200);

  IBusServo.begin(Serial2);

}

void loop() {
  ibusServo();

}
//
//
//

void ibusServo()
{
 // show first 14 servo channels
  for (int i=0; i<14 ; i++) {
    Serial.print("Ch");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(IBusServo.readChannel(i));
    Serial.print(" ---- ");

  }
 Serial.println("Next");

  delay(1000);
}

Has anyone encountered such a problem ??
I tried to download only Stm32Cores on a clean installation and IbusBM also does not work ;(

Image
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Problem with data reception after iBus

Post by fpiSTM »

It seems the library has been ported to support STM32 but only tested with STM32F1.
https://github.com/bmellink/IBusBM/pull/2

I think it is not enough generic.
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

Re: Problem with data reception after iBus

Post by nawasaqi »

The worst part is that exactly a year ago, maybe one and a half everything was working on the blackpill STM32F411.
And I did some dumb updates a while ago and it stopped working.
I installed clean windows10 for this arduino IDE earlier versions I only added STM32 and ibusBM. Unfortunately, no success.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Problem with data reception after iBus

Post by ag123 »

if you can output to the serial monitor
I'd suggest patch Serial.print() statements in the code, to see what is happening
there are some things that is a little curious
https://github.com/bmellink/IBusBM/blob ... BM.cpp#L84

Code: Select all

#if defined(_VARIANT_ARDUINO_STM32_)
void IBusBM::begin(HardwareSerial &serial, TIM_TypeDef * timerid, int8_t rxPin, int8_t txPin) {
#else
void IBusBM::begin(HardwareSerial &serial, int8_t timerid, int8_t rxPin, int8_t txPin) {
#endif
https://github.com/bmellink/IBusBM/blob ... M.cpp#L122

Code: Select all

      #elif defined(_VARIANT_ARDUINO_STM32_)
        // see https://github.com/stm32duino/wiki/wiki/HardwareTimer-library
        HardwareTimer *stimer_t = new HardwareTimer(timerid);
        stimer_t->setOverflow(1000, HERTZ_FORMAT); // 1000 Hz
        stimer_t->attachInterrupt(onTimer);
        stimer_t->resume();
it is looking for _VARIANT_ARDUINO_STM32_, i'm not sure if that is the correct way to detect the STM core.
so one of those things is maybe you could either try to

Code: Select all

#define _VARIANT_ARDUINO_STM32_ 
before your

Code: Select all

#include "IBusBM.h"
to see if it helps
it may take editing boards.txt to define that using a -D_VARIANT_ARDUINO_STM32_ or editing the variant file to #define that.
a better way is to copy the library files into the project folder and work specifically with that, you could edit codes if need be so as to get around code problems in the original library.
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

Re: Problem with data reception after iBus

Post by nawasaqi »

ag123 wrote: Wed Jun 01, 2022 2:21 pm
it is looking for _VARIANT_ARDUINO_STM32_, i'm not sure if that is the correct way to detect the STM core.
so one of those things is maybe you could either try to

Code: Select all

#define _VARIANT_ARDUINO_STM32_ 
before your

Code: Select all

#include "IBusBM.h"
to see if it helps


When I add this definition, I have a compilation error:

Code: Select all

c:/users/backu/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: sketch\iBus.ino.cpp.o: in function `setup':
iBus.ino.cpp:(.text.setup+0x1c): undefined reference to `IBusBM::begin(HardwareSerial&, TIM_TypeDef*, signed char, signed char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
if you can output to the serial monitor
I am weak when it comes to arduino, how should I give the output from IBusServo to the serial monitor ?? because I only know through xDD print

Code: Select all

#include <IBusBM.h>

IBusBM IBusServo;

void setup() 
{
  Serial.begin(115200);
  IBusServo.begin(Serial2);   //PA3-RX2   PA2-TX2
}

void loop() {
  
  
  delay(50);

}
Thank you for your help
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Problem with data reception after iBus

Post by ag123 »

Serial monitor is normally

Code: Select all

Serial.println("hello world");
you can replace that with anything you want to print, so you could print anything to have it sent back to your serial monitor to look at

I'd suggest copy that library into the project folder both the include and cpp file, then put the

Code: Select all

#define _VARIANT_ARDUINO_STM32_ 
near the top of your own copy of it.
this would make it easier for you to 'debug' it as well, e.g. using Serial.print() statements. exclude that library from the IDE if you are doing that.
the copy of the library files should be that in your project folder.
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

Re: Problem with data reception after iBus

Post by nawasaqi »

Ok, I found a solution. The problem is the stm32duino ibus sensor works on the old version 1.9.0 on the newer one does not want to work in any way.
Is there a chance to solve this problem and where can I report it?

This code work on version 1.9.0 but don't work on 2.0.0, 2.1.0, 2.2.0

Code: Select all

#include <IBusBM.h>

IBusBM IBusSensor;

HardwareSerial Serial2(PA3, PA2); //RX, TX

  
void setup() {

 
  IBusSensor.begin(Serial2);
  IBusSensor.addSensor(IBUS_MEAS_TYPE_GPS_DIST);

IBusSensor.setSensorMeasurement(1, 200); 


}

void loop() 
{

}
roskonedelchev1
Posts: 2
Joined: Thu Jun 23, 2022 1:00 pm

Re: Problem with data reception after iBus

Post by roskonedelchev1 »

Hello everyone, is there anyone who has managed to use the <IBusBM.h> library with stm32duino 2.1.0 or 2.2.0? If someone has succeeded let me share how defines serial ports to work?
Thank you in advance!
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

Post by nawasaqi »

Hi, I decided to check if something has changed in Core 2.3 and the IbusBm library.
It turns out that the STM32 Core 2.3 version started working ibus Servo but IbusSensor does not work. So I don't have telemetry. I can control e.g. servo motors etc (now i have the correct PWM values which was the problem in the first post) but I can't send anything using ibusSensor, any value, e.g. temperature, distance.

Below is the code that works on version 1.9 but does not work on version 2.3
The only difference in version 1.9 is that I have to define myself
HardwareSerial Serial2(PA3, PA2); //RX, TX
in version 2.3 it is assigned by default.

Code: Select all

#include <IBusBM.h>

IBusBM IBusSensor;

//HardwareSerial Serial2(PA3, PA2); //RX, TX

  
void setup() {

 
  IBusSensor.begin(Serial2);
  IBusSensor.addSensor(IBUS_MEAS_TYPE_GPS_DIST);

IBusSensor.setSensorMeasurement(1, 200); 


}

void loop() 
{

}


The strange thing is that if I connect UART6 IbusServo to UART1 GPS, my program works normally. And if I additionally connect to the UART2 IbuSensor, the whole program hangs. On version 1.9 it works fine :shock:
I don't think this is a problem with the IbusBM library itself. Since it works on 1.9 and on version 2.3 it works halfway but does not send data after ibusServo, the problem probably lies elsewhere.
Maybe someone more knowledgeable than me would take a look, which may cause that an attempt to send a value to any sensor does not work.

link to the library
https://github.com/bmellink/IBusBM/tree/master/src
Post Reply

Return to “General discussion”