Siemens S7 programming

I take issue with this assessment.

Take your example of C vs Visual Basic. There's a dramatic difference between the two, and quite often the requirements of a project will determine which language to use... things like development time, low-level hardware access, GUI requirements, target system, execution time, etc. In some cases, C is advantageous. In others, you'd be fool to use C.

The difficulty and complexity in Siemens grants the programmer ZERO advantages over, say, an Allen Bradley Controllogix. Zero advantages. No matter the requirements of the system, it will almost always be much easier and more straightforward with Allen Bradley, especially for a beginner. (Barring any oddities like being locked into an incompatible network protocol... AB is only slightly better at Profinet than Siemens is with Ethernet/IP.)

Having worked extensively with both, I just can't take seriously anyone who disagrees with this.

Anytime I come across a Siemens programmer who raves about how great TIA Portal is, I know right away I've come across a guy who lives and breathes Siemens and has never worked with other high-end controllers. Sure, coming from Step7 5.5 (or, God forbid, Step 5), it's a HUGE leap forward... but it's practically unusable for large projects.

Siemens is today where Allen Bradley was 15 years ago, when AB was shedding off the shackles of RSLogix500. At the time when RSLogix5000 was in its infancy (which lasted until version 12 or so), it was releasing very buggy development software and buggy hardware. The new crop from Siemens is no different... and it'll be a few years before it's stable enough to use in industry. I say that after some hard lessons learned in the field, so consider it a warning.
Hello Bapi,

First off I would like to suggest you not get hung up on this discussion.

What I have learned from programming both AB and Siemens is that if you are familiar with AB, then Siemens is easy to learn, except for STL. LAD between both is very similar. AB ST and Siemens SCL tend to follow the MS VB code language with there own variations. FBD is FBD.

The main difference is the execution of the programming.

My experience with AB has not yet come across any programming language like Siemens STL.

I learnt to program in LAD, FBD, and Code (ST or SCL).

AB has certain functions that do not work in a certain programming language. IE: The PIDE function does not work in LAD.

Sometimes Code language is more efficient. However, not everyone knows Code language.

>I desperately want to know how I can use the FC,SFC,SFB,DB
>for creating my programs with better flexibility.As of now I
>am using only the OB1 to write all my program in it.Can I
>use other Ob's also ?

1. Look at FBs and FCs as routines. More so with version 16 and later, as Add On Instructions. If you are familiar with AOIs, then you already know how to program FBs and FCs. Only minor variances on how they are implemented.

Conceptually they are similar.

2. Think of OB1 as your Main routine in AB.

Use the main routine to call your AB subroutines.
Use OB 1 to call your Siemens subroutines.

3. SFCs and SFBs are equivalent ABs prebuilt functions.

IE: SFB4 is the equivalent to ABs TON. Timer function.

4. Siemens DBs are equivalent to ABs Tags.
Siemens uses two types DBs. Instance and general.

Instance DBs are generated when calling an FB.
General DBs are created by you.

In Siemens, you can create function tags and call them directly like you do in an AB program. However, to use a DB tag, you have to use the DB path.

IE: DBnn.DBX 0.0 or DBnn.DBW 2.
If using Symbol Information: "Global Data".TagName.BitName or "Global Data".TagName.

5. OBs other than OB1 are similar to ABs SFs (System Functions).
For starters, do not worry about other OBs until you are ready to move on to more advanced issues and control.

IE: OB82 is an IO Fault routine. When an IO fault occurs, OB82 is called. If no program is in OB82, it defaults to what Siemens programmed it to do. If you want some logic to execute on an IO fault, then you program the OB82.

ABs default IO fault control is configured in the module. If you want some logic executed on an IO fault, then you program it in a routine.

>How do I call the different Functions form my main program
>and how do they return the values ?

1. In your LAD editor, add an empty box to the network. in the blank space, type in the FBnn, or FCnn, where nn is the FB or FC number.

If you call an FB, it will require you to enter a DBnn.
If you call an FC, it will not require a DB.

2. To use a system function, you can enter SFBnn or SFCnn if you know what it is.

If not, then you need to get it from the Library. Don't worry, the library is just as confusing as ABs. Unless you use the function regularly and know what it is, you need to read the description and try it out to see if it what you need. Same way with AB.

Most functions fit the average usage, however, if you need a specialized function, you may have to program it yourself.

>Any help with a small example would be most appreciated.
>Is there any way I can get some real programming examples ,
>easy enough for a beginner like me ?

It would take to long to provide examples for all the different aspects of programming.

What I would do is an internet search for a particular example of what you are trying to accomplish. IE: the use of a timer to pulse a light.

Or post a routine from an AB program and ask if someone could provide an equivalent function in Step 7.

The advantage is that you know what your AB routine does and providing a Siemens example allows you to follow the Siemens equivalent and see how the program is equivocally executed.

I found this link to a list of S7 Functions.

There is also an Excel spreadsheet link.
I would agree to some extent that Siemens Step 7 has a lot to offer when it comes to programming languages (which can be overwhelming for beginners as it was my case some 6 years before) but this feeling does not stay for long once you get the feeling of the basics.

In fact, when I am on a project where I have to replace some other vendor plc (GE Fanuc, AB RsLogix etc) understanding their code could be very simple or it could be difficult if the task like algorithms are implemented in apparently simple LAD or FBD.

Which makes me come to the point that there are some tasks that can be easily implemented in LAD or FBD. However, a little complex tasks like data management, loops, batch management or dynamic routing is better implemented using SCL (High Level Language). When it comes to driver building which is a complex task (i-e modbus RTU or ASCII etc) then stl which is essentially an assembly language is the choice. So it is the task you want to perform that makes a certain programming language ideal to use not the programming language itself.

And if you happen to use Siemens Step 7 but want to finish your task quickly then there is another option of using CFCs/SFC that is essentially a graphical representation of FBs,FCs,SFCs,SFBs from the standard/custom libraries. Here you just have to use a mouse to quickly connect IOs and data flow from one function to another and rearrange the functions in correct execution order.

I rest my case here that Step 7 though is very flexible and powerful tool when you want to code in different programming languages and then combine them into a single program.

P.S. Siemens new Step7 (TIA Portal) for S7-1200 and S7-1500 PLCs is a piece of cake for beginners when it comes to easy and quick logic. Check some videos on Youtube or Siemens website to have an idea.
Hello Bapi,

I have made some usefull blocks(FC/FB) for Siemens S7 that I can send to you for free by e-mail if you want. The name of these blocks is "" that you retrieve from Siemens S7 software under "File".

Included in these blocks are also an All-in-one PID-Controller that have been used in many plants all over in Scandinavia.
All-in-one means that this Controller is an analog as well as a step-controller in the same block with much more features than normal Siemens software.

Look forward to hear from you or from others that may reading this note.

Kindly regards
J. S. Nielsen
Hi Denmark, that was a great response. Among the many responses you seam to want to be of help to Papi.
Kindly allow me to also learn from you. I have some level of Siemens programming experience, but needs to become better.
My email: [email protected]
Thank you