Timers are used to measure specific time intervals. Timers circuits have different applications in different systems. A timer is a specialized type of clock used for measuring specific time intervals. The timer is used to generate signals for checking or doing specific or periodic task on particular time and/or with some intervals.


Now  double click on the MAIN (PRG) and it will open an editor where we can replace it with the following code (by copy paste to the upper part and lower part of the editor).

//Header, upper part
testBool : BOOL := FALSE;
testInt : INT := 0;
testReal : REAL := 3.14;
testString : STRING := 'MyString';
myTimer : TON;

//Lower part (body of the program)
myTimer(IN:= TRUE, PT:=T#500MS); IF myTimer.Q = TRUE THEN myTimer(IN:= FALSE); testInt := testInt +1; IF testInt > 30999 THEN testInt:= 0; END_IF END_IF

When we make the program by using the template provided by Beckhoff, it creates a header and empty body. Now it is programmer’s work to continue from this point building the program according to the requirement.

If  we activate the program by pressing activate button in visual studio (arrow 1) and then login to the program (arrow 2) we see the above program running.

Congratulations! you have made your first ST program that is running in TwinCAT simulator.