Pitch, Roll and Accel Values

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
hotfly
Posts: 3
Joined: Sat Jun 08, 2019 1:24 pm
Country: -

Pitch, Roll and Accel Values

Post by hotfly » Sat Jun 08, 2019 1:56 pm

Greeting all - I am new to openXsensor - I am using version : 8.02 really like it! Great work Rainer.
Reading MS5611 Baro sensor and GPS perfectly, but not sure if I am getting the right data from my MPU 6050. Some help would be really appreciated.
I am using an Frsky Rx with SPort and Open Tx 2.2.2.
I have selected Pitch and Roll to be displayed as well as Test Values - hope to read these to get the accelerations as well.
#define ACCX_SOURCE PITCH
#define ACCY_SOURCE ROLL
#define ACCZ_SOURCE TEST_1
#define T1_SOURCE TEST_2
#define T2_SOURCE TEST_3
It does respond to pitch and roll movement, but I was expecting values in tenths of a degree. That's definitely not the case - it does not make sense to me.
I am also not seeing Test values, but I think there must a setting somewhere to turn on Test output values.
Does openXsensor output pitch and roll obtained from the IMU DMP?
I did run in debug mode and got "Initializing MPU...Success" on the serial monitor, so it's definitely talking OK.
It maybe I am not setting the sensor up correctly on the telemetry page of the Tx (??)
oXs_config.h
(15.7 KiB) Downloaded 13 times
Hope this makes sense - Justin


mstrens
Posts: 1231
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Pitch, Roll and Accel Values

Post by mstrens » Sun Jun 09, 2019 7:11 am

Normally oXs can calculate Roll and Pitch.
Still I think your issue is due to the use of ACCX and Y to handle the data.
If I remember well, on Tx side, the 2 last digit being sent as ACC are lost (due to the format foreseen by Frsky for ACC).
To solve this, it is possible to setup a scale = 255 in the telemetry field on openTx side. At least this is possible with some version of openTx (2.1?).
Perhaps the way to change the scaling has been modified in latest version of openTx (not sure about this).


The fields TEST_1, 2 and 3 are foreseen to transmit different kinds of information. So it not enough to define in which Frsky field (e.g. T1) you want to transmit a value (e.g. TEST_2) but you have to define also which information has to be filled in TEST_1,2,3.
I suggest that you use the latest version of oXs from github (8.2.12). You have there some options for filling TEST_1,2 and 3.

Note: In this version, the config is splitted in 2 files (basic and advanced) in order to make simple config easier.

hotfly
Posts: 3
Joined: Sat Jun 08, 2019 1:24 pm
Country: -

Re: Pitch, Roll and Accel Values

Post by hotfly » Sun Jun 09, 2019 8:27 am

OK - I will try and find some more information about the way Open Tx is handling this. You can select precision and a Ratio value, but it's not very clear.
I will also give 8.2.12 a try and let you know how I get on.

Thanks - Justin

Carbo
Posts: 357
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: Pitch, Roll and Accel Values

Post by Carbo » Sun Jun 09, 2019 12:22 pm

hotfly wrote:
Sun Jun 09, 2019 8:27 am
OK - I will try and find some more information about the way Open Tx is handling this.
Pretty easy, it took me only about 4 years to find out ;) (and still not 100% sure)
radio/src/telemetry/frsky_sport.cpp has the sensor definitions, the last number defines the number of decimals (precision). But internal ratio calculation is independent from number of decimals, it calculates with the raw value. We have to consider number of decimals in ratio. A factor of 1 corresponds

definition -> ratio
0 decimal -> 255 (e.g. RSSI)
1 decimal -> 25.5 (e.g. current)
2 decimal -> 2.55 (e.g.VFAS)

So if a sensor has to be multiplied with 4, the ratio is:
definition -> ratio
0 decimal -> 1020
1 decimal -> 102
2 decimal -> 10.2

For example number of sats transmitted in ACCX is displayed as 0.12 for 12sats. Setting a ratio 255 (x100) and precision 0 in ACCX sensor in OpenTX displays 12. Ratio 255 and Precision 1/2 results in 12.0/12.00 in this case.

Code: Select all

  { RSSI_ID, RSSI_ID, 0, ZSTR_RSSI, UNIT_DB, 0 },
  { ADC1_ID, ADC1_ID, 0, ZSTR_A1, UNIT_VOLTS, 1 },
  { ADC2_ID, ADC2_ID, 0, ZSTR_A2, UNIT_VOLTS, 1 },
  { A3_FIRST_ID, A3_LAST_ID, 0, ZSTR_A3, UNIT_VOLTS, 2 },
  { A4_FIRST_ID, A4_LAST_ID, 0, ZSTR_A4, UNIT_VOLTS, 2 },
  { BATT_ID, BATT_ID, 0, ZSTR_BATT, UNIT_VOLTS, 1 },
  { R9_PWR_ID, R9_PWR_ID, 0, ZSTR_R9PW, UNIT_MILLIWATTS, 0 },
  { T1_FIRST_ID, T1_LAST_ID, 0, ZSTR_TEMP1, UNIT_CELSIUS, 0 },
  { T2_FIRST_ID, T2_LAST_ID, 0, ZSTR_TEMP2, UNIT_CELSIUS, 0 },
  { RPM_FIRST_ID, RPM_LAST_ID, 0, ZSTR_RPM, UNIT_RPMS, 0 },
  { FUEL_FIRST_ID, FUEL_LAST_ID, 0, ZSTR_FUEL, UNIT_PERCENT, 0 },
  { ALT_FIRST_ID, ALT_LAST_ID, 0, ZSTR_ALT, UNIT_METERS, 2 },
  { VARIO_FIRST_ID, VARIO_LAST_ID, 0, ZSTR_VSPD, UNIT_METERS_PER_SECOND, 2 },
  { ACCX_FIRST_ID, ACCX_LAST_ID, 0, ZSTR_ACCX, UNIT_G, 2 },
  { ACCY_FIRST_ID, ACCY_LAST_ID, 0, ZSTR_ACCY, UNIT_G, 2 },
  { ACCZ_FIRST_ID, ACCZ_LAST_ID, 0, ZSTR_ACCZ, UNIT_G, 2 },
  { CURR_FIRST_ID, CURR_LAST_ID, 0, ZSTR_CURR, UNIT_AMPS, 1 },
  { VFAS_FIRST_ID, VFAS_LAST_ID, 0, ZSTR_VFAS, UNIT_VOLTS, 2 },
  { AIR_SPEED_FIRST_ID, AIR_SPEED_LAST_ID, 0, ZSTR_ASPD, UNIT_KTS, 1 },
  { GPS_SPEED_FIRST_ID, GPS_SPEED_LAST_ID, 0, ZSTR_GSPD, UNIT_KTS, 3 },
  { CELLS_FIRST_ID, CELLS_LAST_ID, 0, ZSTR_CELLS, UNIT_CELLS, 2 },
  { GPS_ALT_FIRST_ID, GPS_ALT_LAST_ID, 0, ZSTR_GPSALT, UNIT_METERS, 2 },
  { GPS_TIME_DATE_FIRST_ID, GPS_TIME_DATE_LAST_ID, 0, ZSTR_GPSDATETIME, UNIT_DATETIME, 0 },
  { GPS_LONG_LATI_FIRST_ID, GPS_LONG_LATI_LAST_ID, 0, ZSTR_GPS, UNIT_GPS, 0 },
  { FUEL_QTY_FIRST_ID, FUEL_QTY_LAST_ID, 0, ZSTR_FUEL, UNIT_MILLILITERS, 2 },
  { GPS_COURS_FIRST_ID, GPS_COURS_LAST_ID, 0, ZSTR_HDG, UNIT_DEGREE, 2 },
  { RBOX_BATT1_FIRST_ID, RBOX_BATT1_LAST_ID, 0, ZSTR_BATT1_VOLTAGE, UNIT_VOLTS, 3 },
  { RBOX_BATT2_FIRST_ID, RBOX_BATT2_LAST_ID, 0, ZSTR_BATT2_VOLTAGE, UNIT_VOLTS, 3 },
  { RBOX_BATT1_FIRST_ID, RBOX_BATT1_LAST_ID, 1, ZSTR_BATT1_CURRENT, UNIT_AMPS, 2 },
  { RBOX_BATT2_FIRST_ID, RBOX_BATT2_LAST_ID, 1, ZSTR_BATT2_CURRENT, UNIT_AMPS, 2 },
  { RBOX_CNSP_FIRST_ID, RBOX_CNSP_LAST_ID, 0, ZSTR_BATT1_CONSUMPTION, UNIT_MAH, 0 },
  { RBOX_CNSP_FIRST_ID, RBOX_CNSP_LAST_ID, 1, ZSTR_BATT2_CONSUMPTION, UNIT_MAH, 0 },
  { RBOX_STATE_FIRST_ID, RBOX_STATE_LAST_ID, 0, ZSTR_CHANS_STATE, UNIT_BITFIELD, 0 },
  { RBOX_STATE_FIRST_ID, RBOX_STATE_LAST_ID, 1, ZSTR_RB_STATE, UNIT_BITFIELD, 0 },
  { SD1_FIRST_ID, SD1_LAST_ID, 0, ZSTR_SD1_CHANNEL, UNIT_RAW, 0 },
  { ESC_POWER_FIRST_ID, ESC_POWER_LAST_ID, 0, ZSTR_ESC_VOLTAGE, UNIT_VOLTS, 2 },
  { ESC_POWER_FIRST_ID, ESC_POWER_LAST_ID, 1, ZSTR_ESC_CURRENT, UNIT_AMPS, 2 },
  { ESC_RPM_CONS_FIRST_ID, ESC_RPM_CONS_LAST_ID, 0, ZSTR_ESC_RPM, UNIT_RPMS, 0 },
  { ESC_RPM_CONS_FIRST_ID, ESC_RPM_CONS_LAST_ID, 1, ZSTR_ESC_CONSUMPTION, UNIT_MAH, 0 },
  { ESC_TEMPERATURE_FIRST_ID, ESC_TEMPERATURE_LAST_ID, 0, ZSTR_ESC_TEMP, UNIT_CELSIUS, 0 },
  { GASSUIT_TEMP1_FIRST_ID, GASSUIT_TEMP1_LAST_ID, 0, ZSTR_GASSUIT_TEMP1, UNIT_CELSIUS, 0 },
  { GASSUIT_TEMP2_FIRST_ID, GASSUIT_TEMP2_LAST_ID, 0, ZSTR_GASSUIT_TEMP2, UNIT_CELSIUS, 0 },
  { GASSUIT_SPEED_FIRST_ID, GASSUIT_SPEED_LAST_ID, 0, ZSTR_GASSUIT_RPM, UNIT_RPMS, 0 },
  { GASSUIT_RES_VOL_FIRST_ID, GASSUIT_RES_VOL_LAST_ID, 0, ZSTR_GASSUIT_RES_VOL, UNIT_MILLILITERS, 0 },
  { GASSUIT_RES_PERC_FIRST_ID, GASSUIT_RES_PERC_LAST_ID, 0, ZSTR_GASSUIT_RES_PERC, UNIT_PERCENT, 0 },
  { GASSUIT_FLOW_FIRST_ID, GASSUIT_FLOW_LAST_ID, 0, ZSTR_GASSUIT_FLOW, UNIT_MILLILITERS_PER_MINUTE, 0 },
  { GASSUIT_MAX_FLOW_FIRST_ID, GASSUIT_MAX_FLOW_LAST_ID, 0, ZSTR_GASSUIT_MAX_FLOW, UNIT_MILLILITERS_PER_MINUTE, 0 },
  { GASSUIT_AVG_FLOW_FIRST_ID, GASSUIT_AVG_FLOW_LAST_ID, 0, ZSTR_GASSUIT_AVG_FLOW, UNIT_MILLILITERS_PER_MINUTE, 0 },
  { SBEC_POWER_FIRST_ID, SBEC_POWER_LAST_ID, 0, ZSTR_SBEC_VOLTAGE, UNIT_VOLTS, 2 },
{ SBEC_POWER_FIRST_ID, SBEC_POWER_LAST_ID, 1, ZSTR_SBEC_CURRENT, UNIT_AMPS, 2 },

hotfly
Posts: 3
Joined: Sat Jun 08, 2019 1:24 pm
Country: -

Re: Pitch, Roll and Accel Values

Post by hotfly » Mon Jun 10, 2019 8:27 pm

Hi Carbo thanks for your help on this - I do get the right sort of values with a Ratio of 25.5 (pitch and roll are transmitted in 1/10ths of a degree).
I've been looking at the code, but it is not making sense to me... and there are hardly any comments!

int32_t TelemetrySensor::getValue(int32_t value, uint8_t unit, uint8_t prec) const
{
if (type == TELEM_TYPE_CUSTOM && custom.ratio) {
if (this->prec == 2) {
value *= 10;
prec = 2;
}
else {
prec = 1;
}
value = (custom.ratio * value + 122) / 255;
}

Where does 122 come from??
From some of the other functions, a precision of 1 means that the precision multiplier and divider are set to 10.

Can anybody shed some more light on this?
Justin


Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”