BMP280 Code cleanup
[openXsensor.git] / openXsensor / oXs_config_advanced.h
bloba13127b72e971053ddfcf2f26aecfc1977209c41
2 //******************************************************************************************************************************************************* //
3 // //
4 // ! IMPORTANT NOTE !!!!!!!!!! Another file in this project provides detailed explanations on how to set up this file (see oXs_config_description.h). //
5 // //
6 //******************************************************************************************************************************************************* //
7 // Note: the oXs_config_advanced.h file present on the GitHub site is not always meaningful.
8 // It could be that the combination of active/non active parameters is not consistent.
9 // This is just the result of many updates and tests in this document.
10 // 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.
12 #ifndef OXS_CONFIG_ADVANCED_h
13 #define OXS_CONFIG_ADVANCED_h
14 //#include "oXs_config_macros.h"
17 // --------- 1 - Telemetry protocol --------- Protocol is defined in oXs_config_basic.h file
19 // ****** 1.1 - Pin connected to Rx ********
20 #define PIN_SERIALTX 4 // The pin which transmits the serial data to the telemetry receiver, Usually pin 4 (otherwise pin 2)
21 // For Frsky protocols, it is also possible to use pin 7 (useful for receiver running the D16 firmware written by MikeB)
22 // ***** 1.2 - SPORT_SENSOR_ID used (only for Frsky Sport protocol) ***** See list of available values in oXs_config_descripion.h
23 #define DATA_ID_VARIO 0x00 // = sensor 0 used for Alt and Vspeed
24 #define DATA_ID_FLVSS 0xA1 // 1 used for Cell values
25 #define DATA_ID_FAS 0x22 // 2 used for vfas , current and fuel
26 #define DATA_ID_GPS 0x83 // 3 used for GPS data
27 #define DATA_ID_RPM 0xE4 // 4 used for rpm, T1, T2, airspeed
28 #define DATA_ID_ACC 0x67 // 7 used for Acc X, Y, Z
29 #define DATA_ID_TX 0x0D // used to read data sent by Tx in order to adjust some oXs parameters (flow sensor or ppm)
30 // --------- 2 - Data to transmit ---------
31 // ***** 2.1 - Frsky data ***** see oXs_config_basic.h file
32 // ***** 2.2 - Hott data ***** see oXs_config_basic.h file
33 // ***** 2.3 - Multiplex data ***** see oXs_config_basic.h file
34 // ***** 2.4 - Jeti data ***** see oXs_config_basic.h file
36 // ***** 2.5 - How to fill TEST_1, TEST_2, TEST_3 ******
37 //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
38 //#define EXPECTED_ALT_AT_SEC 0.2 // time (in sec) for expected Alt (this line must be uncommented wen previous is uncommented
40 //#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
42 //#define FILL_TEST_1_2_WITH_VSPEED_AND_ALT_FROM_SECOND_VARIO // uncomment to activate this option
44 //#define FILL_TEST_1_WITH_DTE // uncomment to activate this option
46 //#define FILL_TEST_2_WITH_PPM_AIRSPEED_COMPENSATION // uncomment to activate this option
48 //#define FILL_TEST_1_WITH_YAWRATE // uncomment to activate this option
50 //#define FILL_TEST1_WITH_HEADING_FROM_MAGNETOMETER // uncomment to activate this option
52 //#define FILL_TEST_1_2_3_WITH_FLOW_SENSOR_CONSUMPTION // uncomment to activate this option
54 //#define FILL_TEST1_WITH_GPS_NUMBER_OF_SAT // uncomment to activate this option; note: when there is a GPS fix 3D (or higher), then number of sat is increased by 100
56 //#define FILL_TEST2_WITH_GPS_HDOP // uncomment to activate this option
58 //#define FILL_TEST_1_2_WITH_LQ // uncomment to activate this option
60 // --------- 3 - PPM settings ---------
62 #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
63 #define PPM_MIN_100 988 // default 1500 - 512 ; // pulse width (usec) when TX sends a channel = -100
64 #define PPM_PLUS_100 2012 // default 1500 + 512 ; // pulse width (usec) when TX sends a channel = +100
66 //#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)
68 // --------- 4 - Vario settings --------- Type of baro is defined in oXs_config_basic.h file
70 // ***** 4.1 - Connecting 1 or 2 barometric sensor(s) *****
71 #define SECOND_BARO_SENSOR_USE NO_BARO // select between NO_BARO , MS5611
73 // ***** 4.2 - Type of Vspeed to transmit ***** Is defined only in oXs_config_basic.h file
75 // ***** 4.3 - Sensitivity predefined by program *****
76 #define SENSITIVITY_MIN 80 // normal value for MS5611; for BMP, it is probably better to use a lower value like 20
77 #define SENSITIVITY_MAX 300
78 #define SENSITIVITY_MIN_AT 100
79 #define SENSITIVITY_MAX_AT 1000
81 // ***** 4.4 - Sensitivity adjusted from the TX *****
82 #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
83 #define SENSITIVITY_MAX_AT_PPM 40
84 #define SENSITIVITY_PPM_MIN 20 // common value for vario is 20
85 #define SENSITIVITY_PPM_MAX 100 // common value for vario is 100
87 // ***** 4.5 - Hysteresis parameter & Alt compensation based on sensor temp *****
88 #define VARIOHYSTERESIS 5
89 //#define ALT_TEMP_COMPENSATION 800
91 // ***** 4.6 - Vertical speeds calculations based on PPM *****
92 #define VARIO_PRIMARY FIRST_BARO // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
93 #define VARIO_SECONDARY AIRSPEED_COMPENSATED // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
94 #define SWITCH_VARIO_MIN_AT_PPM 10
95 #define SWITCH_VARIO_MAX_AT_PPM 90
97 // ***** 4.7 - Analog vertical speed *****
98 //#define PIN_ANALOG_VSPEED 3 // Uncomment this line to get an analog voltage related to Vspeed
99 #define ANALOG_VSPEED_MIN -3
100 #define ANALOG_VSPEED_MAX 3
102 // ***** 4.8 - Calculating glider ratio, average sink/climb rate ******************************
103 //#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)
104 #define SPEED_TOLERANCE 5 // in % of speed
105 #define VSPEED_MIN_TOLERANCE -200 // out of tolerance when Vspeed is lower than this value (cm/sec)
106 #define VSPEED_MAX_TOLERANCE -10 // out of tolerance when Vspeed is upper than this value (cm/sec)
107 #define GLIDER_RATIO_ON_AT_PPM -100 // Glider ratio is calculated when PPM has this value ; keep as comment when ppm is not used
109 // --------- 5 - Airspeed settings ---------
110 //#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)
111 //#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)
113 #define AIRSPEED_RESET_AT_PPM 100
115 #define COMPENSATION_MIN_AT_PPM 60
116 #define COMPENSATION_MAX_AT_PPM 90
117 #define COMPENSATION_PPM_MIN 80
118 #define COMPENSATION_PPM_MAX 140
120 // --------- 6 - Voltages & Current sensor settings ---------
122 // ***** 6.1 - Voltage Reference to measure voltages and current *****
123 #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)
124 //#define USE_EXTERNAL_REFERENCE // uncomment this line if you use an external reference instead of Vcc
125 //#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)
127 // ***** 6.2 - Voltage parameters *****
128 // 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
129 #define PIN_VOLTAGE 6 , 8 , 8 , 8 , 8 , 8 // Fill all 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.
130 #define RESISTOR_TO_GROUND 2.95 , 10 , 10 , 10 , 0 , 18 // set value to 0 when no divider is used for a voltage; can contains decimals
131 #define RESISTOR_TO_VOLTAGE 46.9 , 8.7 , 22 , 27 , 0 , 47 // set value to 0 when no divider is used for a voltage; can contains decimals
132 #define OFFSET_VOLTAGE 0 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, must be integer, in principe in mv
133 #define SCALE_VOLTAGE 1.00 , 1.0 , 1.0 , 1.0 , 1.0 , 1.0 // optionnal, can be negative, can have decimals
135 // ***** 6.3 - Max number of Lipo cells to measure (and transmit to Tx) ***** Is defined only in oXs_config_basic.h file
137 // ***** 6.4 - Convert voltage to temperature (° Celcius) *****
138 //#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)
139 #define LAST_NTC_ON_VOLT_NR 1 // specify index of last voltage being used for conversion to temperature (e.g. 6 means VOLT_6)
140 #define SERIE_RESISTOR 4700 // resistance connected to Arduino Vcc (in Ohm)
141 #define STEINHART_A 7.00111E-4 // these parameters are specific to the NTC being used.
142 #define STEINHART_B 2.1644E-4
143 #define STEINHART_C 1.0619E-07
145 //#define TERMISTOR_NOMINAL 100000 // nominal resistor of NTC (in Ohm) Those 3 parameters are not used anymore (replaced by STEINHART8A B and C
146 //#define TEMPERATURE_NOMINAL 25 // nominal temperature of NTC (in degree Celcius)
147 //#define B_COEFFICIENT 3950 // B coefficient of NTC
149 // ***** 6.5 - Current parameters *****
150 #define PIN_CURRENTSENSOR 6 // Arduino pin used to measure the voltage provided by a current sensor
151 #define MVOLT_AT_ZERO_AMP 2500 // in millivolt
152 #define MVOLT_PER_AMP 60 // in milliVolt per Amp
153 #define RESISTOR_TO_GROUND_FOR_CURRENT 0 // put as comment or set to 0 if no divider is used (e.g. 19.8 for 1.1 internal ref)
154 #define RESISTOR_TO_CURRENT_SENSOR 0 // put as comment or set to 0 if no divider is used (e.g 39 for 1.1 internal ref)
156 // ***** 6.6 - Ads1115 parameters *****
157 //#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
158 //#define ADS_FULL_SCALE_VOLT MV2048, MV4096, MV6144, MV4096 // select between MV6144 MV4096 MV2048 MV1024 MV512 MV256
159 //#define ADS_OFFSET 0, 0 , 0 , 0 // must be an integer (positive or negative)
160 //#define ADS_SCALE 1, 1, 1, 1 // can be a float
161 //#define ADS_RATE MS2 , MS9, MS9 , MS2 // select between MS137, MS69, MS35, MS18, MS9, MS5, MS3 , MS2
162 //#define ADS_AVERAGING_ON 10 , 20, 30, 50 // number of values used for averaging (must be between 1 and 254)
163 //#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
164 //#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
166 // --------- 7 - RPM (rotations per minute) settings ---------
167 #define PULSES_PER_ROTATION 2
169 // --------- 8 - Persistent memory settings ---------
170 //#define PIN_PUSHBUTTON 2 // default is 10 but my own device is 2
172 // --------- 9 - GPS ------------------------------------------------------------------------------------------------
173 //#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)
174 #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)
175 #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
177 // --------- 10 - IMU 6050 --- (accelerometer + gyro) and HMC5883 (magnetometer) --------------------------------------
178 // ***** 10.1 - IMU 6050 *****
179 #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)
181 //#define DISPLAY_ACC_OFFSET // used ONLY in order to display the acceleration offset on pc terminal; KEEP AS COMMENT once offsets have been setup
183 #define ACC_OFFSET_X 0 // fill here the first value reported when DISPLAY_ACC_OFFSET is activated (eg. -160)
184 #define ACC_OFFSET_Y 0 // fill here the second value reported when DISPLAY_ACC_OFFSET is activated (eg. -150)
185 #define ACC_OFFSET_Z 0 // fill here the third value reported when DISPLAY_ACC_OFFSET is activated (eg. -1100)
187 // ***** 10.2 - HMC5883 *****
188 //#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
190 #define XMAG_OFFSET 2.4683 // must be an integer
191 #define YMAG_OFFSET -1.3694 // must be an integer
192 #define ZMAG_OFFSET 138.9683 // must be an integer
193 #define XXMAG_CORRECTION 0.122082 // can have decimals
194 #define XYMAG_CORRECTION -0.00204026
195 #define XZMAG_CORRECTION 0.00377534
196 #define YXMAG_CORRECTION -0.00204026
197 #define YYMAG_CORRECTION 0.130413
198 #define YZMAG_CORRECTION -0.00491189
199 #define ZXMAG_CORRECTION 0.00377534
200 #define ZYMAG_CORRECTION -0.00491189
201 #define ZZMAG_CORRECTION 0.138038
203 // --------- 11 - Flow sensor ---------
204 #define PULSES_PER_ML 10.0 // number of pulses per milli liter (depends on sensor); can have decimals
205 #define TANK_CAPACITY 1000 // tank capacity in ml
206 #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
207 #define FLOW_SENSOR_RESET_AT_PPM 95 // when absolute value of ppm is greater than this, flow counter is reset.
209 // -------- 13 - Rf link quality ----
210 #define PULSE_INTERVAL_MIN 17000 // minimum delay (micro second) between 2 PWM pulses generated by the Rx
211 #define PULSE_INTERVAL_MAX 19000 // maximum delay (micro second) between 2 PWM pulses generated by the Rx
212 #define LQ_COUNT_MAX 50 // number of PWM pulses used to calculate the 2 Rf quality parameters; 50 means that you get the measurement once per second (e.g. 18msec * 50)
213 #define WIDTH_ERROR_MAX 1 // PWM pulse is considered wrong if the width of 2 conscutive pulses differs by this parameter or less. Normally this parameter should be set on 1 or 2.
215 // --------- 20 - Sequencer ---------
216 //#define SEQUENCE_OUTPUTS 0b100000
217 #define SEQUENCE_UNIT 2
218 #define SEQUENCE_m100 1 , 0b100000 , 3 , 0b000000 , 1 , 0b100000 , 3 , 0b000000
219 //#define SEQUENCE_m75 1 , 0b100000 , 1 , 0b000000 , 2 , 0b100000 , 2 , 0b000000
220 //#define SEQUENCE_m50 5 , 0b100000 , 5 , 0b000000
221 //#define SEQUENCE_m25 5 , 0b100000 , 5 , 0b000000 , 0 , 0b100000
222 #define SEQUENCE_0 3 , 0b100000 , 1 , 0b000000
223 //#define SEQUENCE_25 2 , 0b100000 , 2 , 0b000000
224 //#define SEQUENCE_50 5 , 0b100000 , 5 , 0b000000
225 //#define SEQUENCE_75 7 , 0b100000 , 7 , 0b000000
226 #define SEQUENCE_100 8 , 0b100000 , 16 , 0b000000 , 24 , 0b100000 , 32 , 0b000000
227 //#define SEQUENCE_LOW 10 , 0b100000 ,10 , 0b000000 // sequence for Low voltage
228 //#define SEQUENCE_MIN_VOLT_6 4000 // sequence_100 will be activated if voltage 6 is lower that the value.
229 //#define SEQUENCE_MIN_CELL 3000 // sequence_100 will be activated if lowest cell is lower that the value.
232 #endif// End define OXS_CONFIG_ADVANCED_h