Siemens STEP 7 Lite

Latzi

Lifetime Supporting Member
Join Date
Nov 2007
Location
Brisbane
Posts
118
Hi,

I am brand new with Siemens 300 series.I did little work with 200 series using Microwin software.My main problem is that I was given a small project as a starter with STEP 7 Lite V3 and I have quite a few questions.
I am probably preconditioned by Allen Bradley but I saw that this is different big time.
I've read the literature from the installation CD and started to make my program I went quite ok untill I reached a point where I have to use a counter.Good.Now all counters have a preset number.So I created in OB1 a tag or symbol of INT type but I can't believe that you cannot assign a value for that symbol.
So I have counter C1 and I want to assign a value of 3 for the preset for this counter.
Do you have to use a move instruction somewhere at the beginning of the program to move a value of 3 into the "C1_PRE" or there is another way to make that integer value 3.
I saw in the absolutely useless sample program they provide that some data blocks are used and there you can do that.
Do you must use data blocks in a program or for a simple program you could get away just using the symbol table tags??
Could somebody explain this to me.Maybe even give me a sample file illustrating this?
The internet is big but not big enough just yet to contain a *.k7p file for download.Please help me out with this one.Thanx
 
Latzi said:
Hi,

I am brand new with Siemens 300 series.I did little work with 200 series using Microwin software.My main problem is that I was given a small project as a starter with STEP 7 Lite V3 and I have quite a few questions.
I am probably preconditioned by Allen Bradley but I saw that this is different big time.
I've read the literature from the installation CD and started to make my program I went quite ok untill I reached a point where I have to use a counter.Good.Now all counters have a preset number.So I created in OB1 a tag or symbol of INT type but I can't believe that you cannot assign a value for that symbol.
So I have counter C1 and I want to assign a value of 3 for the preset for this counter.
Do you have to use a move instruction somewhere at the beginning of the program to move a value of 3 into the "C1_PRE" or there is another way to make that integer value 3.
I saw in the absolutely useless sample program they provide that some data blocks are used and there you can do that.
Do you must use data blocks in a program or for a simple program you could get away just using the symbol table tags??
Could somebody explain this to me.Maybe even give me a sample file illustrating this?
The internet is big but not big enough just yet to contain a *.k7p file for download.Please help me out with this one.Thanx

Hello Latzi;
First, an answer to your queestion: presets for counters are not expecting n integer value, but a Counter data type value, written C#3 for a value of 3. It is a BCD value.
Second, a recommendaton. If you want to make your transition to Step 7 less frustrating, do not presume all you learned in the world of Rockwell translates point for point, and lose the " I can't believe that you cannot... (whatever)" attitude.
The F1 key on an instruction will open a help file which, amongst other things will point out what data types are expected for Step 7 instructions parameters. Take the time to read and understand these requirements and you will make your life easier.
If you cannot adapt to Step 7 basic instructions, look at their IEC alternatives in the Standard and System Function library. For example SFB1 is a IEC CU (Counter Up) instruction, which works with integer parameters, and counts up to 32764 instead of a limit of (BCD)999.
Hope this helps,
Daniel Chartier
 
Thanks for the answer.But I still don't have a clear answer.

I am happy to drop the "I can't believe" type of attitude to learn however where in the help says that for a counter?The answer is nowhere.What I thought doing with the counter I just used a move instruction to move constant value 3 into the int type which is the counter PV.However I will do what you said it is much easier.My new question would be if doing it with the move is correct?I did compile the program and no errors so it seems that we have a bit of flexibility with this.
Second and eben more important question is How do I assign a value to a variable situated at address MW1?? Data Type would be int?How do I make the PLC understand that the value at address MW1 should be for instance 200??
Do I have to use FB's for a simple program (control a few motors and conveyors) or I can get away by doing the whole lot in the OB1 which seems to me like the MAIN in Allen Bradley.Sorry for the analogy but I have to hang on to something I already know.?
 
Hello Latzi;

Reading the online help will show you what dataa type is expected for all parameters, as i said before.

Here is an example:



S7_Counters.jpg




The help file on S_CU instruction (select S_CU in the instruction list, open Help with F1 key) clearly states that the PV instruction is expecting a WORD value, or 16-bit hexadecimal, or a BCD Counter value. I have chosen C#3, a counter constant value of 3.

:whistle: Well I admit it is obvious mostly to people who have worked with Siemens a whole long time; but as a newbie you will have to spend some time deciphering the requirements for these units.



To make this value easily modifiable inside your program, you need a "placeholder" of the correct format. I like to use DBs for this, as in the following example:

S7_CounterPV_Move.jpg




The DB value CounterPV has a starting value that will be maintained everytime the project is restarted, but it can be modified during the project (math manipulations, move, etc...).





There is absolutely nothing stopping you from programming everything in OB1, in a single block. But that would limit the resources you could have access to.

Siemens has always prided itself on its memory management that made its CPUs very powerful with much less physical memory requirements than its main competitors (read Rockwell amongst others). The use of FCs, FBs and DBs in their programming is a good part of that.

Even Rockwell programmers learn to use subroutines, and appreciate them for the flexibility they allow. And the reception of the Logix5000 version 16 Add-On Instructions has been nothing less than thunderous, and those AOI are nothing more than come-lately FBs, in my opinion.



Hope this helps,

Daniel Chartier
 
Latzi - Where abouts are you creating your program ? From the sound of it, you are using the source code method as you mentioned that you compiled the program with no errors. There is a ladder editor that you can use (as shown in the previous post).
Do you have access to the plc hardware ?
 
One mistake a lot of beginners make is programming the whole program in OB1.

For experienced Siemens programmers, this is seen as very bad practice.

OB1 is a distribution block, it allows you to split the program into logically related sections, very helpful for later fault finding.

Normally my programs would have OB1 as very small and look something like the following

JU FC1 // Input conditioning
JU FC2 // Common data configuration
JU FC3 // Communication Handling
JU FC4 // Line sequence control
JU FC5 // Output Control


Then these blocks themselves could be distribution to specific parts of the line or machine, making it easy for anyone fault finding to get to the correct part of the program.

When they get there they only have a relatively small section of code to read through.

Its also easier for modifying as well, you don't need to download the whole program with Siemens, you can download just a single block if you wish, so segregating the program always makes sense.
 
One thing with Siemens counters as well, the status bit is high if the count is non-zero, which is why most people use them by presetting them high and counting down, then doing what's required when the count reaches zero and the status bit goes off.
 
One more question

In the last days I did nothing else but study Siemens.I have AB ,OMRON,GEFANUC background.What can I say so far is that the sofware is not too bad.But there are still a few things I don't really understand.Main one right now is what is the way to assign a tag (Symbol as Siemens call it) a constant value.Every or most PLC programs use machine constants.For instance I have a compare block LE_I and I would like to compare a value which is the counter accumulated value (Don't care about status bit in this case) with a constant.A number.My case 3.If I type in 3 against IN2 on the LE_I block I get an error.Should I make up a DataBlock?? Do you have to call that DB from OB1? Or it is scanned and available without calling it?
And in general if you make up a new symbol in OB1 named test which is the easiest or normal way to make that symbol value 300 if the type is integer ???
Thanx for all your help.I've made good progress understanding what;s going on with Siemens unfortunately I have to finish a program by tomorrow (simple program) and I am frenetically searching for answers.I've made the program in Allen Bradley RSLogix500 and tested it with Emulator works perfectly now I am converting manually that program to step7.I just got messed up a bit when it came to assigning a constant value to a symbol.Or use the constant integer value in a LE_I block.
Help Pls.
 
Hello latzi;

Let's make things easier for you since you are in a hurry. i suggest you use IEC counters, SFB0 ("CTU")instead of the Simatic counters; their PV (preset) and CV (output) values are of Integer type so Integer comparison instructions are directly usable.

S7_Counter_IEC.jpg

You will fing SFB0 in the Blocks tab of the instruction selector, under System Function Blocks.
Simply remember to click on the "???" sign above the SFB when you drag it to your rung and replace the ??? by DBx, where x is any unused DB number. A SFB is an FB amnd it requires an instance DB for it to run.
Notice also that this counter operates closer to our intuitive approach: Output Q remains at value 0 until PV > CV.

We'll come back later to data type converting for your programs. Let's get this first one running first.
Hope this helps,
Daniel Chartier
 
Last edited:
What have you got for the IN1 ?

Here's two examples - if you click on the error tab at the bottom of the editor screen, you get the error information displayed.

cmp002.JPG
 
I think I have done it.

Hi Guys.Thanx for all your help.It worths a million as every bit of information I get it helps me to understand the Step7 environment.I didn't use the IEC counters as I am not sure about what db to call and when.I have done it differently if you don't mind to have a look at the code I will upload it.It is STEP7 V3 a k7p file.I really look forward for your answer so I have some peace of mind.o_O
or alternatively here's a picture of the bit where I used the counter
BagVac.jpg
 
Latzi said:
what is the way to assign a tag (Symbol as Siemens call it) a constant value.Every or most PLC programs use machine constants.For instance I have a compare block LE_I and I would like to compare a value which is the counter accumulated value (Don't care about status bit in this case) with a constant.A number.My case 3.If I type in 3 against IN2 on the LE_I block I get an error.

You can directly use the constant value, as shown above with other answers, you can move a constant into flagwords you specify and use these or you can create a DB and assign the values you wish to them.

Using flagwords can help by assigning a symbol to it to state what and why the constant is used for. But as you have to move the constant into it in the program, it would require a program change to adjust it.

Using a Dataword, means you ca assign the value to the dataword without having to move the value in the program, which means you could change this value if you desired, without making a 'logic' change. It would still need saving afterwards though, otherwise a future download could put the initial value in.

Using flag and data words, also means the value could be calculated and therefore variable if required.


Latzi said:
Should I make up a DataBlock?? Do you have to call that DB from OB1?

No, you call the DB before you need to use it. If you access a dataword in the program, it will use the last called DB as the current block. A mistake often made is to forget to open the correct block and then attempt to access the wrong DB, this can cause a crash if the last DB is not long enough at worse, and cause corruption at best.

You don't need to continuously open a DB, once it is open you can then continue to access it until you open another DB.


Latzi said:
Or it is scanned and available without calling it?

As above, you must open the DB you require before you access it.


In your example, you open the DB "CONSTANTS" at the start, you then access the datawords by fully qualifying the address, as in "CONSTANTS".Counter_PRE. You do not need to do both, when you fully qualify the address, it in itself opens the DB.

One thing to look out for, say you opened a DB called "SETPOINT" at the start instead of "CONSTANTS", after the fully qualified addressing of "CONSTANTS".Counter_PRE in the logic, then "CONSTANTS" would be the open DB after that point and not "SETPOINT".

After you opened the DB "CONSTANTS", you did not need to fully qualify the address "CONSTANTS".Counter_PRE, if Counter_PRE was dataword 6, then you could have simply used DBW6 at the counter preset, as "CONSTANTS" DB was already open.

Most people usually like to fully qualify the address though, because if you don't you cannot see the synbolic name, the only drawback is the fact that every time you use the fully qualified method, it attempts to open the DB, whether it is already open or not. To me, this is a waste of memory and scantime.

I have seen programs where people have created all their BOOL memory as dataword bits, and accessed them throughout as fully qualified addressing, which meant the opened DB was constantly being changed, slugging down the scan and eating the memory.
 
I understand I think

Thank you for your reply.I think I did it right in my code.As I used only one db (no need to but for fun) and I used one unconditional (OPN) for DB Constants.I assigned a Start Value for COUNTER_PRE and used the tag in the program.I used the OPN one rung before using the COUNTER_PRE which I think Is ok.
Would you mind just have a quick look at the code itself in the zip file.As you have experience with Siemens probably you'll see straight away if there are any major problems with the code.The logic is ok as I tested it with Logix500 Emulator(the RSLogix500 version of it).Just pls have a look if you don't mind and let me know in 2 words what u think.Thanx
 
My S7 is on another machine, so cannot look as yet, I'm sure Simon will have looked and will tell you if there is any glaring errors.

The point I was trying to get across with the DB, there is no problem with your code, just you did not need Network 7, as in network 8 you open the same datablock just by entering "CONSTANTS".Counter_PRE.

As soon as you entered that address, it opens DB "CONSTANTS", so Network 7 was uneccessary.

You only need to open the DB, if you address individual components in the DB, without the DB up front.

i.e.

L DB10.DBW10 //This will open DB10 and then load the value held in DBW10 from DB10 into the accumulator.

L DBW10 //This will load the contents of DBW10 from the currently opened DB into the accumulator.

The currently opened DB could have been opened by an instruction such as OPN DB5 or via the an explicit address instruction such as L DB5.DBW50.

There is nothing wrong with your code just to be aware for example, if in Network 8 you had "AN_OTHER_DB".A_Value as an address, from that point on, "AN_OTHER_DB" would be the opened DB and not "CONSTANTS", even though the last OPN instruction was to open "CONSTANTS" in Network 7.
 

Similar Topics

Hi everyone CAN SOMEONE EXPLAIN THE FUNCTION OF THE SYMBOL TABLE AND FLOW CHARTS.ON A PLC. Thanks James
Replies
2
Views
1,562
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
248
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
547
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
674
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
625
Back
Top Bottom