Replies: 3 comments 1 reply
-
|
Beta Was this translation helpful? Give feedback.
-
Sorry I was not clear enough: my question was about NV14 switches; I understand the reasons behind the 6POS calibration. |
Beta Was this translation helpful? Give feedback.
-
On NV14, all switches are connected to analog inputs. I assume, this design decision was made to be able to have more than 2-pos switch with only a single pin on the STM32F4 microcontroller. The code presently uses rigid thresholds for detecting the switch positions on NV14: edgetx/radio/src/targets/nv14/keys_driver.cpp Lines 128 to 141 in dcbdde2 The raw 12-bit ADC value range goes from 0 to 4095. A measurement with a value less than 1024 is output as position 0, measurements between 1024 and 3072 are output as position 1 and measurements above 3072 as position 2. The analog switches, although not included in, nor strictly necessary for calibration, are wrongly listed under edgetx/radio/src/targets/nv14/board.h Lines 317 to 333 in 8150b00 The Line 38 in dcbdde2 |
Beta Was this translation helpful? Give feedback.
-
Presently, e.g. 6 position on a number of radios (TX16S, T16, T18), some 2 and 3 position switches (e.g. NV14, PL18, PL18EV) or button arrays (e.g PL18EV stick end buttons), are being included in CalibratedAnalogs and handled as proportional analog channels.
E.g. see:
edgetx/radio/src/targets/horus/board.h
Line 448 in 8150b00
edgetx/radio/src/targets/nv14/board.h
Lines 324 to 331 in 8150b00
edgetx/radio/src/targets/pl18/board.h
Lines 335 to 340 in a704b57
All these analog switch options have predetermined output values, with some manufacturing tolerance, and in my opinion can be skipped from calibration. Whereas on 2 and 3 position switches, the output is either near 0V, near VREF, or near ratiometric middle (3-pos), the division is not so equidistant for the 6-pos. on TX16S, T16, T18 and the 4-pos. PL18EV stick end buttons (4 positions, as the analog output on PL18EV stick end buttons has 4 levels: no button pressed, 1st button pressed, 2nd button pressed, both buttons pressed simultaneously). Nevertheless, also for these two latter special cases (6 and 4 pos.), the values provided from the radios are known, and with the help of a community, the manufacturing deviations can be estimated.
The suggestion is to drop the calibration requirement for analog switches and going with pre-programmed thresholds for the detection (for more fancy cases, like the 6-pos and the 4-pos, the thresholds likely need to be hard-coded to be specific to the radio target).
Here, a community feedback (e.g. with the help of PR #1421) could be useful to figure the ideal borders.
Consider following fictive 4-position analog switch that from a range of tested radios would give a following normalized distribution for the 4 switches across a 12-bit ADC range:
The means of switch positions in 12-bit raw values are:
switch 1 = 50
switch 2 = 1500
switch 3 = 2200
switch 4 = 3400
In this fictive Gaussian distribution example, no overlap happens and perfect thresholding is possible.
The detection borders could in this fictive case be:
A = 775 (= (1500 - 50)/2 + 50 )
B = 1850
C = 2800
Output in blue zone would be detected as switch 1, orange as switch 2, gray as sw3 and yellow as sw 4.
In order to facilitate outliers and possible own hardware modifications that might deviate from the standard separation values, the idea would be to allow optional calibration values in YAML to be used, e.g. similar to
txVoltageCalibration
to override or offset the hard-coded default values.Interested on your thoughts! Thx!
Beta Was this translation helpful? Give feedback.
All reactions