IEC Timers Problem

Jolan

Member
Join Date
Oct 2007
Location
Leiden
Posts
5
Hi guys, first....great forum ! I got alot of information off it witch helpt me alot.

But i ran into a problem where i couldn't find a solution for. It's about the IEC Timers. First i used S5 Timers but then i read that it is better to use SFB4 TON Timers, so used it in a multiple instance. FB400 is the multiple instance block where i call all my SBF4 timers with symbolic names (around 20 timers). Everything is oke till then.

In several places in my program (FC's and FB's) i use the timers, i make the input .IN directly high in the program when i want the timer to be set. And if the timer expires, i look direcly to the output .Q and continue the program. The PT input is getting his time delay value from a shared datablock.

But now the timers won't work in PLCSIM, only 3 of them. And there is no difference in calling the timers between them. If i look in the instance datablock of the multiple instance (all the data from all the timers are stored there) i see that the IN input is set, but the timer won't run. So the output Q stay's low.

Also i call FB400 in OB1 at the end of the program, don't know if that is a problem. It is scanning al the timers every scan.

I already put the Hotfix over it for the problems of ignoring the PT value, so that's fixed but now this.

I really buggering with it and can't find a solution.

Further i am using PLCSIM V5.3 + SP1 + Hotfix and Step7 V5.4 + SP2
 
Last edited:
Well the three timers are used to delay the time for the feedback signal of the three valves to return. Every valve has his own timer. Witch is set when a valve starts to move, and reset when the feedback signal from the valve is set.

But only those works and run, and they are the first three timers that are used. All the other timers won't run....
 
I've just run a ten timer example and they all work. I've used flags in the inputs for testing in the simulator. Here's the source code of the block that I ran.

Code:
FUNCTION_BLOCK FB 400
TITLE =
VERSION : 0.1

VAR
  fbTimer1 : "TON"; 
  fbTimer2 : "TON"; 
  fbTimer3 : "TON"; 
  fbTimer4 : "TON"; 
  fbTimer5 : "TON"; 
  fbTimer6 : "TON"; 
  fbTimer7 : "TON"; 
  fbTimer8 : "TON"; 
  fbTimer9 : "TON"; 
  fbTimer10 : "TON"; 
END_VAR
BEGIN
NETWORK
TITLE =
	  CALL #fbTimer1 (
		   IN					   := M	100.0,
		   PT					   := T#5S);
	  CALL #fbTimer2 (
		   IN					   := M	100.1,
		   PT					   := T#5S);
	  CALL #fbTimer3 (
		   IN					   := M	100.2,
		   PT					   := T#5S);
	  CALL #fbTimer4 (
		   IN					   := M	100.3,
		   PT					   := T#5S);
	  CALL #fbTimer5 (
		   IN					   := M	100.4,
		   PT					   := T#5S);
	  CALL #fbTimer6 (
		   IN					   := M	100.5,
		   PT					   := T#5S);
	  CALL #fbTimer7 (
		   IN					   := M	100.6,
		   PT					   := T#5S);
	  CALL #fbTimer8 (
		   IN					   := M	100.7,
		   PT					   := T#5S);
	  CALL #fbTimer9 (
		   IN					   := M	101.0,
		   PT					   := T#5S);
	  CALL #fbTimer10 (
		   IN					   := M	101.1,
		   PT					   := T#5S);
END_FUNCTION_BLOCK
 
I will post the code, but most of the timers that doesn't work are indeed filled with Time Value zero.

Also i am now setting the IN bit of a timer directly in the code, so i do not use memory bits. Don't know if that is a problem, but also if i use memory bits it doens't work.....
 
Jolan said:
...but most of the timers that doesn't work are indeed filled with Time Value zero.

... so they will not work.

How many timers are there that have non-zero Time values that don't work.
 
I checked again, and with Memory bits it will work ! I used direct adressing before and that didn't work.

But is there a beter way then Memory bits, because then if i want to use symbols the symbol table is filt with timer in and outs.

but still strange that with time value zero it doesn't work. I will try and see if 0.1ms will work.

but thnx in advance for the quick response !
 
Calling SFB4 with PT=0 initialises the timer. Click on SFB4 then press F1 to read the help provided in Step 7
If you want the Q output to follow the input if PT=0, then use your own FB that simply calls SFB4 but with processing logic to override SFB4 behaviour. E.g. call FB4000 instead of SFB4

Code:
FUNCTION_BLOCK FB 4000
TITLE =
VERSION : 0.1
 
VAR_INPUT
IN : BOOL ; 
PT : TIME ; 
END_VAR
VAR_OUTPUT
Q : BOOL ; 
ET : TIME ; 
END_VAR
VAR
mySFB4 : "TON"; 
STATE : BYTE ; 
STIME : TIME ; 
ATIME : TIME ; 
END_VAR
BEGIN
NETWORK
TITLE =
 
	 CALL #mySFB4 (
		 IN					 := #IN,
		 PT					 := #PT,
		 Q						:= #Q,
		 ET					 := #ET);
NETWORK
TITLE =
	 L	 #PT; 
	 L	 0; 
	 ==D ; 
	 JCN ok; 
	 A	 #IN; 
	 =	 #Q; 
ok: L	 #mySFB4.STATE; 
	 T	 #STATE; 
	 L	 #mySFB4.ATIME; 
	 T	 #ATIME; 
	 L	 #mySFB4.STIME; 
	 T	 #STIME; 
	 SET ; 
	 SAVE ; 
END_FUNCTION_BLOCK
 
Thank you very much for you help, it all worked out just the way i want it!

No more timer problems anymore, thnx !
 

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,372
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,105
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,481
Hi I did quick hacks for TP and TOF to get reset functions in them. Here is the source: FUNCTION_BLOCK TPR TITLE = Resettable Pulse Timer...
Replies
3
Views
2,607
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,469
Back
Top Bottom