Example: Thermocouple Monitoring#
Read a thermocouple channel, inspect its status bit, and raise a fault flag when the sensor fails.
The SLM-THM-4 differs from other analog modules in two ways: readings are already linearised and reported as floating-point temperatures in the configured unit, and the module exposes a burnout status bit per channel that indicates an open-circuit condition independently of the reading itself.
Hardware#
Slot |
Module |
|---|---|
1 |
SLM-THM-4 (4-channel thermocouple input) |
Wire a Type K thermocouple on channel 1.
Backplane configuration#
Open Device → Backplane Configuration, select slot 1, and set:
Field |
Set to |
|---|---|
Channels Enabled |
CH1 - CH4 |
Burnout Detection / Units |
High burnout, degrees C |
CH1 Type |
Type K |
CH2 - CH4 Type |
as fitted |
Each channel’s sensor type is set independently.
Thermocouple channels are always reported as REAL on %ID:
Slot |
Channel |
Address |
Alias |
|---|---|---|---|
1 |
TC1 |
|
|
1 |
TC1 Burnout |
|
|
1 |
TC2 |
|
|
1 |
TC2 Burnout |
|
|
1 |
TC3 |
|
|
1 |
TC3 Burnout |
|
|
1 |
TC4 |
|
|
1 |
TC4 Burnout |
|
|
The program#
Variables#
Name |
Class |
Type |
Location |
Initial Value |
Documentation |
|---|---|---|---|---|---|
|
Local |
|
|
Channel 1 temperature |
|
|
Local |
|
|
Channel 1 burnout status bit |
|
|
Local |
|
TRUE while the reading is trusted |
||
|
Local |
|
Most recent trusted reading |
VAR
furnace_temp : REAL AT Furnace_Temp; (* Channel 1 temperature *)
tc1_burnout : BOOL AT TC1_Burnout; (* Channel 1 burnout status bit *)
sensor_valid : BOOL; (* TRUE while the reading is trusted *)
last_valid_temp : REAL; (* Most recent trusted reading *)
END_VAR
Code body#
sensor_valid := NOT tc1_burnout;
IF sensor_valid THEN
last_valid_temp := furnace_temp;
END_IF;
The burnout bit is read directly from the module; it is not inferred from the reading value. On a burnout condition, the program freezes last_valid_temp and the rest of the logic can test sensor_valid to decide how to respond.
Burnout status bit#
The Burnout Detection setting determines what the reading does when the thermocouple circuit opens:
High burnout drives the reading to the top of the range. This is the safer choice for heating: a broken sensor reads as over-temperature, so control logic that acts on the reading turns the heat off.
Low burnout drives the reading to the bottom of the range. In a heating application this is dangerous: a broken sensor reads as a cold process, the control logic calls for more heat, and the temperature can run away.
In general, choose the direction that drives your control logic toward its safe state when the sensor fails. This example monitors a furnace, so it uses High burnout.
The burnout status bit is set in either case. Do not rely on the burnout direction alone: read the bit and act on it, as the program above does. The bit is more reliable than inferring a fault from the value, because it is set directly by the module’s open-circuit detection circuit.