Object oriented programming on StructuredText in S7

SIMATIC S7-200/300/400, Step7, PCS7, CFC, SFC, PDM, PLCSIM,
SCL, Graph, SPS-VISU S5/S7, IBHsoftec, LOGO ...
Post Reply
trofimich
Posts: 6
Joined: Mon Apr 20, 2015 11:07 am
Location: Kharkov, Ukraine

Object oriented programming on StructuredText in S7

Post by trofimich » Mon Apr 20, 2015 11:21 am

Hello!

I'm a C# programming, but currently developing programs for Beckhoff TwinCAT PLC on ST using object oriented extensions.

I have very many troubles with TwinCAT. It's most buggy environment i've ever seen, so i want to migrate from Beckhoff to Siemens with hope that Siemens is less buggy :D

For migration i need to enshure that all functionality i've used in TwinCAT also works on Siemens in ST language. Here they are:
1) Full support IEC 61131-3 related to object oriented programming (properties, inheritance, polymorphism, interfaces, ets)
2) Dynamic memory allocation (in TwinCAT this is non-standard __NEW operator). Very need this.
3) Libraries support (need to share same base classes between few projects, debugging should works in libraries, has troubles with this in TwinCAT).
4) Environment should be stable (TwinCAT is a bunch of bugs and i spent too much time on them).

Very need you help. Development stopped because of blocking bugs in TwinCAT. Beckhoffs support ignore more than month (ev)

bilbo_321
Posts: 87
Joined: Wed May 19, 2010 2:22 pm
Location: Bulgaria

Re: Object oriented programming on StructuredText in S7

Post by bilbo_321 » Sun Apr 26, 2015 10:27 am

This is what I can answer to your questions:

1) Full support IEC 61131-3 related to object oriented programming (properties, inheritance, polymorphism, interfaces, ets):
Yes, Step7 and TIA Portal conforms to IEC 61131-3, but it is NOT object oriented programming.
Classic IEC 61131-3 standard doesn't define or use any OOP (Object Oriented Programming).
The PLC languages which conform to IEC 61131-3 are: Ladder diagram (LD), Function block diagram (FBD), Structured text (ST or SCL), Instruction list (IL or STL), Sequential function chart (SFC) and Continuous Function Chart (CFC). None of them is OOP language. They are at most procedural languages.

Siemens PLCs and STEP7 or TIA Portal development software doesn't support OOP, as far as I know.
However, you can think of FB (function block) in Step7 as something like class. It has it's own code and data (only static variables) and you can define a variables of that FB type, similar to defining object of that class in OOP. You can use pointer and ANY data type for sophisticated programming, but that is not true OOP programming.

One general question: Can you use object oriented programming (objects, classes, properties, inheritance, polymorphism, interfaces, ets) in PASCAL or ANSI C (not C++)? Answer is NO.


2) Dynamic memory allocation (in TwinCAT this is non-standard __NEW operator):
No such a thing as Dynamic memory allocation in hardware PLC. PLC task is not to dynamically allocate and release memory. It's task is to read inputs, execute program (cyclically, at preset time interval or on event), update outputs and do the housekeeping tasks (OS tasks).

First read some basic manuals about how the PLC works, how to program it and PLC languages. Then read Step7 manual. It seems that you have no idea how the PLC works and how to program PLC. I mean hardware PLC, not software emulated PLC like Beckhoff TwinCAT.


3) Libraries support (need to share same base classes between few projects, debugging should works in libraries, has troubles with this in TwinCAT):
Yes, you can create libraries in Step7 and TIA Portal and reuse it. Actually it is like paste of code, so yes, debugging works in libraries.

4) Environment should be stable (TwinCAT is a bunch of bugs and i spent too much time on them):
Step7 and latest TIA Portal is very stable.


My advice is: Keep doing C# programming and give the PLC programming job to somebody else, more experienced. Otherwise you will spend a lot of time (and eventually loss money) and the worse - could cause damage or injuries. Except if you do it as hobby of course, not for living.

Good luck!

trofimich
Posts: 6
Joined: Mon Apr 20, 2015 11:07 am
Location: Kharkov, Ukraine

Re: Object oriented programming on StructuredText in S7

Post by trofimich » Mon Apr 27, 2015 11:12 am

bilbo_321, thank you very much! I've got answers on my questions (thnx)

Post Reply