S7 IEC Timers

TurpoUrpo

Lifetime Supporting Member
Join Date
May 2008
Location
Switzerland
Posts
1,571
Hi

I did quick hacks for TP and TOF to get reset functions in them. Here is the source:

Code:
FUNCTION_BLOCK TPR

TITLE = Resettable Pulse Timer

VAR_INPUT            
  IN, R: BOOL;
  PT : TIME;
END_VAR

VAR_OUTPUT            
  Q : BOOL;
  ET : TIME;
END_VAR

VAR                  
  STATE : BYTE;
  R_Edge : BOOL;
  STIME, ATIME : TIME; 
END_VAR

BEGIN
NETWORK
TITLE = 

A R;
FP R_Edge;
JCN nres;
L B#16#00;
T STATE;

nres: UC SFB 3;

END_FUNCTION_BLOCK


FUNCTION_BLOCK TOFR

TITLE =   Resettable Off Delay TIMER

VAR_INPUT            
  IN, R: BOOL;
  PT : TIME;
END_VAR

VAR_OUTPUT            
  Q : BOOL;
  ET : TIME;
END_VAR

VAR                  
  STATE : BYTE;
  R_Edge : BOOL;
  STIME, ATIME : TIME; 
END_VAR

BEGIN
NETWORK
TITLE = 

A R;
FP R_Edge;
JCN nres;
L B#16#00;
T STATE;

nres: UC SFB 5;

END_FUNCTION_BLOCK

I looked into making also retentive timer types, but could not find where does ATIME get its value from, has anyone of you found it?

I made one version using SFC 6. And updating STIME while timer was "paused". But I dont think its good way to do it.
 
I looked into making also retentive timer types, but could not find where does ATIME get its value from, has anyone of you found it?

Isnt this from the same place as TIME_TCK?

To answer my own question YES..

ATIME is actual time (System time)
STIME is started time

Be aware that the system time has a max value of 2147483647 then it starts at zero ..
 
Last edited:
Hmh o_O, im sure i tried it, but only in simulator. That was my first guess on where it does get its time from.

Need to try again.
 

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,382
I've tried to add an "s" after the tag for the PT value of an IEC timer but it's rejected, even if the tag type is "time". As the timebase is ms...
Replies
4
Views
2,111
Hi´ I have been using S5timer for the last decade, but every time I have to change the timers from a HMI Panel the problems start, and as I can...
Replies
13
Views
3,482
Heya im doing a small program in gx iec developer 7 and havnt really programmed in years so some help with this would be nice im programming an...
Replies
6
Views
5,473
Hello, I want to create a FC function that uses SCL code that checks deviation of a controllers actual measured value from its setpoint and then...
Replies
3
Views
7,107
Back
Top Bottom