ControlLogix: Ladder vs. Structured Text

And colorization IS a nice feature, I'll admit that, but I don't see why ST couldn't do the same thing. If it's a boolean variable and it's ON, then show the variable name in bright green.

Colorization would be fantastic if added to RSLogix, to at least show the value of BOOLs. Right now hovering over a tag will tell you at that time what the value is, but doesn't update unless you move off and move back. Plus if you're looking at 6 conditions for a machine to change state, it can be hard to monitor vs. in ladder where you can see the inputs come in as they happen. There's no reason they couldn't add this colorization, but they haven't, and that's what cripples ST for troubleshooting. SFC at least highlights the active step.

Another good thing with Ladder, is when other constructs are used (counters, timers, messages), you also see what the accumulator and preset values are as they come in, if it's in error, DN, etc.

Good point about use of JMPs and LABELS. It's just not considered good programming practice. Leave that stuff to the compiler writer.
Excessive JMPs can be hazerdous in a PLC program cause done improperly they can lead to watchdog fault, if you never leave your loop


As to your reply regarding the "popularity" of Ladder logic, I really believe Ladder has survived because Industrial Controls programming (for whatever reason) has lived in a vaccum all these years, while conventional programming languages have continued to evolve. Windows OS is not written in Ladder logic. No application that runs on your phone is written in Ladder Logic. Ladder Logic is not "popular", it's just a niche "language" that evolved for PLC processors out of the early days of relays. But instead of moving mainstream with the PLC programming language, Rockwell chose to expand Ladder to include Function Blocks, then user-defined Function Blocks, and that's about it. And while Ladder was probably readable in the early days, it's gotten too convoluted with all the rungs extending down the screen, and all the awkward wiring connections you have to insert when IFs start getting more complicated.

Industrial controls probably exist in a vacuum because products have really long lifecycles. So much time and cost goes into building any given custom PLC panel and program, upgrades can be hard to justify, as it can easily costs hundreds of thousands to upgrade a complex system, with no major improvement in functionality since the mechanical system it's controlling is the same. For this reason we have PLC2 ladder programs that were converted to PLC5 programs, and we're struggling to get funding to convert to ControlLogix as PLC5 is approaching its sunset date.

With ladder it's probably more readable now because high resolution monitors are so common place vs text based 6200 software, or handheld programmers.

Use the right tool for the job. We have programs that use a combination of ST, SFC, and LD.

ST for algorithms, and initialization code
SFC to control the main state of the process (with steps that aren't that complicated)
LD dealing with the actual IO.

Usually when maintenance are in, they are looking at the IO in the ladder, as that's where the problem usually resides. This combinations leaves maintenance happy because they can still troubleshoot their ladder, and leaves the programmers happy because they can use ST.
 
keshik:
====
Rockwell has a "bad ST editor"?? What's so bad about it? Are you saying it doesn't continuously check for errors (like Visual Studio and any decent editor nowadays does)?

I mean bad in several ways. One is the way that the editor functions. In Studio 5000 as far as I can tell, you can't make online edits with it (which will make your life terrible in a production environment). You can't see the actual value of a tag without using a watch window. In Codesys I believe that online edits are an option (depending on the actual hardware). As well, you can see the status of all of your tags at run time as well without having to use the watch window.

Also, different manufacturers implement structured text differently. Just because some instruction is used in Codesys doesn't mean that you can use that same instruction in Studio 5000. If you go back in time a bit on Peter's posts you will see some of his comments about it in regards to how different vendors match up to the actual standard.

That all being said, I used to use ST almost exclusively when I was working with Codesys systems. This is a combination of (in my opinion at least) that their implementation of ST is pretty good and ladder is pretty bad. I was also the only person who was maintaining those systems. Now I'm at a different company where I use Rockwell and I pretty much exclusively use ladder. I'm pretty sure I would get myself in some hot water if I used anything else as there's a lot more people here that would also support these systems.
 
I mean bad in several ways. One is the way that the editor functions. In Studio 5000 as far as I can tell, you can't make online edits with it (which will make your life terrible in a production environment). You can't see the actual value of a tag without using a watch window.

Really?!...:sick:...As far as you can tell...
 
Really?!...:sick:...As far as you can tell...

I haven't figured out how to do it, though I haven't tried super hard to, as I haven't used much ST in Studio 5000.

Worst case I suppose you can do the same trick that you do with AOIs, is to make a new AOI/routine with a different name (and your changes), import it, and then change your JSR. What could go wrong doing that? đź’€
 
Well, I'm wrong about that. From the Online Help:

About Structured Text Online Editing
The Logix Designer application allows you to make online edits to your structured text routines from within the Structured Text editor window. To make an online change, simply start a pending edit from within the routine.
 
I don't particularly enjoy doing online edits to Studio 5000 ST routines, because the editor as acting on the whole sheet, not just one one line like it would in an RLL editor.

It tends to be a little laggy (on my VM, which is the only environment I use) because it's continuously updating the syntax checks for the whole sheet as I type.

So when I make wholesale changes to a ST routine, I copy it out to Notepad++ then copy the whole thing back in.

The hovertext feature does work well to show tag details (including the current value), and I'm not really sure how I'd feel about active colorization because I've never seen it done.
 
The hovertext feature does work well to show tag details (including the current value), and I'm not really sure how I'd feel about active colorization because I've never seen it done.

I don't know about in newer versions, but in Version 20, when the tooltip pops up it will show the value at that time, but not after that. I just checked and verified this was the case by hovering over a timer.acc value. The timer was counting up, but the displayed "value" doesn't update.

Colorization might be a good optional feature. Much like autoscroll in SFC.

29v1nrm.png


Also, online edits are started by clicking the far left icon in the editor (paper with pencil) "Start Pending Routine Edits"
 
Last edited:
I don't know about in newer versions, but in Version 20, when the tooltip pops up it will show the value at that time, but not after that. I just checked and verified this was the case by hovering over a timer.acc value. The timer was counting up, but the displayed "value" doesn't update.

The statement you have quoted refers to Online ST (Structured Text) programming tooltip.

Your example is LAD; the Accumulator value is real time displayed within the TON instruction graphic block.
 
Look at the top part of his screenshot.

And?!

'timer1' is configured and running in LAD; you're looking at it.

There is no TON in ST programming?! ST timing is using the TONR.

Configure a TONR in ST, get it running and hover the pointer over the Accumulator; you will see the real time value.
 
It doesn't matter WHERE the tag is set, when you hover over a tag in an ST program in RSLogix 5000 v 20 (can't speak to newer), the tooltip does not update after it first appears.

Observe a TONR timer. I have the Program tags window open, and a trend of the ACC, showing that yes the timer is functioning, and the trend ACC value matches program tags. The tool tip is frozen to a value from several seconds earlier.

29c5eb.png
 
frankly I've been trying to steer clear of this thread – because it's rather obvious that many (most?) of the contributors have clearly made up their minds - and there's no way to change their opinions ... (Ford? or Chevy?) ...

but ...

there have been a couple of posts that have offered some programming techniques that (at least in SOME cases) MIGHT (that's MIGHT) present an unsafe condition ...

I've decided to at least mention these – for anyone who might not be aware of what evil lurks just under the surface of this particular pond ...

in the figure below, we have three separate pumps – which have been programmed by three separate programmers ...

PUMP_A has been programmed in Relay Ladder Logic using a very common "seal-in" type of construction ...

PUMP_B has been programmed by a programmer who was trying to come up with the same functional operation – but by converting the same "seal-in" type of construction to its equivalent in Structured Text ...

PUMP_C has also been programmed to give exactly the same operation – again by trying to duplicate the Ladder Logic's "seal-in" construction in the equivalent Structured Text format ...

(note that the STOP button is wired Normally-Closed in the field) ...

so ...

when the boss comes around to check the operation of the pumps – he is pleased with the results ...

each pump starts running when the START button is pressed ...

and each pump keeps running when the START button is released ...

and each pump quits running when the STOP button is pressed ...

and each pump remains stopped when the STOP button is released ...

specifically, all of the pumps "meet the specifications" which the programmers were trying to achieve – at least in normal day-to-day operation ...

but ...

suppose that all of the pumps happen to be running merrily along – and then the ControlLogix processor has a "Go-To-Run" experience ... (you can test this situation out by just switching the processor from the RUN mode – to the PROGRAM mode – and then back to the RUN mode again) ...

naturally all three of the pumps turn OFF while the processor is in the PROGRAM MODE (as expected) ...

but oops! ...

when the processor is placed back into the RUN mode, we're surprised to find that PUMP_C comes back ON again ... the other two pumps do NOT come back ON until the START button gets pressed ...

so ...

is the UNEXPECTED and SURPRISING start-up of PUMP_C a "big deal?" ...

well, in many (most?) cases – probably not ... but then again – in some cases (maybe just a few) this effect could lead to a very dangerous situation ...

in any event, the words "UNEXPECTED" and "SURPRISING" are seldom (if ever) welcome additions to a PLC programmer's vocabulary ...

the reason for the difference in the operation of PUMP_C relates to the little [square bracket] characters around the := "assignment" element ...

naturally there's more to it than this – but here's a quick down-and-dirty explanation ...

[:=] makes a simple NON_RETENTIVE assignment ... (which is treated similar to an Output Energize instruction during the processor's PRE-SCAN operation) ...

:= (on the other hand) makes a RETENTIVE assignment (similar to a Latch or an Unlatch instruction) – and so the processor's PRE-SCAN operation doesn't automatically tell this type of element to go write into its bit/box during a "Go-To-Run" event ...

anyway ...

many people begin writing their Structured Text code without knowing that there can be differences in operation between the two "assignment" elements – and the results of those differences can be quite "spectacular" in some cases ...

party on ...
.

STX_vs_RLL.PNG
 
Last edited:
Personally, I would only use Structured Text for handling large arrays of data, in code that once you get hashed out never really needs to be looked at again. If you're doing a bunch of internal math, techs don't really need to see that (just make sure it works). But anything with real-world I/O should be done in Ladder or Function Block.
 
Last edited:

Similar Topics

Is it possible to export a routine programmed in structured text and import it into a ladder routine?
Replies
2
Views
2,879
I created a new program task under that I created 2 ladder files. My first ladder does not have the 1 flag in the ladder icon designating it is...
Replies
8
Views
4,211
Hi all, Is there a equivalent function block that do the same as MOV function in ladder? Thanks.
Replies
5
Views
2,326
I am making some changes in a control logix PLC program that an engineering programmed for my company. In the program they have used the same I/O...
Replies
15
Views
7,408
Hi everybody, Until now I worked only with ladder logic. Now I have a program with function blocks. It looks more complicate, e.g. you have to...
Replies
4
Views
3,055
Back
Top Bottom