mstrens / oXs_on_RP2040

version of openXsensor to be used on raspberry pi pico RP2040 (more protocols, more functionalities)
87 stars 22 forks source link

FlySky Ibus altitude telemetry issue #90

Closed aeropic closed 1 year ago

aeropic commented 1 year ago

I get now 5 flysky Rx: one FS-IA10B and four FS-IA6B and I get weird results with the same RP2040 Oxs!

I've the feeling those Rx do not embark the same firmware and IBUS telemetry decommutation is not done the same way between both families of Rx...

I do not exactly know what OXS could do to make it work for both families ? Are you aware of firmware issues with those Rx ? Sans titre Sans titre2

aeropic commented 1 year ago

from IBUS telemetry.h here https://github.com/qba667/FlySkyI6/blob/master/source/source/ibustelemetry.h#L44 I read this //4 byte sensors

define IBUS_MEAS_TYPE_GPS_LAT 0x80 //4bytes signed WGS84 in degrees * 1E7

define IBUS_MEAS_TYPE_GPS_LON 0x81 //4bytes signed WGS84 in degrees * 1E7

define IBUS_MEAS_TYPE_GPS_ALT 0x82 //4bytes signed!!! GPS alt m*100

*#define IBUS_MEAS_TYPE_ALT 0x83 //4bytes signed!!! Alt m100**

define IBUS_MEAS_TYPE_ALT_MAX 0x84 //4bytes signed MaxAlt m*100

define IBUS_MEAS_TYPE_S85 0x85

define IBUS_MEAS_TYPE_S86 0x86

define IBUS_MEAS_TYPE_S87 0x87

define IBUS_MEAS_TYPE_S88 0x88

define IBUS_MEAS_TYPE_S89 0x89

define IBUS_MEAS_TYPE_S8a 0x8a

//#define IBUS_MEAS_TYPE_ALT_FLYSKY 0xf9 // Altitude //2 bytes signed in m

define IBUS_MEAS_TYPE_SNR 0xfa // SNR

define IBUS_MEAS_TYPE_NOISE 0xfb // Noise

define IBUS_MEAS_TYPE_RSSI 0xfc // RSSI

define IBUS_MEAS_TYPE_ERR 0xfe // Error rate

define IBUS_MEAS_TYPE_UNKNOWN 0xff

maybe a old version of flysky is delivering alt in meters 2 bytes ?

aeropic commented 1 year ago

I made it work at least in the office... in IBUS.CPP formatIbusValue I added a division by 10 of the altitude: case RELATIVEALT: ibusValue= fields[fieldId].value/10 ; // from cm to cm break;

Then under EDGETX telemetry screen for the sensor "altitude" I set the RATIO to 1 (don't ask why !) With this the altitude seems to behave correctly with delta h of around 1 m, the EDGETX display follows...

aeropic commented 1 year ago

well there is a bug in EDGETX, the ratio parameter is 10x the actual value as shown in companion... Hence a RATIO = 1 means another division by 10 of the altitude. So indeed those RX want an altitude in meter...

But dividing the value by 100 directly in OXS doen not seem to work... Weird FDSCT3fjm0

aeropic commented 1 year ago

tested under a drone at 50m of altitude. It works fine with this double division by 10x :-)

aeropic commented 1 year ago

I compiled a new version where the altitude dividor factor can be accessed from serial interface (command IA10B=xx) I incremented by one the config version and modded few files. ibus.cpp case RELATIVEALT: ibusValue= fields[fieldId].value/config.fsAltRatio ; // from cm to cm if IA10B = 1 from CM to m if IA10 = 10 break;

param.cpp processcmd printf("-To change IBUS altitude FSIA10B dividor, enter e.g. IA10B=10 to divide altitude by 10\n"); ... // change FSIA10B altitude dividor if ( strcmp("IA10B", pkey) == 0 ) { db = strtod(pvalue,&ptr); if (*ptr != 0x0) { printf("Error : value is not a valid float\n"); } else { config.fsAltRatio = db; updateConfig = true; } } ... printconfig printf("FSIA10B altitude dividor = %f\n", config.fsAltRatio);

param.h

define CONFIG_VERSION 7

struct CONFIG ... float fsAltRatio = 1;

Here is the result:

processing cmd

Commands can be entered to change the config parameters

-To change the protocol, enter PROTOCOL=x where x= S(Sport Frsky), F(Fbus Frsky), C(CRSF/ELRS), H(Hott), M(Mpx), 2(Sbus2 Futaba), J(Jeti), E(jeti Exbus), L (spektrum SRXL2) ,or I(IBus/Flysky) -To change the CRSF baudrate, enter e.g. BAUD=420000 -To change voltage scales, enter SCALEx=nnn.ddd e.g. SCALE1=2.3 or SCALE3=0.123 Enter SCALEx=0 to avoid sending voltage x to the Transmitter (for Frsky or Jeti) -If a TMP36 is used on V3, enter TEMP=1 (if a second one is on V4, enter TEMP=2)-To change voltage offset, enter OFFSETx=nnn.ddd e.g. OFFSET1=0.6789 -To change GPS type: for an Ublox, enter GPS=U (configured by oXs) or E (configured Externally) and for a CADIS, enter GPS=C -To change RPM multiplicator, enter e.g. RPM_MULT=0.5 to divide RPM by 2 -To change IBUS altitude FSIA10B dividor, enter e.g. IA10B=10 to divide altitude by 10 -To force a calibration of MP6050, enter MPUCAL -To use a channel to setup Airspeed compensation factor and/or to select between the 2 Vspeed, enter the channel with ACC=1...16-To change (invert) led color, enter LED=N or LED=I -To select the failsafe mode to HOLD, enter FAILSAFE=H -To set the failsafe values on the current position, enter SETFAILSAFE -To get the internal telemetry values currently calculated by oXs, enter FV (meaning Field Values) -To test a protocol, you can force the internal telemetry values to some dummy values for dummy positive values, enter FVP; for dummy negative values, enter FVN -To get the current PWM values (in micro sec, enter PWM) -To get the current config, just press Enter Note: some changes require a reset to be applied (e.g. to unlock I2C bus) processing cmd

Cmd to execute: IA10B=10 read error MS5611 config has been saved Device will reboot

Version = 2.6.8 Function Pin Change entering XXX=yyy (yyy=255 to disable) Primary channels input = 255 (PRI = 5, 9, 21, 25) Secondary channels input = 255 (SEC = 1, 13, 17, 29) Telemetry . . . . . . . . = 29 (TLM = 0, 1, 2, ..., 29) GPS Rx . . . . . . . . . = 255 (GPS_RX = 0, 1, 2, ..., 29) GPS Tx . . . . . . . . . = 255 (GPS_TX = 0, 1, 2, ..., 29) Sbus OUT . . . . . . . . = 255 (SBUS_OUT= 0, 1, 2, ..., 29) RPM . . . . . . . . . . = 255 (RPM = 0, 1, 2, ..., 29) SDA (I2C sensors) . . . . = 26 (SDA = 2, 6, 10, 14, 18, 22, 26) SCL (I2C sensors) . . . . = 27 (SCL = 3, 7, 11, 15, 19, 23, 27) PWM Channels 1, 2, 3 ,4 = 255 255 255 255 (C1 / C16= 0, 1, 2, ..., 15) PWM Channels 5, 6, 7 ,8 = 255 255 255 255 PWM Channels 9,10,11,12 = 255 255 255 255 PWM Channels 13,14,15,16 = 255 255 255 255 Voltage 1, 2, 3, 4 = 255 255 255 255 (V1 / V4 = 26, 27, 28, 29)

Protocol is ibus(Flysky) CRSF baudrate = 420000 Voltage parameters: Scales : 1.000000 , 1.000000 , 1.000000 , 1.000000 Offsets: 0.000000 , 0.000000 , 0.000000 , 0.000000 No temperature sensors are connected on V3 and V4 RPM multiplier = 1.000000 FSIA10B altitude dividor = 10.000000 Baro sensor is detected using MS5611 Sensitivity min = 100 (at 100) , max = 300 (at 1000) Hysteresis = 5 Acc/Gyro is detected using MP6050 Acceleration offsets X, Y, Z = -39 , 75 , -3257 Gyro offsets X, Y, Z = -116 , -92 , -166 Airspeed sensor is not detected No Vspeed compensation channel defined; oXs uses default settings First analog to digital sensor is not detected Second analog to digital sensor is not detected Foreseen GPS type is Ublox (configured by oXs) :GPS is not (yet) detected Led color is normal (not inverted) Failsafe type is HOLD

Config parameters are OK Press ? + Enter to get help about the commands

I join the source files, please feel free to use or discard it ! src.zip

aeropic commented 1 year ago

NEWS : after having updated EDGETX to firmware 2.8.5, it seems the issue is gone, both families of IA6B Rx deliver the same altitude value with the genuine OXS code.

It seems however EDGE TX still has an issue to display negative altitude values with one of the IA6B families (it displays something like 65532 instead of -0.1 m). Let's see all this in flight with true altitudes values... and I'll report the results! :-)

EDIT : found this in the change log of EDGE TX which confirms the bug was in EGDTE TX 2.8.4 / https://github.com/EdgeTX/edgetx/commit/ee68f2ba19fa46aed0b9b216553193e0eccf7b68 "Fixed a bug in AFHDS2 Alt decoding."

aeropic commented 1 year ago

tested in flight: everything OK with EDGE TX 2.8.5