Conversion of Ladder Logic

A

Thread Starter

Arun Velagapalli

Can anyone suggest me a tool/platform/editor to convert existing Ladder logic program to a Structured Text and/or Convert a Ladder logic program to Statement Lists
 
On the Mitsubishi editors you can program in ladder and then upload the raw instruction list. But why would you do this?
 
A lot of PLC programming packages can toggle the display between Ladder and IL (Statement List). Ladder and IL are normally just alternate visual representations of the same thing.

The problem of course is that most IL and Ladder implementations only work with a specific brand or model of PLC. If you are interested in a particular PLC then post another question as to whether you can do it with that PLC. You can do this with Siemens PLCs for example.
 
A

arun velagapalli

Thanks a lot for your response, I am trying for the conversion on a Allen Bradley , is it possible in that case.

The problem is to actually to convert a Ladder program to a readable way like

some IF ELSE Statements / IL for my research , please guide me in that direction what would be best way.
 
Ab's RS5000 series for control-logix and compact-logix has tools for programming in ladder, functions or structured text. I'm assuming if you design with ladder logic u should be able to switch and view the program in structured text. I do not know myself of other Rockwell softwares that would do the same.
 
I think if you are using AB PLCs, you are out of luck in that respect. A good many other brands do let you toggle programming modes (see other comments for details).

You can translate a ladder program to IL manually by inspection. However, some PLCs don't have a documented IL format. All PLCs that I am aware have some form of IL (that's what they actually execute), but in some cases it's just a set of internal codes and you can't use it to write or modify programs (or even see it).

What does your research consist of? We might be able to make a better suggestion if we know what you are trying to accomplish. I have written a soft logic system, so I know what some of the issues are with respect to IL to Ladder and Ladder to IL conversions.
 
S
"I think if you are using AB PLCs, you are out of luck in that respect."

You won't be able to view the entire program in mnemonics in the programming package, but if you copy a range of rungs and paste it into a program other than RSLogix, it will appear as mnemonics.

I used to use this to generate repetitive code blocks when I wasn't supposed to use a subroutine, both manually and with a script.
 
A

arun velagapalli

Hi,

Thank you very much for response. I am working towards finding a way to translate Ladder to a readable structure

I would like to extract the inputs/Outputs and the conditions /process and represent a single network of Ladder as something like

Inputs Condition .... Output , I can have extra fields like Sensor/actuator data , So I am thinking of conversion of Ladder to Structured Text/ IL and parse it to extract the required.

Please advise

Thanks
 
J

Jeremy Pollard

Doing it with Rockwell native file formats cannot be done by the mere mortal.

I would suggest that you save the file as a text file. This will give you the ladder logic as it resides in the PLC with mnemonic representations

For instance XIC is Examine Input Closed or --] [---

BST = Branch Start
BND= branch End
NXB=next branch
Sor/eor = start of rung/end of rung

You could parse this text file and represent the logic in a different format by developing a backend compiler if you will.

This format can allow you to do a bunch of thingsJ

Cheers from: Jeremy Pollard, CET The Caring Canuckian!
Crisis, necessity, change
www(.)tsuonline.com
Control Design www(.)controldesignmag.com
Manufacturing Automation www(.)automationmag.com
 
In reply to Jeremy Pollard: Parsing the text ladder output sounds possible, if not exactly easy. You would first reduce the text ladder output to a regular matrix of instruction cells, and then compile the instruction matrix into IL. I've done the latter for a ladder editor that I am writing, but I still have a few bugs to solve. It's certainly possible though.

1) Break the program up in to subroutines.
2) Break the subroutines up into rungs.
3) Convert each rung into a rectangular matrix. This consists of:

3a) Convert the rung into a list of strings.

3b) Scan each string for patterns using regular expressions, where each patter represents a class of instructions (e.g. NO contact, coils, etc.). When you find an instruction, look at known offsets for additional data (e.g. addresses).

3c) Copy the instructions to a rectangular matrix, where you can annotate each cell with additional data. This by the way includes branches.

3d) Process the matrix into IL. Outputs are easy, but contact inputs can only be resolved by their relationships with other inputs.

So, this is all possible, although it's a lot of work. Unless you have a really compelling reason to use AB PLCs (rather more compelling than "I like them", or "lots of people use them", that is), then you are better off doing whatever it is that inspires this effort with something that has an exportable IL format.
 
D

Dave Ferguson

I think the point is he already has AB so Jeremy suggested that. AB exports the rungs into a readable format so that you pull it into excel and the find all Xic's and replace with il instruction.

Not easy but not as complicated as you make out.

Bigger question, use the language that best fits the application. Why do you want it transposable, has never been an issue for me.

Dave Ferguson
Process Control Engineer
 
In reply to Dave Ferguson: XIC gives you the "class" of instruction, but by itself it doesn't tell you what the actual IL would be. You have to look at the context in which it is used in order to decide if it's a STORE, AND, or OR instruction. It's not just a case of doing a simple context-free string substitution.

When Jeremy Pollard said "represent the logic in a different format by developing a backend compiler", that covers a lot of ground. The "back-end compiler" would transform this context sensitive representation to context-free IL. Although we don't really know the objective of the original poster's project, I suspect that this is more work than he would wish to engage in. And I will add that I'm not really sure that what he thinks he wants is what he really needs.

Most AB users have no desire to look at IL so none of this is relevant to them. That no doubt is why AB hasn't bothered to include this ability. For some other brands of PLC, there are some things which can *only* be done in IL, so they have to accommodate it in their editors.
 
D

David Ferguson

I understand..........you look for a BST for an OR and another instruction for an AND, but my point was you can "program" this compiler in excel (have done it) but as you have pointed out and so did I ...... Why, it is not like French and German users needing 2 languages, it is programmers preferences and wanting to see the switching ability.

I also get the some processors needing specific languages only for example Siemens S5 IL only in FB's etc.........but the only thing I have ever seen end users wanting is to see it in ladder, never have I heard of an end user wanting to go the other way.

We are living in the world of 61131-3 and yet most end users prefer ladder. Go into any plant and ask the shift electrician what he / she prefers ........ and after all this is a higher level language so the end user can understand what is going on with all those 1's and 0's. I usually write in IL if I want it never to be touched because the % of users who get it is small so they are afraid of it and leave it alone.

I use FB for process people and the Instrument Men (I show my age), I find most SFC is implemented incorrectly and usually has no way out of a step say when step tells valve to open and transition is "valve opened" and it does not and just hangs there.

I have been a part of the "european"/programmers" type programs, the "I can name that tune in 3 lines of code" that are impossible to see in real time what is going on. I have a friend who is an amazing control programmer, he writes the "coolest" code. Problem is I think its cool, but as I tell him (and he has gotten burned) by noone being able to read it and the Electricians rebelling against his code. He just finished programming the first Iron Nugget plant in the world in Northern Mn, did it all in ST, was very cool, I told him they will tell you to rewrite it, first code review, they told him to rewrite it in ladder ............ it is still cool.

In the end if you step back, you could program it all in machine language, or all in 1's and 0's, or in a graphical like ladder or as I like to do, skip a step and make the HMI (Humans to damn machines) actually tell the Humans what is wrong so they do not need to address the machine to figure it out and with standards only need to go in for additions to the code, not to use as a troubleshooting tool.

Personally I try to be very open and I like all of the languages and object abilities and think the efficiency is cool, but in the end, ladder has, is, and will rule for a long time, its death has been greatly exaggerated for as long as I have been in the game. Maybe as younger Engineers show up, but my goal in life is to NOT spend my evenings in the plant. As one old timer I worked with said "If you do the work from 7-3, you do not need to work from 3-7". But in order to fullfill this dream, I realize that the Electricians are my customers and MY customers demand ladder. (Even though I would like them to realize how COOL all this other stuff is), and I do not see them changing for a long, long time (at least here in the US).

Dave Ferguson
Control Systems Engineer
 
In reply to David Ferguson: If you have ever tried to write a program using the Step-5 ladder editor you would know why so many Siemens programmers preferred to use IL mode. The ladder editor was absolutely wretched. The result was a generation of PLC programmers who avoided ladder like the plague because they didn't want to fight with the Step-5 editor.

The Siemens S5 PLC also had another problem in that the IL (which they called Statement List) was not designed with ladder in mind. It's actually fairly similar to Intel 8051 assembly language (Siemens also was an 8051 licensee) with a few high level things like timers and counters tacked on. A lot of the instructions just don't have a ladder equivalent. Many of these instructions were also very low level, which means that you needed to chain multiple instructions together to do many basic operations. The ladder editor would sometimes string together multiple low level IL instructions to provide a single "ladder instruction", but a lot of the necessary IL instructions simply could only be used in IL mode. For example, you would typically have to do a series of test and jump operations. This just doesn't fit the ladder model very well. It's necessary with S5 IL though because of the way many of their instructions and addressing modes worked.

The Siemens S7-300/400 family fixed some of the problems in the S5 series, and the Step-7 editor is much better than Step-5 was. However, it's an evolutionary development of the S5, and so many of the fundamental design problems are still present in the S7-300/400. It's now reasonably easy to write the majority of your program in ladder, but you still need to know S7 IL if you want to do a lot of things.

The S7-200 family was radically different (basically, it's a Japanese style PLC with IEC addressing). With the S7-200, every instruction had a ladder representation and there was no need to use IL for anything. What is more it had instructions for things like copying data built right in (if you were an old type Siemens programmer, that was an absolutely stunningly advanced feature). I can't recall ever seeing an S7-200 program that was written in IL even though there is an IL editing mode available.

So, I don't think it's a case of Americans (and Japanese) like ladder and Europeans like IL. I think it has more to do with the market leader in Europe (and the world, for that matter) designed PLCs that made writing ladder difficult.

IL is nice if you want to do some sort of automated code analysis or generation as it's already in a form which a program can easily process. A tokenized form of IL is in fact what the PLC would actually execute. That's just not something that many people want to do however. I'm not really sure just what the original poster wants to accomplish, but it sounds like IL is what he needs to do it.
 
D

David Ferguson

I agree and in fact am in the middle of a giant S5 to Controllogix conversion right now, it is my 3rd one and I have always been amazed at the code they had to write to accomplish simple things today.........

I find myself saying "Oh that is why I hated that 20 years ago" a lot as I get the code converted. I also think that North American electricians were very used to relay logic from the old days......not sure if Europe had the same "history" with such things.

I did a project in 94/95 that I had to go to Sweden and work with someone cowriting code and I was always amazed at their efficiency and also how complex they could make something both at the same time. Having said that, that machine is still running today and I cannot think of a single time we had to go in and troubleshoot using the code.

As always it is the painter/artist and not which set of paints he/she uses.

Thanks for the Reply

Dave Ferguson
Control Systems Engineer
 
S
"The Siemens S7-300/400 family fixed some of the problems in the S5 series, and the Step-7 editor is much better than Step-5 was. However, it's an evolutionary development of the S5, and so many of the fundamental design problems are still present in the S7-300/400. It's now reasonably easy to write the majority of your program in ladder, but you still need to know S7 IL if you want to do a lot of things."

And then there's even certain things you can't do in IL and have to use ST. The next version of the programming software for the S7-300/400 will integrate with what they have now for the 1200, so I wonder if some of those limitations will go away. Allen-Bradley may only have one or two languages, but at least every language supports every feature.

Another factor that relates to programmer familiarity with IL is that back in the day when we had to use handheld programmers, most brands worked in IL, though some worked in LAD. (Toshiba for one)
 
J

Jeremy Pollard

Nice dialog guys!! Very interesting and informative for all. Everything always boils down to who at 3am will be troubleshooting.. thus Ladder is King!

And it is a North American thing for sure.. also I understand that the floor guys in Germany are technicians/engineers and not electricians. Different learning set.

My back-end compiler comment was simply to change one command set with another. I didn't really take any other issue(s) into consideration. And it seems there were a few!! Sorry to be so vagueJ

Cheers from: Jeremy Pollard, CET The Caring Canuckian!
Crisis, necessity, change
www(.)tsuonline.com
Control Design www(.)controldesignmag.com
Manufacturing Automation www(.)automationmag.com
 
D

David Ferguson

In Reply to Steve:

Controllogix supports 4 of the 5 languages (Not 2):

Ladder
SFC (Sequential Function Charts)
Function Block
ST (Structured Text)

Agree with comments

Dave Ferguson
Control Systems Engineer
 
Top