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
168 stars 41 forks source link

No data output from jetiexbus after enabling ms5611 #78

Closed ahfynjj closed 2 years ago

ahfynjj commented 2 years ago

I am planning to make a 2 in 1 sensor, GPS and MS5611 altimeter, and tried to use the new GPS module, and the test was successful, but after compiling the code with MS5611, it does not work. I also tested the MS5611 separately and it doesn't work either. Here is my config.h file

#ifndef CONFIG_H
#define CONFIG_H
#include "constants.h"

/* Receiver protocol */
#define RX_PROTOCOL RX_JETIEX

/* Sensors */
#define CONFIG_ESC_PROTOCOL PROTOCOL_NONE
#define CONFIG_GPS true
#define GPS_BAUD_RATE 115200 
#define CONFIG_VOLTAGE1 false 
#define CONFIG_VOLTAGE2 false 
#define CONFIG_NTC1 false 
#define CONFIG_NTC2 false 
#define CONFIG_CURRENT false 
#define CONFIG_AIRSPEED false 
#define CONFIG_I2C1_TYPE I2C_MS5611 
#define CONFIG_I2C1_ADDRESS 0x77

/* Refresh rate in 0.1s (1 = 100ms) */
#define CONFIG_REFRESH_RPM 1
#define CONFIG_REFRESH_VOLT 1
#define CONFIG_REFRESH_CURR 1
#define CONFIG_REFRESH_TEMP 1
#define CONFIG_REFRESH_GPS 1

/* Averaging elements (1 = no averaging) */
#define CONFIG_AVERAGING_ELEMENTS_RPM 1
#define CONFIG_AVERAGING_ELEMENTS_VOLT 1
#define CONFIG_AVERAGING_ELEMENTS_CURR 1
#define CONFIG_AVERAGING_ELEMENTS_TEMP 1
#define CONFIG_AVERAGING_ELEMENTS_DEF 1

/* Analog multipliers */
#define VOLTAGE1_MULTIPLIER 1
#define VOLTAGE2_MULTIPLIER 1
#define CURRENT_MULTIPLIER 1

/* RPM multipliers (optional, this may be done in transmitter*/
#define RPM_PAIR_OF_POLES 1
#define RPM_PINION_TEETH 1
#define RPM_MAIN_TEETH 1

/* BMP filter. Higher filter = lower noise: 1 - low, 2 - medium, 3 - high */
#define BMP280_FILTER 3

/* Pwm out */
#define CONFIG_PWMOUT false
#define PWMOUT_DUTY 0.5 // 0.5 = 50%

/* Only smartport and opentx */
#define SENSOR_ID 10 // Sensor Id
#define DATA_ID 0x5000 // DataId (sensor type)
//#define ESC_SIGNATURE // HW V4 signature (only smartport). This outputs esc signature and raw current to sensors 5100, 5101 and 5102
//#define CONFIG_LUA

/* XBus */
//#define XBUS_CLOCK_STRECH_SWITCH

/* Jeti Ex */
#define JETI_GPS_SPEED_UNITS_KMH

/* Use library I2C_T3 for Teensy LC/3.X */
#define I2C_T3_TEENSY

/* Add init delay for FlyFun ESC. Uncomment if the ESC doesn't arm */
//#define ESC_INIT_DELAY 10000

/* HW V4/V5 parameters */
#define CURRENT_THRESHOLD 25
#define ESCHW4_DIVISOR 11
#define ESCHW4_AMPGAIN 0
#define ESCHW4_CURRENT_MAX 0

/* Force eeprom write */
//#define FORCE_EEPROM_WRITE // Uncomment to force write eeprom as defined in config.h. Useful when using lua and eeprom is messed up. Reflash againg with line commented or config will be reset at power up

/* Debug
   Disconnect Vcc from the RC model to the Arduino
   Do not connect at the same time Vcc from the model and usb (TTL)
   Telemetry may not work properly in debug mode
   Connect arduino Rx to TTL Tx for flashing, then if applicabe connect arduino Rx to esc or gps
*/

//#define DEBUG
//#define DEBUG_PACKET
//#define DEBUG_SBUS_MS
//#define DEBUG_EEPROM_WRITE
//#define DEBUG_EEPROM_READ

//#define DEBUG_HW3
//#define DEBUG_HW4
//#define DEBUG_ESC_KONTRONIK
//#define DEBUG_APDF
//#define DEBUG_APDHV
//#define DEBUG_GPS
//#define DEBUG_PWM
//#define DEBUG_CASTLE
//#define DEBUG_CASTLE_RX

//#define SIM_RX
//#define SIM_SENSORS
//#define SIM_LUA_SEND
//#define SIM_LUA_RECEIVE

#endif
dgatf commented 2 years ago

Which board are you using?

dgatf commented 2 years ago

Have you added pull up resistors to SDA and SCL?

dgatf commented 2 years ago

Have you tested the ms5611 with a separate library to test if it works?

ahfynjj commented 2 years ago

I use ATMEGA 328P and 10k pull up resistors, the 5611 is brand new, here is my schematic Both GPS and barometer are soldered on the PCB, and it won't work as long as the 5611 is turned on when flashing the firmware.

ahfynjj commented 2 years ago

原理图

dgatf commented 2 years ago

This is issue is due to no memory available. The maximum number of sensors for Jeti with ATmega328 (2k ram) is 11 sensors

I've added a parameter in jetiex.h, JETIEX_LOW_MEMORY. It is disabled by default. You need to enable it (uncomment it). If this parameter is enabled, some sensors with less important telemetry values are not created.

It disables the following sensors:

With your config, GPS+vario, and JETIEX_LOW_MEMORY enabled, there are 10 sensors. Still you can add one more sensor.

dgatf commented 2 years ago

I also tested the MS5611 separately and it doesn't work either

Did you change the Jeti connections?

If you disable the GPS, you need to connect Jeti to Rx & Tx pins instead

ahfynjj commented 2 years ago

Following your instructions, I disabled some sensors in the code and it worked successfully. thank you very much. But I observed that the reading of MS5611 was abnormal, and the same thing happened with another brand new one 123 456 .

dgatf commented 2 years ago

Please enable DEBUG_MS5611 in config.h, connect arduino Tx to programmer Rx and arduino GND to programmer GND. With a serial monitor at 9600, post the output

ahfynjj commented 2 years ago

After many attempts I got correct data output at 250000 baud, not gibberish at 9600 baud. As shown below 33

At the same time, I conducted the serial port test of arduino Libraries, the data is as follows 2

dgatf commented 2 years ago

Sorry, my bad. There was an error reading the PROM parameters from MS5611. Fixed with 57b3a8dcdd4de028674db9bdd88a07f961aa2330

ahfynjj commented 2 years ago

The problem is stil 微信截图_20220318203745 l

ahfynjj commented 2 years ago

I enabled GPS at 115200 bit rate, and it seems normal to see the serial monitor, then I turned off the DEBUG MS5611, connected Jeti to pins 7&12, the problem persists

微信截图_20220318214751

ahfynjj commented 2 years ago

Abnormal data was observed, as shown in the figure: Also, when I tried to blow a 100°C temperature to the 5611 with a heat gun, I didn't see the temperature reading of the sensor in the serial monitor rise, but there was a -2° drop, which is strange 微信截图_20220318222134 微信截图_20220318222150 f319fbadea21fb73cc8d2b85eea0231 .

dgatf commented 2 years ago

To debug MS5611, keep GPS enabled (with baud rate as configured in the GPS module) in config.h. With a serial monitor at GPS baud rate (9600, 115200...) you'll see the debug output for MS5611. If you disable GPS, serial monitor will be switching between 125000 and 250000 due to Jeti. Also you will see some garbage characters when in 125000

Regarding the wrong sensor values, please download and flash the updated code as there was some issues when converting the raw sensor values. Fixed with dd36569482d0aeb8c4213f8d05a1ab26f7d53022

ahfynjj commented 2 years ago

Thanks, I downloaded it and saw that the temperature is normal, the Altitude and Vario are still having issues. At the same time, I also have a FRSKY X20S. I tried to use RX_SMARTPORT, flashed the sensor and connected the GR6 receiver. The data of 5611 displayed on the X20S is normal. This seems to be a problem with JETI's data processing.

dgatf commented 2 years ago

Altitude and Vario are still having issues

Which issues? There is no additional processing for Jeti

ahfynjj commented 2 years ago

https://youtu.be/EgHonEp0JSk I recorded a video so it will be clearer

ahfynjj commented 2 years ago

In order to rule out the problem of 328p, I used teensylc, and connected the iic interface through two wires, and connected GND, the result is the same. https://youtube.com/shorts/w3mQs1a8D0U?feature=share

dgatf commented 2 years ago

Please post the debug for DEBUG_MS5611

dgatf commented 2 years ago

It seems an issue of negative numbers with Jeti. I've changed handling of negative numbers for Jeti. Please try the updated code

ahfynjj commented 2 years ago

Video of debug for DEBUG_MS5611 https://youtube.com/shorts/aJxN-QgIywY?feature=share

ahfynjj commented 2 years ago

I downloaded the latest one and the problem persists

dgatf commented 2 years ago

It seems that Jeti uses two complement for negative numbers.

Please try updated code. Should work now.

ahfynjj commented 2 years ago

After 10 minutes of testing, 5611 works fine, thank you very much.

dgatf commented 2 years ago

Still it was needed to fix the number of decimals for negative values. Please download updated code.