STEP 7 programming

katratzi

Member
Join Date
Mar 2005
Posts
210
First time using Siemens Step 7 (normally an RSLogix 5/500 user) and I have to say it is very different. I received this software only 2 days before a machine is due for delivery (of course! :)
and the requirements for one particular part of the program are this:

An operator enters two values into the HMI. They are "count value" and "range value". count value is the number of samples to be taken, typically 1-10. range value is the value entered so that when the samples taken are compared to each other, and they all fall within this range, the process is complete. for example, for a temperature measurement that specifies a range of 5 degrees, all of the readings in the sample would have to be within 5 degrees of each other.

Using A-B, I would start by using a timer to increment a counter every 0.5 or 1 second, an then pull the data from the analog I/O register, place it into a file, when the counter was done, I could then proceed to check the data for the range values. S7 seems to have plenty of timers and counters, so I think I am ok there, but I haven't seen many instructions like the CPT (compute) instruction in RSLogix. Is comparing values like this more difficult in S7? If anyone could point me in the right direction on this, I would appreciate it. I am not even sure I know enough math to know how to check these data points against each other and to come up with the right answer as to whether they are in range or not. My first thought would be to average them, and check each against this average, but these numbers repesent readings that are expected to vary quite a bit when the process is first started, then "settle out" as you get closer to being "done". When 10 values (or whatever number is input) all fall within this range, this batch is finished and it is time for the next.
 
For the sampling you can use a couple of methods that do not need timers. One is to use a timed interupt OB another is to make use of the clock memory.

I don't have my program package at the moment, so I can't be specific on the OB's. There are a number of OB's with pre-determined time spans, there are also OB's you can determine what the timespan is by configuring them in the hardware profile by selecting properties of the CPU. Not sure how many of each are available for your specific PLC. The advantages are obvious, you don't need code to create the rate, you just need a bit which if on starts the sample and another that resets for the next sample.

The second way (clock memory), again in hardware profile and properties of the CPU, you can select clock memory and state which memory byte to place it in (normally default to MB0). This gives you 8 bits which toggle at different rates from something like 100mS to 2 seconds.

The maths part, depends on what you want to do, you may have to learn a little STL, especially if you want to be accurate and convert to floating point etc. In the help section you can select help in ladder and help in STL, these should give you some pointers. It may be better to look at these and then ask some specifics on how do use the instructions that you think you may need.
 
Thanks, the timers you spoke of will be easier than coding new ones. This is sure a bad time to learn STL! I have only used ladder in the past, I have looked a a part of this program which has already been written by someone else in STL. I have compared a short network that was written in STL to the STL instructions in the "HELP" section, and I can see I have a way to go.
 
With such a short time to finish, forget STL and use your experience from Ladder in AB. S7 LAD is so similar that you can port code with only a few changes.

One of the biggest differences are the timers.
There are several ways, but I advice you to go with the IEC timers and not the S5 timers. IEC timers resemble ABs timers much more than the S5 timers.

Maybe the STL code you are looking at can be viewed in LAD. Try CTRL+1 to switch to LAD and CTRL+2 to switch to STL.
 
katratzi said:
but I haven't seen many instructions like the CPT (compute) instruction in RSLogix.
All math instructions are very similar to AB as long as you stay in LAD.
There are two things you should be aware of:
1. Math is split into three groups, 16-bit INT math, 32-bit DINT math, and 32-bit REAL (floating point math).
2. There is no Compute function in S7 (unless you consider SCL which we shall not in the short time). For morre complex math formulas, STL is actually better, but just stay in LAD even if it means that you have to make one operation at a time.

katratzi said:
Is comparing values like this more difficult in S7?
No, it is exactly the same as AB, only you have to distinguish between INTs, DINTs and REALs.
 
you're right, Jesper. with my time frame, I need to stay with what I'm familiar with. what or where are these IEC timers? I've only seen the ones listed S_ODT, etc. The part of the program I am having trouble reading right now is posted below, I hope......

A "Auto Mode"

A "Conveyor Reached Pos"
O "Platen Bit"
= L 12.0
A L 12.0

AN M 52.2
A "Cycle Stop PB"
AN "M6.0"
= "Platen Bit"
A L 12.0
BLD 102
R "Conveyor Reached Pos"
R "M5.0"


I THINK this reads as so:

-first rung

IF "Auto Mode" AND M51.0 OR M51.1 THEN 12.0

-next rung

IF 12.0 AND NOT M52.2 AND I4.3 AND NOT M6.0 THEN M51.1

-last rung

IF 12.0 RESET M51.0 AND M5.0



I think this is what it is saying, but I am not certain. This part of the program is causing the dreaded "unexpected operation" in another part of the program, specifically the M51.1 bit coming on when it seems that it should not. Thanks for any input.
 
katratzi said:
you're right, Jesper. with my time frame, I need to stay with what I'm familiar with. what or where are these IEC timers? I've only seen the ones listed S_ODT, etc. The part of the program I am having trouble reading right now is posted below, I hope......

The first part

katratzi said:
A "Auto Mode"

A "Conveyor Reached Pos"
O "Platen Bit"
= L 12.0

The L is a local temp flag, its not usually good to program these directly, its better to create temp flags in the TEMP area in the block header. Having said that it looks like a conversion from ladder, not got the S7 package on this machine but this whole section may convert straight to ladder.

Anyway.. In auto and (conveyors reached position or platen bit) turns on the local flag L12.0

katratzi said:
A L 12.0

AN M 52.2
A "Cycle Stop PB"
AN "M6.0"
= "Platen Bit"

This section should be straight forward, just AND's and AND NOT's.

The platen bit maintains the L 12.0 bit until one of the other bits turns off the platen bit.


katratzi said:
A L 12.0
BLD 102
R "Conveyor Reached Pos"
R "M5.0"

BLD is a screen conversion instruction for displaying ladder (even more sure this converts to ladder).

So conveyor position reached is reset once L 12.0 is on.

katratzi said:
-first rung

IF "Auto Mode" AND M51.0 OR M51.1 THEN 12.0

-next rung

IF 12.0 AND NOT M52.2 AND I4.3 AND NOT M6.0 THEN M51.1

-last rung

IF 12.0 RESET M51.0 AND M5.0



I think this is what it is saying, but I am not certain. This part of the program is causing the dreaded "unexpected operation" in another part of the program, specifically the M51.1 bit coming on when it seems that it should not. Thanks for any input.

Platen bit is M 51.1.

The only thing that can bring this on is the coveyor reached position bit being set when M52.2 and M6.0 are both off.


I wish I had my S7, it will definately convert to ladder I'm sure.
 
Peter -

Is it possible this local flag could be turning on somewhere else in the program? I think this is what is happening. When a certain action is being carried out on the HMI, the M51.1 bit turns on and platen does its thing. The HMI keypad causes this when any one of several different buttons are pressed. These buttons directly turn on "M" bits in the plc, but they are programmed using the HMI software as "exclusive" buttons, i. e., when one in the group is pressed the others will turn off their plc memory bit if it is on. Is there a way to check out the location of this flag?
I tried to convert that network to ladder, but it did not work.
I just need to dive into this software and learn how to use it.
 
conversion from ladders or FBD to read in STL are pretty confusing. The obvious one will be NOP 0. If you see this at the bottom of the statements, means this rung have high chances of conversion.

You may want to do a search for indirect addressing for MW50 or MW51. Right click>go to>location or, at Simatic Manager>Right Click>Reference Data>Display for cross-reference. Look at the assignments.

Otherwise, purely STL. After this project I'd suggest you spend some time learning STL in S7 bcoz it's really powerful.
 
katratzi said:
Peter -

Is it possible this local flag could be turning on somewhere else in the program? I think this is what is happening. When a certain action is being carried out on the HMI, the M51.1 bit turns on and platen does its thing. The HMI keypad causes this when any one of several different buttons are pressed. These buttons directly turn on "M" bits in the plc, but they are programmed using the HMI software as "exclusive" buttons, i. e., when one in the group is pressed the others will turn off their plc memory bit if it is on. Is there a way to check out the location of this flag?
I tried to convert that network to ladder, but it did not work.
I just need to dive into this software and learn how to use it.


The local flag is undetermined until it has been conditioned in the block, in this case:

A "Auto Mode"

A "Conveyor Reached Pos"
O "Platen Bit"
= L 12.0


It is not used before this point so it should be OK.
 
As I am in work, I have converted it.

convert.JPG



I did this by closing the gaps and in the block selecring view from the top menu and changing view from STL to ladder.

The L temp flag, as I suspected was an automatic Siemens insertion which you don't see in ladder at all.
 

Similar Topics

Hi, I have a 315-2 PN/DP CPU. It was programmed in Step 7 V5.5. Then a colleague programmed it in TIA Portal V13 for a test. Now I want to...
Replies
6
Views
2,278
Hi, I am programming a blow moulding machine with 2 stations. So far I have the sequence done with function STEP ( and SNXT). How can I jump...
Replies
1
Views
1,584
I need material for programming step 5 Plc SIEMENS?
Replies
3
Views
1,594
DEAR FRIENDS, I WANT TO KNOW THAT WHAT IS THE USE OF S100 BIT IN DELTA PLC PROGRAMMING. CAN ANYBODY GIVE ME ANSWER. THANK YOU :nerves:
Replies
2
Views
2,295
Back
Top Bottom