Beckhoff Object oriented vs Functional programming

Cowmanator

Member
Join Date
Sep 2015
Location
Birmingham
Posts
21
Hello Gentlemen,

I am working on developing a new standard code concept for one of my company's solutions, this concept will be used for the next 20 years, the main question is, for the future, do you think that the paradigm should be Object oriented or functional.

I know that we all love function based programming, and that in the higher level world OO is the way things work. but are PLC's really going this route, considering the disparity in the skillset, ie one minute your are adjusting a sensor/overseeing electrical installation then the next minute to get the system running you need to understand object oriented programming.

Don't get me wrong I am all for change and do consider OO as a better method, its just when I think about the site engineer who will maybe want to look at a nice ladder network to fault find. I am unsure if this is the right approach.

any thoughts ?
 
I don't see why there needs to be a choice. Object programming is just a matter of how code and data are grouped together in a class. I do most of my programming in C but it is still roughly object based in the way the program is organized. The "methods" in side a class are or can be functions. The only difference if that the methods are can be local to the class or public. Also, if you look at the generated code what you see is that there is a "this" pointer that gets passed to the "methods". You don't see this in most object oriented languages but it happens so that the "methods" can access the data and other methods in the class structure. In C in need to pass the pointer to the structure so it is much more obvious what is going on.
 
What should definitely be is flexible and easy to read for whoever will maintain or commission the equipment.

As Peter said, the main concept of OO can be translated to many languages as what is important is how data is grouped and protected. With Siemens PLC's, for example, you can have FB's created for valves, motors, and even higher level functionality.
 
Hi Peter Nachtwey

Thanks for the post.

The reason for the decision is the code will be used by 300+ engineers from around the world and a large % of them (including myself) are unfamiliar with OO. So the question really is, is OO the future in plc's? as if we take this step, a large number of engineers will require training(cost). I suppose that there are other questions also, like, what are benefits vs functional. maybe I am making this too black and white but as I am a functional guy myself, I am not 100% sure what type of beast OO is. (I am currently reading books and watching videos to try and get up to speed)

all input appreciated
 
Hi cardosocea

I am thinking structure text with a graphical front /main end to make viewing easier for anyone that needs to look at the code for fault finding

Thanks
 
Please provide examples of what you mean by OO and FP. Because nobody loves the Functional Programming Paradigm, and everyone loves OO.

With OO, you logically group your data with your code.

So you have
Valve1.Status
Valve1.Commands
Valve1.OpenRoutine()
Valve1.CloseRoutine()

Valve2.Status
Valve2.Commands
Valve2.OpenRoutine()
Valve2.CloseRoutine()

With FP, you have functions that manipulate your data
Valve1.Status
Valve1.Commands

Valve2.Status
Valve2.Commands

Valve1 = GlobalValveCloseRoutine(Valve1)
Valve2 = GlobalValveCloseRoutine(Valve2)
Valve1 = GlobalValveOpenRoutine(Valve1)
Valve2 = GlobalValveOpenRoutine(Valve2)

OO is definitely the way you want to live your life.

Why do you think you can't OO with ladder?
 
Hi AustralIan

I don't know enough about OO to make a judgment on the ladder situation.
But the reasons I mention ladder is to give an example of if someone will be able to add/modify functions / Object classes without knowing much about OO.

Thanks for your input
 
Sample Program

https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_sampleprogram1/27021597865201931.html&id=16354[/URL]


If you go to the bottom there is link to download the project
 
Ah, I realise now you are talking specifically about Beckhoff's implementation of OO. I don't have Twincat, but can see from the writeup how the classes and inheritance and instances are programmed. It doesn't look like you can open specific instances to debug, but I could be wrong.

Ideally you would have more of a template style OO where:

1. Define template objects (class), under version control.
2. Copy those templates to where you intend to use them (object instance). Reference the version used.
3. If your instro tech looks at that instance, obviously he can easily see what is going on. 4. If they modify the code, it is now seen as an overloaded object (ie object instance of a new class that inherits from template class version x.y.z).
5. If you decide to modify the template object, you can either:
5a. Use that version only for all future object instances.
5b. manually replace each past object instance, incorporating the overloaded instro tech modifications.
5c. automatically change object instances that haven't been modified/overloaded, and automatically provide a list of modified/overloaded instances that need the new template merged.

I would leave actual inheritance and implements type OO keywords for template generation.

Good Luck!
 

Similar Topics

I'm new to TwinCAT3 and I've been searching for a tutorial on object-oriented programming. I've seen this link on Beckhoff's Infosys site but was...
Replies
2
Views
2,794
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
996
Hello sameone have Beckhoff PLC Siemens Sinamics V90 configuration example?
Replies
0
Views
98
hello, I am using Beckhoff with TwinCAT3 and when I change or add some new hardware or for any reason, there is a mismatch in the real hardware vs...
Replies
1
Views
126
I have a Beckhoff CX7000 IPC with some digital I/O built-in and I additionally need two analog inputs 0-10V. Can I install both Ethernet terminals...
Replies
4
Views
205
Back
Top Bottom