why use structured text and function block over Ladder

spidermonkey

Member
Join Date
Dec 2009
Location
in
Posts
30
So we are getting in some new equipment that the program has a lot of structured text and function block in it.

So now I am going to have to upgrade my 5000 software to professional to even see it and I am going to have to learn it. I have never seen it or been around it.

So my question is what reson would you use this over ladder?
 
TurpoUrpo pretty much summed it up. Some tasks that would take dozens of rungs of ladder can be done in a few lines of nice compact code that is much easier to read and understand.
 
here's my personal opinion – for what it's worth ...

for Structured Text:

in many cases it's because the programmer just graduated from college and Structured Text looks a lot more like the languages that he studied in his programming classes – whereas Ladder Logic looks like something from another era ...

for Function Block Diagrams:

theoretically, it's used because "process control" engineers tend to think about the systems that they deal with in terms of moving the various signals from one "block" to another "block" – with each "block" performing a specific "function" ... so ... as a very simple example: a signal comes in – it gets fed into a block to be scaled – then on to a PID block – then on to an output device ...

in theory, a Function Block Diagram program can in many ways follow much the same layout as the P&ID (Piping and Instrumentation Drawing) that documents the flow of signals through the plant's control hardware ...

I'm not going to enter the debate over which programming method is better – or worse ... but I do know that I'm getting more and more students these days who are in the same boat as spidermonkey ...

now I am going to have to upgrade my 5000 software to professional to even see it and I am going to have to learn it. I have never seen it or been around it.

keep in mind that most of my students are NOT programmers who deal with the RSLogix5000 software day-in and day-out ... instead these are maintenance technicians who have problems to troubleshoot and repair in their plants' electrical, hydraulic, pneumatic, mechanical, plumbing, and who-knows-what-all other types of systems ... these guys typically only fire up the laptop and go online when they're forced to do it – and at that point the bo$$ is usually demanding to know "How long before it's working again?" ...

so yes, Structured Text and Function Block Diagram techniques might indeed make things easier on the programmer ... but then long after his work is done, the down-in-the-trenches maintenance technicians who have to keep the system up and running are asking the perfectly valid question: "Do we really need all of THIS just to turn the pumps on and off?" ...

personally, I have ZERO complaints about either Structured Text - or Function Block Diagrams – or Sequential Function Charts – or Equipment Phases – or Add-On Instructions - for reasons that should be obvious if you look at part of spidermonkey's original post ...

... and I am going to have to learn it.


yep ... and you're not in that boat all by yourself ...
 
Last edited:
In the case of the ControlLogix, there are instructions available in Block that are not available in Ladder unfortunately. The example that jumps to mind is the SCL Instruction.

Stu....
 
I think I was the first to go through Ron's SFC. We did structure text as well. I couldn't be happier with the results.
It does make it much easier on the programmer to use these other language. I am now on both sides of the coin I get to troubleshoot and now write programs for a living.

I still program for the maintenance guy. I don't know if it came from being a 1 myself or what.

I did a job converting SFC to RLL. It was less than fun.
 
It is lot better for some tasks than ladder can ever be. Math for example.

I've used a lot of ladder logic, FBD, STL (Siemens assembly) etc. Higher-level text based languages such as structured text are quicker to code but harder to troubleshoot.
 
The idea behind Function Blocks is to provide a pre-canned solution to a machine function.

The simplest function blocks are the TON timers and CTU counters that we all use. Looking at the timer, the ideas of Time base, preset, accumulator, done bit, timing bit and enabled bit are all taken care of by the function block. You never need to go "inside" to see how it works or to debug it because it is already done.

Now imagine a machine builder with a machine with 20 identical index tables. It is very advantageous to be able to write one function block for an index table and use it 20 times. If there is a change in the way the index tables need to function, he changes the code once and automatically he knows the change is applied identically to all index tables. Trying to do something like that in ladder becomes a nightmare of indirect addressing or you have 20 versions of the same code with different addresses. Either way, it's very messy.

To have a decent implementation, the builder needs to make the function block "bullet proof" with extensive testing, using logical status or error outputs from the block and also checking the inputs for things like proper type and range. Done properly, there is nothing for the maintenance person to do besides check if the inputs to the block are what they should be and to look at what the status code coming out of the block is. And, once they figure out how one of the index table blocks work, they know how they all work.

As others have stated, structured text is invaluable and easier to follow for intensive math usage or also for string manipulation. An example of this may be parsing an ascii string received from a gage to pull out the actual dimension and convert it into a number.

The big pitfall I have seen with structured text is when people use it to try to mimic ladder and forget that a rung has two functions:

  • Put a 1 in the bit box when the conditions solve true
  • Put a 0 in the bit box when the conditions solve false
It is this 2nd one that trips up many programmers. In ST, when you have an IF without an ELSE, you are generally creating a Latch. Fine if you want to use a latch but not if you want to mimic a standard output rung.

The other place where I have used ST and like it is with CASE statements. When you have to do one of several things based on a number this statement lets you selectively run code in a clear way or create a "state machine" if you know that terminology.
 
I've used a lot of ladder logic, FBD, STL (Siemens assembly) etc. Higher-level text based languages such as structured text are quicker to code but harder to troubleshoot.

It depends on editor, not ST. SCL editor blows for debug, CoDeSys ST editor is very good for debug. Oh, and well written ST code describes itself and is thus very easy to debug. You can read how it should work straight up from code itself. In some simple cases comments are not needed at all.

There is place for ST, place for FBD, place for LAD, place for STL, place for SFC, place for CFC and so on. It depends on task.
 
If I need a hammer and only have a crescent wrench I can certainly get the job done, but not as quickly or gracefully as if I had a hammer.

If I had never before seen a hammer and had been driving and pulling nails with a crescent wrench for years I might not like the hammer very much at first - till I used it a bit.

More tools in the tool box allow you to use the best tool for the job.
 
for those of you who have never even SEEN the programming languages being discussed in this thread, here is a VERY SIMPLE example which shows the same basic constructions in:

(1) Relay Ladder Logic (RLL) ...
(2) Structured Text (STX) ... and
(3) Function Block Diagram (FBD) ...

.




3SideBySide.jpg
 
keep in mind that most of my students are NOT programmers who deal with the RSLogix5000 software day-in and day-out ... instead these are maintenance technicians who have problems to troubleshoot and repair in their plants' electrical, hydraulic, pneumatic, mechanical, plumbing, and who-knows-what-all other types of systems ... these guys typically only fire up the laptop and go online when they're forced to do it – and at that point the bo$$ is usually demanding to know "How long before it's working again?" ...

As always, you hit the nail on the head. When Morley developed the original Modicon PLC one of the criteria was to have programming that could be understood by electricians used to working with relay panels.

I started programming my systems with high level languages - Basic etc. - and then moved to PLCs when the HMI and anaolg prices came down. The debugging was an order of magnitude simpler with ladder, and the simplicity of HMI configuration was icing on the cake.

The younger guys I had working for me use a mix of programming. The basic structure is ladder, because it is easy to customize to specific project requirements. They've developed function blocks for repetitive tasks that show up on every project, particularly calculation intensive tasks. Once the blocks have been debugged and proven it makes for a simpler program and faster programming. Thinks like turning off a motor on a fault is better in ladder. The mix is great.
 
All programming methods have their uses - Use what ever suits the environment.
In Australia I am a qualified Electrician - Also worked as a senior technician.
My Reason for liking Ladder is it is easier for other electricians to read and fault trace - A printout is also easier for them.
I fully understand and use the other programming methods.
As my original training was relay logic (i'm 52) i still sketch in ladder
 
Last edited:
Siemens Simatic Manager Languages

I'm hope this picture turns out OK. I kinda hacked it together. Since Ron was kind enought to show off some of the AB side languages I figured I would throw some Siemens up there.
From Left to Right:
LAD - Ladder editor
FBD - Function block
STL - Statement list
SCL - Structured control language

Also there is Graph but I have never used it.

The images for LAD, FBD and STL are all of the same rung. The SCL image is of something random but shows the basic structure.

Languages.jpg
 
Graph or Graphcet is similar to a flow chart.
Ron's second extract is the same as the Siemens Logo PLC
 

Similar Topics

I am curious on something with a Case Statement in Structured Text. I am not the greatest at it so I want to know if my assumption is wrong or...
Replies
5
Views
2,126
Is there a reason why Studio5000 structured text and function block seems incomplete? I have the license for them but it appears there are...
Replies
9
Views
2,657
I have read all the posts I can find on ramp functions. I need some help with getting a linear ramp output. I want to have a ramp function...
Replies
9
Views
7,354
Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,170
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating...
Replies
3
Views
441
Back
Top Bottom