How-to
EL3314 status word error handling in TwinCAT PLCs
Short answer
Declare the EL3314's four channels as one array of value-and-status structures with AT %I*, link each element through an index-to-member assignment in the TcLinkTo attribute, and decode the status WORD with three AND masks: 16#0001 underrange, 16#0002 overrange, 16#0040 error. Dividing the raw integer by 10.0 gives degrees Celsius at 0.1 °C resolution; one function block instance per channel packages scale and decode so four indexed calls replace copy-pasted rungs.
On this page
- How do you declare variables for four EL3314 channels in TwinCAT?
- How do you link EL3314 value and status channels without manual linking?
- Which EL3314 status bits report underrange, overrange and error?
- How do you convert the EL3314 raw value to degrees Celsius?
- How do you build one function block that handles all four EL3314 channels?
- How do you prove every EL3314 link before the kiln runs?
- Questions asked
Each EL3314 channel hands the PLC two process-data objects: a 16-bit INT value and a 16-bit WORD status, and every fault signal you need lives in that status word. Declare the four channels as one array of value-and-status structures with AT %I*, bind each element to its terminal channel through the TcLinkTo attribute's index-to-member pattern, decode the word with three AND masks — 16#0001 underrange, 16#0002 overrange, 16#0040 general error — and scale in REAL by dividing the raw integer by 10.0. Package scale and decode in one function block, instantiate it once per channel, and four indexed calls replace the copy-pasted per-sensor rungs.
How do you declare variables for four EL3314 channels in TwinCAT? #
Declare one structure per channel and put the four structures in a single array: the structure carries the INT value and the WORD status that the terminal publishes for that channel, and the array declaration with AT %I* places all eight objects in the PLC input process image.
The EL3314 publishes a 16-bit value and a 16-bit status word per channel in its process data, so the structure mirrors exactly that pair and one element equals one channel:
TYPE ST_TcChannel :
STRUCT
Value : INT; // raw counts, one EL3314 channel
Status : WORD; // status word, same channel
END_STRUCT
END_TYPE
// Global variable list IO
TcChannel AT %I* : ARRAY[1..4] OF ST_TcChannel;
AT %I* asks TwinCAT to place the variable in the input process image and choose the addresses itself; it is a placement, not a link, and the binding to a specific EL3314 channel happens in the next step. Keep the raw types matched to the process data — INT for the value, WORD for the status — and keep scaled engineering values out of this layer entirely. The raw integers stay untouched here, which is what makes a later fault investigation possible: the exact counts the terminal sent remain visible whatever the application does with them.
How do you link EL3314 value and status channels without manual linking? #
Use the TcLinkTo attribute with one bracketed assignment per element; the documented pattern is an array index, a member name and the full target path, so four channels become eight explicit lines and the project links itself when you download.
Manual linking is serviceable for one terminal: compile, and the variables appear under the PLC task's Inputs, where each Value and Status object in the EtherCAT tree drops onto its matching element. The attribute above the declaration does the same job in source, which survives a rebuild and a different laptop:
{attribute 'TcLinkTo' :=
'[1].Value := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 1^Value;
[1].Status := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 1^Status;
[2].Value := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 2^Value;
[2].Status := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 2^Status;
[3].Value := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 3^Value;
[3].Status := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 3^Status;
[4].Value := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 4^Value;
[4].Status := TIID^Device 1 (EtherCAT)^Term 1 (EK1100)^Term 4 (EL3314)^TC Inputs Channel 4^Status'}
TcChannel AT %I* : ARRAY[1..4] OF ST_TcChannel;
The device, term and channel names in that block are the example tree's; copy the exact path segments from your configured terminal's process-data tree, because every project names its devices itself. Never infer that adjacent variables map to adjacent channels — monitor the terminal object and its linked element together and confirm both change in the same scan.
TwinCAT can also generate a PLC data type from the slave's selected process data and link that structure as one unit, which removes the manual member-pairing. Treat a process-data change as an interface change: the generated type is rebuilt with a new identity, so regenerate it, repair the links, compile and retest every consumer that used the old type.
Which EL3314 status bits report underrange, overrange and error? #
Three masks cover fault handling: AND the status WORD with 16#0001 for underrange, 16#0002 for overrange and 16#0040 for the general error bit; a nonzero result means that flag is set, and the terminal sets the error bit together with the range flags.
The EL3314 documents each channel's status as a 16-bit word that links into the controller alongside the value, so the decode runs on one WORD per channel, in the PLC, with no extra reads. The bits that decide thermocouple fault handling:
| Mask | Bit | Meaning when set | Action in logic |
|---|---|---|---|
| 16#0001 | 0 | Underrange, signal below the measuring range | Invalidate the reading, raise a sensor alarm |
| 16#0002 | 1 | Overrange, signal above the measuring range | Invalidate the reading, raise a sensor alarm |
| 16#0040 | 6 | General error, set together with overrange or underrange | Treat the channel as faulted; on a thermocouple this is the broken-wire signature, and the terminal's error indication points at the sensor |
Decode by mask, not by equality, because other status bits can be set at the same time. Take channel 2 reporting 16#0041: 16#0041 AND 16#0001 gives 16#0001, so underrange is set; 16#0041 AND 16#0002 gives 16#0000, so overrange is clear; 16#0041 AND 16#0040 gives 16#0040, so the general error bit is set. That combination is the broken-wire case: the open circuit has pushed the input below range, and the number in Value is not a temperature.
One safety note: this decode is monitoring, not a safety function — where a lost thermocouple reading must stop the machine, that stop belongs to the validated safety function designed for it, not to this PLC logic alone.
If the decode is later rewritten as ladder contacts, read why a WORD bit reference fails in ladder and how to copy around it first: direct bit access on a WORD misbehaves in ladder, while the mask-and-compare form in this article does not.
How do you convert the EL3314 raw value to degrees Celsius? #
Divide the raw INT by 10.0: the EL3314 presents temperature at 0.1 °C resolution, so a raw count of 2354 is 235.4 °C — 2354 divided by 10.0 equals 235.4, with the arithmetic done in REAL after the integer conversion.
The delivered configuration gives one count per tenth of a degree, so the whole conversion is one REAL division after the integer conversion, and it lives in exactly one place, the handler:
Temperature := INT_TO_REAL(TcChannel[1].Value) / 10.0;
Treat the factor as configuration rather than scripture: it follows the resolution the terminal presents, so pass it into the handler as a parameter and guard the divisor against zero when it comes from settings. The raw INT stays in the process image untouched and the engineering-unit REAL exists only downstream, so a fault investigation can still read exact counts.
If a control loop runs on the same signal, feed it the scaled value from this step. The reverse direction, loop output back to counts, is the same discipline in reverse and is covered in scaling a PID real output to analog output counts.
How do you build one function block that handles all four EL3314 channels? #
One function block per channel, four instances in an array: the block takes one raw structure and a scale factor, publishes the scaled REAL plus the three fault BOOLs, and four instances replace every copy-pasted rung without sharing state.
FUNCTION_BLOCK FB_TcChannel
VAR_INPUT
Raw : ST_TcChannel; // Value : INT, Status : WORD
ScalingFactor : INT := 10; // counts per degree Celsius
END_VAR
VAR_OUTPUT
Temperature : REAL;
Underrange : BOOL;
Overrange : BOOL;
Error : BOOL;
END_VAR
Underrange := (Raw.Status AND 16#0001) <> 0;
Overrange := (Raw.Status AND 16#0002) <> 0;
Error := (Raw.Status AND 16#0040) <> 0;
IF ScalingFactor > 0 THEN
Temperature := INT_TO_REAL(Raw.Value) / INT_TO_REAL(ScalingFactor);
ELSE
Temperature := INT_TO_REAL(Raw.Value);
Error := TRUE; // configuration fault, not a sensor fault
END_IF
Four indexed instances replace every copy of that logic:
fbTc : ARRAY[1..4] OF FB_TcChannel;
FOR i := 1 TO 4 DO
fbTc[i](Raw := TcChannel[i]);
END_FOR
// application structure for this kiln example
Kiln.EastTC.Temperature := fbTc[1].Temperature;
Kiln.EastTC.Fault := fbTc[1].Error;
Kiln.WestTC.Temperature := fbTc[3].Temperature;
Kiln.WestTC.Fault := fbTc[3].Error;
East on channel 1 and West on channel 3 comes from the wiring and the links, not from the code, so keep that mapping in one place next to the link definitions. No instance shares state with another, which means channel 3's fault can never light channel 1's alarm. The mask-and-compare form says what a TO_BOOL(Status AND Error) attempt says, without a type conversion, and it reads as a mask test to the next engineer. If the calling POU is ladder rather than structured text, the instance call follows the same rules as connecting a TON output to a function block input in TwinCAT ladder.
How do you prove every EL3314 link before the kiln runs? #
Work one channel at a time and prove each layer with a number you chose: a raw value that changes only when you warm that one sensor, a status that responds only to that sensor's faults, and a scaled result equal to the raw count divided by 10.0.
- Compile and open the PLC task's Inputs: TcChannel must appear there with four elements, and each of the eight members must show a link target, because an unlinked member reads zero forever and no alarm ever fires from it.
- Warm one sensor, for example hold channel 1's tip between your fingers, and watch only element [1].Value move while elements [2] to [4] hold still.
- Pull the wire on channel 2's sensor and confirm [2].Status answers 16#0041 in this example, underrange plus general error, while [1], [3] and [4] stay 16#0000.
- Check the scale: with [1].Value at 2354, fbTc[1].Temperature must read 235.4 °C, which is 2354 divided by 10.0.
- Change only channel 3 and confirm only instance 3's outputs move; unchanged outputs on instances 1, 2 and 4 prove that no two channels feed one element.
- Force the alarm path: set a test channel's Error output TRUE and confirm the SCADA side receives it — the reporting pattern is the same as detecting a failed analog input channel and reporting it to SCADA.
The decision per case: Status 16#0000 means the scaled temperature is trustworthy as a control input. Underrange or overrange alone means the number is outside the measuring range, so invalidate it and alarm. The general error bit means the channel is faulted, and on a thermocouple the sensor and its wiring are the first suspects and the terminal the second. In every fault case the scaled number is invalid: put the process into the state the application design defines and let the alarm name the channel and the fault type.
Questions asked
Does AT %I* connect a TwinCAT variable to the EL3314 by itself?
No. AT %I* places the variable in the PLC input process image and lets TwinCAT choose the byte addresses, but the connection to a specific terminal channel still comes from a link you make in the I/O tree or from a TcLinkTo attribute. After compiling, check the variables under the PLC task's Inputs and confirm each member is bound to the Value or Status object you intended. A fixed address would freeze the position and break on reordering; the star form survives it.
How do you add a second EL3314 with four more thermocouples?
Extend the declaration to eight elements and add four more index-to-member assignments to the same TcLinkTo attribute, using the new terminal's own tree path. The declaration sets the array size, the attribute sets the links, and the function block array grows to eight instances inside the same FOR loop. Only the tree segment names differ between terminals, so copy them from the configured hardware, not from another project.
Do underrange and overrange leave a usable temperature in the value?
Treat the number as unusable. When underrange or overrange is flagged, the input has left the thermocouple's measuring range, so the value no longer represents a temperature the control can act on; only a status word of 16#0000 says the reading is in range. Invalidate the scaled output, raise the alarm with the fault type taken from the decoded flags, and keep the raw word available for diagnostics.
How do the four temperatures and fault flags reach an HMI or SCADA tag list?
Expose the outputs symbolically and read them like any PLC tag. An array of four function block instances gives the HMI one named array, so a single block request reads all four temperatures and flag sets together, and each alarm message picks Underrange, Overrange, Error and Temperature by index. Keep the raw Value and Status structures in the same variable list for diagnostics.