ladder writing etiquette

Nice example Tom....point well made and my thoughts exactly.

I program mainly Mitsubishi PLC's and they allow you to continue adding bits to a line until it spills onto the next line and so on.

Instead of a coil (or instruction) at the end of the line it puts an arrow to indicate it is continued on the next line.

I dont like this for the reasons above, so if I cant fit all the bits on one line, I end it with an internal coil and use a n/o of that coil to start the next new line.

When trouble shooting, the logic is broken up into single lines with a memory coil at the end of each line. Much easier to grasp what is happening.
 
Hand in hand with the difficulty of troubleshooting really big rungs is the great big long monolithic program with no subroutines. My general rule of thumb is that if the subroutine is longer than about 25-30 rungs, break it down some more. This is not always applicable when you want to keep a program topic together, such as range checking a recipe, but I've found it to be a fairly useful practice.
 
Alaric said:
Hand in hand with the difficulty of troubleshooting really big rungs is the great big long monolithic program with no subroutines. My general rule of thumb is that if the subroutine is longer than about 25-30 rungs, break it down some more. This is not always applicable when you want to keep a program topic together, such as range checking a recipe, but I've found it to be a fairly useful practice.

I couldn't agree more. My personal opinion is that you really can't break something down too much, unless of course there's only one rung in the subroutine (but there again I've done that before too!).
 
Referring to the original question...
If your interface allows it... then why the hell not?

Doing so helps to localize timer-actuated Latch activities and subsequent conditional Unlatch activities. I do so quite often.

If a particular function is timer activated then bring that particular function as close as possible to the timer!

It's kinda like having... not only a radio... but a clock-radio! That is, it is like developing a function which also has a timer incorporated. Depending on the nature of the timer, the timer might be used to either initiate a function or to cancel a function. Some functions (clock-radios) use both.

It's powerful and it's local. You end up with a focal point. This only reduces the number of places that you have to look to find out what's really going on. In troubleshooting you have only one place to look for conditional results. Then you can follow each of those particular conditions to their particular sources.
.
.
.
Ol' Lefty said...
"Writing an extremely long rung of ladder logic, like using one very long run-on long-winded sentence in normal writing, is not technically incorrect and is certainly allowed by the programming software but it is considered bad technique and certainly discouraged by knowledgeable people in the respective fields because this type of run on sentence and very long wrap around ladder logic is difficult to decipher and makes understanding the intent of the author and absorption of the message more difficult,..."

To which I say... Hey Pardner... obviously, you ain't read no Faulkner (who is considered by many to be THE Standard of Classical American Authors). In his style, he used really huge run-on sentences simply for the purpose of building a picture... a concept, as it were.

"TURBOTATER" from Missouri????
I would have guessed IDAHO!
 
Last edited:
Rungs :)

Subroutines are important. They break up the program into logical blocks. In many PLCs the subroutine is not available. Older Modicon PLCs used segments to divide program logic, more for coordinating logic with I/O drops. Mitz and GE Mini series One have no way to divide logic. AB is nice to work with. Our new sorter and stacking upgrades are now going to be control logix. I wanted two 540s, to simply plug into our existing network. Supplier said no way. We lost our head saw to a fire on Monday, I now have to work this weekend to get it running by Tuesday. :( I guess Im lucky the fire didnt gut the whole mill. OK guys/gals I have to learn Control logix. Im in my happy place....Im in my happy place......Grrrrrrrrrrrr......!@@#$#(*^*(()%$#@ ...:) OK I fell better.
 
Back to the original question... I think that if you want to change the function of a rung of code in a working machine that you are worried might not work, then duplicating the rung and placing an always off contact before the final output works well. That way you can see how the original code is working while you test the new code and spot any unintended consequences.

One trick we often use at my work is that code changes made during commissioning are labelled with an always on contact with the coder's initials. That way, when you clean up the code at the end of commissioning you can find all the changes with a quick find-all.
 
Binaural said:
Back to the original question... I think that if you want to change the function of a rung of code in a working machine that you are worried might not work, then duplicating the rung and placing an always off contact before the final output works well. That way you can see how the original code is working while you test the new code and spot any unintended consequences.

One trick we often use at my work is that code changes made during commissioning are labelled with an always on contact with the coder's initials. That way, when you clean up the code at the end of commissioning you can find all the changes with a quick find-all.

Hmmm, I don't think that will work properly in some instances. Duplicated coils will always be equal to that last evaluated expression in the program scan. Modicon Proworx won't even let you duplicate a coil online. So, I suppose it will be machine specific.

#2 tip is a good one.
 
Terry, if you are sure you are a Faulkner or a Joyce go ahead and make your rungs as long as you want. Of course, you should also make sure that the people who look at your logic afterwards have a half-semester or so to decipher your intent.
For myself, I never thought much of Joyce or Faulkner. Give me Mark Twain anyday.

There is no arguing taste, I guess.
 
Older Modicon PLCs used segments to divide program logic, more for coordinating logic with I/O drops.
Omron have several options here. One can brek to code into sections and, say, use one section for alarms, anothe for shutdowns, another for analogues, anothe for screen handling. I find it a pain and go straight back to one program as it is easier for me to troubleshoot rather than having to open different sections all the time.

Another is FB which is really a far better way to do things if one has repetative tasks. Pain if no repetative tasks.

Another is "tasks". The Europeans wil be familiar with this. When you need a task to run turn it on, if no need to run turn it off. uts back scan times when code is not required to run.

Then there are all the usual jumps, interlocks, sub routines etc.

I think that if you want to change the function of a rung of code in a working machine that you are worried might not work, then duplicating the rung and placing an always off contact before the final output works well. That way you can see how the original code is working while you test the new code and spot any unintended consequences.

A good method although I hear with Control Logix I here there is an area one can do all this and watch it really run before downloading into the real program. Sort of like a simulator real time I guess with real inputs. Any comment from the AB people? Sounds exremely usefull.

One trick we often use at my work is that code changes made during commissioning are labelled with an always on contact with the coder's initials.

I have been doing that ever since I started programming and there was enough memory available to allow it. In the very early days, one had to look for one or two spare instructions that could be removed to allow a change to a program. Used counters before for compares to save one instruction each time I did it. Darn usefull to be able to turn a rung on and off during commissioning and view actions before turning it back on again. By thge way, I normally use an always on contact and just put a "slash" through it to turn it off. Really easy.

Hmmm, I don't think that will work properly in some instances. Duplicated coils will always be equal to that last evaluated expression in the program scan. Modicon Proworx won't even let you duplicate a coil online. So, I suppose it will be machine specific.

Definately PLC specific and can cause lots of problems if one is not very carefull. Better to use internal bits for outputs if possible before allowing the scan full access. Perhaps what I here about Control Logix will be really good if the testing area is really like a simulator and will allow duplicated outputs in the two areas but no action on the outputs in the testing area.
 
Tom Jenkins said:
this type of run on sentence and very long wrap around ladder logic is difficult to decipher and makes understanding the intent of the author and absorption of the message more difficult

I don't know Tom - I got your meaning right away . . .
 
turbotater said:
is it proper to branch around a timer with a latching bit
instead of writing a new rung ?

Not quite sure what construct you are talking about but my standard construct for time delay of outputs is as follows:

 
Delayed
Cond_1 Cond_2 T4:0/DN Output
----] [-----]/[-----+-----] [-------( )---
|
| +-[TON]---+
+-----+ T4:0 +-
+---------+



Where Cond_1 and Cond_2 are really whatever logic it takes to start the time delay.

This puts everything: The timer, the done bit and the delayed output, in the same place. I can't remember who I "borrowed" this from but it has always serverd me well.
 
my original problem was that the conditions for starting the timer
would go false and i wanted to use the TT bit and the done bit
for two different operations and the done bit had to stay on
until another operation completed . so i needed to latch that
timer on keeping it true until not needed . the question was just
whether to wright an additional rung or just branch around the timer which made it easy to see what held the timer on after the conditions went false .

btw Terry Woods ,
i got turbotater from all the turbocharged cars i have built
( last name Tate )
 
Bruce99
I am surprised that you believe that Mitsubishi PLC's do not allow sub-routines. I have been working with these for more than 20 years and have always been able to use sub-routines. The older A Series processors even allowed you to write sub routines/programmes in 8086 assembler if you needed to perform tasks which were not possible using ladder or instruction list. Having said all that I should add that I now use Control Logix extensively and consider this to be the best platform currently available.
 
I definitely do a lot of branching in order to assemble logic in chunks.
ndzied1's example is exactly what I mean (only I put the timer in the top branch).
It means that everything (or almost everything) that is relevant to a certain state, or alarm, or function is in one rung. That improves the readability of the program - at least to my opinion.
Obviously, the entire rung must be possible to view on the screen.

If you want to compare with regular language, then a well-phrased sentence must not be too long.
Cutting the language into many short sentences (telegram style) surely is irritating as well.
 
Subs

I have used only the "shoebox" or brick Mitz that came with the arrow speed control VFD. These had no subroutine capability, and had a hand held programer. The application was a material hoist underground. It traveled 3 levels and there were inputs for limits used to adjust speed. This was back in 1989, I have to think hard here, but two limits at the bottom, one to signal slowdown and a second to signal stop. At the top there was four limits. Each one signaled a speed reduction with an overtravel switch at the track end. The operator had a "deadman" switch used to enable the control relay. There was a signal system also. In total less than 4 pages of logic. I only made a few small changes. I remember it was not easy to follow the program. Someone correct me here but Arrow speed controls used these all the time. I was sure it was a Mitz but I could be wrong. I look forward to the new addition of Control logics. I am hoping to get RSLogics 5 now. I want to get away from AI. With RSLogics 5000 it will be easier to get RSLogics 5. (I think).:)
 

Similar Topics

so, im interested in hearing some secret tips people may use to stay organized and on task when writing a program from scratch. I do the typical...
Replies
12
Views
3,637
I need someone help to write a ladder logic in PLC 5 to take an average of 8 input values within 2hrs of an analogue input connected to channel...
Replies
12
Views
7,433
Hi all. Sorry for the mayby extreme newbee questions writing Mitsubishi ladder code but there are something I can't figure out :-) I have a demo...
Replies
6
Views
4,340
Hi , I am sure this has been addressed on this site already. I would like to ask the senior members for advice on how they write programs. I am...
Replies
16
Views
6,953
Hello all, Can I request help on writing LD on this forum. I have a three way switch that's going to the plc to run my motor cw, ccw, and reverse...
Replies
4
Views
4,518
Back
Top Bottom