RBC Input¶
Overview¶
An RBC Input decodes a Reflected Binary Code — better known as
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, one per encoder/switch line. Create them
first. - Each source is read as a bit: a non-zero value is
1, zero is0. - Know the order of the lines from most- to least-significant bit.
Add it in the app¶
- Add a new input and choose RBC Input as the type.
- Give it a clear alias (e.g.
Gear Position). - Add the bit inputs in order, most-significant bit first.
- Check the decoded number against each physical switch position.
Settings reference¶
| 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.
Example — 3-line Gray-coded gear selector¶
A selector exposes three Gray-coded digital lines, G2, G1, G0.
- Type RBC Input, alias
Gear Position. - Add the bit inputs in order
G2(MSB),G1,G0(LSB). - 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 — the per-line bit sources.
- Mux Input — select one of several inputs by an index.
-
Analog Switch Input — decode a multi-position switch on
a single analog pin.
Updated by Adam Klama 1 day ago · 3 revisions