Siemens step7 time variables adding together?

Lare

Member
Join Date
Jan 2006
Location
Finland
Posts
2,048
Hi!

I need to add 2 different variables together at Siemens. Variables are with type: time/ t#__s

On FBD-editor I can't find direct block for addind time variables. Is there any block for this?

I can change time variables to dint-variables first, add together with add (double) and convert back to time-format, but then I neeed more variables for converting/adding variables together

Is only way to use STL-coding, if I don't convert varibles first?

On STL, I can use, I think this code?

L varible1 (type = time)
L varible2 (type = time)
+D
T varible3 (type = time)
NOP 0 (not necessary?)


any thoughts of this? I prefer FBD or ladder
 
Create an FC (using STL) to perform the time addition function required and then call it when you need it instead of doing the processing "in-line" in STL
 
See attachment. I like your solution better, but if you want to do it in LAD or FBD this should work..

AddTimes.jpg
 
I programmed FC-block for this and call it inside FB-block, just wondered why there is no easy way/ build in block for this at siemens.

p.s Need for this comed from using IEC timers at program (SFC4/Ton). I noticed strange behavier with timer value t#0s (timer preset value), with TP=0ms value IEC timer will not work at all and output (Q) stays allways off.

With s5t timer timer will set output to "1" right away even with preset value s5t#0s. Also on others plc I haven't noticed before, that timer would not work with 0s values.

Preset value is changeable from scada, so there can be situations that preset value = 0ms/zero.


So for fixing I add now 1ms to preset value before IEC timer. On PLC isn't enought s5t-timers. (timers are for alarms and so on, and there is plenty of them. I also use IEC timer inside FB-block, so it is easier to use that than Tx timers, because I don't need to care of if I have allready used timer somewhere in the program.
Problem occured with start sequence, there was iec timer and timer had zero value at PT input, sequence never started...;)
 
Last edited:
Code:
L varible1 (type = time)
L varible2 (type = time)
+D
T varible3 (type = time)
Nothing wrong with this approach. Take advantage of that you can mix STL code, for when you have to overrule type checking, and LAD or FBD code for regular visual programming.
Just comment what you do and why you do it.
 

Similar Topics

This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
119
When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
139
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
531
Hi, I received a Step7 Backup from my client and tried opening this backup but it won't open as there seems to be files missing from the backup...
Replies
11
Views
3,000
Hi! i'm just wondering did there is any chance to change Set Time(TV) on Siemens plc timer without step 7 using c# or python if timer not set in...
Replies
1
Views
1,243
Back
Top Bottom