Beckhoff Automation GmbH & Co. KG TX1200 — 3 Sample Program

Sample Program In order to use the POU TP in the POU WAIT we must create a local instance from TP. For this we declare a local variable ZAB (for elapsed time) of the type TP (between the keywords VAR, END_VAR). The declaration part of WAIT thus looks like this: Function Block WAIT, Declaration Part In order to create the desired timer, the body of the POU must be programmed as follows:

Function Block WAIT, Instruction Part At first the question is posed whether Q has already been set at TRUE (as though the counting had already been executed), in this case we change nothing with the occupation of ZAB, but rather we call the function block ZAB without input (in order to check whether the time period is already over). Otherwise we set the variable IN in ZAB at FALSE, and therefore at the same time ET at 0 and Q at FALSE. In this way all variables are set at the desired initial condition. Now we assign the necessary time from the vari-able TIME into the variable PT, and call ZAB with IN:=TRUE.

In the function block ZAB the variable ET is now calculated until it reaches the value TIME, then Q is set at FALSE. The negated value of Q is saved in OK after each execution of WAIT. As soon as Q is FALSE, then OK produces TRUE. The timer is finished at this point. Now it is time to combine our two function blocks WAIT and TRAFFICSIGNAL in the main program PLC_PRG. First we declare the variables we need. They are two instances of the function block TRAFFICSIGNAL (TRAFFICSIGNAL1, TRAFFICSIGNAL2) and one of the type WAIT (DELAY as delay). PLC_PRG now appears as follows: TX1200 35 Version: 1.3