Comparator / 2 Points Regulator
The Comparator / 2 Points Regulator node compares two numeric input values and generates a logic output according to two configurable thresholds.
The node calculates the difference between Input 1 and Input 2:
$$Difference = Input\ 1 - Input\ 2$$
The output is then determined as follows:
- if the difference is greater than Threshold for ON, the node sends 1 to Output;
- if the difference is lower than Threshold for OFF, the node sends 0 to Output;
- if the difference is between the two thresholds, Output maintains its previous state.
The interval between the ON and OFF thresholds creates a hysteresis area that prevents frequent switching when the input values fluctuate around the regulation point.
This node can be used, for example, for:
- two-point temperature regulation;
- switching a device according to the difference between a setpoint and a measured value;
- maintaining a stable output when the input value fluctuates;
- controlling heating, cooling, ventilation, or other ON/OFF devices.
Connectors
| Connector | Direction | Data type | Description |
|---|---|---|---|
| Input 1 | Input | Number | First value used to calculate the difference. |
| Input 2 | Input | Number | Second value used to calculate the difference. |
| Output | Output | 1 bit | Logic result of the comparison between the calculated difference and the configured thresholds. |
Main properties
| Property | Description |
|---|---|
| Threshold for ON | Threshold above which Output is set to 1. |
| Threshold for OFF | Threshold below which Output is set to 0. |
| Gate | When enabled, adds the Gate connector, which can be used to enable or disable node processing. |
| Await all inputs | When set to True, the node waits until all connected inputs have received at least one value before performing the comparison. |
To create a valid hysteresis interval, Threshold for OFF must be lower than Threshold for ON.
For the general operation of the Gate connector, refer to Gate connector.
Operation
The node first calculates the difference between the two input values:
$$Difference = Input\ 1 - Input\ 2$$
It then compares the result with the configured thresholds.
Difference above the ON threshold
When:
$$Difference > Threshold\ for\ ON$$
the node sends 1 to Output.
Difference below the OFF threshold
When:
$$Difference < Threshold\ for\ OFF$$
the node sends 0 to Output.
Difference within the hysteresis interval
When:
$$Threshold\ for\ OFF \leq Difference \leq Threshold\ for\ ON$$
the node does not change the output. Output maintains its previous value.
Behavior of the Comparator / 2 Points Regulator node
Comparison summary
| Calculated difference | Output behavior |
|---|---|
| Difference > Threshold for ON | Output is set to 1. |
| Difference < Threshold for OFF | Output is set to 0. |
| Threshold for OFF ≤ Difference ≤ Threshold for ON | Output maintains its previous state. |
Example
Assume the following thresholds are configured:
- Threshold for ON = 1;
- Threshold for OFF = -1.
The node operates as follows:
| Input 1 | Input 2 | Difference | Result |
|---|---|---|---|
| 22 | 20 | 2 | The difference is greater than 1, therefore Output is set to 1. |
| 20.5 | 20 | 0.5 | The difference is between -1 and 1, therefore Output maintains its previous state. |
| 19 | 20 | -1 | The difference is equal to the OFF threshold, therefore Output maintains its previous state. |
| 18 | 20 | -2 | The difference is lower than -1, therefore Output is set to 0. |
The comparison uses the conditions greater than and lower than. When the difference is exactly equal to one of the thresholds, it remains within the hysteresis interval and the previous output state is maintained.
Temperature regulation example
The node can be used as a two-point regulator by connecting:
- the temperature setpoint to Input 1;
- the measured room temperature to Input 2;
- the heating command to Output.
Assume:
- setpoint: 21 °C;
- Threshold for ON: 0.5;
- Threshold for OFF: -0.5.
The difference is calculated as:
$$Difference = Setpoint - Measured\ temperature$$
The resulting behavior is:
| Measured temperature | Difference | Output behavior |
|---|---|---|
| 20 °C | 1 | The difference is greater than 0.5, therefore heating is activated. |
| 20.8 °C | 0.2 | The difference is within the hysteresis interval, therefore the previous output state is maintained. |
| 21.2 °C | -0.2 | The difference is within the hysteresis interval, therefore the previous output state is maintained. |
| 22 °C | -1 | The difference is lower than -0.5, therefore heating is deactivated. |
The hysteresis interval prevents the heating output from switching continuously when the measured temperature fluctuates close to the setpoint.
Verification through simulation
To verify the node using Offline Simulation:
- Connect two input nodes to Input 1 and Input 2.
- Configure Threshold for ON and Threshold for OFF.
- Connect Output to a node that allows the resulting value to be monitored.
- Enable Await all inputs if the comparison must start only after both inputs have been initialized.
- Start Offline Simulation.
- Set the inputs so that the calculated difference is greater than Threshold for ON.
- Verify that Output changes to 1.
- Set the inputs so that the difference remains between the two thresholds.
- Verify that Output maintains its previous state.
- Set the inputs so that the difference is lower than Threshold for OFF.
- Verify that Output changes to 0.
During Offline Simulation, input values must be set manually. The simulation does not communicate with the KNX bus or with the real system objects.
Configuration notes
- Both inputs must contain valid numeric values.
- Use Await all inputs when the comparison must not be performed before both inputs have been initialized.
- Configure Threshold for OFF lower than Threshold for ON to obtain a valid hysteresis interval.
- A wider interval reduces the frequency of output switching.
- A narrower interval provides more precise regulation but may cause more frequent switching when the input values fluctuate.
- Verify the order of Input 1 and Input 2, because reversing them also reverses the sign of the calculated difference.
- If the Gate connector is used, make sure that it receives a valid value; otherwise, the node may remain disabled.
