Simatic Timer not counting problem

kevinlin_5

Member
Join Date
Mar 2016
Location
Singapore
Posts
13
Dear All,

I have a problem with the Simatic Timer.

I'm writing a program to check the pulse signal input, if the input signal is keep changing periodically, then output is set, otherwise, output will reset. I used some timers to achieve this, and the input was a clock memory input with period of 2seconds. When the input 'Pulse_Input' is high, timer T210 will starts to count, output of this timer 'Timer_ON' will be set after 1 second, and this time the input 'Pulse_Input' is expected to be low, so I use 'Pulse_Input' and 'Timer_ON' to set the output 'Communication_Good'. The same way for input 'Pulse_Input' is low. This is how I program it.

But now the problem is the timers are not counting at all, even when the input of timer are high. Attached is the screenshot of the program for your reference. Can someone help to give any comments on how to solve?

Thanks for the help.

program.jpg
 
Thank you for the reply.


Actually my main problem is the timer was not counting at all, and this caused my output was also keep changing. Do you have any idea on this?

Thanks.


You could use 2 on-delay timers, one for the signal being on, and one for the signal being off. Place the 2 outputs of the on-delay timers in series as NC contacts, with an output coil for communication good.
 
Do not use Temp data like this in a FC. Temp data is shared between all other blocks. This means a LW 0 in one FC is the exact same memory location as a LW 0 in another FC. Using it for anything persistent through scan cycles is NOT recommended as it usually won't work.

Try using merkers and see if that fixes your problem.
You can also use timer directly in Network 5 in stead of the extra variables.
 
Temp data is shared between all other blocks. This means a LW 0 in one FC is the exact same memory location as a LW 0 in another FC.

Actually, each call of an FC/FB has it's own entry on the L-STACK (local stack). The L-STACK grows when at the beginning of the execution of an FB/FC, and shrinks a the end. Therefore, there is no overlapping of L-memory (ex: LW 0) between different FB/FCs. All TEMP variables inside any FB/FC only belongs to that call of the FB/FC, whether symbolically or directly addressed, and no others.
 
Code:
Call FC1
Call FC2
Call FC3

All 3 blocks use the same portion of the L-Stack. Means the local data written in LW0 by FC1 is overwritten by the following calls if they write to LW0. Local data should only be used to store temp values used within the same block within the same call. The usage of local data in this case is wrong.
 
All 3 blocks use the same portion of the L-Stack. Means the local data written in LW0 by FC1 is overwritten by the following calls if they write to LW0.

Correct. They happen to use the same portion of the L-Stack, for which the statement they "must be re-initialized again when they used for the first time in a block" comes in effect. This is true whether L addresses or names are used for the TEMP variables (or L addresses). What's worse... if you use address LW 0 in FC2, and didn't create any TEMP data in FC2, you will be using FC1's LW 0 value (if you created TEMP data in FC1).

I'm saying if you have nested FCs (FC1 calling FC2, for example), then LW 0 in FC 2 has nothing to do with LW 0 in FC1.
 
Thank you for the reply.


Actually my main problem is the timer was not counting at all, and this caused my output was also keep changing. Do you have any idea on this?

Thanks.


Click on the S_ODTS timer and press F1 and read the help - this will answer your question.
 

Similar Topics

Dear Sir, can you explain that how can we implement the timer s5t Timer time base changes in plc working program. as i have changed the timer...
Replies
8
Views
2,494
Hi all, Another question relating to my difficulties with translating my S7-1200 FB's to S7-300 FB's :) In my S7-1200 FB I have two IEC timers...
Replies
5
Views
6,819
Hi guys, Good day! I've been working with this problem for quite some time now but still I can't find the solution. I need a timer where I...
Replies
3
Views
4,199
Hello I'm programming something in STEP 7 package for S7-300 PLC and I'm having some problems with timers. One of my function blocks (written...
Replies
10
Views
7,880
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
83
Back
Top Bottom