RBC Input » History » Revision 2
Revision 1 (Adam Klama, 06/21/2026 02:34 PM) → Revision 2/3 (Adam Klama, 06/21/2026 02:34 PM)
# RBC Input
## Overview
An **RBC Input** decodes a **Reflected Binary Code** — better known as
[**Gray code**](https://en.wikipedia.org/wiki/Gray_code) — from a set of single-bit
inputs into an ordinary integer.
Gray code is an encoding where consecutive values differ by only **one** bit. It is
common on absolute rotary/position encoders and gear-position selectors because
only one line changes at a time, so the reading never glitches through a wrong
value while the switch moves between positions.
Each listed input supplies one bit of the Gray code; the input converts the whole
set to a plain binary number you can act on.
## Prerequisites
- The **source inputs** that supply the bits — usually
[Digital Inputs](Digital-Input.md), one per encoder/switch line. Create them
first.
- Each source is read as a bit: a non-zero value is `1`, zero is `0`.
- Know the **order** of the lines from most- to least-significant bit.
## Add it in the app
1. Add a new input and choose **RBC Input** as the type.
2. Give it a clear **alias** (e.g. `Gear Position`).
3. Add the **bit inputs** in order, most-significant bit first.
4. Check the decoded number against each physical switch position.
## Settings reference
> Schema: `config/RbcInputConfigData.proto`.
| Setting | Meaning | Unit | Range / values | Notes |
|---|---|---|---|---|
| **Bit inputs** | Ordered list of single-bit inputs forming the Gray code | — | list of input ids (uint32) | Each input is one bit. The **list order** sets bit significance; the input converts the Gray code to a binary value. |
**Gray → binary:** the most-significant bit is taken as-is; each lower binary bit
is the running XOR of the higher binary bit with the next Gray bit. The result is
the ordinary integer (e.g. an 8-position encoder decodes to `0`–`7`). If the value
counts the wrong way for your wiring, reverse the order the inputs are listed in.
## Common settings
RBC Input also uses the shared setting — alias. See
[Common IO Settings](../Common-IO-Settings.md).
## Example — 3-line Gray-coded gear selector
A selector exposes three Gray-coded digital lines, `G2`, `G1`, `G0`.
1. Type **RBC Input**, alias `Gear Position`.
2. Add the **bit inputs** in order `G2` (MSB), `G1`, `G0` (LSB).
3. The input converts the Gray code to a binary value `0`–`7`, one per position,
with only one line changing between adjacent gears.
## Troubleshooting
- **Decoded number counts the wrong way:** the bit order is reversed for your
wiring — change the order the inputs are listed in.
- **One position is always wrong / stuck:** check that line's source input on its
own; a stuck bit usually means a wiring or threshold problem at the source.
- **Values jump by more than one between positions:** the lines are not actually
Gray-coded (or one is mis-ordered) — verify the encoder's coding.
- **Unexpected code values:** confirm every intended line is in the list and none
is listed twice.
## Related
- [Digital Input](Digital-Input.md) — the per-line bit sources.
- [Mux Input](Mux-Input.md) — select one of several inputs by an index.
- [Analog Switch Input](Analog-Switch-Input.md) — decode a multi-position switch on
a single analog pin.