Analog Switch Input » History » Version 1
Adam Klama, 06/21/2026 02:11 PM
| 1 | 1 | Adam Klama | # Analog Switch Input |
|---|---|---|---|
| 2 | |||
| 3 | ## Overview |
||
| 4 | An **Analog Switch Input** reads a **multi-position switch** on a single analog |
||
| 5 | pin. Instead of one wire per position, the switch presents a different **voltage** |
||
| 6 | (or **resistance**) for each position, and this input decodes which position is |
||
| 7 | selected. Use it for rotary mode switches, multi-button steering controls and |
||
| 8 | resistor-ladder keypads. |
||
| 9 | |||
| 10 | ## Prerequisites & hardware |
||
| 11 | - A switch wired to one analog pin that produces a distinct level per position. |
||
| 12 | - Know each position's nominal value so you can set the recognition tolerance. |
||
| 13 | - **External divider:** the input does **not** provide an internal pull-up. In |
||
| 14 | **Resistors** mode you fit an **external pull-up** resistor (and optionally a |
||
| 15 | pull-down) to turn the switch's resistance into a voltage, and enter those |
||
| 16 | resistor values so the controller can work out the switch resistance. In |
||
| 17 | **Voltage** mode the switch presents the voltages directly and no divider is |
||
| 18 | needed. |
||
| 19 | |||
| 20 | ## Add it in the app |
||
| 21 | 1. Add a new input and choose **Analog Switch Input** as the type. |
||
| 22 | 2. Select the **pin** the switch is wired to. |
||
| 23 | 3. Give it a clear **alias** (e.g. `Mode Switch`). |
||
| 24 | 4. Choose the **mode** and **range**. The two modes are mutually exclusive — pick |
||
| 25 | whichever suits your hardware: |
||
| 26 | - **Resistors:** enter the external **pull-up** (and **pull-down**) resistor |
||
| 27 | values that form the divider. |
||
| 28 | - **Voltage:** enter the **voltage range** (min/max voltage) the position sits |
||
| 29 | in. |
||
| 30 | 5. Set the **precision** and, for mechanical switches, the debounce timings. |
||
| 31 | |||
| 32 | ## Settings reference |
||
| 33 | > Schema: `config/AdcSwitchConfiguration.proto`. |
||
| 34 | |||
| 35 | | Setting | Meaning | Unit | Range / values | Notes | |
||
| 36 | |---|---|---|---|---| |
||
| 37 | | **Range** | Input voltage range / scaling reference | — | `5 V`, `Internal 5 V`, `12 V`, `Raw` | Choose to cover the switch's full-scale voltage. `Raw` reports unscaled counts. | |
||
| 38 | | **Mode** | How the position is defined — the two are mutually exclusive | — | `Resistors`, `Voltage` | `Resistors` = an external pull-up/pull-down divider turns the switch resistance into a voltage; `Voltage` = the position is recognised by its voltage range. Configure only the fields for the mode you choose. | |
||
| 39 | | **Pull-up** | Value of the **external** pull-up resistor forming the divider | Ω | uint32 | **Resistors mode only.** Tells the controller the divider's upper leg so it can compute the switch resistance. | |
||
| 40 | | **Pull-down** | Value of the external pull-down resistor | Ω | uint32 | **Resistors mode only.** The lower leg of the divider (optional). | |
||
| 41 | | **Min voltage / Max voltage** | Voltage range for the position | mV | uint32 | **Voltage mode only.** The window the position's voltage falls in. | |
||
| 42 | | **Precision** | Matching tolerance for recognising the position | — | uint32 | How close a reading must be to count as this position. Too loose = wrong position; too tight = missed positions. | |
||
| 43 | | **Enable filter** | Turns on debounce filtering | — | on / off | Recommended for mechanical switches. | |
||
| 44 | | **Delay** | Debounce delay before a change is accepted | ms | sint32 | New position must be stable this long. | |
||
| 45 | | **Hold** | Minimum time a position is held | ms | sint32 | Stops rapid re-triggering. | |
||
| 46 | | **Interspace** | Minimum gap between transitions | ms | sint32 | Ignores transitions closer than this. | |
||
| 47 | |||
| 48 | ## Common settings |
||
| 49 | Analog Switch Input also uses the shared settings — alias and pin. |
||
| 50 | See [Common IO Settings](../Common-IO-Settings.md). |
||
| 51 | |||
| 52 | ## Example — detect one switch position (Voltage mode) |
||
| 53 | Each Analog Switch Input recognises **one** position/level. This example detects a |
||
| 54 | single rotary position that sits at ~2.5 V: |
||
| 55 | 1. Type **Analog Switch Input**, alias `Mode Pos 2`, on the switch's pin. |
||
| 56 | 2. Mode `Voltage`, **Range** `5 V`. |
||
| 57 | 3. **Min/Max voltage** `2300`/`2700` mV — the window around that position. |
||
| 58 | 4. **Precision** moderate so the detent maps cleanly to this position. |
||
| 59 | 5. **Enable filter**, **Delay** `20`, **Hold** `30` to settle between detents. |
||
| 60 | |||
| 61 | > To decode every position of a multi-position rotary as its own signal, add one |
||
| 62 | > Analog Switch Input per position — e.g. a 5-position rotary uses 5 inputs, each |
||
| 63 | > watching its own voltage range. That is a valid setup but not the typical use; |
||
| 64 | > most installs detect a single switch level. |
||
| 65 | |||
| 66 | ## Troubleshooting |
||
| 67 | - **Wrong position selected / jumps between two:** the levels are too close for the |
||
| 68 | **precision** — tighten precision or space the positions further apart. |
||
| 69 | - **No position recognised:** in Voltage mode the reading is outside **Min/Max |
||
| 70 | voltage**; in Resistors mode the entered **pull-up/pull-down** values don't match |
||
| 71 | the resistors actually fitted. |
||
| 72 | - **Position flickers when turning:** enable the filter and raise **Delay** / |
||
| 73 | **Interspace**. |
||
| 74 | - **Voltage doesn't change with the switch (Resistors mode):** check the **external |
||
| 75 | pull-up** is fitted — without it the divider produces no voltage. |
||
| 76 | |||
| 77 | ## Related |
||
| 78 | - [Analog Input](Analog-Input.md) — single analog voltage rather than a switch. |
||
| 79 | - [Digital Input](Digital-Input.md) — single on/off contact. |
||
| 80 | - [Mux Input](Mux-Input.md) — select between several inputs by a selector. |