NT Command
The NT command (Numeric counTer) allows managing 32 arithmetic counters (accumulators) that can be incremented, decremented and generate triggers when reaching limits.
What is it used for?
- 🔢 Count events (input activations, reports sent, etc.)
- 🎯 Trigger actions when reaching a specific value
- 📊 Accumulate values for statistics
- ⚡ Create conditional logic based on counts
Counter Types
| Index | Type | Persistence |
|---|---|---|
00-15 | Volatile | Lost on restart |
16-31 | Non-volatile | Maintained after reset |
Use counters 16-31 for values that must persist (e.g.: maintenance count).
Syntax
Available operations
| Operation | Command | Description |
|---|---|---|
| Configure | SNTaabbbbb | Defines the counter maximum |
| Query | QNTaa | Reads the current value |
| Increment | SNTaa+n | Adds n to the counter |
| Decrement | SNTaa-n | Subtracts n from the counter |
| Reset | SNTaaR | Sets the counter to 0 |
| Maximize | SNTaaS | Sets the counter to maximum |
Response
RNTaabbbbbcccccParameters
| Parameter | Description | Range |
|---|---|---|
aa | Counter index | 00-31 |
bbbbb | Configured maximum value | 00000-65535 |
ccccc | Current counter value | 00000-65535 |
n | Value to increment/decrement | 1-65535 |
NT Signal (Trigger)
The counter generates a trigger on the NT signal when:
| Condition | Trigger | Behavior |
|---|---|---|
| Increment exceeds maximum | NT+ | The counter wraps around |
| Decrement goes below zero | NT- | The counter wraps from maximum |
Mathematical formulas:
- Increment:
(value + increment) Mod (maximum + 1) - Decrement:
((value - decrement) Mod (maximum + 1)) + (maximum + 1)
Examples
Basic configuration
>SNT0200299< // Configure counter 02 with maximum 299
>SNT02+30< // Increment 30 → value = 30
>SNT02-15< // Decrement 15 → value = 15
>QNT02< // Query: RNT020029900015Count input activations
// Configure counter 05 with maximum 100
>SNT0500100<
// Increment each time IN00 is activated
>SRL00E;TRG=IN00+;ACC={SNT05+1}<
// Trigger alert when reaching 100
>SRL01E;TRG=NT05+;ACC={GCP00H}<Trip counter (non-volatile)
// Use counter 20 (persistent) to count trips
>SNT2099999<
// Increment when ignition turns on
>SRL10E;TRG=IN07+;ACC={SNT20+1}<Complete Demo
>SNT0300299< // Configure counter 03, maximum 299
// RNT030029900000
>SRL00E;TRG=NT03+;ACC={STX TRIGGER}< // Rule: show when it triggers
// RRL00E;TRG=NT03+;ACC={STX TRIGGER}
>QNT03< // Query: value = 0
// RNT030029900000
>SNT03+1< // Increment → value = 1
// RNT030029900001
>SNT03+100< // Increment → value = 101
// RNT030029900101
>SNT03+200< // Exceeds 299 → triggers NT03+
// RNT030029900001 // Value = (101+200) mod 300 = 1
// RTX TRIGGER // Trigger executed!
>SNT03-7< // Decrement → goes below 0 → triggers
// RNT030029900294 // Value = 294
// RTX TRIGGER // Trigger executed!
>SNT03S< // Set to maximum
// RNT030029900299 // Value = 299
>SNT03R< // Reset to zero
// RNT030029900000 // Value = 0Compatibility
💾Firmware:v1.00.00
SP-IOT
SM-IOT
Last updated