Siemens Step-7 Newbie

windy

Guest
W
Hi, a newbie to siemens step-7 who has no training at all.
Currently have a few questions regrading programming,
1) what is the step-7 equivilent of rslogic500's OSR,first scan pulse,? how do i add it to my rung?

2)how do i change the timers/counter's timebase? its stated in the help file as a 16bit word but i do not know how to change/edit that value.

3) how do i assess the timer's done status as opposed to rslogic500 timer/dn and timer/en bit??

many thanks in adv!!!
 
Assuming S7 300/400 processors:

During start up, OB100 runs on a cold restart, OB101 runs on a warm restart. Any initialisation can be done inside these blocks.
If you want to detect the first scan of OB1, then you have to use a flag bit and generate the first scan logic yourself.

Timer times use the format w#16#BHTU
where B=time base, 0=0.01s, 1=0.1s, 2=1s, 3=10s
H=hundreds, T=Tens, U=Units
e.g. w#16#2500 = 500second timer.

Timer status is checked using the timer number as if it was any other logic variable e.g. "A T13"
 
Timer times use the format w#16#BHTU
where B=time base, 0=0.01s, 1=0.1s, 2=1s, 3=10s
H=hundreds, T=Tens, U=Units
e.g. w#16#2500 = 500second timer.



Alternatively you can use the form
L S5T#hH_mmM_ssS_xxxMS

if Hours, Mins, etc. are zero, then you can just leave them out.
e.g.

Code:
A M0.0 //Timer Start condition
L S5T#1S //Set Time = 1 Sec.
SP T1	 //and start T1 as Impulse
UN M0.0 //When Start signal removed,
R T1	 //Reset Timer
A T1	 //While Timer is running
= Q0.0 //switch on output A0.0

Edit: Oops, wrong language, A0.0 should of course be Q0.0
Oops 2, Und should be And!

Is SI still OK Jesper? Don't bother, just looked it up and changed it!
 
Last edited:
what is the step-7 equivilent of rslogic500's OSR,first scan pulse,?
Windy's post is a bit ambigous here.

"first scan" is done like Simon describes it.

A oneshot ("[OSR]"in an AB) is done with "FP" in STL in S7, or "(P)" in LAD in S7.
 
thks guys for your help...
but i am using lad programming is it possible to show me how to configure a first scan bit and the specification of the timer's time base .
is the data type s5timer and data type timer different? and lets say if i want to specify a 5 second timer ON delaywith time base 0.01s, is the following the correct way?
s5t#5s or is it w#16#0500

thanks and regards
 
Timers.....

Say you have a timer in some ladder logic. When you come to enter the timer value, the variable you enter must be in "s5time" format.

If the timer is to run for a fixed time, you would enter "s5t#5s". Your timer would work at 5 seconds for ever. If you wanted to change the time you would have to edit the block.
If you want to change the time according to a calculation, you would create an "s5time" variable, say in the temp data area, and then your program would write to that variable using calculated numbers. The calculated numbers would be in the w#16#0500 format and the timer would be assigned the variable name instead of a fixed time.
 
First scan bit....

Say we use M0.0 to be the first scan bit.
In OB100/101 set M0.0
The very last network in OB1 would reset M0.0

M0.0 will only be true for the first scan of OB1.
 
I'm going to start a campaign to rid the world of S5Timers!! I hate them.

They're awkward to configure, impossible to do arithmetic on (time differences etc), of limited duration and each CPU has only so many available. Let's get everyone using proper IEC timers. Who's with me, brothers? Programmers of the world unite, you have nothing to lose but your BCD-coded 3-digit timers!

Regards

Ken

(Sorry. Got a bit carried away there. For those who don't know what I'm talking about, try SFB4 'TON' from the STEP7 Library 'System Function Blocks' folder.)
 
I have basic knowledge of ladder logic but totally new to STL. Is STL tough to learn? If there any online materials that teach newbie the STL? Please advise.

Thanks a million.
 
STL-->LAD

A nice way to learn if you have only done ladder is actually in Step 7, here you can convert your ladder code into STL, it can help you learn to read it , note that not all STL functions can be used doing Ladder, the siemens help file should be sufficient as a reference manual

Regards

Rheinhardt
 
Ken
You're right-it's simply the least user-friendly data type ever. I create an FB called 'Timers' and use multi instances of SFB4 (TON). It's easier to handle the data.
Using this method, there's no limit on the number of timers (except the length of the instance data block) and you don't have to remember which timer number you're up to.

pp
 
PP


Spot on, brother. The revolution has now just increased its numbers by 100%. We're on the path to righteousness. Let's get some of the big hitters on-board - where are you S7Guy, JesperMP, RMA, Daniel Chartier, JVDCande and the others ...?

Ken
 
Sorry Ken, I'll probably be the lone dissenter. :)

I don't have a problem with Siemens timers, but it's probably because that is all I've ever used and they are second nature to me. They are actually pretty slick when you think about it: They have the five types, and although I mostly use the on-delay (SD), there are times I'm very glad the SS timer exists. I'm not worried about which ones have been used because I assign them dynamically on start-up, but I can see how that would be an issue in some projects, especially if they are addressed indirectly.

I haven't used SFB4, but in general I use such functions sparingly. For instance, the execution time of SFB4 is about 100 times longer than the SD instruction, and that may or may not make a difference, but I normally like to keep my scan times short and sweet if I can.

The time constants of Siemens timers can be tricky, and I'm sure if they could go back in time (about 1978), they would have designed the instruction set such that the timers didn't use the hokey 0-999 value and 10ms-10s multiplier. But at least they made it easier with S7, where you can just type in S5T#2M30S if that is what you want, plus you can use the S5Time data type in UDTs.

Doing math with the timers is definitely a challenge, and I don't even bother anymore. Instead, if I need to track the elapsed time against another timer, I'll just manufacture one programmatically. For instance, here is an On-Delay Timer:

Code:
[font=Arial][size=2]			A #StartTimer[/size][/font]
[font=Arial][size=2]			JC M001[/size][/font]
[font=Arial][size=2]			L 0[/size][/font]
[font=Arial][size=2]			T MW 50[/size][/font]
[font=Arial][size=2]M001: L MW 50[/size][/font]
[font=Arial][size=2]			L #OB1PreviousScanTime[/size][/font]
[font=Arial][size=2]			+ I[/size][/font]
[font=Arial][size=2]			T MW50[/size][/font]
[font=Arial][size=2]			L #DesiredOnDelay[/size][/font]
[font=Arial][size=2]			>=I[/size][/font]
[font=Arial][size=2]			= #PulseOnDelay[/size][/font]
[font=Arial][size=2]			R #StartTimer[/size][/font]

In real life, I make this type of timer using a canned UDT, and I just insert it in my other UDTs as needed, and the variables are right there when I need them. It can be easily modified for any type of timer, and there is no real limit to the time constant. In this case, I used the scan cycle time, but I have also use the interrupt OBs to pulse a trigger as well.

edit: Hmm, the code formatted kind of strange, but you get the idea.
 
First Scan: I'll assume you are accustomed to using the first scan bit to initialize data only when the PLC is first powered up and that is what you want to do with your S7. If this is right, then don't think about it like that. Instead, put your initialization logic in OB100. For example, if you need a bit set, you could do something like this:


MB0.0 MB0.0
--|\|-----( )--


S5Timer Specification: If you want to use a constant time specification for your timer, then yes S5T#5S is what you want. If you want to use a variable, then the data type should be S5Time.

S5Time Base: The time base is not specified in S7 as it is with Allen-Bradley. Bits 12 and 13 specify the time base (i.e. 00 = 10ms, 01 = 100ms, 10 = 1sec, 11 = 10sec). So this is how you would specify the time base. If you use a constant for the time specification, then the PLC uses the smallest possible time base. The smallest time base is not necessarily 10ms. If you specify 2 hours, the time base can't be 10ms due to the structure of the S5Time data type.

S5Timer Types: You probably have feel for the five types of timers - pulse, extended pulse, on-delay, retentive on-delay, and off-delay. If not, use the context sensitive help.

S5Timer Status: With AB, you are accustomed to having access not only to the DN bit, but also the TT and EN bits. I believe the only status provided is that at the output Q of the timer. The status of this output depends on the timer type. If you regularly want the equivalent to EN, DN, and TT, then you can write your own function block to provide these bits.

IEC Timers: If you are going to use a lot of timers, these are nice to work with. Use them in a multi-instance function block otherwise you may use up a unique data block for each call of a timer. There are three type in the standard library as system function blocks (SFB3 pulse, SFB4 on-delay, and SFB5 off-delay). Here is a link to an example of amulti-instance function block with IEC timers. EntryID18723826
The PDF document that installed with Step 7 on your PC called "Working with Step 7, Getting Started" has a good multi-instance example.
 

Similar Topics

Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
214
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
526
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
591
Hello, We monitor the temperature of a pipe via a 4-20mA temperature transducer. This goes into DB135(Read Analog Inputs). The issue I have is the...
Replies
0
Views
615
Please excuse the basic question, but I've never worked on Step 7 before (until now, only dealt with Mitsubishi Q-series PLCs)... What is the...
Replies
16
Views
3,289
Back
Top Bottom