CXAIN Command - Analog Input Configuration
Configures the interpretation of magnitudes read by the device’s AD inputs, allowing transformation and scaling of values according to the application.
What is it for?
| Use case | Description |
|---|---|
| 📊 Fuel sensors | Convert voltage to liters or percentage |
| 🌡️ Temperature sensors | Transform analog signal to °C |
| ⚡ Voltage measurement | Scale voltage readings |
| 📈 Custom calibration | Adjust readings to specific units |
Related Commands
- It is recommended to recalibrate the analog reading constant through the AR Command
- The AD value reading for each input can be obtained through the AIN Command
- To query all readings obtained from all AD inputs of the device or generate a report with these values, use the AD Report
Commands
Configure
SCXAINaabccccdeeeefgggghiiiijkkkklmmmmQuery
QCXAINaaResponse
RCXAINaabccccdeeeefgggghiiiijkkkklmmmmParameters
| Field | Description | Range |
|---|---|---|
| aa | Analog input index | 00, 01, 02, 07 |
| b | Sign of lower output limit (BOTTOM) | + / - |
| cccc | Magnitude of lower output limit (BOTTOM) | 0000–9999 |
| d | Sign of upper output limit (TOP) | + / - |
| eeee | Magnitude of upper output limit (TOP) | 0000–9999 |
| f | Sign of first calibration point voltage (XA) | + / - |
| gggg | First calibration voltage XA in hundredths of a volt (0500 = 5.00 V) | 0000–9999 |
| h | Sign of second calibration point voltage (XB) | + / - |
| iiii | Second calibration voltage XB in hundredths of a volt (0500 = 5.00 V) | 0000–9999 |
| j | Sign of output value at the first point (YA) | + / - |
| kkkk | Output value corresponding to XA (YA) — free unit | 0000–9999 |
| l | Sign of output value at the second point (YB) | + / - |
| mmmm | Output value corresponding to XB (YB) — free unit | 0000–9999 |
How the reported value is computed
The device performs a linear interpolation between the two points (XA, YA) and (XB, YB) over the measured voltage, then clamps the output to the [BOTTOM, TOP] range:
Y = YA + (Vin − XA) · (YB − YA) / (XB − XA)
output = clamp(Y, BOTTOM, TOP)Vinis expressed in hundredths of a volt (same as XA and XB).YA,YB,BOTTOMandTOPare in the output unit of your choice (liters, %, °C, mV, etc.).- The clamp ensures that voltages outside the calibrated range never produce nonsense values.
XA and XB are hundredths of a volt, not tenths. For example:
0500= 5.00 V1230= 12.30 V3300= 33.00 V
Mixing up the scale (writing 0050 thinking “5 V”) is the most common mistake when configuring this command.
Examples
Resistive fuel sensor 0–5 V → 0–100 %
Linear sensor whose output ranges from 0 V (empty tank) to 5 V (full tank).
>SCXAIN01+0000+0100+0000+0500+0000+0100<
// aa = 01 → input AD1
// BOT = +0000 → lower output clamp = 0 %
// TOP = +0100 → upper output clamp = 100 %
// XA = +0000 → 0.00 V (empty tank)
// XB = +0500 → 5.00 V (full tank)
// YA = +0000 → 0 %
// YB = +0100 → 100 %Capacitive fuel sensor 0–33 V → 0–200 L
Higher-range sensor (common on trucks) that delivers up to 33 V for a 200-liter tank.
>SCXAIN01+0000+0200+0000+3300+0000+0200<
// XA = 0.00 V → 0 L
// XB = 33.00 V → 200 L
// Output clamped to [0, 200] litersTemperature sensor 0–5 V → −40 °C to +150 °C
Output with negative offset: at 0 V the sensor reports −40 °C; at 5 V it reports +150 °C.
>SCXAIN01-0040+0150+0000+0500-0040+0150<
// BOT = -0040 → minimum reported = −40 °C
// TOP = +0150 → maximum reported = +150 °C
// XA = +0000 → 0.00 V → YA = -0040 (−40 °C)
// XB = +0500 → 5.00 V → YB = +0150 (+150 °C)Direct battery reading 0–36 V
Identity mapping in hundredths of a volt: the output equals the voltage (1245 → 12.45 V).
>SCXAIN01+0000+3600+0000+3600+0000+3600<
// XA = 0.00 V → YA = 0
// XB = 36.00 V → YB = 3600
// Output clamped to [0, 3600] (hundredths of a volt)Passthrough — no transformation (raw ADC value)
Useful when you want to obtain the raw ADC reading with no scaling. This is the factory default.
>SCXAIN01-9999+9999-0000+0001-0000+0001<
// Unit slope with clamp at [-9999, +9999]
// Equivalent to applying no conversionTo query the current configuration of any input, use QCXAINaa. The device responds with an RCXAIN that has the exact same format as the SCXAIN previously sent:
>QCXAIN01<
>RCXAIN01+0000+0100+0000+0500+0000+0100<Compatibility
See Also
- AIN Command - Query analog inputs
- AR Command - Analog ranges
- AD Report - Analog values report