0bject oriented programming, yes...no ?

geniusintraining

Lifetime Supporting Member + Moderator
Join Date
Jun 2005
Location
SC
Posts
8,287
Who uses it, what is your definition? How does it help?

I am installing a Controllogix with Ethernet and DH+, with a Red lion G308, this is a new system that will be hooking up to a old system

On one hand I have the opportunity to start fresh with a CLX and program it the way it should be (I’ll let you know if it works out)

I like the style of some of the programmers here (Alaric is one of) and several times he has brought up the object oriented programming and that he likes that method/approach

I have just finished pulling the wires and have started making the terminations, so I want to think about the programming side, where to start for a good structure/back bone

This project is small for now, but in the future it will grow to be very big, if I start out good...I hope it will stay that way

I have search “object oriented programming” and found a few things on it, but I would like to know what everyone thinks? Is it a bad idea because the old system is not? Do you have a style that you like better? who cares if you get a output when you want it, that's all that matters?

Thanks
 
When I write my programs, I write strictly in symbolic mode and use udts throughout. All of my data is arranged as "components", and I sort of treat them as objects, i.e. when I reference something that pertains to a conveyor, I pass the whole UDT into a function rather than individual variables. I guess that is as close to object oriented programming as I can get.
 
I think it depends on the project. I have a function block that I use for pump on/off. It has everything I need for start/stop/ovld/alarms everything built in. I then use it anywhere I need that type of logic. If I want to make a change I can change the FB once and they all still work the same. I think of this as object type programming. One peice of code being ran several times.

If your project has a lot of repeat logic then I think something like this is great. It is also good to use this same block in different projects. I always know how it will work.
 
Timers, counters, latches, one-shots..... now let's add inheritance, modularity, polymorphism, and encapsulation to the mix.... I think not !
 
Hi Guys,
Would an understanding of these concepts be beneficial to a PLC programmer even if you couldnt implement them?

My point being are there concepts from High level languages which are useful in PLC programming?

what about other languages that are not High level like C?

I found that assembly learned at college has helped with siemens STL.
 
My definition is simply "re-usable code".

That said, it is very do-able in c-logix.

We had a tire building machine program that was pieced together from the work of 3 individuals and literally pasted together the day before commissioning. Of course there were some details that had to be planned. In our case, we just had to ensure that we used the correct controller scoped tags for things that interlocked the pieces, and it was a five minute job to drag and drop the pieces together from two instances of rslogix5000, create the controller tags in the new file and verify it...
 
If I were to somehow relate PLC's and OOP, PLC's would be defined as the code behind the object. To truly define the object, you would have to use a higher level tool, such as an HMI software. For example, in your HMI software, you could define a "valve" object that has particular attributes and functionality. The attributes of the valve could relate to a generic UDT in the CLogix, and functionality could be defined in tasks or routines. The UDT could be passed as a parameter to the particular routine, and its various attributes would be updated accordingly. This is about as close to OOP in a PLC that you're going to get presently, but you still need that higher level tool as several have already mentioned.

Jeff
 
bernie_carlton said:
The term 'object oriented programming' doesn't really apply to the PLCs I've seen so far including the ControlLogix line.

Although not truly object oriented programming as in the higher level computer programming sense, UDTs in controllogix can be seen as use of objects/classes.
 
If UDT stands for user defined data type, then this is just a collection of fields in Siemens Step7 - is this the same in controllogix ?

A simple structure definition doesn't bring it any closer to OOP.
 
I think it is not possible to implement a true OOP in PLC programming, not at least with the all it's functionalities. But the new programing softwares, help to it. (For example Machine Edition in GE-Fanuc make a big step into this concept. Siemens Step 7 helps a lot also).

Where I'm working now we are using and implementing the software with the model of the S88. In this norms, there are a lot concepts taken from the OOP.

Althougt, it was hard at first to understand the implementation of the norms, (it has it learning curve), if you ask me now, I think it's the way to go. It leads to 'code reusability' once you implement somthing with it, it's very easy to modify.

I'll recomend you to take a look at those norms. If you need some help, I can lend a hand towards the implementation of them. (or at least how we implement it).
 
Comparing OOP in C++ to PLC's is like comparing apples to bowling balls. When I first got into OOP years ago, it to me was like learning to speak Klingon, very hard to grasp the concept.
Next time you are at the bookstore, browse through the books on OOP. Look at the sections on classes and inheritance. UDT's are basically arrays even when you reference one UDT to another.

P.S. I never did learn to speak Klingon all that well.
 
Mark Buskell said:
Comparing OOP in C++ to PLC's is like comparing apples to bowling balls. When I first got into OOP years ago, it to me was like learning to speak Klingon, very hard to grasp the concept.
Next time you are at the bookstore, browse through the books on OOP. Look at the sections on classes and inheritance. UDT's are basically arrays even when you reference one UDT to another.

P.S. I never did learn to speak Klingon all that well.

Refresher course:

http://www.kli.org/

nuqjatlh?
 
Last edited:

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,814
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...
Replies
9
Views
2,575
Could someone please explain what object oriented software is exactly? Thanks
Replies
5
Views
2,639
Hello All, I am stumped on how to convert a %MW to a %MF using Machine Expert Basic and a Modicon M221. The help files show a word to a double...
Replies
1
Views
75
Hi, I am trying to set up a plc. I've never done any programming with ladder logic previously. I'm trying to set up a a program to turn a device...
Replies
7
Views
240
Back
Top Bottom