Structured lab text problems
Latching In ladder logic it is very easy to latch. Consider the following implementation of the seal circuit on the next slide
To implement this program in structured text we need to implement a latch
Structured text program IF (NO_PB=TRUE AND NC_PB=TRUE AND Int_relay=FALSE THEN (*conditions to latch the output on - not latch must be off and the latch is set when the output goes on*) Int_relay:=TRUE; (*latch is set*) Output:=TRUE; (*turns on output*) END_IF IF (NC_PB=FALSE AND Int_relay=TRUE) THEN (*conditions to latch the output off - note latch must be set to enter into this routinet*) Int_relay:=FALSE;(*latch is reset*) Output:=FALSE;(*turns off output*)
Program definitions PROGRAM PLC_PRG VAR Int_relay: BOOL :=FALSE; END_VAR
Global variables that interact with the operator screen VAR_GLOBAL NC_PB: BOOL:=1; (*static declaration*) NO_PB: BOOL; Output: BOOL; END_VAR
Implementation of a timer using structured text To implement a time one calls up the timer function. Consider the following problem A Normally open pushbutton (NO_PB) causes a delayed start to a motor of 10s. If the stop push button has been pressed again the motor switches off and the timer is reset.
Structured text code IF NO_PB=TRUE THEN motor_start:=TRUE; END_IF timer(IN:= motor_start, PT:= t#10s , Q=>motor_on , ET=> ); IF NC_PB=FALSE THEN motor_start:=FALSE;
Local variables PROGRAM PLC_PRG VAR motor_start: BOOL; timer:TON; END_VAR (*note that the timer has been assigned the type timer_on ‘TON’ which is created by the insertion of a function block TON)
Global Variables VAR_GLOBAL motor_on: BOOL; NO_PB: BOOL; NC_PB: BOOL:=1; END_VAR (*note these are to interface with the operator screen*)