Appendix
EL33xx-00x0
184
Version: 4.2
// THIS CODE IS ONLY AN EXAMPLE - YOU HAVE TO CHECK APTITUDE FOR YOUR APPLICATION
PROGRAM MAIN
VAR
nBuffer_INT : INT; // Buffer for reading or writing values from/to CoE objects
aTCElement : ARRAY[0..9] OF REAL := // Type K µV entries in 10°C Steps:
[-1156, -778, -392, 0, 397, 798, 1203, 1612, 2023, 2436];
nTabIndex : INT; // Index of node in table
nT_start : INT := -300; // -30°C for 0.1°C resolution
nT_ResTab : REAL := 100; // 10°C resultion of table (for 0.1°C resolution of values)
// Variables for calculation:
// ---------------------------
nDiff_U_node2node : REAL; // Voltage difference of two nodes
nDiff_U_node2U_TC : REAL; // Voltage difference of node and U TC
nSlope : REAL; // Slope for 1st interpolation (temperature to voltage)
nResidual : REAL; // Residual value for interpolation
nRelation : REAL; // Relation for 2nd interpolation (voltage to temperature)
// ===========================
nU_TC : REAL; // Voltage of temperature inkl. CJC
nT_CJ : REAL; // Cold junction temperature
nU_CJ : REAL; // Corresponding voltage of CJ
nT_Result : INT; // Resulting Temperatur (resolution 0.1°C)
END_VAR
Ausführungsteil (nState=100):
// Cold junction temperature by CoE:
nT_CJ := INT_TO_REAL(nBuffer_INT);
// 1. Convert temperature to voltage:
// ========================================================================
// Determinate index of table:
nTabIndex := TRUNC_INT((nT_CJ - nT_start)/nT_ResTab);
// Calculate difference of two values with real value between them:
nDiff_U_node2node := (aTCElement[nT1]-aTCElement[nTabIndex]);
// Get residual value of real value with integer value:
nResidual := nT_CJ - (nTabIndex * nT_ nT_start);
// Calculate slope nSlope = DY / DX:
nSlope := nDiff_U_node2node/nT_ResTab;
// Calculate interpolated voltage of the cold junction (m*x+b):
nU_CJ := nSlope * nRe aTCElement[nTabIndex];
// ========================================================================
// 2. Add this value to the PDO value:
nU_TC := INT_TO_REAL(nTC_Inputs_Value) + nU_CJ;
// ========================================================================
// 3. Convert calculated voltage to temperature:
// ========================================================================
// Search index of higher target node:
nTabIndex := 0;
// Loop as long U TC is greater than a node:
WHILE nU_TC > aTCElement[nTabIndex] DO
nTabIndex := nTa 1;
END_WHILE
// Loop ended with resulting nTabIndex
IF nTabIndex = 0 THEN
// Temperature is below first table entry: end here
nT_Result := nT_start;
ELSE
// Voltage difference between U_TC and lower target node
nDiff_U_node2U_TC := nU_TC - aTCElement[nTabIndex-1];
// Voltage difference between two target nodes with U_TC nested between them:
nDiff_U_node2node := aTCElement[nTabIndex]-aTCElement[nTabIndex-1];
// Relation of the two differencies:
nRelation := nDiff_U_node2U_TC/nDiff_U_node2node;
// Resulting temperature in 0.1°C resoltion:
nT_Result := REAL_TO_INT(nT (nRnTabIndex-1) * nT_ResTab);
END_IF
Summary of Contents for EL33-00 Series
Page 2: ......
Page 6: ...Table of contents EL33xx 00x0 6 Version 4 2...
Page 17: ...Product overview EL33xx 00x0 17 Version 4 2 Fig 10 EL3312 Fig 11 EL3314...
Page 18: ...Product overview EL33xx 00x0 18 Version 4 2 Fig 12 EL3314 0002 Fig 13 EL3314 0010...
Page 61: ...Mounting and wiring EL33xx 00x0 61 Version 4 2 Fig 45 EL3314 0010 Fig 46 EL3314 0090...