Timers in S7 300

Here you go, i kenw i had read a post on here before about roll your on on S7

10BaseT. said:
If you do want to roll you own - try this , I posted it before , but I can't find where :-
You need to sub M10.0 for your first cycle flag , and MD58 is your last scan time - you may find it gives you what you want .
FUNCTION "TON" : VOID
TITLE =TON - Timer On Delay
//If the enable condition go true, timer TON starts incrementing according with
//the last CPU cycle time. When the accumulated value is greater than or equal to
//the preset value, the timer stops and sets the timer done bit.
NAME : TON
VERSION : 0.1


VAR_INPUT
EN : BOOL ; //Timer Enabled
Pre : TIME ; //Timer Preset
END_VAR
VAR_OUTPUT
TT : BOOL ; //Timer Timing
DN : BOOL ; //Timer Done
END_VAR
VAR_IN_OUT
Acc : TIME ; //Timer Accumulator
END_VAR
BEGIN
NETWORK
TITLE =Reset Accumulator Value If Timer Not Enabled Or First CPU Cycle

A( ;
ON #EN;
O M 10.0;
) ;
JNB _001;
L 0;
T #Acc;
_001: NOP 0;
NETWORK
TITLE =Accumulator Value Increasing

A #EN;
A( ;
L #Acc;
L #Pre;
<=D ;
) ;
JNB _002;
L MD 58;
L #Acc;
+D ;
T #Acc;
_002: NOP 0;
NETWORK
TITLE =Timer Done

A( ;
L #Acc;
L #Pre;
>D ;
) ;
A #EN;
= #DN;
NETWORK
TITLE =Timer Timing

A #EN;
AN #DN;
= #TT;
NETWORK
TITLE =ENO Setting

SET ;
SAVE ;
END_FUNCTION
 

Similar Topics

I've used the following timer code in S7-300's for a long time. When migrated to an S7-1500 plc, the timer behaviour changes so that I no longer...
Replies
22
Views
5,376
Dear all colleagues and members I have worked for a company and I created a program for them for small automation but they dont want to give my...
Replies
12
Views
4,706
Hi, I'm looking for a way to pause the timers I have in my PLC. I'm making a program which has a safety switch which is supposed to pause the...
Replies
5
Views
2,139
Hi all, I probably have some short questions for you. I'm trying to understand timers and the Siemens operating system in more detail...
Replies
9
Views
12,350
Hello, I need to be able to write time directly to a Siemens TON SFB4 timer. How can I do that through Wonderware Intouch using DasSiDirect...
Replies
2
Views
4,742
Back
Top Bottom