Setting up openXsensor

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
ElPete
Posts: 5
Joined: Thu Oct 25, 2018 5:43 pm
Country: -

Setting up openXsensor

Post by ElPete » Thu Oct 25, 2018 6:17 pm

Hi,
I am new to this forum.
I built two openXsensors a few years ago, and now I am trying to get them working again. They worked OK with vario and altitude.
Now I want to expand and use other inputs like current, voltages and airspeed etc.
I am using Frsky SPORT Tx/Rx and version 8.2.12 of openXsensor.
I stuggle with the setup of "data to transmit" and "sensor ID:s" etc (yes I have read the oxs.config_desciption several times) but I cannot understand how to set them up.
Is there a simple procedure (=manual) on how to proceed?

I have tried several times (also with v 2.5) to get it to work. Vspeed, Alt and Curr are running OK. But how to set up Vfas and other voltages?

Any help?

Regards Pete


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

Re: Setting up openXsensor

Post by mstrens » Thu Oct 25, 2018 9:07 pm

With version 8.x.x, for frsky Sport, you do not have to specify (anymore) in which fields data like Alt, Vspeed, Curr, Airspeed, GPS are transmitted.
It is automatically done by oXs using the default fields are sensor ID.

To get VFAS, you have to specify which voltage measurement has to be used.
This is done in oXs_config_basic.h in line
#define VFAS_SOURCE VOLT_3
In this example, it is assume that the voltage measured in the 3rd pin (e.g pin 1 if you have #define PIN_VOLTAGE 6 , 2 , 1 , 8 , 8 , 8 ) has to be used.

In order to get individual cell measurements, you have to specify the pins being used for cell1, cell2, ... in oXs_config_advanced.h in line #define PIN_VOLTAGE 6 , 2 , 1 , 8 , 8 , 8
and then you have to specify the max number of cells in
#define NUMBEROFCELLS 3
(here for a 3S lipo)

Please note that in order to claculate individual cells, oXs measures voltage of cell 1, of cell 1+ cell2 , ...and individual cell voltage is based on the difference between 2 measured voltages. oXs makes checks that the individual cells voltage are valid (e.g. > 0.5 volt and less than 5 volt). If cell voltages are not valid (e.g. because cell1 is not connected), oXs does not transmit individual cell voltage.

If you want to get other voltages, you have to "misuse" (reuse) other telemetry fields e.g T1 or T2 and you have to uncomment a line like
#define T1_SOURCE VOLT_4 // here to transmit the voltage specified in position 4 of line #define PIN_VOLTAGE

You normally do not have to change the sensor ID (except if you got a conflict with other frsky sensors).

If this is still unclear, explain what you want and put here your current config files. I will check them.

ElPete
Posts: 5
Joined: Thu Oct 25, 2018 5:43 pm
Country: -

Re: Setting up openXsensor

Post by ElPete » Sat Oct 27, 2018 6:27 pm

Hi,
Thanks for your reply!
I have tested for some hours now - but I struggle to understand how this works :x
I get no good results and I am not confident in what I an doing.
I have VFas and two other voltages working (I think) - but no current.
May I ask you to prepare config files for me. I will compare them with the default files, to see how this should be done....

I was planning to have "Curr" on A0, "VFas" on A1 and maybe "Voltage" on A2, A3 and A6 for a 3-cell battery

/Pete

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

Re: Setting up openXsensor

Post by mstrens » Sat Oct 27, 2018 7:26 pm

Here the config files you could use.
Note : the values for the resistances (for current and voltage dividers) have to be modified according to your values.
You have also have to modify the parameters for current sensor (sensitivity, offset) according to your sensor.
I assume that you use the internal voltage reference. It means that you have to select resistors in order not to exceed 1.1 volt at arduino pins.

Code: Select all

// OpenXsensor https://github.com/openXsensor/
// started by Rainer Schlosshan and maintained by Michel Strens

// This is version : 8.2.12 (29 dec 2017)

//******************************************************************************************************************************************************* //
//                                                                                                                                                        //
// ! IMPORTANT NOTE !!!!!!!!!!   Another file in this project provides detailed explanations on how to set up this file (see oXs_config_description.h).   //
//                                                                                                                                                        //
//******************************************************************************************************************************************************* //
//  Note: the oXs_config_basic.h and oXs_config_advanced.h files present on the GitHub site are not always meaningful.
//       It could be that the combination of active/non active parameters is not consistent.
//       This is just the result of many updates and tests in this document.
//       So take always care to set up the files according to your needs and check carefully all options.
//  For old version 2 and 3 of oXs, there was a program named "configurator" running on PC that allowed easier editing of a oXs_config.h file
//       Still this configurator is not developped anymore. So this version request manual editing. 


#ifndef OXS_CONFIG_BASIC_h
#define OXS_CONFIG_BASIC_h

// --------- 1 - Telemetry protocol ---------  
#define PROTOCOL  FRSKY_SPORT   // select between FRSKY_SPORT , FRSKY_HUB , FRSKY_SPORT_HUB , MULTIPLEX , HOTT, JETI

// ***** 1.1 - Pin connected to Rx ************                              See oXs_config_advanced.h (normally no need to change it) (default is arduino pin 4 connected to RX) 
// ***** 1.2 - SPORT_SENSOR_ID (used only for Frsky Sport protocol)  *****   See oXs_config_advanced.h (normally no need to change it) 

// --------- 2 - Data to transmit ---------   uncomment the lines below if you want to transmit some extra oXs measurements into some telemetry fields
// ***** 2.1 - Frsky data *****                
#define VFAS_SOURCE  VOLT_4                 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4 
//#define FUEL_SOURCE   ADS_VOLT_1                 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define A3_SOURCE     ADS_VOLT_1                 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define A4_SOURCE     ADS_VOLT_3                 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define ACCX_SOURCE     TEST_1                   //  select between TEST_1, TEST_2, TEST_3, GLIDER_RATIO , SECONDS_SINCE_T0 ,AVERAGE_VSPEED_SINCE_TO , VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, PITCH, ROLL , YAW, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4 
//#define ACCY_SOURCE     TEST_2                 //  select between TEST_1, TEST_2, TEST_3, GLIDER_RATIO , SECONDS_SINCE_T0 ,AVERAGE_VSPEED_SINCE_TO , VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, PITCH, ROLL , YAW, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define ACCZ_SOURCE     TEST_3                 //  select between TEST_1, TEST_2, TEST_3, GLIDER_RATIO , SECONDS_SINCE_T0 ,AVERAGE_VSPEED_SINCE_TO , VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, PITCH, ROLL , YAW, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define T1_SOURCE       TEST_1                   //  select between TEST_1, TEST_2, TEST_3 , GLIDER_RATIO , SECONDS_SINCE_T0 ,AVERAGE_VSPEED_SINCE_TO , SENSITIVITY, PPM, VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define T2_SOURCE       TEST_2                    //  select between TEST_1, TEST_2, TEST_3, , GLIDER_RATIO, SECONDS_SINCE_T0 ,AVERAGE_VSPEED_SINCE_TO , SENSITIVITY, PPM, VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4

// ***** 2.2 - Hott data *****
//#define CELL_UNDERVOLTAGE_WARNING 3300            // Warning threshold in mV; 
//#define BATTERY_1_SOURCE          ADS_VOLT_1                 // select between VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define BATTERY_2_SOURCE          ADS_VOLT_2                 // select between VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define MAIN_BATTERY_SOURCE       ADS_VOLT_3                 // select between VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
//#define TEMPERATURE_1_SOURCE      VOLT_1          //  select between VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, TEST_1, TEST_2, TEST_3 , GLIDER_RATIO , SENSITIVITY , PPM
//#define TEMPERATURE_2_SOURCE      PPM             //  select between VOLT_1, VOLT_2, VOLT_3, VOLT_4, VOLT_5, VOLT_6, TEST_1, TEST_2, TEST_3 , GLIDER_RATIO , SENSITIVITY, PPM

// ***** 2.3 - Multiplex data *****
#define SETUP_MULTIPLEX_DATA_TO_SEND    \
                        5 , REL_ALTIMETER , 1 , 1 , 0 , -16384 , 16383 , \
                        6 , VERTICAL_SPEED , 1 , 1 , 0, -500 , 500  , \
                        7 , ALTIMETER_MAX , 1 , 1 , 0 , -16384 , 16383 
                        // 8 , VOLT_1 , 1, 1 , 0 , -16384 , 16383
                        // 6 , CURRENTMA , 1 , 1, 0 , -16384 , 16383 ,\
                        // 7 , MILLIAH  , 1 , 1, 0 , -16384 , 16383
                        // 7 , CELL_TOT , 1 , 1 , 0 , -16384 , 16383 , \
                        // 4 , VOLT_4 , 1 , 1 , 0 , -16384 , 16383 , \
                        // 9 , PPM , 1 , 1 , 0 , -16384 , 16383 
                        // 3 , ALTIMETER , 1 , 1 , 0 , -16384 , 16383 , \
// ***** 2.4 - Jeti data *****
#define VOLTAGE_SOURCE   VOLT_1                     // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6
//#define TEMPERATURE_SOURCE NTC                   // select between MS5611 and NTC

// ***** 2.5 - How to fill TEST_1, TEST_2, TEST_3  ******     see oXs_config_advanced.h (required only when some measurements have to be filled in TEST_1, TEST_2 or TEST_3)

// --------- 3 - PPM settings ---------            see oXs_config_advanced.h (default, this option is not active)

// --------- 4 - Vario settings ---------
// ***** 4.1 - Connecting 1 or 2 barometric sensor(s)  ***** 
#define FIRST_BARO_SENSOR_USE   MS5611       // select between NO_BARO , MS5611, GY86 , BMP085 , BMP180 , GY87,  BMP280  
                                              // Note : when used, second sensor is to define in oXs_config_advanced.h
                                              
// ***** 4.2 - Type of Vspeed to transmit  *****                                    
#define VSPEED_SOURCE  FIRST_BARO    // select between FIRST_BARO, BARO_AND_IMU, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED or PPM_SELECTION

// ***** 4.3 - Sensitivity predefined by program *****                               see oXs_config_advanced.h (normally no need to change it)
// ***** 4.4 - Sensitivity adjusted from the TX *****                                see oXs_config_advanced.h (normally no need to change it)
// ***** 4.5 - Hysteresis parameter & Alt compensation based on sensor temp *****    see oXs_config_advanced.h (normally no need to change it)
// ***** 4.6 - Vertical speeds calculations based on PPM  ****                       see oXs_config_advanced.h (change only if PPM_SELECTION is used)
// ***** 4.7 - Analog vertical speed *****                                           see oXs_config_advanced.h (change if you want to activate it)
// ***** 4.8  - Calculating glider ratio, average sink/climb rate **************     see oXs_config_advanced.h (change if you want to get those measurement)
// --------- 5 - Airspeed settings ---------                                         see oXs_config_advanced.h for additionnal parameters (normally no need to change them)
#define AIRSPEED_SENSOR_USE       NO_AIRSPEED       // select between NO_AIRSPEED , MS4525 , MPXV7002

// --------- 6 - Voltages & Current sensor settings ---------

// ***** 6.1 - Voltage Reference to measure voltages and current *****              see oXs_config_advanced.h when voltage reference is not Vcc and 5 volt

// ***** 6.2 - Voltage parameters *****                                             see oXs_config_advanced.h for additionnal parameters when YES
#define ARDUINO_MEASURES_VOLTAGES   YES                                        //   select between YES , NO (When NO, following line is discarded)

// ***** 6.3 - Max number of Lipo cells to measure (and transmit to Tx) *****
#define NUMBEROFCELLS 3                                                 // Put this line as comment or set value to 0 (zero) if you do not want to transmit cell voltages.

// ***** 6.4 - Convert voltage to temperature (° Celcius) *****                    see oXs_config_advanced.h if you want to measure temperature(s) with thermistor

// ***** 6.5 - Current parameters  *****                                           see also oXs_config_advanced.h for additionnal parameters if you want to measure current with a current sensor
#define ARDUINO_MEASURES_A_CURRENT   YES                                       //   select between YES , NO 

// ***** 6.6 - Ads1115 parameters  *****                                           see oXs_config_advanced.h for additional parameters when AN_ADS1115_IS_CONNECTED is YES
#define AN_ADS1115_IS_CONNECTED   NO                 // select between YES , NO

// --------- 7 - RPM (rotations per minute) settings ---------                     see oXs_config_advanced.h for additional parameter about the number of pulses per rotation
#define CALCULATE_RPM     NO                         // select between YES , NO       

// --------- 8 - Persistent memory settings ---------                             ( see also oXs_config_advanced.h - used mainly when a flow sensor is connected )
#define SAVE_TO_EEPROM     NO

// --------- 9 - GPS ---------------                                               see oXs_config_advanced.h for additionnal parameters (normally no need to change them)
#define A_GPS_IS_CONNECTED      NO                   // select between YES , NO

// --------- 10 - IMU 6050 --- (accelerometer + gyro)  and HMC5883 (magnetometer) --  see oXs_config_advanced.h for additionnal parameters e.g. about calibration
// ***** 10.1 - IMU 6050 *****
#define A_MPU6050_IS_CONNECTED      NO              // select between YES , NO

// ***** 10.2 - HMC5883 *****
#define CALCULATE_YAW_WITH_HMC5883   NO             // select between YES , NO ; YES requires that A_MPU6050_IS_CONNECTED is YES here above

// --------- 11 - Flow sensor ---------------                                       if YES, see also oXs_config_advanced.h 
#define A_FLOW_SENSOR_IS_CONNECTED      NO          // select between YES , NO

// --------- 20 - Sequencer ---------                                               see oXs_config_advanced.h (only when oXs has to generate signals in sequence)


#endif// End define OXS_CONFIG_BASIC_h

Code: Select all

//******************************************************************************************************************************************************* //
//                                                                                                                                                        //
// ! IMPORTANT NOTE !!!!!!!!!!   Another file in this project provides detailed explanations on how to set up this file (see oXs_config_description.h).   //
//                                                                                                                                                        //
//******************************************************************************************************************************************************* //
//  Note: the oXs_config_advanced.h file present on the GitHub site is not always meaningful.
//       It could be that the combination of active/non active parameters is not consistent.
//       This is just the result of many updates and tests in this document.
//       So take always care to set up the oXs_config_basic.h and oXs_config_advanced.h files according to your needs and check carefully all options.

#ifndef OXS_CONFIG_ADVANCED_h
#define OXS_CONFIG_ADVANCED_h
//#include "oXs_config_basic.h"


// --------- 1 - Telemetry protocol ---------  Protocol is defined in oXs_config_basic.h file

// ****** 1.1 - Pin connected to Rx ********
#define PIN_SERIALTX      4                 // The pin which transmits the serial data to the telemetry receiver, Usually pin 4 (otherwise pin 2)

// ***** 1.2 - SPORT_SENSOR_ID used (only for Frsky Sport protocol)  *****   See list of available values in oXs_config_descripion.h 
#define         DATA_ID_VARIO  0x00  // = sensor 0 used for Alt and Vspeed
#define         DATA_ID_FLVSS  0xA1  //          1 used for Cell values
#define         DATA_ID_FAS    0x22  //          2 used for vfas , current and fuel
#define         DATA_ID_GPS    0x83  //          3 used for GPS data
#define         DATA_ID_RPM    0xE4  //          4 used for rpm, T1, T2, airspeed
#define         DATA_ID_ACC    0x67  //          7 used for Acc X, Y, Z
#define         DATA_ID_TX     0x0D  //           used to read data sent by Tx in order to adjust some oXs parameters (flow sensor or ppm)
// --------- 2 - Data to transmit ---------                   
// ***** 2.1 - Frsky data *****                              see oXs_config_basic.h file
// ***** 2.2 - Hott data *****                               see oXs_config_basic.h file
// ***** 2.3 - Multiplex data *****                          see oXs_config_basic.h file   
// ***** 2.4 - Jeti data *****                               see oXs_config_basic.h file

// ***** 2.5 - How to fill TEST_1, TEST_2, TEST_3  ******    
//define FILL_TEST_3_WITH_EXPECTED_ALT                        // uncomment this line if oXs has to calculate an expected Alt in the future based on current Alt, Vspeed and vertical Acc
//#define EXPECTED_ALT_AT_SEC 0.2                               // time (in sec) for expected Alt (this line must be uncommented wen previous is uncommented

//#define FILL_TEST_1_2_3_WITH_LINEAR_ACC                     // uncomment this line if oXs has to fill TEST_1, TEST_2, TEST_3 with linear Acc

//#define FILL_TEST_1_2_WITH_VSPEED_AND_ALT_FROM_SECOND_VARIO  // uncomment to activate this option

//#define FILL_TEST_1_WITH_DTE                                 // uncomment to activate this option

//#define FILL_TEST_2_WITH_PPM_AIRSPEED_COMPENSATION           // uncomment to activate this option

//#define FILL_TEST_1_WITH_YAWRATE                             // uncomment to activate this option

//#define FILL_TEST1_WITH_HEADING_FROM_MAGNETOMETER              // uncomment to activate this option

//#define FILL_TEST_1_2_3_WITH_FLOW_SENSOR_CONSUMPTION             // uncomment to activate this option

// --------- 3 - PPM settings ---------
//#define PIN_PPM           2     // Uncomment this line in order to use a Rx channel to control oXs; default is 2 but my own device use 3
#define PPM_MIN_100       988     // default 1500 - 512 ; // pulse width (usec) when TX sends a channel = -100
#define PPM_PLUS_100      2012    // default 1500 + 512 ; // pulse width (usec) when TX sends a channel = +100

//#define PPM_VIA_SPORT             // uncomment this line to get ppm data over SPORT protocol instead of from a PWM channel (it requires a Tx with openTx running LUA script)

// --------- 4 - Vario settings ---------    Type of baro is defined in oXs_config_basic.h file

// ***** 4.1 - Connecting 1 or 2 barometric sensor(s)  ***** 
#define SECOND_BARO_SENSOR_USE    NO_BARO                    // select between NO_BARO , MS5611

// ***** 4.2 - Type of Vspeed to transmit  *****             Is defined only in oXs_config_basic.h file                       

// ***** 4.3 - Sensitivity predefined by program *****
#define SENSITIVITY_MIN 80          // normal value for MS5611; for BMP, it is probably better to use a lower value like 20
#define SENSITIVITY_MAX 300
#define SENSITIVITY_MIN_AT 100
#define SENSITIVITY_MAX_AT 1000

// ***** 4.4 - Sensitivity adjusted from the TX *****
#define SENSITIVITY_MIN_AT_PPM 10    // sensitivity will be changed by OXS only when PPM signal is between the specified range enlarged by -5 / +5
#define SENSITIVITY_MAX_AT_PPM 40
#define SENSITIVITY_PPM_MIN  20      // common value for vario is 20
#define SENSITIVITY_PPM_MAX 100      // common value for vario is 100

// ***** 4.5 - Hysteresis parameter & Alt compensation based on sensor temp *****
#define VARIOHYSTERESIS 5
//#define ALT_TEMP_COMPENSATION 800

// ***** 4.6 - Vertical speeds calculations based on PPM *****
#define VARIO_PRIMARY       FIRST_BARO          // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
#define VARIO_SECONDARY     AIRSPEED_COMPENSATED          // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
#define SWITCH_VARIO_MIN_AT_PPM 10
#define SWITCH_VARIO_MAX_AT_PPM 90

// ***** 4.7 - Analog vertical speed *****
//#define PIN_ANALOG_VSPEED 3                 // Uncomment this line to get an analog voltage related to Vspeed
#define ANALOG_VSPEED_MIN -3
#define ANALOG_VSPEED_MAX  3

// ***** 4.8  - Calculating glider ratio, average sink/climb rate ******************************
//#define GLIDER_RATIO_CALCULATED_AFTER_X_SEC 1  // Uncomment this line as comment if a calculation must be performed ; value must be higher or equal to 1 (sec)
#define SPEED_TOLERANCE   5              // in % of speed
#define VSPEED_MIN_TOLERANCE -200        // out of tolerance when Vspeed is lower than this value  (cm/sec)
#define VSPEED_MAX_TOLERANCE  -10        // out of tolerance when Vspeed is upper than this value  (cm/sec)
#define GLIDER_RATIO_ON_AT_PPM -100      // Glider ratio is calculated when PPM has this value ; keep as comment when ppm is not used 

// --------- 5 - Airspeed settings ---------
//#define AIRSPEED_AT_SEA_LEVEL_AND_15C // if this line is commented, airspeed is calculated using baro pressure and temperature (so being "true" airspeed instead of normalised airspeed)      
//#define AIRSPEED_IN_KMH  // uncomment this line if airspeed has to be in km/h instead of knot/h ( except some old versions, openTx expects knot/h) 

#define AIRSPEED_RESET_AT_PPM   100

#define COMPENSATION_MIN_AT_PPM 60
#define COMPENSATION_MAX_AT_PPM 90
#define COMPENSATION_PPM_MIN  80
#define COMPENSATION_PPM_MAX 140

// --------- 6 - Voltages & Current sensor settings ---------

// ***** 6.1 - Voltage Reference to measure voltages and current *****
#define USE_INTERNAL_REFERENCE  // uncomment this line if you use 1.1 volt internal reference instead of Vcc (voltage divider mst be used to reduce voltages to 1.1 volt max)
//#define USE_EXTERNAL_REFERENCE  // uncomment this line if you use an external reference instead of Vcc
//#define REFERENCE_VOLTAGE 4970    // set value in milliVolt; if commented, oXs will use or 1100 (if internal ref is used) or 5000 (if internal ref is not used) 

// ***** 6.2 - Voltage parameters *****
// Each of following lines contains 6 parameters, the first value is for VOLT_1, the second for VOLT_2, ... up to the sixth for VOLT_6 
#define PIN_VOLTAGE        2  , 3     , 6   , 1    , 8   , 8               //  Fill 6 values; set to 0 up to 7 for analog pins A0 up to A7 ; set the value to 8 for the voltage(s) not to be measured.
#define RESISTOR_TO_GROUND  0 , 6   , 3  , 3 , 0  , 18               // set value to 0 when no divider is used for a voltage; can contains decimals 
#define RESISTOR_TO_VOLTAGE 0 , 47 , 47 , 47  , 0 , 47              // set value to 0 when no divider is used for a voltage; can contains decimals 
#define OFFSET_VOLTAGE      0   , 0     , 0    , 0    , 0   , 0                // optionnal, can be negative, must be integer, in principe in mv
#define SCALE_VOLTAGE       1.00 , 1.0   , 1.0  , 1.0  , 1.0 , 1.0              // optionnal, can be negative, can have decimals

// ***** 6.3 - Max number of Lipo cells to measure (and transmit to Tx) *****      Is defined only in oXs_config_basic.h file

// ***** 6.4 - Convert voltage to temperature (° Celcius) *****     
//#define FIRST_NTC_ON_VOLT_NR 1   // uncomment this line when thermistor are used; specify index of first voltage being used for conversion to temperature (e.g. 5 means VOLT_5)
#define LAST_NTC_ON_VOLT_NR 1    // specify index of last voltage being used for conversion to temperature (e.g. 6 means VOLT_6)
#define SERIE_RESISTOR 4700      // resistance connected to Arduino Vcc (in Ohm)
#define STEINHART_A 7.00111E-4   // these parameters are specific to the NTC being used.
#define STEINHART_B 2.1644E-4
#define STEINHART_C 1.0619E-07

//#define TERMISTOR_NOMINAL 100000 // nominal resistor of NTC (in Ohm)                    Those 3 parameters are not used anymore (replaced by STEINHART8A B and C
//#define TEMPERATURE_NOMINAL 25 // nominal temperature of NTC (in degree Celcius)
//#define B_COEFFICIENT 3950 // B coefficient of NTC

// ***** 6.5 - Current parameters  *****
#define PIN_CURRENTSENSOR   0  //      Arduino pin used to measure the voltage provided by a current sensor
#define MVOLT_AT_ZERO_AMP              2500    // in millivolt
#define MVOLT_PER_AMP                  60      // in milliVolt per Amp
#define RESISTOR_TO_GROUND_FOR_CURRENT  20  // put as comment or set to 0 if no divider is used (e.g. 19.8 for 1.1 internal ref)
#define RESISTOR_TO_CURRENT_SENSOR      39   // put as comment or set to 0 if no divider is used (e.g  39   for 1.1 internal ref)

// ***** 6.6 - Ads1115 parameters  *****
#define ADS_MEASURE A0_TO_A1 ,  ADS_OFF , ADS_OFF , ADS_OFF // select 4 values between A0_TO_A1, A0_TO_A3, A1_TO_A3, A2_TO_A3, A0_TO_GND, A1_TO_GND, A2_TO_GND, A3_TO_GND, ADS_OFF
#define ADS_FULL_SCALE_VOLT  MV2048, MV4096, MV6144, MV4096 //  select between MV6144 MV4096 MV2048 MV1024 MV512 MV256
#define ADS_OFFSET 0, 0 , 0 , 0 // must be an integer (positive or negative)
#define ADS_SCALE 1, 1, 1, 1 // can be a float
#define ADS_RATE  MS2 , MS9, MS9 , MS2 // select between MS137, MS69, MS35, MS18, MS9, MS5, MS3 , MS2
#define ADS_AVERAGING_ON 10 , 20, 30, 50 // number of values used for averaging (must be between 1 and 254) 
//#define ADS_CURRENT_BASED_ON ADS_VOLT_1  // uncomment if current, and comsumption have to be calculated based on one of ADS voltage measurement; select then the voltage to be used between ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
#define ADS_AIRSPEED_BASED_ON ADS_VOLT_1  // uncomment if airspeed (and dte) have to be calculated based on one of ADS voltage measurement ; select then the voltage to be used between ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4

// --------- 7 - RPM (rotations per minute) settings ---------                      
#define PULSES_PER_ROTATION 2

// --------- 8 - Persistent memory settings ---------
//#define PIN_PUSHBUTTON    2   // default is 10 but my own device is 2

// --------- 9 - GPS ------------------------------------------------------------------------------------------------
//#define GPS_SPEED_IN_KMH  // uncomment this line if GPS speed has to be sent in km/h instead of knot/h (only for Frsky protocol)
#define GPS_SPEED_3D      // uncomment this line if GPS speed has to be the 3d speed instead of the 2d speed (note: 3d is probably less accurate - to test) 
#define GPS_REFRESH_RATE  5      // rate at which GPS sent new data; select between 1, 5 or 10 (Hz). Default = 5 Hz; Ublox NEO6 does not support 10 hz  

// --------- 10 - IMU 6050 --- (accelerometer + gyro) and HMC5883 (magnetometer) --------------------------------------
// ***** 10.1 - IMU 6050 *****
#define PIN_INT_6050 2   // Interrupt from 6050 has to be connected to Arduino pin 2 or pin 3 (do not use here the same pin as PPM)

//#define DISPLAY_ACC_OFFSET // used ONLY in order to display the acceleration offset on pc terminal; KEEP AS COMMENT once offsets have been setup 

#define ACC_OFFSET_X 0 // fill here the first value reported when DISPLAY_ACC_OFFSET is activated (eg. -160)
#define ACC_OFFSET_Y 0 // fill here the second value reported when DISPLAY_ACC_OFFSET is activated (eg. -150)
#define ACC_OFFSET_Z 0 // fill here the third value reported when DISPLAY_ACC_OFFSET is activated (eg. -1100)

// ***** 10.2 - HMC5883 *****
//#define GENERATE_MAG_CALIBRATION_DATA   // uncomment this line when HMC5883 calibration has to be performed. Set back as comment once calibration parameters have been introduced 

#define    XMAG_OFFSET 2.4683     // must be an integer
#define    YMAG_OFFSET -1.3694     // must be an integer
#define    ZMAG_OFFSET 138.9683     // must be an integer
#define    XXMAG_CORRECTION  0.122082   // can have decimals
#define    XYMAG_CORRECTION  -0.00204026
#define    XZMAG_CORRECTION  0.00377534 
#define    YXMAG_CORRECTION  -0.00204026
#define    YYMAG_CORRECTION  0.130413
#define    YZMAG_CORRECTION  -0.00491189
#define    ZXMAG_CORRECTION  0.00377534
#define    ZYMAG_CORRECTION  -0.00491189
#define    ZZMAG_CORRECTION  0.138038

// --------- 11 - Flow sensor ---------
#define PULSES_PER_ML                    10.0                 // number of pulses per milli liter (depends on sensor); can have decimals
#define TANK_CAPACITY                    1000                 // tank capacity in ml
#define INIT_FLOW_PARAM  30 , 100 , 500 , 700 , 0 , 0, 0, 0   // define at 4 levels of flow (in mliter/min) (e.g. 30, 100, 500, 700) 4 correction parameters (in %; e.g. 20, 10, -5, 15); flow levels have to be sorted from low to high
#define FLOW_SENSOR_RESET_AT_PPM         95                   // when absolute value of ppm is greater than this, flow counter is reset.

// --------- 20 - Sequencer ---------
//#define SEQUENCE_OUTPUTS 0b100000  
#define SEQUENCE_UNIT 2
#define SEQUENCE_m100    1 , 0b100000 , 3 , 0b000000 , 1 , 0b100000 , 3 , 0b000000 
//#define SEQUENCE_m75     1 , 0b100000 , 1 , 0b000000 , 2 , 0b100000 , 2 , 0b000000
//#define SEQUENCE_m50     5 , 0b100000 , 5 , 0b000000
//#define SEQUENCE_m25     5 , 0b100000 , 5 , 0b000000 , 0 , 0b100000
#define SEQUENCE_0       3 , 0b100000 , 1 , 0b000000
//#define SEQUENCE_25      2 , 0b100000 , 2 , 0b000000
//#define SEQUENCE_50      5 , 0b100000 , 5 , 0b000000
//#define SEQUENCE_75      7 , 0b100000 , 7 , 0b000000
#define SEQUENCE_100     8 , 0b100000 , 16 , 0b000000 , 24 , 0b100000 , 32 , 0b000000  
//#define SEQUENCE_LOW    10 , 0b100000 ,10 , 0b000000   // sequence for Low voltage
//#define SEQUENCE_MIN_VOLT_6 4000 // sequence_100 will be activated if voltage 6 is lower that the value.
//#define SEQUENCE_MIN_CELL   3000 // sequence_100 will be activated if lowest cell is lower that the value.


// --------- xx - Reserved for developer. DEBUG must be activated here when we want to debug one or several functions in some other files. ---------
//#define DEBUG
///#define DEBUG_BLINK   // use by developper in order to blink the led without using uart for debugging


#define BASED_ON_AIRSPEED 0
#define BASED_ON_GPS_SPEED 1
#define AVERAGING_DELAY_MILLISEC  AVERAGING_TOLERANCE * 100  

#define FIRST_BARO 1
#define SECOND_BARO 2
#define AVERAGE_FIRST_SECOND 4
#define AIRSPEED_COMPENSATED 3
#define BARO_AND_IMU 5
#define PPM_SELECTION 6

#include <Arduino.h>
struct ONE_MEASUREMENT {
  uint8_t available ;
  int32_t value ;
} ;

#define FRSKY_SPORT      1
#define FRSKY_HUB        2
#define FRSKY_SPORT_HUB  3
#define MULTIPLEX        4
#define HOTT             5
#define JETI             6

#define NO_BARO 1
#define MS5611  2
#define GY86    3
#define BMP085  4
#define BMP180  5
#define BMP280  6
#define GY87    7

#define NO_AIRSPEED 1
#define MS4525      2
#define MVPX7002    3

#define NO  1
#define YES 2

#define NTC 20

#define SECONDS_SINCE_T0        32
#define AVERAGE_VSPEED_SINCE_TO 33 

/***************************************************************************************/
/* oXs code used by Flow sensor and for SPORT Lua scripts                                                        */ 
/***************************************************************************************/
#define TX_FIELD_FLOW_1     0
#define TX_FIELD_FLOW_2     1
#define TX_FIELD_FLOW_3     2
#define TX_FIELD_FLOW_4     3
#define TX_FIELD_FLOW_CORR_1    4
#define TX_FIELD_FLOW_CORR_2    5
#define TX_FIELD_FLOW_CORR_3    6
#define TX_FIELD_FLOW_CORR_4    7
#define TX_FIELD_TANK_CAPACITY  8
#define TX_FIELD_RESET_FUEL     9
#define TX_FIELD_PPM          0x10


#ifdef DEBUG
//#include "HardwareSerial.h"
#endif

#ifdef GPS_INSTALLED
//#include "HardwareSerial.h"
#endif



#ifdef FIRST_BARO_SENSOR_USE
  #if (FIRST_BARO_SENSOR_USE ==  MS5611 ) || (FIRST_BARO_SENSOR_USE ==  GY86 ) || (FIRST_BARO_SENSOR_USE ==  BMP085 ) || (FIRST_BARO_SENSOR_USE ==  BMP180 ) || (FIRST_BARO_SENSOR_USE ==  BMP280 ) || (FIRST_BARO_SENSOR_USE ==  GY87 )
    #define VARIO
  #endif
  #if  (FIRST_BARO_SENSOR_USE ==  BMP085 ) || (FIRST_BARO_SENSOR_USE ==  BMP180 )  || (FIRST_BARO_SENSOR_USE ==  GY87 )
    #define SENSOR_IS_BMP180
  #endif
  #if  (FIRST_BARO_SENSOR_USE ==  BMP280 ) 
    #define SENSOR_IS_BMP280
  #endif
#endif

#ifdef SECOND_BARO_SENSOR_USE
  #if SECOND_BARO_SENSOR_USE ==  MS5611  
    #define VARIO2
  #endif
#endif  

#if ( defined( FIRST_BARO_SENSOR_USE ) && ( (FIRST_BARO_SENSOR_USE ==  MS5611 ) || (FIRST_BARO_SENSOR_USE ==  GY86 ) )) || ( defined( SECOND_BARO_SENSOR_USE ) && ( (SECOND_BARO_SENSOR_USE ==  MS5611 ) || (SECOND_BARO_SENSOR_USE ==  GY86 ) ))
  #define SENSOR_IS_MS5611
#endif

#ifdef  AIRSPEED_SENSOR_USE 
  #if ( AIRSPEED_SENSOR_USE == MS4525 )
    #define AIRSPEED    
  #endif
#endif  


#ifdef CALCULATE_RPM 
  #if ( CALCULATE_RPM == YES )
    #define MEASURE_RPM
  #endif
#endif  


#ifdef  A_GPS_IS_CONNECTED 
  #if ( A_GPS_IS_CONNECTED == YES )
    #define GPS_INSTALLED
  #endif
#endif  


#ifdef  A_MPU6050_IS_CONNECTED 
  #if ( A_MPU6050_IS_CONNECTED == YES )
    #define USE_6050 
  #endif
#endif  

#ifdef  A_MPU6050_IS_CONNECTED 
  #if ( A_MPU6050_IS_CONNECTED == YES ) 
    #ifdef CALCULATE_YAW_WITH_HMC5883
      #if ( CALCULATE_YAW_WITH_HMC5883 == YES )
        #define USE_HMC5883
      #endif
    #endif    
  #endif
#endif  

#if defined( DISPLAY_ACC_OFFSET ) && defined ( A_MPU6050_IS_CONNECTED ) && ( A_MPU6050_IS_CONNECTED == YES )
  #define DEBUG
#endif
#if defined( GENERATE_MAG_CALIBRATION_DATA ) && defined ( A_MPU6050_IS_CONNECTED ) && ( A_MPU6050_IS_CONNECTED == YES ) && defined ( USE_HMC5883 )   
  #define DEBUG
#endif


#endif// End define OXS_CONFIG_ADVANCED_h


ElPete
Posts: 5
Joined: Thu Oct 25, 2018 5:43 pm
Country: -

Re: Setting up openXsensor

Post by ElPete » Sun Oct 28, 2018 7:00 pm

Many thanks!!
It works very well :-)
It seems so easy (when you know what and how to configure).
I will continue with setup and testing. By the way - what is the difference between Volts and ADS-volts?

I will probably come back with more questions....
Next in plan is to add airspeed (I already have a MPXV7002 and ADS1115)

Regards Pete


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

Re: Setting up openXsensor

Post by mstrens » Sun Oct 28, 2018 9:31 pm

Volt are measurements performed by arduino it self.
Accuracy is limited by the number of bits of arduino ADC (10 bits I think) and the accuracy of the internal 1.1 volt reference.
In most case, this accuracy is enough.

Still, if it is not enough, it is possible to add an external module ADS1115 to the arduino. This module has an ADC with 16 bits, a better internal volt and the ability to measure the difference of voltage between 2 pins ( instead of measuring voltage regarding to ground).
The voltage measurements performed via this external module are named ADS_VOLT.

Please read carefully the file oXs_config_description.h
This file explains normally all oXs topics.

tedbmoss
Posts: 117
Joined: Sun Jul 15, 2012 10:42 pm
Country: -
Location: Phoenix, AZ

Re: Setting up openXsensor

Post by tedbmoss » Fri Feb 01, 2019 2:14 pm

Thanks very much for all your work on this project.
I made one several years ago and am now trying to get a single battery voltage (8 cell) and a vario working. So far, no luck.
Did you combine the advanced and basic config.h files? My reason for using this is the FrSky ESC telemetering does not work or can't be discovered in openTX.

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

Re: Setting up openXsensor

Post by mstrens » Fri Feb 01, 2019 2:30 pm

There are 2 config files (basic in advanced) because there are many parameters that can be defined and I expected that in most cases, it would be enough to just change the "basic" parameters. This is e.g. the case when you just want to make a vario.
When you (also) want to make a voltmeter, then you need more parameters and you have to set up both files.
Please, read carefully the file config_description.h
It will explain that you have to use 2 resistors to build a voltage divider in order to reduce the 8s voltage to a value that the arduino can accept.
It will also explain that you have to put the values of those resistors into the config file and you have to ask oXs to transmit the voltage e.g.as "Vfas"

If it is not clear, just ask for more details.

tedbmoss
Posts: 117
Joined: Sun Jul 15, 2012 10:42 pm
Country: -
Location: Phoenix, AZ

Re: Setting up openXsensor

Post by tedbmoss » Wed Feb 06, 2019 7:05 pm

Thank you. :D So far, I have vspd id 1,temp2 id 5 and alt id1.now for the next thing.

tedbmoss
Posts: 117
Joined: Sun Jul 15, 2012 10:42 pm
Country: -
Location: Phoenix, AZ

Re: Setting up openXsensor

Post by tedbmoss » Sat Feb 09, 2019 6:40 pm

So I am confused by oxs config having the same parameters in 6- voltages and current settings as advanced has.
I took out the config_basic but it did not change anything because it was not used, so I put it back in and commented out the extra voltages in the config file then set the parameters in the advanced file and it works. Unfortunately the FrSky ESC only puts out zeros for the readings so far.
Last edited by tedbmoss on Sun Feb 10, 2019 7:36 am, edited 1 time in total.

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

Re: Setting up openXsensor

Post by mstrens » Sat Feb 09, 2019 7:41 pm

Can you explain which measurements you want.
Do you already knows which resistors you will use for the voltage divider?
Have you decided if you use the internal voltage (about 1.1 volt) or Vcc as reference?
Once this defined, I can write the related config lines.

tedbmoss
Posts: 117
Joined: Sun Jul 15, 2012 10:42 pm
Country: -
Location: Phoenix, AZ

Re: Setting up openXsensor

Post by tedbmoss » Sun Feb 10, 2019 7:52 am

Thanks, but I wanted to figure it out myself and I did. Thank you again for building this (and maintaining it). I used 39.2k and 6.8k for the VFAS (8cell)
and 4.7 and 2.2k for A3 (Rx batt 7.3 volt) with a little offset on both.The voltage ref is 5v. I used a .00001 as a divider to avoid the divide by zero error that showed up.
So my Sig 1/4 scale cub is almost ready to go.

tedbmoss
Posts: 117
Joined: Sun Jul 15, 2012 10:42 pm
Country: -
Location: Phoenix, AZ

Re: Setting up openXsensor

Post by tedbmoss » Fri Feb 15, 2019 7:37 pm

just a note: I got the frsky ESC to work , but the readings aren't right yet


Post Reply

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