DUTs ---- GVLs ---- GVL_EL3174 ^^^^^^^^^^ :: {attribute 'qualified_only'} VAR_GLOBAL CONSTANT (* Analog scaling *) fRawUpperLimit : LREAL := 16#7736; // Highest raw signal that can be read fRawLowerLimit : LREAL := 16#0000; // Lowest raw signal that can be read fScaleUpperLimit : LREAL := 300.0; // Upper limit in L/min fScaleLowerLimit : LREAL := 0.0; // Lower limit in L/min END_VAR GVL_IO ^^^^^^ :: // PLC IO from terminal modules {attribute 'qualified_only'} VAR_GLOBAL (* Slot 1 EL9184*) (* Slot 2 EL1008*) {attribute 'pytmc' := ' pv: @(PREFIX):LEAK01 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 1^Input'} bLeak01 AT %I* : BOOL; // Ch1 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK02 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 2^Input'} bLeak02 AT %I* : BOOL; // Ch2 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK03 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 3^Input'} bLeak03 AT %I* : BOOL; // Ch3 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK04 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 4^Input'} bLeak04 AT %I* : BOOL; // Ch4 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK05 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 5^Input'} bLeak05 AT %I* : BOOL; // Ch5 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK06 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 6^Input'} bLeak06 AT %I* : BOOL; // Ch6 {attribute 'pytmc' := ' pv: @(PREFIX):LEAK07 io: i field: ZNAM "LEAK" field: ONAM "OK" '} {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E02_EL1008]^Channel 7^Input'} bLeak07 AT %I* : BOOL; // Ch7 (* Slot 3 EL9184*) (* Slot4 EL3202-0010 *) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E04_EL3202-0010]^RTD Inputs Channel 1^Value'} nPCWTempRaw01 AT %I* : INT; // Ch1 {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E04_EL3202-0010]^RTD Inputs Channel 2^Value'} nPCWTempRaw02 AT %I* : INT; // Ch2 (* Slot5 EL3202-0010 *) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E05_EL3202-0010]^RTD Inputs Channel 1^Value'} nPCWTempRaw03 AT %I* : INT; // Ch1 (* Slot6 EL3202-0010 *) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E06_EL3202-0010]^RTD Inputs Channel 1^Value'} nTempMonRaw01 AT %I* : INT; // Ch1 {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E06_EL3202-0010]^RTD Inputs Channel 2^Value'} nTempMonRaw02 AT %I* : INT; // Ch2 (* Slot7 EL3202-0010 *) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E07_EL3202-0010]^RTD Inputs Channel 1^Value'} nTempMonRaw03 AT %I* : INT; // Ch1 {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E07_EL3202-0010]^RTD Inputs Channel 2^Value'} nTempMonRaw04 AT %I* : INT; // Ch2 (* Slot 8 EL3174-0002 *) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E08_EL3174-0002]^AI Standard Channel 1^Value'} nPCWFlowRaw01 AT %I* : INT; // Ch1 0-20mA Extended Range (0-30518) {attribute 'TcLinkTo' := 'TIIB[FMS_PLC_E08_EL3174-0002]^AI Standard Channel 2^Value'} nPCWFlowRaw02 AT %I* : INT; // Ch2 0-20mA Extended Range (0-30518) END_VAR POUs ---- FB_PCWFlow ^^^^^^^^^^ :: // Monitors temperature sensors FUNCTION_BLOCK FB_PCWFlow VAR_INPUT nPCWFlowRaw : INT; // Raw signal from the ADC END_VAR VAR_OUTPUT {attribute 'pytmc' := ' pv: FLOWRATE io: i field: EGU L/MIN field: LOPR 0.0 field: HOPR 300 field: LSV MINOR '} fFlow : LREAL; // Flow reading in L/min (0-30) END_VAR //Scale the raw hex value to the flowrate set in the Keyence (0-20ma -> 0-30L/min) fFlow := (INT_TO_LREAL(nPCWFlowRaw)/(GVL_EL3174.fRawUpperLimit - GVL_EL3174.fRawLowerLimit)) * GVL_EL3174.fScaleUpperLimit; END_FUNCTION_BLOCK Related: * `GVL_EL3174`_ FB_TemperatureMonitor ^^^^^^^^^^^^^^^^^^^^^ :: // Monitors temperature sensors FUNCTION_BLOCK FB_TemperatureMonitor VAR_INPUT nTempMonRaw : INT; // Raw signal from the ADC END_VAR VAR_OUTPUT {attribute 'pytmc' := ' pv: TEMP io: i field: EGU C field: LOPR 0.0 field: HOPR 1000 field: LSV MINOR '} fTemperature : LREAL; // Temperature reading in celsius END_VAR //Scale the signed int value from the input to an output reading in celsius fTemperature := INT_TO_LREAL(nTempMonRaw) / 10; END_FUNCTION_BLOCK MAIN ^^^^ :: PROGRAM MAIN VAR //PCW flow monitors {attribute 'pytmc' := 'pv: @(PREFIX):PCW:FLOW01'} fbPCWFlow01 : FB_PCWFlow; //PCW flow monitor 01 {attribute 'pytmc' := 'pv: @(PREFIX):PCW:FLOW02'} fbPCWFlow02 : FB_PCWFlow; //PCW flow monitor 02 // Gross temperature monitors (PT-1000) {attribute 'pytmc' := 'pv: @(PREFIX):MON:TEMP01'} fbTempMon01 : FB_TemperatureMonitor; // System temperature monitor 01 {attribute 'pytmc' := 'pv: @(PREFIX):MON:TEMP02'} fbTempMon02 : FB_TemperatureMonitor; // System temperature monitor 02 {attribute 'pytmc' := 'pv: @(PREFIX):MON:TEMP03'} fbTempMon03 : FB_TemperatureMonitor; // System temperature monitor 03 {attribute 'pytmc' := 'pv: @(PREFIX):MON:TEMP04'} fbTempMon04 : FB_TemperatureMonitor; // System temperature monitor 04 //PCW temperature monitors (PT-1000) {attribute 'pytmc' := 'pv: @(PREFIX):PCW:TEMP01'} fbPCWTemp01 : FB_TemperatureMonitor; //PCW temp monitor 01 {attribute 'pytmc' := 'pv: @(PREFIX):PCW:TEMP02'} fbPCWTemp02 : FB_TemperatureMonitor; //PCW temp monitor 02 {attribute 'pytmc' := 'pv: @(PREFIX):PCW:TEMP03'} fbPCWTemp03 : FB_TemperatureMonitor; //PCW temp monitor 03 END_VAR (******************************************************************* Feed each device function block inputs from the PLC IO. Collect error states detected by the function blocks into stErrors. *******************************************************************) (* Monitors PCW temperature from sensor 1 *) fbPCWTemp01( nTempMonRaw := GVL_IO.nPCWTempRaw01 ); (* Monitors PCW temperature from sensor 2 *) fbPCWTemp02( nTempMonRaw := GVL_IO.nPCWTempRaw02 ); (* Monitors PCW temperature from sensor 3 *) fbPCWTemp03( nTempMonRaw := GVL_IO.nPCWTempRaw03 ); (* Monitors temperature from RTD sensor 1 *) fbTempMon01( nTempMonRaw := GVL_IO.nTempMonRaw01 ); (* Monitors temperature from RTD sensor 2 *) fbTempMon02( nTempMonRaw := GVL_IO.nTempMonRaw02 ); (* Monitors temperature from RTD sensor 3 *) fbTempMon03( nTempMonRaw := GVL_IO.nTempMonRaw03 ); (* Monitors temperature from RTD sensor 4 *) fbTempMon04( nTempMonRaw := GVL_IO.nTempMonRaw04 ); (* Monitors flow rate from Keyence sensor 1 *) fbPCWFlow01( nPCWFlowRaw := GVL_IO.nPCWFlowRaw01 ); (* Monitors flow rate from Keyence sensor 2 *) fbPCWFlow02( nPCWFlowRaw := GVL_IO.nPCWFlowRaw02 ); END_PROGRAM Related: * `FB_PCWFlow`_ * `FB_TemperatureMonitor`_ * `GVL_IO`_