DEV Community

Calum Knott
Calum Knott

Posted on

Reseting IEC Timers on Older Siemens PLC's (S7-300/S7-400)

More of a personal note than a blog, but hopefully useful for some weary internet traveler in the future.

 Problem

Resetting IEC Timers for older Siemens PLC's is a bit of a pain.
They seem to behave a little differently inside or outside of case statemenents.

In newer CPU we can use RESET_TIMER(TIMER) but this is not avaliable
eg:

RESET_TIMER(#IEC_Timer_0_Instance);
Enter fullscreen mode Exit fullscreen mode

So we are forced to do a little more work

Solution

Setup the timer as normal

#IEC_Timer_0_Instance(IN:=TRUE,PT:=T#5s);
Enter fullscreen mode Exit fullscreen mode

Then use the following fairly verbose setup to reset it.

// This is required to reset the timer on Older CPUs.
// In newer CPU we can use RESET_TIMER(TIMER) but this is not avaliable here.
// RESET_TIMER(#IEC_Timer_0_Instance);

#IEC_Timer_0_Instance.IN := FALSE;
#IEC_Timer_0_Instance.PT := T#0s;
#IEC_Timer_0_Instance.Q := FALSE;
#IEC_Timer_0_Instance.ET := T#0s;
#IEC_Timer_0_Instance.STATE := 0;

Enter fullscreen mode Exit fullscreen mode

Top comments (0)