Timers in Step7

Mars

Member
Join Date
Oct 2014
Location
Copenhagen
Posts
17
Hi,

I want to use a timer that i can read the set value for the timer from a DB (because of OP). The regular Siemens timers seem to be too stupid for this assignment as we only can set the set value "on" the timer in the software.

So in this DB i want to set the timer, read the actual value of timer and send the result 1/0 to the DB for using the bits to activate functions.
 
Last edited:
Asuming step7, the standard timers (SFB4,5) are perfectly capable of this.

I would use a integer for the time setpoint in the HMI.
In the plc you would convert this to time format (or s5time if you use the old timers).

sidenote rant: dont use T,M and C its not S5 any more.
 
Programming software? TIA or S7 V5.5 or MicroWin or what?

CPU model number?

Sorry, S7 V5.5 and CPU 313C-2DP


Asuming step7, the standard timers (SFB4,5) are perfectly capable of this.

I would use a integer for the time setpoint in the HMI.
In the plc you would convert this to time format (or s5time if you use the old timers).

sidenote rant: dont use T,M and C its not S5 any more.

The solution are quite complex and is not to easy made. I have one CPU for the control and then i will connect to a master PLC where the OP is connected.

Do you have an example of using standard timers for this?

I want to store following in a DB.

Set value
Act Value
0/1 bit to activate function.

So you say that the values in DB should be in INT and then convert to time format. How do i convert to time format? In this case i will need a new DB for storing the TIME value converted from INT?
 
The reason why I would use integers is that these simpler to use in the HMI.
The disadvantage is that you would have only 1 unit per timer (sec,minutes,hours). For example "Pump delay: x seconds".
Having a single unit works 99% in my case.


Converting interger to time is simple

L DB_Timers.Timer1.Set_Value
L L#1000
*D
T tmp_time

The tmp_time you can put in the timer.

<timerblock is here>

The elapsed time is the other way around

L tmp_ET
L L#1000
/D
T DB_Timers.Timer1.Act_Value

You could also make a remaining by calculating the difference between setpoint and elapsed time.

Make a nice FB with the UDT of the timer in the in/out and call the FB's in a other FB as instances
 
Last edited:
The reason why I would use integers is that these simpler to use in the HMI.
The disadvantage is that you would have only 1 unit per timer (sec,minutes,hours). For example "Pump delay: x seconds".
Having a single unit works 99% in my case.


Converting interger to time is simple

L DB_Timers.Timer1.Set_Value
L L#1000
*D
T tmp_time

The tmp_time you can put in the timer.

<timerblock is here>

The elapsed time is the other way around

L tmp_ET
L L#1000
/D
T DB_Timers.Timer1.Act_Value

You could also make a remaining by calculating the difference between setpoint and elapsed time.

Make a nice FB with the UDT of the timer in the in/out and call the FB's in a other FB as instances
Can i do it like this in a FC? I need to do it as simple as possible.

Capture1.jpg capture2.jpg
 
Stop writing code and specify the complete functionality required. Use diagrams if required.

For example "just a auto signal..." means nothing to me.
 
Stop writing code and specify the complete functionality required. Use diagrams if required.

For example "just a auto signal..." means nothing to me.

When i get signal true from a other system a Timer on should start to count. The set value must be set in a DB as i set it from a HMI panel, the actual value needs to be send to the DB so i can show it on the HMI panel, and the result when the timer has elapsed need to be send to the DB so i can transfer false/true to to the two motors that should start to run.

When these motor start too run we have a second timer (off) that start to count, when this timer has elapsed the first motor stops and a third timer(off)starts to count when this has elapsed the second motor stops and the first timer (ton) should run again.

If its possible to this with the S5 timers in a FC i will welcome that. I need to do is as simple as possible.
 
Here's an example implementation. I've coded it so the motors are controlled via the DB so it can be tested in one plc (I used plcsim).

If you want to control the motors using the timerQs in the other plc, you will have to modify this program so the timerQs stay on (I don't see how you will know when to reset them without having to have another handshake bit back from the other plc).
 
  • I get a actual level on a tank on bus and a set value on bus. If the actual level is greater or equal i will set a bit that should start the sequence.
  • When timer 1 has elapsed --> Motor 1 and 2 should start.
  • When timer 2 has elapsed --> Motor 1 should stop and timer 3 start to count.
  • When timer 3 has elapsed --> Motor 2 should stop and timer 1 starts again.
I need also a timer 4 that that starts when i get a true signal on bus it will stop three motors after the set timer.


All the set value is coming from bus for the timers.


I need also a timer 5 that should set a output true for a while (set value timer)and set the output false.


I also has a question regarding the FC105 scale of analog signal 4-20mA. When i have scaled through this FC it is a REAL value and a DWORD and i need to convert it to INT and Word what is the easiest?
 
Here's an example implementation. I've coded it so the motors are controlled via the DB so it can be tested in one plc (I used plcsim).

If you want to control the motors using the timerQs in the other plc, you will have to modify this program so the timerQs stay on (I don't see how you will know when to reset them without having to have another handshake bit back from the other plc).
From the other CPU is only for showing in the HMI and to set the timers. The whole sequence is controlled in our CPU
 
Last edited:
From the other CPU is only for showing in the HMI and to set the timers. The whole sequence is controlled in our CPU

Use SFB4 TON
Create a DB with a Setpoint as TIME, ElapsedTime as TIME
Use them in the TON as shown.

When you reference the tag in the hmi, the setpoint and elapsed time will be in milliseconds. You can scale it to seconds, or whatever you want in the tag or by using the decimal point shift to 3 will get you Seconds.

db1timer.JPG

ob1timer.JPG

shiftdec.JPG
 
  • I get a actual level on a tank on bus and a set value on bus. If the actual level is greater or equal i will set a bit that should start the sequence.
  • When timer 1 has elapsed --> Motor 1 and 2 should start.
  • When timer 2 has elapsed --> Motor 1 should stop and timer 3 start to count.
  • When timer 3 has elapsed --> Motor 2 should stop and timer 1 starts again.
I need also a timer 4 that that starts when i get a true signal on bus it will stop three motors after the set timer.


All the set value is coming from bus for the timers.


I need also a timer 5 that should set a output true for a while (set value timer)and set the output false.


I also has a question regarding the FC105 scale of analog signal 4-20mA. When i have scaled through this FC it is a REAL value and a DWORD and i need to convert it to INT and Word what is the easiest?


MD4 is REAL
MD8 is DINT
MW10 is INT
MW12 is INT

To convert from REAL to INT, you have to either ROUND or TRUNC the REAL into a DINT. Then you extract the 2 high bytes into an INT.
On the downside, depending on what your REAL value is, you're losing all of the data after the decimal point. There are ways around that too, holler if you need help with it.
It's super fun and totally intuitive. Thanks Siemens. Good Luck
scale.jpg
 

Similar Topics

Can I reuse the same timer in a Function Block? I have a bunch of time delays that never run concurrently. I would like to just reassign a the...
Replies
4
Views
2,312
I am setting up the structure on a project that uses 6 identical manifolds. Each manifold has I/O, HMI events, timers , recipe steps, etc. I...
Replies
4
Views
4,950
Hello, How can we use the timer S_ODT with a variable instead of constant time. For exmaple not typing "S5TIME#2S" for TV, but using a time...
Replies
6
Views
3,984
Hello guys, I have another, very weird problem with Step 7 functions. In the attachments, you can find sorces for OB1 and two functions. Both...
Replies
9
Views
3,450
Hello guys, I have one small problem Idea is: 1. After time 10 s set "Step1" 2. After 8 s, set "Step2" and reset "Step1" 3. After 5 s, set...
Replies
5
Views
2,649
Back
Top Bottom