dgatf / msrc

Multi Sensor for RC with RP2040 - FrSky D, SmartPort, XBUS, SRXL, IBUS, SBUS, Multiplex Sensor Bus, Jeti Ex Bus, Hitec
GNU General Public License v3.0
169 stars 42 forks source link

Jeti EX Bus GPS not working #103

Closed andypnz closed 1 year ago

andypnz commented 1 year ago

Hi. Great project!!

Using a RPi PICO (2040). Matek M10-5883 GPS (9600, NMEA).

Voltage telemetry works (pin not connected - floating - but I get numbers on the transmitter)

GPS enabled, 9600 baud. The transmitter recognizes a GPS sensor attached. Unfortunately no data on the transmitter (all zeros)

Jeti Ex Bus logic analyzer capture attached if of any use?Really keen to try and get this going - happy to try any suggestions / firmware / do more captures, etc :-)

GPS data capture attached (inside, but would expect a satellite or two, and does have location data) gps capture.zip

Jeti EX Bus telem stream with GPS sensor + voltage floating (2).zip

Debug output below (this was with the GPS set to 57600 baud + 200ms). The green LED on the PICO is flashing...

Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Vspeed (106): 0.00 Distance (100): 0.00 USB (134) Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Text (104) > 3B 1 1B 7F 3A 13 F 11 0 A4 0 A4 0 7 33 56 73 70 65 65 64 6D 2F 73 10 8C 45 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 23 7F 3A 1B F 59 0 A4 0 A4 0 10 0 29 0 0 0 0 39 0 0 0 20 44 0 0 20 51 0 20 2E C5 ED Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Vspeed (106): 0.00 Distance (100): 0.00 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 22 7F 3A 1A F 58 0 A4 0 A4 0 61 0 20 71 0 20 84 0 0 0 95 0 0 0 A5 0 0 20 1A 9A D4 Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex(104) < 3D 1 8 7F 3A 0 5E 9D Jeti Ex Values (104) > 3B 1 13 7F 3A B F 49 0 A4 0 A4 0 B1 0 20 E1 6B ED

andypnz commented 1 year ago

Ok, managed to sort that - the code was not handling southern hemisphere -ve latitude (or -ve long either)......

If you like I can share with you the changes I made to fix this, and also improve the displayed gps resolution....

aepub commented 1 year ago

I also use JETI. When using the RP2040, the GPS has no signal, and the GPS TX is connected to the 6 pins of the RP2040. Replace with ATmega328PB, and the GPS signal is normal. The author has not replied to any questions recently.

aepub commented 1 year ago

After I modified led. c and led. h, the RGB indicator light flickered. At least that way, I knew that rp2040 was working. I tested MS5611, ACS758-150B, and the test voltage, and everything was basically normal. The only problem currently is that GPS data is not displayed on the remote control. 99999998888888

dgatf commented 1 year ago

Ok, managed to sort that - the code was not handling southern hemisphere -ve latitude (or -ve long either)......

If you like I can share with you the changes I made to fix this, and also improve the displayed gps resolution....

Yes, please share. Thank you

Is it with the RP2040?

andypnz commented 1 year ago

Yes, RP2040

Its been a while since I looked at this :-)

project 230218_1554hrs_WORKING.zip

I have attached the project directory - but from memory it was just changes to these two files. But if these don't cover it I am afraid you will need to do some file comparisons with my attached zip.....

jeti.c, around line 280 change to:

               int32_t value = (int32_t)*sensor->value;
               if (value < 0)
               {
                    format |= 1 << 6;
                    value *= -1;
                }
                *(buffer + *buffer_index) = sensor_index << 4 | sensor->type;
                uint8_t degrees = value / 60000;
                uint32_t degreesDecimals = ((value % 60000)); 
                *(buffer + *buffer_index + 1) = (uint16_t)degreesDecimals;      // degrees (dec, l)
                *(buffer + *buffer_index + 2) = (uint16_t)degreesDecimals >> 8; // degrees (dec, h)

nmea.c, around lines 23-24:

    *parameter.lat = 692761.0;               //-692.761166667;  // 11º32'45.67" +N, -S
    *parameter.lon = 10320.0;               //-2500; //-1251.964833333; // 20º51'57.89" +E, -W

around line 131:

            *parameter->lat =(((atof(degrees) * 60.0 + minutes)) *1000.0) * lat_dir ;

around line 139:

            *parameter->lon = ((atof(degrees) * 60 + minutes)) * 1000 * lon_dir; 
dgatf commented 1 year ago

Ok, I see. Negative coordinates where not correct. I'll add value *= -1; to fix it. Commit 2b9397bfd497eb6ccadac713fbca77673c9d9b51 I guess multiplier 1000 is to increase accuracy. I may add it later

But based on the debug, the issue was related to gps module not being read by rp2040 and that's why all were zeros in the transmitter

andypnz commented 1 year ago

I think you really need to add the multiplier - without this, the GPS accuracy is very poor.......

dgatf commented 1 year ago

The issue was that the formatting for coordinates for jetiex was wrong. No need to add multipliers. Fixed with 8bf664fb0cb1fd51307aba826ccfbee37594e224

As a side note:

Jeti uses 3 decimals on minutes. This is 2m accuracy. Float has a mantissa of 7 digits, which is ok in most cases for 3 decimals on minutes, except for longitudes > 160°, where accuracy drops to 20m

NMEA protocol sends 5 decimals on minutes, which is 0.2m accuracy (usual gps modules don't have this accuracy though). This requires 10 digits mantissa. A double (16 digits mantissa) instead a float is required to hold all digits. This implies to create sensors for all rx protocols that holds a double instead a float. I may do this as an enhancement