Converting Ladder Logic to Structured Text

Seagull725

Member
Join Date
May 2013
Location
Port Coquitlam
Posts
2
Hello there!

I have a code that is in ladder logic and would like to see it in structured text. The software in which the code was written in was AB's RS500 software. I believe our PLC is SLC 5/05 if it makes a difference.

I noticed that many other softwares such as ISaGRAF and IEC 61131 supports both ladder and ST. Do you think a free demo version will allow me to change between ladder and ST?

The reason I want to see the code in ST is because I want to understand what it's trying to do and I only know C and languages similar to C.

Thank you!
 
Sorry a SLC is ladder only. Even with a ControlLogix processor that supports structured text, there is no automatic conversion between the different languages. Any conversion must be done manually by the user.
 
Welcome to the Forum!
Unfortunately the SLC CPU platform and its dedicated development software (RSLogix 500) do not support Stuctured Text programming.
The only Allen-Bradley hardware/software platform which could be developed using ST is the Logix(Flex-, Compact-, Control-)/RSLogix 5000 (Studio 5000)family of automation controllers.
RSLogix 5000 (Studio 5000) software is very expensive and it needs to be at Professional Grade (or include a separately purchased option) in order to be able to develop Structured Text programming.
One more issue regarding your initial vision...
Even if you do own Structured Text capable Rockwell Automation software, depending of its complexity, a ladder logic developed application cannot be "automatically converted" to Structured Text nor it can be always fully "re-written" strictly in ST; Structured Text available instructions do not perfectly match the number of available ladder logic ones.
 
The reason I want to see the code in ST is because I want to understand what it's trying to do
The easiest way is to get someone to go through the SLC 5/05 program rung-by-rung, and explain what each ladder rung is trying to do. Rung comments (if your program has those) should help a lot with figuring out each rung (unless your programmer was one of these paranoid guys who thinks his programs are a trade secret and should be patented and copyrighted).
 
Thank you for the responses. I can't have the programmer explain to me what the code does because the code as long as a novel and the programmer is from an external company. We will try asking for a PIN chart or some alternative diagrams.

Thank you!
 
If you wanted to express this basic start/stop logic in C

I:1/0 I:1/1 O:2/3
-+----] [----+----]\[-----------------( )--
| |
| |
| O:2/3 |
+----] [----+



You would use something like this.

int I1
int O2

O2 = (((I1 & 1) || (O2 & 8)) && (I1&2==0))? (O2 | 8) : (O2 & ~8)

If you'll bother to learn ladder and recognize its power for handling boolean bit expressions then it will be a lot easier to read and program.
 
I chose an XIO I:1/1 as a stop specifically to show one way an XIO could be converted to a statement in C - not because of the nature of whatever push button might be used in this imaginary circumstance. The intent is to illustrate to the OP that RLL is a good language for writing boolean bit expressions and that it saves the programmer the effort of bitwise AND/ORing words with a mask to access a single bit, which he would have to do in C. Also hopefully seeing the extra steps he will have to take in C will encourage him to overcome any prejudices towards the language and take the time to learn it, adding another skill to his skill set. He will find that it will take him less time to learn RLL than it will to try and translate it to C and then study the C program. He should realize that his background in other languages will IMO make him a better RLL programmer as that background will help him structure his program and data. But he does himself a disfavor if he should decide learning RLL is beneath him.

Edit to add:
On a side note, were I actually needing to express RLL type boolean bit logic in C, which I have had to do from time to time, I would use #define to create my masks and bit access macros to save time. Alternately you can typedef a bit field structure but I think bit mask macros make more readable code. Somewhere around here I posted an example header file a number of years ago but I can't find it right now.
 
Last edited:
...because the code as long as a novel..
After seeing Tim's example, I can believe that a simple ladder program would be as long a novel when converted to C. The ladder software handles a lot of the computer assembly-type language for you, and saves a lot of fiddling steps.
 

Similar Topics

Hi there! I am new to PLC's, and I have undertaken the task of converting a primarily pneumatically-operated machine to electrically &...
Replies
5
Views
2,720
Hi all, Please understand that I am not good at English. I have plan to project with one of our customer have the Ls XGB-XBC-DR60SU PLC. This PLC...
Replies
1
Views
1,489
Hello, Calling on all SattCon nerds – or any other helpful souls! I have to transcribe a program originally written in DOX 10 for SattCon...
Replies
13
Views
5,072
I know this may sound odd, but we have a need to convert a C/C++ application to ladder logic to run on a Modicon PLC. Does anyone know of a...
Replies
7
Views
18,040
Hello, I have to update some PLC firmware (FX1n), the devices out on the market are reflashable via rs232. I cant find where the GX developer...
Replies
0
Views
3,370
Back
Top Bottom