Operators and Math
Logic gates handle the 0/1 decisions; what handles values is the operator group — gain, offset, mixing, comparison, range conversion, low-pass filtering and the few sundries that don't fit anywhere else. They're the small black boxes that turn raw sensor readings into the kind of clean number a downstream module can act on.
The group splits cleanly along data type. Integer operators (u8 / s16 / u16 / u32) stay in the integer domain and run a hair faster; the Float variants do their arithmetic in f32 and accept floating-point inputs. Pick the one that matches the rest of your signal chain — the IDE shows port colours so you can see at a glance whether two ports speak the same type.
Arithmetic basics
These four cover most of what you'll need:
| Module | What it does |
|---|---|
| OpGain / FloatGain | Multiplies the input by a constant gain factor. |
| OpOffset / FloatOffset | Adds a constant offset to the input. |
| OpMixer / FloatMixer | Sums several inputs (each with its own gain), one output. |
| FloatSum | Trivial multi-input sum (no per-input gain). |
Mixer is the workhorse for sensor fusion, audio-style cross-fading, simple PID summing, and any "a · x + b · y + c · z" combination — its inputs parameter increases with right-click → Add Input, like the logic gates.
The Examples/05-Control/P_Controller project demonstrates a proportional controller built from a Gain and a Mixer.
Range mapping
Real signals rarely come in the units a downstream module expects. ADCs give you 0..65535; the dashboard wants 0..100; a PWM wants 0..255. The Range family converts between them:
| Module | What it does |
|---|---|
| Range | Linear remap from one numeric range to another (e.g. ADC 0..65535 → percentage 0..100). |
| RangeModule | Same idea, but with the input range learned by calibration (drive it through its extremes once, save). |
| RangeDeadZone | Range remap with configurable dead zones at the low and high ends of travel — designed for pedals so the mechanical hard-stops reliably read 0 % and 100 %. |
| FloatRange | The floating-point variant — handy when you're converting to a physical unit (e.g. ADC code → volts). |
Range parameters are uniform:
| Parameter | Description |
|---|---|
| Min in / Max in | The input range. |
| Min out / Max out | The output range it maps to. |
| Clamp | Whether to clip outputs that fall outside Min out / Max out, or extrapolate. |
RangeModule's Calibration input is what makes it special: pulse the calibration input to enter learning mode, sweep the source through its physical extremes, pulse it again to leave. The min/max it learned are persisted to EEPROM and applied on the next boot. This is exactly how the IDE's game-controller axis calibration works.
Smoothing — FloatIIRFilter
Noisy sensors (loadcells, magnetometers, anything analog at a high gain) need smoothing before you act on them. FloatIIRFilter is a first-order infinite-impulse-response low-pass — one tuning knob (the time constant or alpha) and a value going in, a smoothed value coming out.
The trade-off is the classic one: a longer time constant smooths more but adds more lag. Start with something like 100 ms for a sensor you'll display, 10 ms for something in a real-time control loop, and tune from there.
Comparator
Sometimes you need a Boolean answer from a value: "is this above a threshold?", "is this between these two bounds?". The Comparator does that.
| Comparison mode | Output is 1 when… |
|---|---|
> / < | Input is above / below a configured threshold. |
>= / <= | Same, inclusive. |
== / != | Input equals / differs from a target value. |
| In range | Input is between two bounds. |
| Out of range | Input is outside two bounds. |
A Comparator feeding an Edge gives you the moment a threshold is crossed — typical for tripping a relay, sending an alert, or stepping a counter.
Counter
The Counter module counts events on its input. Each rising edge of the input increments the internal counter; reaching the configured maximum optionally wraps around or triggers an output pulse.
| Parameter | Description |
|---|---|
| Max | The value at which the counter wraps (or stops, depending on mode). |
| Reset on overflow | Whether to wrap to 0 or stop. |
Pair it with an Edge when the input is a level (a button), so you count presses rather than the entire time the button is held. The Examples/01-Basics/Counter design is the minimal demo.
TypeCast
When two modules speak different numeric types, TypeCast is the explicit converter. Most of the time NodeBlue's wire-colour matching makes the conversion automatic; reach for TypeCast when you want to control rounding, signedness or saturation explicitly (e.g. an f32 from a filter to a u16 for a PWM register).
Constant and Sync
Two tiny utilities that round out the group:
- Constant — emits a fixed numeric value, configured in its parameters. Handy as the "b" in
a + b(paired with a Mixer or Offset) when the value is hand-tuned rather than read from somewhere. - Sync — the named sync source covered in Timers / Sync signals. Driven by a timer once, referenced by name from many consumers.
Once a value is shaped the way you want it, the next thing you'll often do is turn it into something humans can read — see Strings and Text.