This is a continuation of the series on PLC ladder logic. It is meant to be a mid-level tutorial for people who have some familiarity with programming in ladder logic, but want to start the next phase of writing their own programs. So far I have covered Inputs, Outputs, Faults and Auto Sequences. I also posted some general organizational tips last year as “Ladder Logic 101, Where Do I Start?” and “Ladder Logic 102: Organization”. These gave a general overview of how a program is concepted and organized but really didn’t get into any programming examples. For now I am going to leave the basics of what contacts, devices and coils do up to many of the other sites and training books you can find online. I will be posting a true 100 level description of how the individual items work on the ladder rungs at a later time, but for now this tutorial assumes that you know the basics of ladder logic.
For this series I have been using the organization chart shown at the left. The last 201-204 level posts have illustrated what kind of code might be found in the b_Inputs, c_Outputs, d_AutoSequence and e_Faults subroutines along with the reasons for organizing a program this way. There are no hard and fast rules for arranging a program, this is just an example of how a lot of programmers go about making their programs more organized and readable. This posts concerns the contents of the a_System subroutine. This routine generally contains things like mode control, cycle start and stop and overall system housekeeping. The logic example at the top of this post shows how auto and manual modes might be set up. In this example machine operators are prevented from changing modes if the system is faulted or entering manual mode if the machine is auto cycling. The machine is also placed in manual mode upon a home request. The Auto Cycle command allows starting of the auto cycle when in auto mode if no faults are present and stopping of the cycle only when the auto sequence (from last week) has not been started.
In the auto sequence topic a couple of weeks ago you will note that the sequence would only step if the machine was auto cycling. If a fault were to occur, this would ensure that the machine would hold its present state. Other things you might see in this example might be only allowing cycle start when the machine is at home or origin position, a three second hold-down requirement for the cycle start pushbutton (during which a horn might sound), or any number of special requirements as defined by a customer. Other items such as an immediate stop button (allowing stooping of the machine even if in auto cycle) or a memory bit for cycle stop (allowing the cycle to complete without having to press the button again) are common.
A note on the format of the last rung: notice that the first two rungs use latch or “set” bits for auto and manual mode. The last auto cycle rung is also latched by means of a “hold-in” contact, the parallel autocycle bit with the same address as the coil. This is a common technique used in PLC ladder programming and is really just a matter of preference. I use both types, latching and hold-in contacts, depending on the application.
I have titled this post System Routine 1 because there are a lot of other topics that can be covered in the a_System routine, I may wish to discuss these later. If there are other things you would like to discuss in ladder logic programming please leave a comment!