How to calibrate User A2 input

This input is available on OSD board.  It is on black socket marked USER AI, and pin marked A2.  

(TODO: picture)

This input can support many sensors like temperature, pressure, current, rangefinder and others. 

Additionally to numeric value OSD allows to show measure units.

Each sensor has its characteristics and requires calibration.

System allows to use 3 general types of sensors:

Linear sensors

Linear sensors (like temperature or current)  has analog output  voltage proportional to measured value. This output voltage should be in range between 0V and 3.3V. if sensor’s output exceeds 3.3V it should be connected using voltage divider. For this type of sensors use formula:

(*) x = scale * (ADC + offset)

where:
x – it is a result shown on OSD screen
scale – it is a scaling factor to convert measured input voltage
offset – compensation for sensor’s zero offset
ADC it is a value measured on A2 input

NOTE1 values shown on OSD screen for USER A2 input are integral numbers without decimal point and fraction.

NOTE2 temperature sensor sold by Pitlab has output connected to USER A1  slot on the connector. To use  it with USER A2 input you need to change output wire from A1 to A2 slot on the connector. 

To calculate proper values for offset and scale you need to follow these steps:

  1. connect sensor to OSD input,
  2. Connect OSD to  USB port
  3. Run FPV_manager
  4. Open page OSD->Layout
  5. Read layout from OSD
  6. Enable field USER A2
  7. Write layout back to OSD
  8. Open page OSD->settings
  9. in USER A2 frame  set scale = 1 and offset = 0 then press button [save]
  10. Apply first known measured value  to the sensor (e.g. low temperature – Low_in ) and  write down value shown on OSD screen for USER A2 field (Low_osd)
  11. Apply second known measured value to the sensor (e.g. high temperature – Hi_in) and write down value shown on OSD screen (Hi_osd)
  12. Calculate scale using this formula:
    scale =   (Hi_in – Lo-in)  / (Hi_osd – Lo_osd)
    offset =  (Lo_in / scale) – Lo_osd
  13. Set  calculated values into scale and offset fields, set units for measured value and then press button [save].

Example:

Applied low temperature (Low_in):  4 degrees
Value shown on OSD (Low_Osd):  3450
Applied high temperature (Hi_in): 93 degrees
Value shown on OSD (Hi_OSD):  4095

Values to be applied in FPV_manager configuration fields:
scale = (93 – 4) / (4095 – 3450) = 0.138
offset =  (4 /0.138)-3450 = -3421

Non-linear sensors

Sensor with non-linear  characteristics (like airspeed pressure sensors) has output voltage proportional to 2-nd power of measured value. This output voltage should be in range between 0V and 3.3V. if sensor’s output exceeds 3.3V it should be connected using voltage divider. For this type of sensors use formula with square roots:

(*) x = scale * sqrt(ADC – offset)

where:
x – it is result shown on OSD screen
scale – it is a scaling factor to convert measured input voltage
offset – it is sensor zero offset
ADC it is a value measured on A2 input

To calculate proper values for offset and scale you need to follow these steps:

(TODO: steps and formula calculation)

Sensors with PWM

(pulse width modulation)

(TODO: whole description )