UBlox M10 Support
[openXsensor.git] / openXsensor / oXs_config_description.h
blobb4521ace1a9ff0b4f2ddbb3289b61823428a3f44
1 /*
2 *************************************************************************************
3 * Important Note:
4 * The purpose of this file is to provide detailed explanations on how to build and configure an openXsensor (oXs) device.
5 * To configure your oXs you have to edit at least the file oXs_config_basic.h
6 * In some cases, you will also have to edit the file oXs_config_advanced.h
7 *************************************************************************************
9 See OpenXsensor https://github.com/openXsensor/
11 ************************************************************************************************************************
12 ************************************* General explanation of the different options *************************************
13 ************************************************************************************************************************
14 * The files oXs_config_basic.h and oXs_config_advanced.h allow the user to set up different options. Here is a summary of the main options.
16 * 1 - Telemetry protocol
17 * 1.1 - Pin connected to Rx
18 * 1.2 - SPORT_SENSOR_ID (used only for Frsky Sport protocol)
19 * 2 - Data to transmit to Tx
20 * 3 - PPM settings (optional)
21 * 4 - Vario settings (vario is optional)
22 * 4.1 - Connecting 1 or 2 barometric sensor(s)
23 * 4.2 - Type of Vspeed to transmit
24 * 4.3 - Sensitivity predefined by program
25 * 4.4 - Sensitivity adjusted from the TX
26 * 4.5 - Hysteresis parameter & Alt compensation based on sensor temp
27 * 4.6 - Vertical speeds calculations based on PPM (optional)
28 * 4.7 - Analog vertical speed (optional)
29 * 4.8 - Calculating glider ratio, average sink/climb rate, average altitude gain/loose (optional)
30 * 5 - Airspeed sensor settings (optional)
31 * 6 - Voltage measurements and current sensor settings (optional)
32 * 6.1 - Voltage Reference to measure voltages and current
33 * 6.2 - Voltages parameters
34 * 6.3 - Max number of lipo cells to measure (and transmit to Tx)
35 * 6.4 - Convert voltage to temperature (° Celcius)
36 * 6.5 - Current sensor parameters
37 * 6.6 - Ads1115 parameters
38 * 7 - RPM (rotations per minute) sensor settings (optional)
39 * 8 - Persistent memory settings (optional)
40 * 9 - GPS (optional)
41 * 10 - IMU 6050 (accelerometer/gyro sensor) (optionnal) and HMC5883 (magnetometer)
42 * 11 - Flow sensor
43 * 12 - Locator
44 * 13 - Rf link quality
45 * 20 - Sequencer (ON/OFF) for some digital outputs (E.g. for a light controller)
46 * xx - Reserved for developer
48 * Note : Active parameters are normally on a line beginning by "#define", followed by the name of the parameter and most of the time a value.
49 * To deactivate a parameter, in general, you can add "//" just before "#define"; this line will then be considered as a comment and discarded.
50 ************************************************************************************************************************
53 **** 1 - telemetry Protocol **********************************************************************
54 * Currently oXs supports 4 telemetry protocols : Multiplex , Frsky, Jeti and Hott (=Graupner)
55 * One (and only one) protocol has to be selected; e.g. if you activate the Multiplex, the Frsky, Jeti and Hott are disactivated (and the opposite)
56 * To select the protocol to be used by oXs, fill the line #define PROTOCOL with one of the allowed values: FRSKY_SPORT , FRSKY_HUB , FRSKY_SPORT_HUB , MULTIPLEX , HOTT; JETI
57 * Note : FrSky uses 2 different protocols:
58 * - SPORT is used for X series receivers (like X8R or X6R)
59 * - HUB is used for D series receivers (like D4R-II)
60 * Note : for the HUB protocol, only one oXs may be connected to the receiver (other sensors are not allowed).
61 * oXs can in principe support both Frsky protocols simultanously (using option FRSKY_SPORT_HUB). It can detect automatically the type of receiver it is connected to.
62 * This way there is no need to reload the program with another protocol if you want to use the same oXs hardware on another type of Frsky receiver.
63 * Still, the autodetection seems not 100% reliable and requires more memory..
64 * In case autodetection is not reliable or if you need more memory (because many sensors are connected to oXs), you can force a specific FRSKY protocol.
65 * **************************************************************************************************
66 #define PROTOCOL FRSKY_SPORT // select between FRSKY_SPORT , FRSKY_HUB , FRSKY_SPORT_HUB , MULTIPLEX , HOTT, JETI
68 * 1.1 - Pin connected to Rx *****************************************************************************************
69 * OXS has to be connected to the receiver in order to transmit his data.
70 * Therefore, one DIGITAL Arduino pin has to be connected to the receiver.
71 * You must specify the Arduino pin being used.
72 * Default: 4 ; allowed values are 2 or 4 but take care not using the same pin for 2 features.
73 * For Frsky protocols, it is also possible to use pin 7 (foreseen for receiver running the D16 firmware written by MikeB)
74 ************************************************************************************************************************
75 #define PIN_SERIALTX 4
77 * 1.2 ****** SPORT SENSOR ID (for SPORT protocol only) **********************
79 * In SPORT protocol, there may be several sensors connected on the same bus (e.g. a GPS) but each sensor must have a different SPORT_SENSOR_ID.
80 * For SPORT protocol, oXs uses up to 6 SPORT_SENSOR_ID. The 6 SENSOR_ID used by oXs are by default :
81 * DATA_ID_VARIO 0x00 // = sensor 0 used for Alt and Vspeed
82 * DATA_ID_FLVSS 0xA1 // 1 used for Cell values
83 * DATA_ID_FAS 0x22 // 2 used for vfas , current and fuel
84 * DATA_ID_GPS 0x83 // 3 used for GPS data
85 * DATA_ID_RPM 0xE4 // 4 used for rpm, T1, T2, airspeed
86 * DATA_ID_ACC 0x67 // 7 used for Acc X, Y, Z
87 * If needed (e.g. in order to connect 2 oXs devices sending similar data), you can change some SPORT_SENSOR_ID but you must select only values from this list
88 * 0x00,0xA1,0x22,0x83,0xE4,0x45,0xC6,0x67,0x48,0xE9,0x6A,0xCB,0xAC,0x0D,0x8E,0x2F,0xD0,0x71,0xF2,0x53,0x34,0x95,0x16,0xB7,0x98,0x39,0xBA,0x1B
89 * Those SPORT_SENSOR_ID parameters are defined in oXs_config_advanced.h file (section 1.1)
91 ************************************************************************************************************************
94 **** 2 - Data to transmit **********************************************************************************************
95 * Depending on the parameters in the config.h file (and the sensors connected to oXs), oXs calculates several measurements
96 * In Multiplex protocol, you have to specify whch measurements are sent (and on which line on the display) (see below)
97 * In SPORT, HUB , JETI and HOTT protocol, main measurements are automatically transmitted in their expected fields and some set up allows to transmit some extra measurements reusing available fields .
98 * One of the calculated measurement is named "main vertical speed".
99 **** 2.1 FrSKY protocol (SPORT and HUB ) ************************************************************************************
100 * Measurements being automatically transmitted are :
101 * - Relative altitude(cm), main vertical Speed(cm/sec) (when at least first baro sensor is present)
102 * - Cell voltages (when NUMBER_OF_CELLS > 0)
103 * - Current (when Current sensor is present)
104 * - GPS (long, lat, speed, altitude , course) (when GPS sensor is present)
105 * - RPM (hz) (when RPM sensor is present)
106 * On top of this, you can also specify how to fill telemetry fields Vfas, Fuel, A3, A4, T1, T2, AccX, AccY, AccZ (see available options below)
107 * Put those line(s) as comment when no measurement has to be transmitted in those telemetry field(s)
108 * ex :
109 * #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
110 * #define FUEL_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
111 * #define A3_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
112 * #define A4_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
113 * #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
114 * #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
115 * #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
116 * #define T1_SOURCE GLIDER_RATIO // 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
117 * #define T2_SOURCE SENSITIVITY // 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
118 **** 2.2 Hott protocol ************************************************************************************
119 * Measurements being automatically transmitted are :
120 * - Relative altitude(cm), main vertical Speed(cm/sec) (when at least first baro sensor is present)
121 * - Cell voltages, lowest cell voltage (when NUMBER_OF_CELLS > 0)
122 * - up to 3 battery voltages (set up has to specify which voltage measurements are transmitted - E.g. VOLT_1,VOLT_2, ...)
123 * - Current (when Current sensor is present)
124 * - GPS (long, lat, speed, altitude , course, distance from home, direction from home, number of sat, type of fix) (when GPS sensor is present)
125 * - RPM (when RPM sensor is present)
126 * When you measure cell Voltages, you can get an alarm on Tx when lowest cell voltage is lower than a specified level.
127 * To activate this alarm, uncomment next line and specify the voltage (in milliVolt ) that trigger the alarm
128 * //#define CELL_UNDERVOLTAGE_WARNING 3300 // Warning threshold in mV;
130 * On top of this, you can also specify how to fill telemetry fields temperature1 and temperature2
131 * note : those 2 fields can only report a value from -20 up to 235; for PPM, a value of -100 will be displayed as 0 and +100 will be displayed as 200)
132 * Put those line(s) as comment when no measurement has to be transmitted in those telemetry field(s)
133 * ex:
134 * #define BATTERY_1_SOURCE VOLT_4 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6
135 * #define BATTERY_2_SOURCE VOLT_2 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6
136 * #define MAIN_BATTERY_SOURCE VOLT_5 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6
137 * #define TEMPERATURE_1_SOURCE TEST_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
138 * #define TEMPERATURE_2_SOURCE SENSITIVITY // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6 , TEST_1, TEST_2, TEST_3 , GLIDER_RATIO , SENSITIVITY , PPM
140 **** 2.3 Multiplex ************************************************************************************
141 * For Multiplex protocol, you have to define which OXS measurements are sent to Tx and on which lines they appear on the Tx telemetry panels.
142 * You have also to specify if some scaling have to be applied by OXS and you can specify a range of value in order to set alarms on/off.
143 * So, you MUST specify ONE ROW for EACH OXS measurement to transmit to Tx. Each row must contains:
144 * - 1 : the line number where the measurement has to be appear on the display. Valid number are from 2 to 15, do not use twice the same line number
145 * - 2 : a comma
146 * - 3 : the OXS measurement name to transmit on this line (e.g. "VOLT_1") (see note (2))
147 * - 4 : a comma
148 * - 5 : a multiplier factor to apply on the value to transmitted (set "1" to keep the original measurement, 10 to multiply by 10 , ...) (see note (3))
149 * - 6 : a comma
150 * - 7 : a divider factor to apply on the value to transmitted (set "1" to keep the original measurement, 10 to divide by 10 , ...) (see note (3))
151 * - 8 : a comma
152 * - 9 : an offset factor to apply after having applied the multiplier and divider ((set "0" to keep the original measurement, "100" to add 100, ...)
153 * - 10 : a comma
154 * - 11 : an alarm LOW value (see note (4))
155 * - 12 : a comma
156 * - 13 : an alarm HIGH value (see note (4))
157 * - 14 : a comma and "\" if there is least one next more (so don't fill on the last row);
158 * TAKE CARE that "\" MUST be the LAST character on the row (even no space after)
159 * TAKE CARE that no comment lines ("*...") may exist between rows
160 * Note (2) : A OXS measurement name (e.g. VOLT_1) may not appear on several rows.
161 * Note (3) : Multiplier, divider and offset must be integer (no decimal); they can be negative (e.g. "-100").
162 * Multiplier and divider can be useful e.g.
163 * - to convert in other measurement system (meter <> foot)
164 * - to convert in percentage (e.g. multiply by 100 and divide by 4000 in order to get the consumption of current in % for a 4000 mAmph accu)
165 * - to adjust the number of digits displayed on Tx telemetry screen.
166 * - to have e.g. a fuel value starting at 100 (in percent) and going down to 0 when consumption increase (then you must use a negative multiplier and an offset of 100%).
167 * Multiplier/divider/offset must be set up but they are not always taken into account by OXS; it is the case when:
168 * - CELLS_1_2, CELLS_3_4, CELLS_5_6 is transmitted (because those fields have a special formatting required by Tx
169 * Note (4) : alarm limits must be integer (no decimal); they can be negative (e.g. "-100").
170 * In order to set the alarms foresseen in the Multiplex protocol, oXs will procceed as follow:
171 * - adapt the number of decimals in the oXs measurement (most oxs measurements have more decimals than foreseen in Multiplex protocol)
172 * - apply the Multiplier/divider/offset parameters
173 * - compare the result with the alarm LOW & HIGH values
174 * The limits have to be fixed taking into account all the digits that apears on the display.
175 * E.g. Voltages are displayed in 0.1 volt. If you want to get an alarm when voltage is equal or lower than 11.2 volt, set the alarm low value to 112.
176 * In order to avoid alarms, set the LOW value to -16384 and/or the HIGH value to 16383 (limits results from the 15 bits in Multiplex protocol)
178 * Here an example of set up in order to transmit on Multiplex protocol
179 * - on line 3, the relative altitude measurement (without alarms)
180 * - on line 6, the main vertical speed measurement (with alarms if it exceed 50m/s)
181 * #define SETUP_MULTIPLEX_DATA_TO_SEND \
182 * 3 , REL_ALTIMETER , 1 , 1 , 0 , -16384 , 16383,\
183 * 6 , VERTICAL_SPEED , 1 , 1 , -500 , 500
184 * IMPORTANT : keep always the line "#define SETUP_DATA_TO_SEND \" ; do not insert any comment lines after or between the rows used for the set up.
186 * Here the list of oXs measurements that can be sent
187 * Code to be used Meaning
188 * ALTIMETER m Absolute altitude (from first baro sensor)
189 * REL_ALTIMETER m Relative altitude (from first baro sensor)
190 * ALTIMETER_MAX m Max relative altitude
191 * VERTICAL_SPEED cm/s Main vertical speed (as set up in VSPEED_SOURCE)
192 * SENSITIVITY none Vario sensitivity
193 * VOLT_1 0.1V(5) Value read on first PIN_VOLTAGE
194 * VOLT_2 0.1V(5) Value read on 2d PIN_VOLTAGE
195 * VOLT_3 0.1V(5) Value read on 3d PIN_VOLTAGE
196 * VOLT_4 0.1V(5) Value read on 4th PIN_VOLTAGE
197 * VOLT_5 0.1V(5) Value read on 5th PIN_VOLTAGE
198 * VOLT_6 0.1V(5) Value read on 6th PIN_VOLTAGE
199 * CURRENTMA 0.1A MilliAmp measured by current sensor
200 * MILLIAH mAh Consumed milli Amp heure
201 * RPM Hz Rotation per min
202 * AIR_SPEED 0.1 km/h Air speed
203 * CELL_1 0.1V(5) Value based on first PIN_VOLTAGE
204 * CELL_2 0.1V(5) Value based on first and 2d PIN_VOLTAGE
205 * CELL_3 0.1V(5) Value based on 2d and 3d PIN_VOLTAGE
206 * CELL_4 0.1V(5) Value based on 3d and 4th PIN_VOLTAGE
207 * CELL_5 0.1V(5) Value based on 4th and 5th PIN_VOLTAGE
208 * CELL_6 0.1V(5) Value based on 5th and 6th PIN_VOLTAGE
209 * CELL_MIN 0.1V(5) Value based on CELL_1 ... CELL_6
210 * CELL_TOT 0.1V(5) Value based on VOLT1...VOLT6
211 * PPM Value set by Tx to control some functions (sensitivity, ...) (range is normally -100 / +100)
212 * GPS_COURSE 0.1 deg Orientation of plane
213 * GPS_SPEED 0.1 km/h Ground speed (2D or 3D)
214 * GPS_ALTITUDE m Absolute Altitude
215 * GPS_DISTANCE m Distance from home
216 * GPS_BEARING 0.1 deg Direction from home
217 * TEST_1 Value used for test
218 * TEST_2 Value used for test
219 * TEST_3 Value used for test
220 * (5) Unit depends also on the calibration parameter that are used (e.g. when a voltage is provided by a temperature sensor, unit can be degree)
221 * When used in order to measure Cell(s), calibration must ensure that internal unit = milliVolt (and oXS will convert mVolt to 0.1Volt when transmitting over Multiplex protocol.
223 ***** 2.4 - Jeti data ************************************************************************************************************************
224 * Measurements being automatically transmitted are :
225 * - Relative altitude(cm), main vertical Speed(cm/sec) (when at least first baro sensor is present) and maximum altitude
226 * - Cell voltages including min and total (when NUMBER_OF_CELLS > 0)
227 * - Current and consumption (when Current sensor is present)
228 * - GPS (long, lat, speed, altitude , course, distance and direction from home) (when GPS sensor is present)
229 * On top of this, you can also specify to send :
230 * - one of the 6 voltages (if voltage is measured); tip when a NTC is used to measure a temperature, define the VOLTAGE_SOURCE too (see also section about NTC)
231 * - a temperature : you can select between the temeperature provided by the MS5611 sensor or by a NTC
232 * Other fields could be added on request later on.
233 //#define VOLTAGE_SOURCE VOLT_1 // select between VOLT_1, VOLT_2, VOLT_3 , VOLT_4, VOLT_5 , VOLT_6
234 //#define TEMPERATURE_SOURCE MS5611 // select between MS5611 and NTC
236 ****** 2.5 - How to fill TEST_1, TEST_2, TEST_3 ******
237 * oXs can calculate more measurements than foreseen by the protocols.
238 * Some of them can directly be configured in section 2.1 to 2.4 (e.g VOLT_3 can be transmitted in T1 (for SPORT protocol)
239 * Some other are rarely used and required to proceed in 2 steps
240 * - first, decide how to fill temporary fields TEST_1, TEST_2, TEST_3 (in section 2.5)
241 * - second, decide in which telemetry fields those temporary fields are sent (in section 2.1 to 2.4)
242 * To decide how to fill temporary fields TEST_1, TEST_2, TEST_3 uncomment one (or several lines below
243 * If you uncomment several lines, take care to avoid that they share the same temporary fields (results would not be the expected)
244 **************************************************************************************************************************
245 //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
246 //#define EXPECTED_ALT_AT_SEC 0.2 // time (in sec) for expected Alt (this line must be uncommented wen previous is uncommented
248 //#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
250 //#define FILL_TEST_1_2_WITH_VSPEED_AND_ALT_FROM_SECOND_VARIO // uncomment to activate this option
252 //#define FILL_TEST_1_WITH_DTE // uncomment to activate this option
254 //#define FILL_TEST_2_WITH_PPM_AIRSPEED_COMPENSATION // uncomment to activate this option
256 //#define FILL_TEST_1_WITH_YAWRATE // uncomment to activate this option
258 //#define FILL_TEST1_WITH_HEADING_FROM_MAGNETOMETER // uncomment to activate this option
260 //#define FILL_TEST_3_WITH_FLOW_SENSOR_CONSUMPTION // uncomment to activate this option
262 //#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
264 //#define FILL_TEST2_WITH_GPS_HDOP // uncomment to activate this option
266 **** 3 - PPM settings **************************************************************************************************
267 * oXs can (optionally) change some oXs parameters and/or reset some oXs data based on actions taken on the TX.
268 * For all protocol, this can be achieved using a Rx channel in order to get data from the Tx.
269 * This allows, from the TX:
270 * - to change the vario sensitivity using a pot or a switch on TX.
271 * - to switch between uncompensated and compensated vario (when using 2 baro sensors one being connected to a TEK probe)
272 * - to reset the airspeed sensor (when the value drift with temperature)
273 * - to change the vario compensation factor (when compensated vario uses the airspeed) using a pot or a switch on TX
274 * It requires then some mixing on Tx side and some set up in the oXs-config.h file (see below).
276 * If you want to use this feature, you must:
277 * - uncomment the 3 folowing lines
278 * - specify in PIN_PPM the Arduino DIGITAL pin being connected to a Rx channel (like for a servo).
279 * Default: 2 ; you can also use pin 3 to read the PPM signal.
280 * Take care, only pin 2 or 3 may be used for PPM signal.
281 * Remove or keep this line as comment if you want to disable the remote control functionality.
282 * - specify in PPM_MIN_100 the width of the pulse (in micro seconds) when the channel send a "logical" value = -100.
283 * Default value is 988.
284 * - specify in PPM_PLUS_100 the width of the pulse (in micro seconds) when the channel send a "logical" value = +100.
285 * Default value is 2012.
286 * Those 2 last parameters are used in order to calibrate OXS with TX when PPM is used.
287 * Probably that if you use the default values, it will work.
288 * Still it is safe to calibrate them (but only if you use PPM).
289 * To do so, ensure that you transmit the OXS measurement field "PPM" to the TX (e.g. as T1).
290 * Note the values on TX (e.g. in field T1) when the TX send respectively -100 and +100 on the PPM channel (use a switch or a pot).
291 * Fill in those values in those parameters and reload your program in the Arduino.
293 * If you use Sport protocol (for Frsky X receiver) with openTx 2.2 (or above) you can send the "PPM" value without having to wire oXs to a Rx channel.
294 * OpenTx 2.2 alllows to run LUA scripts that will send a value from TX to oXs over the SPORT connection
295 * To activate this option, you have to :
296 * - uncomment the line #define PPM_VIA_SPORT
297 * - let you Tx run a LUA script that will send over SPORT the same digital value that, otherwise, would be sent over a Rx channel. (so a value between -100 and 100)
298 * This lua script must use a command like
299 * local ret = sportTelemetryPush( 0x0D , 0x10 , 0x0010 , -52 )
300 * where
301 * - 0xOD : is the device ID being used (defined in oXs_config_advanced.h)
302 * - 0x10 : is a dummy value (not used)
303 * - 0x0010 : is the code id being used to identify that it concerns a "ppm" value
304 * - -52 : is the value of the ppm to transmit (-52 is just an example; it must be adapt with the value to transmit)
305 * You can find an example of lua script to be used in this package (in folder "lua scripts"). Name is oxsppm.lua and it must be installed in the folder SCRIPTS/FUNCTIONS of the SD card.
306 ************************************************************************************************************************
307 #define PIN_PPM 2
308 #define PPM_MIN_100 988
309 #define PPM_PLUS_100 2012
312 #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)
314 **** 4 - Vario settings ************************************************************************************************
316 * 4.1 - Connecting 1 or 2 barometric sensor(s) (optional feature) *********************************************
317 * oXs can be connected with different barometric sensors.
318 * Best results are provided by the MS5611 barometric sensor. Such a sensor is usually mount on a board (like the GY-63 or the GY-86) which have a 3.3 voltage regulator and a I2C level shifter.
319 * Still it is possible to use a board with a BMP085 or BMP180 or a BMP280 sensor (which are cheaper but less accurate). Please note that only the first sensor can be a BMP085, BMP180 or BMP280.
320 * It is possible to connect 1 or 2 baro sensors; the first sensor can be a BMP085 or BMP180 or a MS5611; the second one must be a MS5611 (because BMP085 and BMP180 have only one I2C address)
321 * Note : when using an Arduino with 5 Volt Vcc, select always a baro sensor board which have a 3.3 voltage regulator and a I2C level shifter.
322 * Each sensor can calculate the absolute/relative altitude (in meter with 1 decimal) and the vertical speed (in meter/sec with 2 decimals).
323 * A second sensor can be useful because if it is associated with a TEK probe and if option PPM is used, it is possible to select from the TX the sensor that will generate the vario tones.
324 * This allows to switch e.g. between a pneumatic compensated and an uncompensated vario.
325 * When 2 baro sensors are used, oXs can transmit as vertical speed the average from both sensors. Still this does not seems to be very usefull.
327 * You must specify which type of baro sensor is used for the first vario using line #define FIRST_BARO_SENSOR_USE MS5611
328 * The value must be selected in this list: NO_BARO , MS5611, GY86 , BMP085 , BMP180 , BMP280 , GY87
329 * You must specify which type of baro sensor is used for the second vario using line #define SECOND_BARO_SENSOR_USE NO_BARO
330 * The value must be selected in this list: NO_BARO , MS5611
331 * Both sensors are connected in parallel (using same Arduino pins A4 and A5).
332 * First sensor ( MS5611 ) reacts on an I2C address 0x77. BMPxxx often reacts on an I2C address 0x76 at least for BMP280 the address can be set also in oxs_config_advanced.h
333 * When used, second sensor (a MS5611) must have the MS5611 CE (chip enable) pin connected to VDD. So it gets automatically an I2C address 0x76. (note: default MS5611 has CE connected to GND and so an I2C address = 0x77)
334 * Note : When only one sensor is used, it must be connected as first sensor.
336 * 4.2 - Type of Vspeed to transmit *****
337 * Depending on the options you implement, oXs can calculate several types of vSpeed and let you select which one is transmitted
338 * Depending on content of line #define VSPEED_SOURCE, it is calculated based on
339 * - first baro sensor (= normal case)
340 * - second baro sensor
341 * - average of both baro sensors
342 * - first baro with compensation from airspeed (= dtE)
343 * - first baro + IMU (accelerometer+ gyro)
344 * - primary or secondary vertical speed selected by PPM
345 ***********************************************************************************************************************
346 #define VSPEED_SOURCE FIRST_BARO // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU or PPM_SELECTION
348 * 4.3 - Sensitivity predefined by program: *****************************************************************************
349 * When a vario is used, oXs can take care of some parameters to adjust sensitivity and hysteresis.
350 * Normal sensitivity can be set between:
351 * - 20 (conservative setting, reaction time = several seconds)
352 * - 150 (fast but lot of errors, reaction time = much less than a second)
353 * 50 is a normal setting when measuring small vertical speed (search for lift with a glider); it gives a reaction time of around 1 sec.
354 * Sensitivity can be predefined by program and/or adjusted from TX.
356 * If you want very short reaction time of the vario, the best solution is to use a MPU6050 sensor (accelerometer/gyro) on top of a baro sensor (see below)
357 * Note: when a vario is used (#define VARIO being uncommented) , you have to specify (in section 9) how the "main vertical speed" has to be calculated
359 * Set up uses 4 parameters:
360 * SENSIVITY_MIN = This is the sensitivity being used in normal condition (most of the time).
361 * So this is the main parameter which controls the vario sensitivity.
362 * This value is used by OXS when the difference between the current calculated Vspeed (every 20 ms) and the previous smoothed VSpeed is LESS than the value set in SENSITIVITY_MIN_AT ; typical value is 40.
363 * SENSIVITY_MAX = This is the maximum sensitivity being used when Vspeed changes very fast.
364 * This value is use by OXS when the difference between the current calculated Vspeed and the previous smoothed VSpeed is GREATER than the value set in SENSITIVITY_MAX_AT ; typical value is 300.
365 * SENSITIVITY_MIN_AT = defines up to which value SENSITIVITY_MIN applies (see above) (cm/s); typical value is 100 (cm/s).
366 * SENSITIVITY_MAX_AT = defines from which value SENSITIVITY_MAX applies (see above) (cm/s); typical value is 1000 (cm/s).
367 * Sensitivity is automatically interpolated between SENSITIVITY_MIN and SENSITIVITY_MAX.
368 * Those parameters allows OXS to automatically have a faster reaction time when Vspeed changes very fast and still keeping a quiet vario in calm condition.
369 * Note: SENSITIVITY_MAX can be set equal to SENSITIVITY_MIN if no automatic adaptation is desired in case of fast change.
370 ************************************************************************************************************************
371 #define SENSITIVITY_MIN 50
372 #define SENSITIVITY_MAX 300
373 #define SENSITIVITY_MIN_AT 100
374 #define SENSITIVITY_MAX_AT 1000
376 * 4.4 - Sensitivity adjusted from the TX *******************************************************************************
377 * Sensitivity can be adjusted from the Tx using a switch and/or a potentiometer on TX and some mixer on a servo channel.
378 * To use this feature, a servo pin from Rx has to be connected to OXS (see PPM in section 3).
379 * When OXS detects a signal from TX, the SENSIVITY_MIN defined in section 4.3 is automatically discarded and replaced by a value calculated based on parameters in section 4.4 and on PPM signal.
381 * Set up uses 4 parameters:
382 * SENSITIVITY_MIN_AT_PPM = When Tx sends this value on the PPM channel, SENSITIVITY_MIN (see section 4.2) will be replaced by SENSITIVITY_PPM_MIN; typical value could be 10.
383 * SENSITIVITY_MAX_AT_PPM = When Tx sends this value on the PPM channel, SENSITIVITY_MIN (see section 4.2) will be replaced by SENSITIVITY_PPM_MAX; typical value could be 40.
384 * The SENSIVITY_PPM_MIN+MAX parameters define the range in which you will be able to adjust the sensitivity:
385 * SENSITIVITY_PPM_MIN = the minimum value for SENSITIVITY_MIN that can be assigned using PPM; typical value could be 20.
386 * SENSITIVITY_PPM_MAX = the maximum value for SENSITIVITY_MIN that can be assigned using PPM; typical value could be 100.
387 * SENSITIVITY_MIN is automatically interpolated between SENSITIVITY_PPM_MIN and SENSITIVITY_PPM_MAX depending on the PPM signal.
388 * Sensitivity will be changed only when PPM signal is between SENSITIVITY_MIN_AT_PPM - 5 and SENSITIVITY_MAX_AT_PPM + 5.
389 * Important note : Sensitivity is changed based on the absolute value of PPM; so PPM = -25 has the same effect as PPM = 25.
390 * This is important in order to combine change in sensitivity with a switch on TX to select the sensor (1 or 2) sending the vertical speed (allowing switching between compensated and uncompensated vario).
391 ************************************************************************************************************************
392 #define SENSITIVITY_MIN_AT_PPM 10
393 #define SENSITIVITY_MAX_AT_PPM 40
394 #define SENSITIVITY_PPM_MIN 20
395 #define SENSITIVITY_PPM_MAX 100
397 * 4.5 - Hysteresis parameter & Alt compensation based on sensor temp ***************************************************
398 * OXS can also apply some hysteresis on vertical speed changes.
399 * It allows to avoid that transmitted Vspeed changes too often (which can result in bad sound alerts). So it is another way to reduce sensitivity
400 * VARIOHYSTERESIS means that transmitted Vspeed will change only if measured VSpeed (after filtering) differs from previous transmitted value by more than this parameter.
401 * Typical value can be 5 (= 5 cm/s); 0 means no hysteresis.
403 * oXs also allows to add an extra compensation to the MS5611 sensor (not to the BMPxxx) in order to reduce the drift of altitude when the internal sensor temperature increase after power on.
404 * Internal temperature of MS5611 increases by several degree when it is read by the Arduino.
405 * In principe MS5611 sensor contains calibration parameters in order to compensate temperature changes.
406 * Still, it seems that those parameters are not always optimal.
407 * So oXs allows to apply an extra compensation for the temperature. Therefore you must use fill the parameter ALT_TEMP_COMPENSATION.
408 * In order to define the optimal value for your sensor, the easiest way is probably to try several values.
409 * Following info can be useful:
410 * - It is better to make the tests when the atmospheric pressure is stable (calm day, no wind)
411 * - Ensure that altitude is displayed on the Tx
412 * - Ensure that MS5611 is protected from light (because the sensor is light sensitive)
413 * - First with ALT_TEMP_COMPENSATION set to zero (or the line being as comment), start Tx and Rx. Do not move oXs (so the altitude on Tx should ideally remains 0).
414 * - After about 5 minutes, notice the altitude drift.
415 * - Power Tx and Rx off for at least 5 min in order to let drop the internal vario temperature.
416 * - Repeat this test one or 2 times
417 * - If the aftitude drift is more or less the same for each test and exceed 1 meter, it will probably be possible to reduce it filling some value in the parameter ALT_TEMP_COMPENSATION
418 * - If the drift is positive, then increase ALT_TEMP_COMPENSATION otherwise decrease it; ALT_TEMP_COMPENSATION can be negative (it should be the case if the initial drift is negative).
419 * - It is difficult to calculate the value to be used. On my sensor I noticed that using a value = 1000 could compensate a drift of about 3 meter but it can varies per sensor.
420 * - Having filled a value in ALT_TEMP_COMPENSATION, repeat the previous tests (powering Tx and Rx, waiting 5 min, looking at the drift) and increase or decrease further more the value if required.
421 * Important note: filling ALT_TEMP_COMPENSATION will not eliminate totally the drift of altitude because:
422 * - it can also be the result of small variation of the atmospheric pressure (that can't be compensated)
423 * - it can be generated by other factors
424 * - temperature compensation is probably not linear over the whole range of temperature and pressure
425 ************************************************************************************************************************
426 #define VARIOHYSTERESIS 5
428 * 4.6 - Switching between different vertical speeds calculations (optional) **************************************************************
429 * When you use two baro sensors or one baro sensor + one airspeed sensor (4525D0 - see section 5) or one baro sensor and one IMU, OXS can calculate several vertical speeds (or dTE).
430 * When the PPM option is implemented, OXS allows to select from TX which value (Vspeed from first or second baro sensor or compensated by airspeed, ...) has to be sent as vertical speed and so will control the vario tone.
431 * This allows switching between e.g. compensated and uncompensated vario.
432 * Even if OXS can calculate up to 5 vertical speeds ( FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU ), it is only possible to switch between 2 predefined vertical speeds.
433 * To enable this feature, additional parameters are required:
434 * 1) Specify what are respectively the primary and the secondary vertical speeds using the lines:
435 * #define VARIO_PRIMARY XXXXXXX
436 * #define VARIO_SECONDARY YYYYYYY
437 * where XXXXXX and YYYYYY are each one values selected between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
438 * 2) Specify a range of PPM value that OXS has to check in order to send or the primary or the secondary vertical speed using the lines:
439 * #define SWITCH_VARIO_MIN_AT_PPM 10
440 * #define SWITCH_VARIO_MAX_AT_PPM 90
441 * When the ABSOLUTE value of PPM is between SWITCH_VARIO_MIN_AT_PPM (typical value = 10) and SWITCH_VARIO_MAX_AT_PPM (typical value = 90),
442 * - OXS will switch to the primary vertical speed IF PPM is POSITIVE
443 * - OXS will switch to the secondary vertical speed IF PPM is NEGATIVE
444 * Note: when the absolute value of PPM is outside this range, OXS will not switch from vertical speed and keep the current one.
445 * This principle allows to use a switch on TX simultaneously with a pot in order to control sensitivity or compensation.
446 * Switching from positive to negative can be achieved on openTx with a mixer using MULTIPLY by -100%.
447 * Sending a PPM value outside this range allows to instruct OXS to apply another order (e.g. reset the airspeed offset) without switching the vertical speed.
448 * 3) Specify in section 4.2 that the source for vertical speed is "PPM_SELECTION"
449 ****************************************************************************************************************************
450 #define VARIO_PRIMARY AIRSPEED_COMPENSATED // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
451 #define VARIO_SECONDARY FIRST_BARO // select between FIRST_BARO, SECOND_BARO , AVERAGE_FIRST_SECOND, AIRSPEED_COMPENSATED , BARO_AND_IMU
452 #define SWITCH_VARIO_MIN_AT_PPM 10
453 #define SWITCH_VARIO_MAX_AT_PPM 90
455 * 4.7 - Analog vertical speed (optional) ***********************************************************************************
456 * OXS can also deliver the vertical speed (from sensor 1 only) as an analog signal that has to be connected to A1 or A2 on FrSky receiver:
457 * This can be useful if you have a receiver that has no digital communication pin (or if it is already used by another sensor)
458 * Additional Hardware (1 resistor + 1 capacitor) is required! Read the WiKi if you want to use this.
459 * To activate this:
460 * - uncomment the 3 following parameters
461 * - define in PIN_ANALOG_VSPEED the Arduino DIGITAL pin being used (see below)
462 * Default 3; The pin can only be 3 or 11 because it has to use timer 2.
463 * - set the min and max limits for the vertical speed (in meter/sec)
464 * - ANALOG_VSPEED_MIN value or lower will apply 0 Volt to the receiver
465 * - ANALOG_VSPEED_MAX value or higher will apply 3.2 Volt to the receiver
466 *************************************************************************************************************************
467 #define PIN_ANALOG_VSPEED 3
468 #define ANALOG_VSPEED_MIN -3
469 #define ANALOG_VSPEED_MAX 3
471 * 4.8 - Calculating glider ratio, average sink/climb rate ***************************************************************
472 * oXs can calculate and transmit glider ratio and average sink/climb rate when airspeed and vspeed stay within some tolerances for more than X seconds (e.g 5 or 10 sec)
473 * The calculated values are :
474 * - enlapsed time used to calculate glider ratio and average sink/climb rate
475 * - averaged sink/climb rate ( = difference of altitude / enlapsed time )
476 * - glider ratio (= distance / difference of altitude) (in fact = airspeed * enlapsed time / difference of altitude )
477 * Glider ratio is a parameter that can be use e.g. to fine tune the setup of the glider. It makes only sense if the speeds are quite regular.
478 * So oXs calculates only when:
479 * - the airspeed does not change by more than a defined % (compared to the beginning of the enlapsed time). This % can be defined by the user in SPEED_TOLERANCE.
480 * - the vertical speed stays withing a range of value defined by the user in VSPEED_MIN_TOLERANCE and VSPEED_MAX_TOLERANCE
481 * Every 0.5 sec, oXs checks if the current measurements are within the tolerance.
482 * If oXs is out of tolerance, it resets all calculations using the last (=current) measurements as new references. Glider ratio and average sink/climb are set to 0
483 * If oXs is within tolerance since more than a user defined enlapsed time (defined by GLIDER_RATIO_CALCULATED_AFTER_X_SEC), it performs the calculations
484 * Note: in this version of oXs, if you want to sent the calculated field you have to fill the data to transmit section using following code
485 * - TEST1 for enlapsed time (in 1/10 of sec)
486 * - TEST2 for averageVspeed (in cm/sec like Vspeed)
487 * - TEST3 for gliderRatio (in 1/10 of units)
488 * Glider ratio requires an airspeed sensor and a vario;
489 * Averaged sink/climb rate can be calculated even without an airspeed (but in this case tolerance on airspeed is discarded)
490 * In order to activate the calculations, you must uncomment the 4 lines of parameters
491 * In order to deactivate the calculation, it is enough to put the line GLIDER_RATIO_CALCULATED_AFTER_X_SEC as comment
492 *************************************************************************************************************************
493 #define GLIDER_RATIO_CALCULATED_AFTER_X_SEC 10 // minimum elapsed time (in sec) to transmit calculations
494 #define SPEED_TOLERANCE 5 // in % of speed
495 #define VSPEED_MIN_TOLERANCE -200 // out of tolerance when Vspeed is lower than this value (cm/sec)
496 #define VSPEED_MAX_TOLERANCE -10 // out of tolerance when Vspeed is upper than this value (cm/sec)
499 ************************************************************************************************************************
500 * Note : it is not required to comment the sensitivity, hysteresis, OutputClimbRateMin/Max, ... parameters when a vario,
501 * is not used (those parameters are just discarded)
502 * The vario setup parameters (sensitivity, hysteresis, PPM, ...) are shared by both baro sensors
503 ************************************************************************************************************************
506 **** 5 - Airspeed sensor settings (optional) ***************************************************************************
507 * oXs can measure the difference between the static and the dynamic pressures provided by a Prandtl probe.
508 * oXs supports 3 types of sensors
509 * - the 4525DO (digital)
510 * - the MPXV7002 (analog)
511 * - the SDP31, SDP32, or SDP33 (or the SDP810-125 or SDP810-500)
512 * About the 4525DO, please note:
513 * Good results are achieved using a specific sensor 4525DO-DS5AI001DP.
514 * This sensor requires a Vcc = 5 Volt and can measure an airspeed up to 360 km/h.
515 * There are other versions of 4525DO sensor with Vcc = 3.3 Volt or allowing higher pressure and so higher airspeed.
516 * The sensor 4525DO is connected to the Arduino in parallel with the MS5611 (so using A4 and A5 on top of Ground and Vcc).
517 * It is recommended adding a decoupling capacitor (100nf) as close as possible from 4524DO between ground and Vcc.
518 * Note: at low airspeed (e.g. below 10 km/h), the difference of pressure to measure is so low that the measurement is not reliable.
519 * Sensor 4525DO-DS5AI001DP is quite expensive and difficult to find.
520 * About the MPXV7002, please note:
521 * It is less accurate (analog) but cheaper
522 * It requires to add also an ADC ADS1115 in order to measure the analog signal with some accuray. See section on ADS1115 below
523 * About the SDP31, SDP32, SDP33 , SDP810:
524 * Those sensors are probably the best solution. They do not requires calibration (and reset) and are more accurate at low speed.
525 * Those sensors exists in 3 versions which differs by the maximum differential pressure (and so the max speed) they can measure
526 * SDP31 (or SDP810-500) can measure up to 500 Pa = 105 km/h
527 * SDP32 (or SDP810-125) can measure up to 125 Pa = 52 km/h
528 * SDP33 can measure up to 1500 Pa = 189 km/h
529 * The difference between SDP3x and SDP800 series is mainly the size of the sensor.
530 * SDP3x are very small (5mm) and require soldering on small pin
531 * SDP810 are bigger (25 mm) and have a 4 pin connector
532 * Currently oXs code is written for SDP3x serie but using a SDP810 requires only to change the I2C address in the openXsensor.ino file.
533 * So to use a SDP810 serie, put first line as comment and uncomment the second line
534 * #define I2C_SDP3X_Add 0x21 // 0x21 is the default I2C adress of a SDP3X sensor
535 * //#define I2C_SDP3X_Add 0x25 // 0x25 is the I2C adress of a SDP810 sensor
537 * In line #define AIRSPEED_SENSOR_USE you must specify the type of sensor being used
538 * Select a value between NO_AIRSPEED , MS4525 , MPXV7002 , SDP3X
540 * The pressure sensors MS4525 and MPXV7002 need some calibration in order to return "0" when airspeed is null.
541 * oXs calibrates automatically the sensor when powered on (considering that the current measurement correspond to a "Zero" airspeed).
542 * To do so, it is important that there is no wind on the Prandtl probe when OXS start up.
543 * Anyway, some drift may occurs when the temperature of the sensor changes.
544 * oXs allows to recalibrate the sensor from the Tx if the PPM option is implemented (see section 3).
545 * The parameter AIRSPEED_RESET_AT_PPM specifies the value that TX has to send on the PPM channel to force a recalibration.
546 * Default value is 100.
547 * The easiest is to configure a TX mixer that will generate a pulse of e.g. 1 sec with this value (e.g. 100).
548 * Please note that the request for recalibration should be send only when the airspeed (on the probe) is really zero otherwise it would generate wrong measurements.
549 * Note : SDP3X sensors does not require calibration
551 * oXs can calculate 2 types of airspeed:
552 * - the first one is an airspeed based on air density at 15 Celcius degree and 1013 hPa (normalised sea level). It is a normalised airspeed (indicated airspeed) as normally used on aircraft.
553 * So e.g. the stall speed does not change with altitude
554 * - the second one take into account the pressure (provided by a baro sensor) and the initial airspeed sensor temperature in order to calculate a "true" airspeed (to be compared with a GPS speed when wind is null)
555 * The normalised airspeed is calculated when line #define AIRSPEED_AT_SEA_LEVEL_AND_15C is uncommented. To get the "true" airspeed, put this line as comment
557 * oXs can send the airspeed in (1/10) of knot/h or in (1/10) km/h. For openTx, you normally must use the knot/h option (only some old 2.1.x versions requires km/h option).
558 * To activate the km/h option, activate this line #define AIRSPEED_IN_KMH
559 * Put this line as comment to activate the knot/h option
561 * oXs can also use the airspeed measurements in order to calculate a compensated vario named PRANDTL_DTE (=delta total energy).
562 * See the web for more informations about dTE (= electronically compensated vario).
563 * The principle is to try to detect only true air movement by neutralising the up and down resulting from elevator changes.
564 * Normally, dTE has to be transmitted as Vspeed (vertical speed = defaultfield) because OpenTX does not yet support a specific field for it.
566 * When the option PPM is implemented, it is also possible to adjust the compensation factor between 2 values.
567 * This requires to uncomment 4 parameters:
568 * COMPENSATION_MIN_AT_PPM specify the PPM value in order to set the compensation to the value specified by COMPENSATION_PPM_MIN; default = 60.
569 * COMPENSATION_MAX_AT_PPM specify the PPM value in order to set the compensation to the value specified by COMPENSATION_PPM_MAX; default = 90.
570 * COMPENSATION_PPM_MIN minimum compensation; in % ; default 80
571 * COMPENSATION_PPM_MAX maximum compensation; in % ; default 120
572 ************************************************************************************************************************
573 #define AIRSPEED_SENSOR_USE MS4525
574 #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)
575 //#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)
577 #define AIRSPEED_RESET_AT_PPM 100
579 #define COMPENSATION_MIN_AT_PPM 60
580 #define COMPENSATION_MAX_AT_PPM 90
581 #define COMPENSATION_PPM_MIN 80
582 #define COMPENSATION_PPM_MAX 120
585 **** 6 - Voltage measurements and current sensor settings (optional) ***************************************************
587 * 6.1 - Voltage Reference to measure voltages and current **************************************************************
588 * Current and Voltages can be measured in (1023) steps or from VCC , or from an 1.1 internal reference or from an external reference.
589 * If VCC is very stable, it is probably more accurate and easier to measure current and voltages based on VCC (so in 1023 steps from VCC).
590 * Still this requires that the voltage applied on Arduino "RAW" pin is regulated or at least always more than 5.5 volt (in order to let the Arduino board voltage regulates it at 5 volt).
591 * If voltage on "Raw" pin is less than 5.5 volt and changes (e.g. due to servo consumption or low battery) then current and voltage measurements will become wrong.
592 * If VCC can't be very stable (e.g. Arduino is powered via RX by a 4.8 NiMh) and you need only the voltages (no need for the current measurement), then it is possible to measure based on the Arduino 1.1 internal voltage reference.
593 * If you need current measurement too, using internal voltage is not "the" solution because current sensor needs stable voltage too.
594 * Take care that voltage dividers (see below) must be setup in order that Arduino analog pin voltage do not exceed VCC or 1.1 volt or the external voltage depending on the option you choose.
595 * - Uncomment the "#define USE_INTERNAL_REFERENCE" to activate the 1.1 internal voltage reference (otherwise, measurements will be based on VCC).
596 * - Uncomment the "#define USE_EXTERNAL_REFERENCE" to activate the external voltage reference (otherwise, measurements will be based on VCC).
597 * Note: in order to use an external reference, you have to use add a voltage reference device to your Arduino. This is quite difficult on Arduino pro mimi because the AREF pin is not available on the pin headers
598 * - In order to get best measurements, you can setup the voltage reference being used with line #define REFERENCE_VOLTAGE.
599 * Value must be defined in millivolt (e.g. 5100 for 5.1 Volt) and may not contains decimals;
600 * If ommitted, oXs will automatically apply 1100 (when USE_INTERNAL_REFERENCE is defined) and 5000 (othewise)
601 * When external reference is used, REFERENCE_VOLTAGE must be specified
602 ************************************************************************************************************************
603 //#define USE_INTERNAL_REFERENCE
604 //#define USE_EXTERNAL_REFERENCE // uncomment this line if you use an external reference instead of Vcc
605 #define REFERENCE_VOLTAGE 5000
607 * 6.2 - Voltages parameters *******************************************************************************************
608 * oXs can measure up to 6 input voltages using the Arduino ADC (please note that depending on manufacturer, some Arduino pro mini have less analog pins available)
609 * In order to measure voltages with Arduino, you :
610 * - must specify you want to measure voltages with Arduino ADC setting YES in line ARDUINO_MEASURES_VOLTAGES
611 * - must specify the Analog pins (A0 to A7) connected to a battery (e.g. a multicell lipo) or to a sensor (e.g. a temperature sensor convert the temperature in a voltage that can be measured)
612 * - must specify the values of resistors being used for the voltage dividers (see below)
613 * - can specify offset and/or scaling to apply
615 * Note : one analog pin can also be used to measure a current using a current sensor; the set up for a current sensor is described in section 6.4 (see below);
616 * Do not use the same analog pin to measure a voltage and a current.
617 * Take care : do NOT use pins A4 and A5 if you use a vario or an airspeed (those pins are reserved for the barometric and pressure sensors).
619 * if no one voltage has to be measured, select NO in line ARDUINO_MEASURES_VOLTAGES
620 * The pins being used to measure some voltages are defined in line #define PIN_VOLTAGE.
621 * When used, this line must contains 6 values (separated by comma); the first value is used to measure VOLT1, the second VOLT2, ...up to VOLT6
622 * Each value must be a number from 0 up to 7 (0 means A0 = analog 0, 1 means A1, ...7 means A7) or the value "8" (when a voltage does not have to be measured).
623 * Note: the same alalog pin values can be used in several voltages (e.g. for VOLT1 and VOLT6).
625 * Note: If lipo voltage to be measured, it MUST start from VOLT1 for 1s, VOLT2 for 2s....., other voltages may be measured but need to be after number of cells to be measured
626 * and the cel number MUST be specified in "numberofcells" (see next section)
627 * The Ax pin number can be at random depending on which pin is connected for each cell.
629 * !! Take care that the voltage applied to Arduino pin may not exceed Vcc (normally 5 volt) or 1.1 volt (if internal reference voltage is used).
630 * It can be that you have to use voltage divider in order to reduce the voltage applied on Arduino pin compared to the voltage you want to measure.
631 * For each voltage to scale down, proceed as follow:
632 * - make a divider with 2 resistors
634 * ------> End point = connect to the device to measure (battery, Current sensor, ...)
636 * __|__
637 * | |
638 * | | R2 (Resistor_To_Voltage)
639 * | |
640 * |_____|
642 * |------> mid point = connect to Arduino pin A0,A1,A2,A3, A6 or A7
643 * __|__
644 * | |
645 * | | R1 (Resistor_To_Ground)
646 * | |
647 * |_____|
649 * ------> connect to Ground
650 * Note: a capacitor (e.g. 100nf) could be added too between ground and Arduino Analog pin in order to get more stable values.
652 * - R1 and R2 are chosen to make sure that voltage apply to Arduino is quiet close to ( but never exceed) VCC or 1.1 volt depending on your choice regarding the current & voltage measurement (see here above)
653 * - Volt on Arduino pin = VCC (or 1.1 volt) = "max voltage to measure from this sensor" * R1 / (R1 + R2)
654 * - R1 could be 10 kOhm; so R2 = R1 * ( ( "max voltage to measure from this sensor" / VCC [or 1.1 depending on the reference] ) - 1 )
655 * e.g. using 1.1 internal voltage reference and in order to measure max 6 volt with R1 = 10000, then R2 = 10000 * (( 6 / 1.1 ) - 1) = 45545 Ohm; best rounded up to high available value e.g 47000 ohm
657 * The resistors used in voltage dividers have to be specified in lines #define RESISTOR_TO_GROUND and #define RESISTOR_TO_VOLTAGE.
658 * Eeach line, must contains 6 values (one for each voltage); each value represent the resistance in Ohm or kOhm but use the same unit for both lines.
659 * If no divider is used for some voltage, set both resistors to 0 (zero)
660 * If no divider at all is used, lines can be commented (adding "//" in front)
662 * In order to get best voltage measurements, oXs can be calibrated. This optional process allows to compensate tolerances on resistors and on Arduino ADC (analog to digital converter).
663 * To calibrate each voltage measurement proceed as follow in order to find the best values to be set up in lines #define OFFSET_VOLTAGE and #define SCALE_VOLTAGE
664 * - set parameters in oXs_config.h
665 * - letting OFFSET_VOLTAGE = 0 and SCALE_VOLTAGE = 1 (so adding no compensation)
666 * - selecting a field to transmit the desired voltage (e.g. T1 for VOLT3) and fill the line "#define SETUP_DATA_TO_SEND" accordingly
667 * - load the program in Arduino
668 * - apply several different voltages on End point (not exceeding the max voltage allowed based on R1 and R2)
669 * - for each applied voltage, measure the applied voltage with a voltmeter and read the value received on telemetry panel on Tx
670 * - set the values in excel (or on a graphic) and calculate the best values OFFSET_VOLTAGE and SCALE_VOLTAGE (using a linear regression)
671 * If this seems too complex, just use 2 voltages as different as possible (but in the range of the normal values you want to measure)
672 * and apply calculation based on following example: .
673 * I expect voltage to be normally between 4 volt and 6 volt, so I apply 2 voltages close to those values to End point
674 * - for first voltage, voltmeter gives 3510 millivolt and telemetry gives 3622
675 * - for second voltage, voltmeter gives 5900 millivolt and telemetry gives 6013
676 * Then SCALE_VOLTAGE = (5900-3510) / (6013-3622) = 0.99958
677 * and OFFSET_VOLTAGE = -3510 + (3622 * 0.99958 ) = 110
678 * Note: You can apply the same principle if you are measuring something else than a voltage.
679 * E.g. You can calibrate a temperature sensor and set the calibration parameter in order to get degree on the TX display.
681 * Line #define OFFSET_VOLTAGE and #define SCALE_VOLTAGE are optional (can be put as comment adding "//" in front)
682 * If defined, each line must contains 6 values. Use 0 (for offset) and 1 (for scale) if no calibration is done for some voltage.
684 ************************************************************************************************************************
685 VOLT1 VOLT2 VOLT3 VOLT4 VOLT5 VOLT6
686 #define ARDUINO_MEASURES_VOLTAGES YES
687 #define PIN_VOLTAGE 2 , 0 , 2 , 3 , 8 , 8
688 #define RESISTOR_TO_GROUND 12 , 20 , 30 , 40 , 50 , 60 // set value to 0 when no divider is used for one of this voltage
689 #define RESISTOR_TO_VOLTAGE 50, 100.1 , 200, 300 , 500 , 600 // set value to 0 when no divider is used for one of this voltage
690 #define OFFSET_VOLTAGE 0 , 0 , 0 , 0 , 0 , 0 // can be negative, must be integer
691 #define SCALE_VOLTAGE 1 , 1 , 1 , 1 , 1 , 1 // can be negative, can have decimals
694 * 6.3 - Max number of Lipo cell to measure (and transmit to Tx) ***********************************************************
695 * The different voltages measured under 6.3 are all related to the ground.
696 * oXs can use some of them to calculate the voltage of some lipo cells.
697 * Define here the max number of cell voltages of a lipo you want to transmit; value can be 0 (no cells),1,2,3,4,5,6.
698 * If a value greater than 1 is defined, then the OXS will calculate the voltage of each cell based on the difference between 2 successive voltages starting from Voltage1.
699 * The total voltage of all cells will be calculated on TX side summing all cell voltages again.
700 * TX will display the total voltage in a telemetry field named "Cells".
701 * TX will also identify the cell with the lowest voltage and display it in a field named "Cell".
702 * TX has also a special screen where all voltages will be displayed (see Taranis manual).
703 * E.g. if number of cells = 3,
704 * voltage on cell 1 will be voltage measured on the first pin defined in PIN_Voltage
705 * voltage on cell 2 will be the difference between voltages measure on second pin and first pin (so VOLT2 - VOLT1)
706 * voltage on cell 3 will be the difference between voltages measure on third pin and second pin (so VOLT3 - VOLT2)
707 * etc.
708 * When transmitting cell voltages, you may NOT FORGET to configure the PIN_VOLTAGE, RESISTOR_TO_GROUND, RESISTOR_TO_VOLTAGE (and optionaly the calibration parameters too) .
709 * The pins MUST start and sequenced from VOLT1,2,3,4.. for 1s, 2s,....
710 * Pins voltage in excess may be used in order to transmit other voltages (e.g. from a temperature sensor)
711 * E.g. if NUMBEROFCELLS = 3, First pin (in the list of 6) must be connected to cell 1 (via a voltage divider calculated for about 4.5 volt
712 * Second pin must be connected to cell 2 (via a voltage divider calculated for about 9 volt
713 * Third pin must be connected to cell 3 (via a voltage divider calculated for about 13 volt
714 * Other pins may still be used for other data (temperature, current, ...)
715 * Notes: You must use voltage dividers to scale down the voltages on each pin of the lipo balance plug
716 * If you use the 1.1 internal reference, you can set all R1 (resistor to ground) = 10 kOhm. Then R2 (resistor to voltage) could best be
717 * 33 kOhm for Voltage1, 68 kOhm for Voltage2, 120 kOhm for Voltage3 and 150 kOhm for voltage4
718 * If you use the 5V Vcc as reference, you do not need a divider for Volt1 and if you use R1 (resistor to ground) = 10 kOhm. Then R2 (resistor to voltage) could best be
719 * 8.7 kOhm for Voltage2, 22 kOhm for Voltage3 and 27 kOhm for voltage4
721 * Please note that the more cells you have the more inaccurate the measurements become specially if you do not calibrate the voltages.
722 * Probably, it make no sense to measure more that 3 or 4 cells individually
723 * If you don't want to transmit cell voltage, set value to 0 (zero) or comment the line.
724 * This parameter defines the max number of cells you expect to transmit.
725 * If OXS is connected to a lipo having less cells, OXS will automatically reduce the number of cells which still let the TX calculate the total voltage and the lowest cell voltage
726 ************************************************************************************************************************
727 #define NUMBEROFCELLS 3
729 // 6.4 - Convert voltage to temperature (° Celcius) ********************************************************************
730 * In order to measure a temperature it is possible to use special electronic component (like lm35) that generates a voltage proportional to the teperature.
731 * In this case, you can just connect the output of this component to an arduino analog pin and configure oXs in section 6.2 in order to measure the voltage.
732 * Adding an offset and a scaling (see section 6.2) accordingly with the characteristic of you component, oXs can directly calculate the temperature in the defined measurement Voltage.
733 * You can then ask oXs to transmit this voltage to the desired telemetry field (e.g. T1) filling a set up as explained in section 2.
735 * Still this kind of component is not foreseen to measure high temperature (e.g. higher than 150 °C).
736 * You can then use thermistors (= NTC).
737 * The drawback of NTC is that the generated voltage is not proportional to the temperature and it requires some extra calculations.
738 * oXs let you use one or several NTC (e.g. one per cylinder) in order to measure high temperature(s).
739 * For each NTC, you have to add a resistor in serie accordingly to this schema
740 * < Arduino Vcc > --[serie resistor]-- <Arduino analog pin> --[NTC]-- <ground>
741 * If you use several NTC, all NTC and resistors have to be identical and they have to be connected to Arduino analog pin that are consecutive (as defined in PIN_VOLTAGE)
743 * oXs reuses the mVolt calculated by oXs. The config must be adapted in a such a way that this mVolt is equal to the raw value returned by the ADC * 1000 (for better accuracy)
744 * Therefore, in section 6.1 and 6.2 ,
745 * USE_INTERNAL_REFERENCE must be as comment (so with // in front off)
746 * USE_EXTERNAL_REFERENCE must be as comment (so with // in front off)
747 * REFERENCE_VOLTAGE must be as comment (so with // in front off)
748 * RESISTOR_TO_GROUND must be set on 0 (for the index being used)
749 * OFFSET_VOLTAGE must (normally) be set on 0 (for the index being used)
750 * SCALE_VOLTAGE must be set on 204.6 (=1000 * 1023/5000) (for the index being used)
751 * Then you have to define some parameters in section 6.4
752 * FIRST_NTC_ON_VOLT_NR specify index of first voltage being used for conversion to temperature (e.g. 3 means VOLT_3) (so it is not the code of analog pin; this one is define in section 6.2)
753 * LAST_NTC_ON_VOLT_NR specify index of last voltage being used for conversion to temperature (e.g. 5 means VOLT_5)
754 * In this expample, it means that you expect to measure 3 temperatures based on NTC connected to the pins used for VOLT_3, VOLT_4 and VOLT_5
755 * note: if you use only one NTC, you must specify the same value for FIRST_NTC_ON_VOLT_NR and for LAST_NTC_ON_VOLT_NR
756 * if you do not use NTC, keep this line as comment
757 * SERIE_RESISTOR specify the resitance (in Ohm) connected between Arduino Vcc and NTC (and analog pin); select a value nearly equal to the resistance of NTC in the range of temperature you expect best accuracy
758 * Next 3 parameters are specific to the NTC you use. Values between brackets are nominal value for a cheap NTC available on aliexpress.com with 100k ohm at 25°C and a Beta coefficient of 3950 for range 25/50
759 * STEINHART_A (e.g. 7.00111E-4 )
760 * STEINHART_B (e.g. 2.1644E-4 )
761 * STEINHART_C (e.g. 1.0619E-07 )
762 * If you do not know those 3 parameters, you can caluclate them measuring the NTC resistance at 3 different temperatures. Use then e.g. the formula given on wikipedia for thermistor
763 * When you use 1 or 2 NTC, the temperature(s) will be registered in VOLT_X and VOLT_Y where X is the value of FIRST_NTC_ON_VOLT_NR and Y the value of LAST_NTC_ON_VOLT_NR
764 * If you use more than 2 NTC, oXS will register in :
765 * VOLT_X the lowest temperature
766 * VOLT_X+1 the index of the highest temperature (1 being the index of the first NTC)
767 * VOLT_Y the highest temperature
768 * You can then define how to transmit those data in section 2
769 ************************************************************************************************************************
770 //#define FIRST_NTC_ON_VOLT_NR 5 // uncomment this line when thermistor are used; specify index of first voltage being used for conversion to temperature (e.g. 5 means VOLT_5)
771 #define LAST_NTC_ON_VOLT_NR 6 // specify index of last voltage being used for conversion to temperature (e.g. 6 means VOLT_6)
772 #define SERIE_RESISTOR 4700 // resitance connected to Arduino Vcc (in Ohm)
773 #define STEINHART_A 7.00111E-4
774 #define STEINHART_B 2.1644E-4
775 #define STEINHART_C 1.0619E-07
780 * 6.5 - Current sensor parameters **************************************************************************************
781 * It is possible to measure a current (and current consumption) if a current sensor is connected.
782 * Connecting a current sensor is an optional feature.
783 * It requires some additional hardware. It can be an IC like ACS712 (for 5, 20, 30 amp) or ACS758 (for 50, 100, 150, 200 amp).
784 * Most sensors can read bidirectional currents but ACS758 has "U" types that read only unidirectional current (providing then an higher sensitivity).
785 * Those current sensors are quite cheap (see e.g. ebay) and return a voltage that depends on the current. This voltage is measured by OXS via an analog pin.
786 * The Pin value to enter in the oXs_config.h is a number from 0 up to 7 (0 means A0, 1 means A1, ...7 means A7).
787 * If a current sensor is used, do not to use a pin that is already used by a voltage.
788 * !! Take care that the voltage applied to Arduino pin may not exceed Vcc (normally 5 volt) or 1.1 volt (if internal reference voltage is used).
789 * It can be that you have to use a voltage divider in order to reduce the voltage applied on Arduino pin.
790 * See explanation above (6.2) about voltage divider.
791 * Take care : do NOT use pins A4 and A5 if you use a vario or an airspeed (those pins are reserved for the barometric and pressure sensors).
792 * Note: The current sensor is normally powered by the 5 volt VCC from OXS (same as the vario sensor).
793 * There are bidirectional sensor and unidirectional sensor.
794 * For bidirectional, output is normally equal to VCC/2 when current = 0 Amp and, for unidirectional, output is normally 0,6 volt at 0 Amp.
795 * If OXS is connected to a battery giving less than 5.2 volt, the supply voltage for the current sensor will vary with the OXS supply voltage.
796 * Therefore VCC/2 ( = O amp) will varies with VCC.
797 * This is an issue if the Arduino ADC is configured to use the 1.1 volt internal reference.
798 * So, in this case it is better to configure the ADC in order to use VCC as reference for conversion.
800 * In order to use a current sensor, you must say YES in line ARDUINO_MEASURES_A_CURRENT and you have in PIN_CURRENTSENSOR the Arduino pin connected to the current sensor.
801 * You must also define 2 parameters depending of the type of sensor being use; those parameters are given in the datasheet of the sensor).
802 * - MVOLT_AT_ZERO_AMP = milliVolt generated by the sensor when current is 0 Amp: normal value is :
803 * - for a bidirectional sensor : Vcc from current sensor / 2 (so = 2500 if sensor is connected to Arduino Vcc and Arduino Vcc is 5 Volt).
804 * - 600 for unidirectional sensor
805 * - MVOLT_PER_AMP = milliVolt per Amp. The value depend on the sensitivity of the sensor (e.g. an ACS712ELCTR-30A-T has a sensitivity of 66 mvolt/A, a ACS758LCB-050U has a sensitivity of 60 mv/Amp)
807 * If you use the 1.1 internal reference to measure voltagse and current, you must also use a voltage divider in order to scale down the voltage produced by the current sensor.
808 * See the section 6.2 above about voltage divider. The principle are just the same but the names of the 2 paraameters are:
809 * - RESISTOR_TO_GROUND_FOR_CURRENT
810 * - RESISTOR_TO_CURRENT_SENSOR
811 * Note: those parameters are automatically discarded when ARDUINO_MEASURES_A_CURRENT is NO.
812 * Note: When current sensor is used, oXs can also calculate and transmit current consumption (milliAh) and Fuel (in % going down from 100% to 0%).
813 * If you want the last one, then use a setup like "Fuel , MILLIAH , -100 , 4000 ,0" in "data to transmit section" (and replace 4000 by the capacity - in milliAmph - of your battery) (see below).
814 * Still, with Tx using openTx or Ersky9x software, it is better to let the Tx calculates those values by it self based on the current.
815 * This ensure that values are consistent; it allows to reset the values on Tx side; it allows to change the value of the battery capacity on Tx side (so without having to reload another set up in Arduino oXs).
816 * E.g on Ersky9x, in Telemetry menu set up "current source" set "FAS"; in "mAh Alarm", set the mah you want for alarm to sound and select warning sound/voice,
817 * ie 70% of 2200 mAh lipo, use 1540. then the FUEL percentage will start from 100% count down to 0% when 1540 is consumed.
818 ************************************************************************************************************************
819 #define ARDUINO_MEASURES_A_CURRENT NO
820 #define PIN_CURRENTSENSOR 2
821 #define MVOLT_AT_ZERO_AMP 600
822 #define MVOLT_PER_AMP 60
823 #define RESISTOR_TO_GROUND_FOR_CURRENT 10
824 #define RESISTOR_TO_CURRENT_SENSOR 40
826 ***** 6.6 - Ads1115 parameters *************************************************************************************
827 * It is possible to connect an external ADC of the type ads1115.
828 * This device is very cheap (about 2 $) and can provide more accuracy than internal Arduino ADC
829 * It has 16 bits resolution, accurate internal voltage reference, a programmable gain amplifier and the ability to measure directly the voltage between 2 pins
830 * See datatsheet of ads1115 for more details
831 * oXs can be connected to one of those device via I2C bus. It can then provide up to 4 voltage measurements named ADS_VOLT_1 ...ADS_VOLT_4
832 * oXs allows to convert one of the ads voltage measurements into current and consumption (when ads1115 is connected to a current sensor)
833 * oXs also allows to convert one ads voltage measurement into airspeed and compensated vario (when ads1115 is connected to a differential baro sensor like the MPXV7002)
834 * MPXV7002 sensor is a cheapier and easier to find alternative to the MS4525 sensor (but is less accurate)
835 * In order to use an ads1115 ADC, you must select YES in line #define AN_ADS1115_IS_CONNECTED from oXs_config_basic.h and you must specify several sets of 4 parameters.
836 * Attention : set AN_ADS1115_IS_CONNECTED on NO if ads1115 is not used (in order to avoid I2C errors and slow down oXs)
837 * In ACD_MEASURE, you specify the ads115 pins being used for voltage measurement
838 * Fill always 4 values. Still, if you do not need all 4 measurements, use the value ADS_OFF for the unrequired measurement(s)
839 * Note : the more measurements you ask for, the more time it require to get each of them because ads can only perfom one at a time
840 * 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
841 * In ADC_FULL_SCALE_VOLT, you specify the ads1115 gain parameter for each of the 4 measurements.
842 * Fill always 4 values even if you do not need all 4 measurements
843 * This allows to amplify a low voltage applied on input pins before it is converted by the ADC. So accuracy of conversion is optimum.
844 * Select between MV6144 MV4096 MV2048 MV1024 MV512 MV256 where the digits give the max mvolt being applied on the pin (e.g. for A0_TO_GND) or between 2 pins (e.g. for A0_TO_A1)
845 * In ADS_SCALE, you specify a scaling factor to be applied on each measurement in order to get a value that conforms the expected measurement.
846 * Fill always 4 values even if you do not need all 4 measurements
847 * When scaling parameter = 1, oXs returns a value = ADC_FULL_SCALE_VOLT when the voltage applied on ads1115 pin(s) is the max voltage set by ADC_FULL_SCALE_VOLT.
848 * So, if ADC_FULL_SCALE_VOLT is set on MV512, when input voltage will be 512mv (or more)), oXs will return 512 if ADS_SCALE = 1.
849 * If you have a voltage divider, the voltage that you want to measure is greater than the voltage applied on ads1115 pin and you have to increase ADS_SCALE.
850 * e.g. if your voltage divider divides your voltage by 10, you must set ADS_SCALE to 10
851 * Note: ADS_SCALE can have decimals (e.g. 100.5) . It can be positive or negative; It can't be 0
852 * In ADS_OFFSET, you specify an offset to be applied.
853 * Fill always 4 values even if you do not need all 4 measurements
854 * When no offset has to be applied, set the value on 0
855 * The specified offset is added to the value calculated after scaling.
856 * each value must be an integer (positive or negative); it can be 0
857 * In ADS_RATE, you specify the number of milli sec that ads1115 takes to convert a voltage.
858 * Fill always 4 values even if you do not need all 4 measurements
859 * Using a high value reduces power consumption still, it reduces the number of measurements that can be performed/transmitted per second
860 * Select values between MS137, MS69, MS35, MS18, MS9, MS5, MS3 , MS2; the digits correspond to the number of milli sec (e.g. MS18 means 18 msec)
861 * Note : oXs will wait at least the specified delay but it can be that the delay is higher due to other tasks to be performed by oXs
862 * In ADS_AVERAGING_ON, you specify the number of voltages to be collected in order to calculate an average.
863 * Fill always 4 values even if you do not need all 4 measurements. If you do not want averaging, set the value on 1
864 * It must must be an integer, positive and different from 0.
865 * Note : Increasing the value is a way to reduce noise. Still it increase the delay between 2 transmissions
866 * In ADS_CURRENT_BASED_ON, you specify which voltage measurement (if any) is used for current (and current consumption)
867 * Uncomment this line only when a conversion is requested
868 * Keep this line as comment if there is no current sensor or if the wurrent sensor is connected to an Arduino pin as explained in section 6.4
869 * Fill only one value; select a value between ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
870 * Note : when oXs calculate a curent based on a voltage, it used also 2 parameters from section 6.4 : MVOLT_AT_ZERO_AMP and MVOLT_PER_AMP
871 * In ADS_AIRSPEED_BASED_ON, you specify which voltage measurement (if any) is used for airspeed
872 * Uncomment this line only when an analog airspeed sensor is connected to ads1115
873 * Keep this line as comment if there is no airspeed sensor connected to ads1115
874 * Fill only one value; select a value between ADS_VOLT_1, ADS_VOLT_2, ADS_VOLT_3, ADS_VOLT_4
875 * Note : A typical airspeed sensor is the MPXV7002DP which is easaly available on ebay or aliexpress.com.
876 * When this sensor is used, you have to configure ads1115 in following way:
877 * - ask only for one ads1115 measurement and it must be a differential voltage : so use this setup : ADS_MEASURE A0_to_A1, ADS_OFF, ADS_OFF, ADS_OFF
878 * - connect one resistor of about 10kohm between ads1115 Vcc and ads1115 A1 and another one of the same value between ads1115 Ground and ads1115 A1; so A1 pin get Vcc/2 volt
879 * - set the ads1115 gain in order to get 2048 mvolt at full scale: so use : ADC_FULL_SCALE_VOLT MV2048,MV2048,MV2048,MV2048
880 * - set the ads rate in order to make ADC conversion as fast as possible; so use : ADS_RATE MS2, MS2, MS2, MS2
881 * - the other parameters are not critical (not used for airspeed)
882 ************************************************************************************************************************
883 #define AN_ADS1115_IS_CONNECTED NO // select between YES and NO
884 #define ADS_MEASURE A1_TO_GND , ADS_OFF , ADS_OFF , ADS_OFF // uncomment when ADS1115 is used; 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
885 #define ADS_FULL_SCALE_VOLT MV4096, MV4096, MV4096, MV4096 // select between MV6144 MV4096 MV2048 MV1024 MV512 MV256
886 #define ADS_OFFSET 0, 0 , 0 , 0 // must be an integer (positive or negative)
887 #define ADS_SCALE 2, 10, 1, 1 // can be a float
888 #define ADS_RATE MS137 , MS5, MS3 , MS2 // select between MS137, MS69, MS35, MS18, MS9, MS5, MS3 , MS2
889 #define ADS_AVERAGING_ON 1 , 10, 50, 50 // number of values used for averaging (must be between 1 and 254)
890 #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
891 #define ADS_AIRSPEED_BASED_ON ADS_VOLT1 // 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
893 **** 7 - RPM (rotations per minute) sensor settings (optional) ***************************************************************************
894 * It is possible to measure RPM using a sensor connected to pin ICP (=PB0, = pin 8) of OXS.
895 * This sensor must provide a level change (0 - Vcc) on this pin each time a blade passes in front of it.
896 * The number of blades has to be defined in PULSES_PER_ROTATION except for Frsky protocol (OpenTx, ...) where it is supposed to be done on Tx side only (so this parameter is discarded for Frsky prtocol).
897 * It is also possible to build a small PCB board that will provide pulsed when connected on a brushless wire.
898 * To activate this function, put YES instead of NO in line #define CALCULATE_RPM .
899 * Note: The digital pin 8 (PB0/ICP) is the only one to be used to measure RPM.
900 * for Frsky protocol, the value calculated by oXs is in Hertz (and not in roration per minute) and the conversion is done by the TX
901 ************************************************************************************************************************
902 #define CALCULATE_RPM NO
903 #define PULSES_PER_ROTATION 2
905 **** 8 - Persistent memory settings ************************************************************************************
906 * Optional Feature.
907 * If persistent memory is activated, current consumption and fuel consumption (+ flow parameters) will be stored in EEProm every 30 seconds.
908 * This value will be restored every power-up.
909 * So, you will get ongoing consumption even if the you turn off the model between flights.
910 * If you want to save those data, you have to say YES in the line "#define SAVE_TO_EEPROM"
912 * It is also possible to reset:
913 * - the current and fuel consumption to zero pressing on a push button connected to OXS.
914 * Therefore a DIGITAL Arduino pin has to be connected to a push button, the other pin of the push button being connected to Gnd (ground).
915 * In order to use this feature, you must specify the DIGITAL Arduino pin being used.
916 * Default: 10 ; other digital pin can be used; Do not use a pin that is already used for another purpose.
917 * - the fuel consumption to zero from TX using a chanel on TX connected to Aduino using PPM feature (see section 3 PPM and 11 flow sensor )
918 ************************************************************************************************************************
919 #define SAVE_TO_EEPROM NO
920 #define PIN_PUSHBUTTON 10
922 **** 9 - GPS (optionnal) *********************************************************************************************
923 * It is possible to connect a GPS module to Arduino. In this case, oXs will transmit to the Tx some data generated by the GPS module.
924 * Note: data are sent to the receiver only when the GPS has a fix.
925 * So, it can take several minutes before oXs start sending GPS data.
926 * If GPS lost his fix, oXs will stop sending GPS data until GPS got a new fix.
927 * When Frsky (SPORT or HUB) receiver is used, oXs will always send longitude, latitude, altitude, ground speed and course.
928 * This does not require any additional lines in the section "Data to transmit" (see 9 here above)
929 * When Multiplex receiver is used, the user has well to specify under the line "#define SETUP_MULTIPLEX_DATA_TO_SEND" which data are sent and the line number where the data have to appear on the display.
930 * Hardware points of attention.
931 * Supported GPS modules: oXs supports modules based on UBLOX GPS (easily available on ebay or aliexpress) like Neo6M, Neo7M and Neo8M.
932 * Most modules have a build in voltage regulator in order to drop the voltage down to 3.3 volt which is about the max allowed by the GPS
933 * They have 4 pins available that have to be connected to Arduino
934 * - GPS gound is connected to Arduino ground
935 * - GPS Vcc is normally connected to Arduino Raw pin (which is normally connected to Vcc from the receiver).
936 * Still take care that the voltage regulator on the GPS module is, most of the time, foreseen for a maximum voltage of 6 Volt while arduino Raw pin accept more.
937 * So, if you Raw pin get more that 6 volt, it is safe to add another voltage regulator to drop the GPS Vcc down.
938 * - GPS Tx pin is connected to Arduino Rx pin
939 * - GPS Rx pin is connected to a resistor (e.g. 10k) and the other pin of the resistor is connected to Arduino pin 6 (digital pin 6).
940 * This resistor is added (at least for an Arduino 5 volt) in order to protect the GPS pin.
941 * This is requested because Arduino will generate a signal with a high level equal to arduino Vcc (so normally 5 volt) while the GPS module should normally not accept more than 3.3 Volt.
942 * To be safier, you could even add a second resistor between GPS Rx pin and Ground (value= 22k) but, in my case, it worked without this second resistor.
943 * Note: it would be possible to use another pin than Arduino pin 6 but then it requires to change some parameters in file oXs_gps.cpp (see "Setup the GPS sensor").
944 * !! IMPORTANT NOTE :
945 * Arduino Rx pin is used for 2 purposed: getting the data from the GPS and uploading the program into the Arduino (normally only to be done once) using a USB to serial adapter.
946 * You must avoid having both GPS and USB connected at the same time because while uploading a program in Arduino, there will be conflicts between the signals sent by the 2 devices and programming will fail.
947 * There is another risk: if your USB to serial adapter generates 5 volts signal, it could damage the GPS module.
948 * So, when you connect the usb to serial adapter to the Arduino, you should disconnect at least the GPS TX pin from the Arduino Rx pin.
949 * Personnaly I use a connector between Arduino and GPS module and so I can disconnect totally the GPS module.
950 * Software points of attention
951 * UBLOX GPS module are normally delivered with a default configuration (generating automatically e.g some NMEA messages at 9600 bauds at a refresh rate of 1 hz).
952 * oXs assumes that, at start up, GPS is working at 9600 bauds. oXs sent then some commands in order to
953 * - disable all NMEA messages
954 * - activates some UBX messages
955 * - increase frequency of calculation (to 10 or 5 Hz instead of 1hz)
956 * - set up the baud rate to 38400 instead of 9600.
957 * Those parameters are not saved in the GPS (because some GPS modules does not allow it). So, oXs will send those commands at each power on.
958 * If you oXs does not send GPS data, please check that your GPS module has still the default configuration (most important is that it is configured to receive UBX command messages at 9600 bauds).
959 * An easy way to check the GPS configuration is to connect the GPS module to a 3.3 volt FTDI ( or USB to serial adapter) and to use a free software named "u-center".
960 * This software is available on the official web site of UBLOX. More info is easily available on the web.
961 * oXs is configured with following parameters (in the oXs_config_basic.h and oXs_config_advanced.h files):
962 * - #define A_GPS_IS_CONNECTED NO : Replace NO by YES if a GPS is connected and has to transmit his data
963 * - #define GPS_M10 : uncomment this line if GPS module is using M9/M10 engine
964 * - #define GPS_SPEED_IN_KMH : uncomment this line if GPS speed has to be sent in km/h instead of knot/h
965 * - #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)
966 * - #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
967 * - #define GPS_TRANSMIT_TIME : for sport only, transmit UTC time from GPS
968 ************************************************************************************************************************
969 #define A_GPS_IS_CONNECTED YES // select between YES , NO
970 //#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)
971 //#define GPS_M10 // 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)
972 #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)
973 #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
974 #define GPS_TRANSMIT_TIME // for sport only, transmit UTC time from GPS
976 ****** 10 - IMU based on mpu6050 (accelerometer/gyro sensor) (optionnal) ********************************************************
977 // ***** 10.1 - IMU 6050 *****
978 * It is possible to connect an IMU sensor (=accelerometer/gyro) to arduino; this is optionnal.
979 * It allows :
980 * - to reduce the reaction time of the vario by about 0.5 sec (note: a baro sensor has to be connected too because oXs merges the data from both sensors)
981 * - to transmit data about accelerations and/or orientation (pitch/roll); in this case it is important that oXs device is mounted in a fix position and is aligned with the plane axis.
982 * Only one IMU sensor is supported : the mpu6050.
983 * This sensor is easily available on ebay, ... under different modules. The best module to use is probably the GY-86 because it has also a voltage regulator (3.3volt), I2C level converters, and a baro sensor (MS5611)
984 * 5 pins from the mpu6050 have to be connected to Arduino:
985 * - MP6050 ground <---> Arduino ground
986 * - MP6050 Vcc <---> Arduino Vcc
987 * - MP6050 SDA <---> Arduino SDA = Arduino A4
988 * - MP6050 SCL <---> Arduino SCL = Arduino A5
989 * - MP6050 INT <---> Arduino INT0 = Arduino 2 OR Arduino INT1 = Arduino 3(do not use the same pin for another purpose like PPM!)
990 * In order to activate the IMU, set YES in the line #define A_MPU6050_IS_CONNECTED
991 * When IMU is activated, this version of oXs calculates a vertical speed in a different way merging the altitude from baro sensor with vertical acceleration from IMU (in Earth reference).
992 * This other type of vertical speed can be send as Vspeed assigning the value BARO_AND_IMU in #define VSPEED_SOURCE (see section 4.2)
993 * It is also possible to assign it in "VARIO_PRIMARY" or "VARIO_SECONDARY" and so to switch between 2 vario sources from the Tx (using a ppm channel)
994 * In order to get best results from IMU, it is required to calibrate the accelerometer offsets. To do so, please :
995 * - upload a version of oXs firmware whith the line #define DISPLAY_ACC_OFFSET uncommented
996 * - let oXs runs while connected to the PC (via USB serial interface = FTDI)
997 * - open Arduino IDE terminal (press CTRL + SHIFT + M simultaniously)
998 * - take care to set the baud rate to 115200 (or 38400 if GPS is activated too)
999 * - after startup, terminal should, every 2 or 3 sec, display Acc followed by 3 numbers being respectively AccX, AccY and AccZ. Please note that those numbers change when mpu6050 moves.
1000 * - ensure that the mpu6050 (on GY86,GY87) is perfectly horizontal and does not move (e.g. put on a table)
1001 * - notice the 2 first numbers ( = AccX and AccY ) ; Don't take care of the 3rd number because when the sensor is in this position, it will reflect the gravity and will be around 16384.
1002 * - rotate mpu6050 in order to get X or Y axis perfectly vertical and do not move. Now, the 3rd number would become much lower (because it does not measure gravity anymore)
1003 * - notice the 3rd number ( = Accz )
1004 * - update oXs_config_advanced.h file filling the 3 numbers in lines #define ACC_OFFSET_X , #define ACC_OFFSET_Y and #define ACC_OFFSET_Z
1005 * - set line #define DISPLAY_ACC_OFFSET as comment (adding "//" in front)
1006 * - upload again oXs firmware in arduino
1007 ************************************************************************************************************************
1008 #define A_MPU6050_IS_CONNECTED NO : Replace NO by YES if a IMU6050 is connected and has to transmit his data
1009 #define PIN_INT_6050 3 // Interrupt from 6050 has to be connected to Arduino pin 2 or pin 3 (do not use here the same pin as PPM)
1010 #define DISPLAY_ACC_OFFSET
1011 #define ACC_OFFSET_X 0 // fill here the value reported when DISPLAY_ACC_OFFSET is activated (eg. -160)
1012 #define ACC_OFFSET_Y 0 // fill here the value reported when DISPLAY_ACC_OFFSET is activated (eg. -150)
1013 #define ACC_OFFSET_Z 0 // fill here the value reported when DISPLAY_ACC_OFFSET is activated (eg. -1100)
1015 // ***** 10.2 - HMC5883 *****
1016 * If you use a module like GY-86 AND if IMU6050 is connected to arduino (see 10.1), oXs can get access to a magetometer HMC5883 in order to get a Yaw measurement.
1017 * This does not require additional wiring.
1018 * In order to activate the HMC5883, set YES in the line CALCULATE_YAW_WITH_HMC5883
1019 * Take care that to get reliable values from the magnetometer, it is mandatory to calibrate it.
1020 * This is a non trivial process.
1021 * I recommend to folow the process described in this link: http://www.physi.cz/hmc5883l-magnetometer-calibration.html
1022 * It means that you have to:
1023 * 1) collect sample data from oXs:
1024 * This require that you:
1025 * - uncomment the line #define GENERATE_MAG_CALIBRATION_DATA
1026 * - upload the program in the Arduino
1027 * - open the Arduino PC terminal
1028 * - in the PC terminal, you will get a few lines of general data followed by a list with 3 values per line (those are the raw X, Y and Z magnetometer readings)
1029 * - rotate the sensor slowly on 360° along ALL axis in order to collect more than 1000 lines of data (this may take several minutes)
1030 * 2)copy and paste the lines from PC terminal to a TXT file (using a text editor like notepad). Remove the first lines of general data (before the list)
1031 * and save this file as TXT file
1032 * 3)download the windows program form the link here above (see "Download Executable" )
1033 * run this program, set norm to 1.0, click "open" and select the TXT file with your sample data and then click on "Calibrate"
1034 * 4) note the 3 "combined bias" values and copy them in XMAG_OFFSET, YMAG_OFFSET and ZMAG_OFFSET (in oXs_config_advanced.h)
1035 * 5) note the 9 "combined scale factors..." values and open now a link to a web site that will let you find the inverse of the matrix of the 9 values :
1036 * https://www.wolframalpha.com/input/?i=%7B%7B591.0437,-13.1628,-15.0294%7D,%7B-13.1628,596.1147,30.5314%7D,%7B-15.0294,30.5314,552.0759%7D%7D%5E-1
1037 * - fill the 9 values in the first input field (respect the special format with {{ , , } , { , , } , { , , }} and click on the button on the right of the input line.
1038 * 6) you will get a "result" matrix. Note the 9 values from result and copy them in XXMAG_CORRECTION , XYMAG_CORRECTION , XZMAG_CORRECTION ... ZZMAG_CORRECTION (in oXs_config_advanced.h)
1039 * 7) set the line #define GENERATE_MAG_CALIBRATION_DATA as comment and upload the program again in Arduino
1040 ************************************************************************************************************************
1041 #define CALCULATE_YAW_WITH_HMC5883 NO // select between YES , NO ; YES requires that A_MPU6050_IS_CONNECTED is YES here above
1043 //#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
1045 #define XMAG_OFFSET 2 // must be an integer
1046 #define YMAG_OFFSET -1 // must be an integer
1047 #define ZMAG_OFFSET 139 // must be an integer
1048 #define XXMAG_CORRECTION 0.122082 // can have decimals
1049 #define XYMAG_CORRECTION -0.00204026
1050 #define XZMAG_CORRECTION 0.00377534
1051 #define YXMAG_CORRECTION -0.00204026
1052 #define YYMAG_CORRECTION 0.130413
1053 #define YZMAG_CORRECTION -0.00491189
1054 #define ZXMAG_CORRECTION 0.00377534
1055 #define ZYMAG_CORRECTION -0.00491189
1056 #define ZZMAG_CORRECTION 0.138038
1058 ****** 11 - Flow sensor ******************
1059 * If you use a fuel engine, you can connect a liquid flow meter to oXs
1060 * This sensor generates a pulse each time some milli liters are going trough the sensor
1061 * oXs can count the number of pulses and calculates 3 data : the current consumed milli liter / min and, taking care of tank capacity, the remaining fuel in ml and in %.
1062 * It is recommended to use following type of flow meter because it is probably more accurate than others when flow is low
1063 * http://www.conrad.be/ce/nl/product/155374/BIO-TECH-eK-FCH-M-Doorstroomsensor-1-stuks-Voedingsspanning-bereik-5-24-VDC-Meetbereik-08-0015-lmin-l-x;jsessionid=EED7B26A7F28BA3F20F0060807E20FD1.ASTPCEN22?ref=searchDetail
1064 * It is foreseen to measure from 0.015 up to 0.8 l/min.
1065 * The output signal of the flow meter sensor has to be connected to arduino pin 9 (and the other 2 pins to 5 volt VCC and to Ground).
1066 * There are other cheap flow sensors on ebay or aliexpress but I expect that there are not accurate enough when flow is low.
1068 * To activate such a flow sensor, you have to:
1069 * - assign YES to the define A_FLOW_SENSOR_IS_CONNECTED (in oXs_config_basic.h file)
1070 * - specify in PULSES_PER_ML the number of pulses generated by the sensor when 1 milli liter of liquid flows trough it
1071 * - specify in TANK_CAPACITY the maximum capacity in milli liter
1072 * - specify 8 values used to calibrate your sensor in INIT_FLOW_PARAM
1073 * Those parameters are used in order to take care that the number of pulses generated by the sensor when 1 milli liter of liquid flows trough it varies with the flow it self.
1074 * For 4 flow values (the first 4 parameters) , oXs allows you to define a correction (in %) in the last 4 parameters.
1075 * The process to calibrate the sensor should be as follow :
1076 * Set last 4 parameters to 0 (so 0% correction)
1077 * Run you engine at 4 different speeds (from very low, to some medium and finally to high speed) for a few minutes.
1078 * For each run,
1079 * - note the remaining fuel (in ml) reported by oXs at start (e.g. 1200) and at end (e.g. 1090)of the run
1080 * - measure the real remaining fuel (in ml) in the tank at start (e.g. 1500) and at end (e.g. 1380)of the run
1081 * - note the enlapsed time (in min) between start and end of the run (e.g. 2 min).
1082 * - compare the consumed ml (difference between remaining fuel at start and at end) reported by oXs and in the reality (e.g. reported = 1200 - 1090 = 110ml; real = 1500 - 1380= 120ml)
1083 * - calculate the correction factor to apply (e.g. (120 - 110) / 110 = 9%) ; note correction could be negative)
1084 * - calculate the flow where this correction applies (= consumed ml reported by oXs / enlapsed time = 110 ml / 2 min = 55 ml/min)
1085 * Fill the first 4 parameters with the calculated flows (e.g. 55) and the last 4 parameters with the correction percentage (e.g. 9).
1086 * Take care that the first 4 parameters have to be in ascending order (so from low speed to high speed).
1087 * Note: when oXs calculates the consumption, it will apply linear interpolation for the related range of values.
1089 * If you move an oXs device from one plane to another, you will probably have to modify the values set in TANK_CAPACITY and/or INIT_FLOW_PARAM.
1090 * This requires to upload a new firmware in your oXs except if you are using JETI protocol or SPORT protocol with openTx 2.2.x (or above).
1091 * For JETI protocol, you can just enter the JETIBOX dialog box, press DOWN key to go to the item to modify and press "<" or ">" to increase/decrease the value.
1092 * Do not forget to activate the SAVE_TO_EEPROM option in section 8 in order to save the parameters and reuse them at next power on.
1093 * For SPORT protocol, you must run some LUA scripts. In this package (in the folder "lua scripts"), you can find 3 lua scripts to be installed in the folder SCRIPTS/FUNCTIONS of the SD card:
1094 * - one (rstful.lua) to reset the consumed fuel to 0 (to be used when tank is filled)
1095 * - one (tank.lua) to define the max capaicity of the tank (prior to run the script, the tank capacity has to be entered in GVAR9 for fase 9
1096 * The value in GVAR9 is the number of 50 ml in the thank. It means e.g. that for a thank of 1000 ml, GVAR9 must be set to 20 (=1000 / 50 )
1097 * - one (calful.lua) to define the 8 (4 X 2) calibration parameters (pior to run the script, the parameters have to be entered in GVAR9 (for fase 0 to 8)
1098 * The first 4 values are the flow in ml/min (min = 30, max = 800) ; the values must be in ascending order
1099 * The last 4 values are the correction in percent to apply (min = -100, max = 100) for each flow
1100 * NOte: the parameters saved in the eeprom or loaded by a LUA script take over the parameters defined in the config.
1102 * Please note that the fuel consumption can be saved every 30 sec in a non volatile memory.
1103 * To activate this option, you have to say YES in the line #define SAVE_TO_EEPROM from section 8
1104 * If this option is activated, when oXs start at power on, it start counting from the last remaining fuel when power goes off.
1105 * Otherwise, oXs reset the fuel consumption and assumes a 100% tank.
1107 * A reset of the fuel consumption can be achieved in different ways. This is really needed when SAVE_TO_EEPROM is activated
1108 * First reset is performed pressing more than 3 sec on the push button (see push button section).
1109 * A reset of the fuel consumption can also be requested from the TX.
1110 * This can be done in several ways depending also on the protocol being used:
1111 * For all protocols, it can be requested using a PPM signal
1112 * This requires to activate the oXs PPM option (see section 3) and to connect a Rx channel to oXs.
1113 * Reset will occur when absolute value of PPM signal exceed the value specified in FLOW_SENSOR_RESET_AT_PPM (section 11)
1114 * Furthermore:
1115 * -for JETI protocol it can be requested from the JETIBOX pressing simultanously the "<" and the ">" keys when the JETIBOX dislay the remaining fuel in percentage
1116 * - for the FRSKY SPORT protocol, since openTX version 2.2.x it is possible to activate a LUA function script that will send a reset command to oXs
1118 * For JETI protocols, oXs transmits automatically the current flow, the remaining fuel in ml and in %
1119 * For other protocols, you have to ask oXs to transmit the data; so you have :
1120 * - to uncomment the line #define FILL_TEST_1_2_3_WITH_FLOW_SENSOR_CONSUMPTION (in section 2.5 )
1121 * - to specify in which telemetry fields, TEST_1 (current flow in ml/min), TEST_2 (remaining fuel in ml) and TEST_3 (remaining fuel in %) are sent (see section 2.1/2.4)
1122 * Please note that if you transmit TEST_1... TEST_3 in AccX...AccZ in FRSKY protocol, the values are divided by 100 by openTx. You can get the original values back if you set up a scale = 255 on Tx side in the telemetry fields
1123 **************************************************************************************************************************************
1124 #define A_FLOW_SENSOR_IS_CONNECTED NO // select between YES , NO
1125 #define PULSES_PER_ML 10.0 // number of pulses per milli liter (depends on sensor); can have decimals
1126 #define TANK_CAPACITY 1000 // tank capacity in ml
1127 #define INIT_FLOW_PARAM 30 , 100 , 500 , 700 , 20 , 10, -5, 15 // 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
1128 #define FLOW_SENSOR_RESET_AT_PPM 95 // when absolute value of ppm is greater than this, flow counter is reset.
1131 // --------- 12 - Locator ---------------
1132 * oXs sent data to Tx using the Rx telemetry protocol over 2.4G band as defined by FrSky, Hott, Jeti or Multiplex.
1133 * when the model is on the ground, the range over 2.4G is quite limitted.
1134 * So if a model is lost at more than a few hundreed meters, the Tx will not get any telemetry data anymore
1135 * oXs allows to use his own tranmitter in order to have an extended range and have a chance to find back a lost model.
1136 * It is possible because it uses a lower frequency, a lower transmitting speed and a spécial protocol(LORA).
1137 * The transmitter is a SX1276/RFM95 LORA module that is easily available (e.g. Aliexpress, ebay, amazon)
1139 * The principle is the following:
1140 * - You have to build 2 devices:
1141 * - an "openXsensor" device with an Arduino , the sensors you want (ideally a GPS and e.g. vario, voltages, current, ...) and a SX1276/RFM95 module
1142 * - a "locator receiver" device with an Arduino, a SX1276/RFM95 module and a display.
1143 * The display must be a 0.96 pouces OLED 128X64 I2C SSD1306. It is small and is available for about 2€.
1144 * - Normally, the locator receiver is not in use. The openXsensor is installed in the model and transmit the sensor data over the normal RC Rx/Tx link.
1145 * The SX1276 module in oXs is in listening mode: it sent data only when it receives a request from the "locator receiver"
1146 * - When a model is lost, the locator receiver" is powered on. It starts sending requests to openXsensor.
1147 * When the SX1276/RFM95 module in openXsensor receives a request, it replies with a small message containing the GPS coordinates and some data over the quality of the request signal.
1148 * The display on the locator receiver shows those data as wel as the quality of the signal received back and the time enlapsed since the last received message.
1150 * Note: the range of communication between two SX1276 modules is normally several time bigger then the common RC 2.4G link.
1151 * Still when openXsensor and locator receiver are both on the ground, it can be that there are to far away to communicate.
1152 * There are 2 ways to extend the range:
1153 * - use a directional antena on the locator receiver.
1154 * The advantage of this solution is that, if you get a communication, you can use the system as a goniometer (looking at the quality of the signal) to know the direction of the lost model.
1155 * This even works if you have no GPS connected to openXsensor.
1156 * The drawback is that a directional antenna is not as small as a simple wire.
1157 * - put the locator receiver (which is still a small device) on another model and fly over expected lost aera.
1158 * In this case, the range can be more than 10 km and the chance is very high that a communication can be achieved between the 2 modules.
1159 * Even if the communication is broken when the model used for searching goes back on the ground, you will know the location of the lost model because the display will still display the last received GPS coordinates
1161 * An openXsensor device with a SX1276/RFM95 does not perturb the 2.4G link and consumes only a few milliAmp because it remains normally in listening mode (and when sending it is just a few % of the time).
1162 * So, in order to increase the reliability of the system, it is possible to power openXsensor with a separate 1S lipo battery of e.g. 200 mAh.
1164 * Cabling : The SX1276/RFM95 module must be connected to the Arduino in the following way (this is valid as wel for openXsensor device as wel for locator receiver device):
1165 * - Arduino digital pin 10 <=> NSS from module
1166 * - Arduino digital pin 11 <=> MOSI from module
1167 * - Arduino digital pin 12 <=> MISO from module
1168 * - Arduino digital pin 13 <=> SCK from module
1169 * - Arduino GRND <=> GRND from module
1170 * - external (or Arduino?) 3.3V <=> 3.3V from module
1171 * !!!!!!!!! module has to be powered with 3.3 Volt and not 5 Volt.
1172 * !!!!!!!!! The Arduino must also be a 3.3 V version (so, with a 8 MHz clock)
1173 * To be checked : perhaps you have to use an additional voltage regulator (cost less than 1€) to get the 3.3 V, because it is not sure that the arduino voltage regulator can provide enough current when module is transmitting (for just a small time)
1175 * On the locator receiver side, you do not have to connect sensor but wel the display. It uses 4 wires:
1176 * - Arduino pin A4 <=> SDA display
1177 * - Arduino pin A5 <=> SCL display
1178 * - Arduino GRND <=> GRND display
1179 * - Arduino 3.3V <=> Vcc display
1182 * The program to upload in the Arduino (nano or pro mini) locator receiver is available on github in the directory locator_receiver.
1184 * In order to use a locator, you must change a line in oXs_config_basic.h
1185 * #define A_LOCATOR_IS_CONNECTED NO // select between YES , NO
1187 * In oXs_config_advanced.h file you can select the frequency to be used between the 2 SX1276 modules (e.g. to avoid perturbation when several devices are used simultanously)
1188 * Note: if you change the frequency, take care to use the same on openXsensor and locator receiver devices.
1191 ****** 13 - Rf link quality ********************************************************************************************************************
1192 * oXs can check the quality of the Rf link monitoring the PWM signal on a normally unused channel
1193 * The principle is the following:
1194 * The Tx generates on a channel a signal that changes continiously (just like when using a servo tester); easiest is probably to use a triangle wave form.
1195 * The Rx receives this signal and generates a pulse at regular interval (e.g. every 18 ms for a Frsky X8R receiver)
1196 * The width of the pulse varies with the signal (normally betwwen 1000 usec and 2000 usec)
1197 * If the Rx does not receives the signal from the Tx, the Rx will still generates a pulse but the width will be the same as the last received (or after some time a predefined value set as failsafe)
1198 * oXs can measure the width of each pulse and compare it with the previous one. Getting 2 identical pulses denotes a lost of Rf signal
1199 * oXs calculates the % of signal losts over a certain time (e.g. based on 50 signals) and the number of consecutive signal losts
1200 * This principle could normally be used will all Rf protocol (FRSKY, JETI, HOTT, MULTIPLEX) if the TX can be programmed in order to generate a varying signal.
1201 * Still currently the 2 measurements are stored internally in TEST_1 and TEST_2 and only FRSKY protocol allows to select telemetry fields to transmit them.
1203 * In order to use this feature you have:
1204 * - let the Tx generates a e.g. triangular wave signal on a free channel.
1205 * With openTx, this requires 2 set up:
1206 * - create a logical switch (e.g. L01) coupled with the free channel (e.g. Channel 8) : set e.g. L01 with "a<x" "Channel 8" "0"
1207 * - create a mixer for a channel (e.g. 8) : Source = the logical switch L01, Delay up and down = 1.0, Slow up and down = 2.0
1208 * - in file oXs_config_basic.h :
1209 * - in section 2.1 (for FRSKY protocol), define in which fields the 2 measurements TEST_1 and TEST_2 have to be transmitted (e.g. in TEMP1 and TEMP2)
1210 * - set MEASURE_RF_LINK_QUALITY on YES
1211 * - in file oXs_config_advanced:
1212 * - in section 2.5, uncomment #define FILL_TEST_1_2_WITH_LQ in order to let TEST_1 and TEST_2 being filled
1213 * - in section 3 (PP setting), define PIN_PPM with the arduino digital pin (should be 2 or 3) that will be connected to the RX channel
1214 * - in section 13, define following parameters
1215 * PULSE_INTERVAL_MIN and PULSE_INTERVAL_MAX are used to discard a PWM pulse measurement if the delay between 2 pulses is not in the expected interval.
1216 * Take care of some tolerances; e.g. 17000 and 19000 seems ok for a FRSKY Rx generating a pulse every 18000 micro sec.
1217 * LQ_COUNT_MAX defines the number of PWM pulses used to calculate the 2 Rf quality parameters; 50 means that you get the measurement about once per second (e.g. 18msec * 50)
1218 * WIDTH_ERROR_MAX defines the max width difference between 2 conscutive pulses.
1219 * If the width difference is less or equal to this parameter, oXs considers that the signal does not have enough variation and so that a Rf frame has not been received.
1220 * Normally this parameter should be set on 1 or 2.
1221 * - for best results, Rx should configured with a fail safe in "Hold".
1222 * If you assign a predefined PWM value for the fail save in your Rx, oXs will not count as error the first frame after the Rx enters in fail safe mode because the PWM value will most probaly differs from the previous one.
1223 * So, in this case, the link quality measurement reported by oXs will be too optimistic.
1224 * Still, normally a Rx does not enter in fail safe mode if only a few rf occurs. So the oXs measurement can still give an acceptable indication of rf quality (at least if the Rx does not enter to fast in fail save mode).
1225 * Note: on some Tx (e.g. those with openTx) you can ask the Tx to calculate and display the lowest % of quality and the highest value of consecutive LQ errors in order to monitor the whole session.
1226 *************************************************************************************************************************************************
1227 #define PULSE_INTERVAL_MIN 17000 // minimum delay (micro second) between 2 PWM pulses generated by the Rx
1228 #define PULSE_INTERVAL_MAX 19000 // maximum delay (micro second) between 2 PWM pulses generated by the Rx
1229 #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)
1230 #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.
1232 ****** 20 - Sequencer (ON/OFF) for several digital outputs **************************************************************************************
1233 * oXs allows you to control (HIGH/LOW) up to 6 digitals Arduino outputs in different sequences.
1234 * Each sequence is composed of one or several steps; each step defines for how long (= a duration) which outputs are HIGH and which outputs are LOW.
1235 * oXs determines normally the sequence to be played based on the signal received on a PPM channel (see section 3 in order to set up a PPM signal).
1236 * Still there are 2 exceptions:
1237 * At power on or when no PPM channel is configured/received, oXs will generate as default the sequence defined in the line #define SEQUENCE_m100 (see below)
1238 * When a low voltage alarm is configured (see below) and if the voltage becomes low, oXs will generate the sequence defined in the line #define SEQUENCE_LOW (see below) as long as the voltage remains low
1239 * When a sequence has been played, oXs can or repeat it or just wait for a new sequence. The difference is made in the set up of the sequence.
1240 * Each time a new (= different) valid PPM signal is received, oXs start immediately the corresponding sequence (even if the current sequence is not completely played)
1241 * - In order to use the sequencer functionality, you first have to define which Arduino digital pin have to be controlled by the sequencer.
1242 * The arduino pins that can be controlled are the pin 13, 12, 11, 10 , 9 and 8.
1243 * This set up is achived by a line like : #define SEQUENCE_OUTPUTS 0b100100
1244 * Each bit (1 or 0 after the "b") represent an output; the least significant bit correspond to pin 8, the bit on the left pin 9 etc... up to pin 13
1245 * Put 1 when the pin has to be controlled by the sequencer, 0 otherwise; In this example, it means that only pins 13 and 10 would be controlled.
1246 * Note: if the line #define SEQUENCE_OUTPUTS xxxx is omitted or put as comment, then the sequencer is not active at all.
1247 * Take care not to use the same pin for the sequencer and for another oXs funtionallity (e.g. as Tx pin, for push button, for PPM, for RPM, ...)
1248 * If a pin is set up with 0 (= not controlled by oXs), it will never be forced to HIGH or LOW by the sequencer even if a 1 or 0 is set up in a sequence.
1249 * When sequencer is activated ( SEQUENCE_OUTPUTS is defined) PPM signal is automatically used ONLY to control the sequence (so PPM can't control any more vario sensitivity, ...)
1250 * Current passing through the digital pins of Arduino should not exceed 40mA per pin (and 200 mA for all pins).
1251 * In case you want to have a higher current (which is the case for most high-power LEDs and LED strips), you need to add a transistor. Connection diagram could easily be found in Google.
1252 * - Then you can (optionnal) specify the units used for defining the durations
1253 * By default, the durations are expressed in 10 milli second. A parameter allow you to increase the unit in multiple of 10 milli second;
1254 * E.g with a line like #define SEQUENCE_UNIT 50, the durations will become multiple of 500 milli second (= 50 * 10).
1255 * Note; this parameter should be an integer between 1 and 1000. So, take care that it is not possible to get a duration less than 10 msec.
1256 * If this line is ommitted (or as comment), the default value (1 = 10 msec) will be applied.
1257 * - Then you have to define the sequences being used for each value of the PPM channel
1258 * You can define up to 9 different sequences.
1259 * A sequence is defined by a line like : #define SEQUENCE_m50 200 , 0b100000 , 300 , 0b000000 , 100 , 0b100100
1260 * Each sequence is identified by the value of the ppm signal that will activate it; suffix m100 (m = minus) means that it should be activated when ppm is about -100, m75 is for ppm = -75, 75 is for ppm = +75, etc...
1261 * Sequence suffix are in multiple of 25; so valid sequence suffix are only : m100, m75, m50, m25, 0, 25, 50, 75 and 100
1262 * Each sequence is composed of several steps (from 1 up to 126 steps or even more) (separated by ",")
1263 * Each step is composed of 2 parameters (also separated by ",") : a duration and a combination (LOW/HIGH) of outputs
1264 * - A duration can be any value between 0 and 255.
1265 * The value fix the minimum duration that a combination of outputs has to be applied. Duration (in msec) = value * SEQUENCE_UNIT * 10
1266 * So a value = 2 means a duration of 1 sec (if SEQUENCE_UNIT = 50).
1267 * Value = 0 has a special meaning. When oXs reachs a duration = 0, it applies the corresponding combination of outputs and keeps it for an unlimitted time.
1268 * This allows to force the outputs to stay with a specific combination after having played the sequence.
1269 * If duration = 0 is used, it should be in the last step of the sequence (because oXs will never apply the following steps).
1270 * If duration is set to 0 in the first step, oXs will apply directly the specific combination of outputs and keep it.
1271 * If duration = 0 is not used in a sequence, oXs will automatically repeat the whole sequence after reaching the last step.
1272 * Note: if you need a duration that is longer than the max duration (= 255 * SEQUENCE_UNIT * 10 msec), you can put several steps with the same combination of outputs.
1273 * - A combination (LOW/HIGH) of outputs defines which pins have to be set to LOW and which one to HIGH
1274 * A combination can be defined in binary format so setting six 1 (HIGH) and/or 0 (LOW) just after "0b" (e.g. 0b100100)
1275 * The least significant bit correspond to pin 8, the bit on the left pin 9 etc... up to pin 13.
1276 * So if SEQUENCE_OUTPUTS = 0b110111, then 0b100100 means that:
1277 * - pins 13 and 10 have to be HIGH,
1278 * - pins 9 and 8 have to be LOW
1279 * - the others (pin 12 and 11) are not controlled by sequence because of the value assigned to SEQUENCE_OUTPUTS = 0b100111
1280 * So #define SEQUENCE_m50 2 , 0b100000 , 3 , 0b000000 , 1 , 0b100100 means (assuming that SEQUENCE_OUTPUTS = 0b100100 and SEQUENCE_UNIT = 50, ):
1281 * - set pin 13 to HIGH and pin 10 to 0 (= 0b100000) when PPM signal becomes -50
1282 * - then wait at least for 2 * 50 * 10 = 1000 ms = 1 sec before changing the outputs
1283 * - after 1 sec, set pin 13 ( and pin 10) to LOW (=0b000000) for a duration of 1.5 sec (3 * 50 * 10)
1284 * - after 1.5 sec, set pin 13 and 10 to HIGH for a duration of 0.5 sec (1 * 50 * 10)
1285 * - after 0.5 sec repeat first step (pin 13 HIGH for 1 sec)
1286 * - continue with next steps
1287 * Note: when a sequence name is not defined, oXs handles it like it would be defined with 0 , 0b000000 (so no repeat, all outputs LOW)
1288 * - Finally you can (but it is not mandatory) set up the condition(s) for a low voltage detection. When a voltage becomes too low, oXs starts automatically SEQUENCE_LOW (and discard PPM channel)
1289 * A low voltage condition can be set up based on 1 or 2 voltage(s):
1290 * - the voltage on the Arduino pin defined by the 6th parameter PIN_VOLTAGE; this set up is achived by a line like : #define SEQUENCE_MIN_VOLT_6 6000 where 6000 is the "low" voltage in mVolt.
1291 * Note: if you use this option, do not forget assign a pin number to the 6th parameter in #define PIN_VOLTAGE and to fill (if requested) the 6th parameter of other voltage parameters.
1292 * The pin defined in the 6th parameter of PIN_VOLTAGE can be the same as another parameter in PIN_VOLTAGE; this can be useful if you want to set up low voltage parameters too.
1293 * - the lowest lipo cell voltage; this set up is achived by a line like : #define SEQUENCE_MIN_CELL 3000 where 3000 is the "low" voltage in mVolt.
1294 * Note: if you use this option, do not forget to define the other voltage parameters PIN_VOLTAGE , etc ... and NUMBEROFCELLS
1295 * Note: when no one low voltage parameter is defined, oXs will not automatically start SEQUENCE_LOW.
1296 * when both voltage parameters are defined, oXs will automatically start SEQUENCE_LOW as soon as one of the 2 voltages becomes low.
1297 * If you want that oXs notifies a low voltage detection do not forget to also define SEQUENCE_LOW (otherwise, oXs will just set all output pins to LOW)
1298 * If you have telemetry, you can also make a set up on Tx side in order to detect a low voltage and then send a specific value on the ppm channel.
1299 * In this case you do not have to define the set up in oXs and the same device can be used on several model.
1300 ************************************************************************************************************************
1302 **** xx - Reserved for developer. **************************************************************************************
1303 * DEBUG must be activated in file oXs_config_macros.h when you want to debug one or several functions in some other files.
1304 * Enabling DEBUG will allow to use Arduino Serial Monitor at 115200 baud (or 38600 when GPS is activated) to see init data and some live sensor values
1305 * You can then select the parts that you want to debug by uncommenting the specifics DEBUG parameters you want in each file
1306 * Note: OXS allows to transmit 3 fields named TEST1, TEST2, TEST3. You can fill those fields with whatever you want where you want if you want to transmit additional data to the Tx.
1307 * Just fill in test1.value (or 2, 3) with an int32_t and test1.available (or 2, 3) with true and add those OXS measurements in the data to be sent section.
1308 ************************************************************************************************************************
1309 //#define DEBUG // !! is to define in file oXs_config_macros.h