Ladder Logic 101: Where do I start?

*Note: This post was written in February of 2011. Since that time I have written a number of other posts on ladder logic you may find useful. These are listed below for your convenience:
Ladder Logic 102: Organization (October 2012)
Ladder Logic 201: Inputs (March 2013)
Ladder Logic 202: Outputs (April 2013)
Ladder Logic 203: Faults (April 2013)
Ladder Logic 204: Auto Sequences (April 2013)
Ladder Logic 205: System Routine 1 (May 2013)
Ladder Logic 206: Scanning (May 2013)
There are also a number of other PLC related posts if you look around on the site.

  • June 29, 2017: Since this post I have made a new tab at the top of the header labeled “PLC”. Click on that to stay up to date on my PLC related posts and series!

Soon after I started my controls company in 1996 and started doing work for NAS, I found that I needed help. My first couple of employees were ITT tech students who worked for me part time building panels and wiring machines, and one in particular showed some initiative and wanted to learn how to program PLCs. At first he would get involved on start-ups, checking I/O online, doing simple debug and making minor changes, but over the course of a couple of years he was able to take a program outline, look at a few examples and write programs himself. Part of this may be simply because he had a lot of interest in the field which was why he had gone to school in the first place.

Over time I hired several full time engineers, most with experience in a maintenance role but not so much in design. It became a challenge to ensure that everyone followed the same general outline which made writing a template a necessity. The template was basically a partially written program with some generic rungs of logic establishing mode control for the machine, showing fault examples and creating I/O buffer type rungs.

Before I used a template though I remember one engineer who didn’t feel he had the ability to generate a program. He could modify existing programs, was an excellent troubleshooter but lacked the confidence to start a program himself. To ease him into programming I started out by writing him a few rungs of logic on graph paper and having him type them in, he would come by my office and ask a few questions and before you knew it he became an excellent programmer.

For those who are just getting into writing ladder logic and have maybe taken a few classes or seen some examples, it is quite simple to write your own template. A great way to start is to write a few mutually latching/unlatching rungs for maintenance/manual mode and auto mode, write a couple of either latching or numerical register comparison fault rungs, say a generic timer rung and a generic E-Stop rung, establish a fault bit and put it into your mode logic in the appropriate place. Write a few generic input and output buffer rungs with your mode logic in the output rungs. Your inputs driving some kind of tag such as InX_status can constitute your input buffer rungs. Separating these into separate subroutines (or function calls/blocks) can make them easy to copy to other programs later. Even a simple auto sequence with perhaps a first and last step and a single generic middle step using some of your generic I/O bits can be helpful. Again, keeping them in separate sections or routines can be very useful later.

For a long time I kept examples of code written by other people or companies as a resource. After a while you come to realize that most people write code in a similar manner to what I have described above. It may be in a different order, use a lot of different techniques, but the general structure is usually similar. There are always those “job security” rungs you will occasionally run across, but disassembling them into separate rungs is usually not too difficult.

If anyone is fairly new to programming and needs some examples or simple templates let me know and I can help you out.

Happy Automating!


Electrical Engineer and business owner from the Nashville, Tennessee area. I also play music, Chess and Go.

21 Comments on “Ladder Logic 101: Where do I start?

  1. hello Phranc,
    i appreciate a well written article when i see one, and you honestly seem to understand the heart of a novice programmer. i just joined an automation company and working with plcs has been a passion, i know nothing of programming and would be most grateful for any materials or help you can offer. i humbly would subscribe to been your apprentice.

    • Hi Avre, I’m happy to help where I can. What is your most common PLC platform/brand? My background is mostly Allen-Bradley, Siemens, Koyo and I have various samples I can send. I also do some GE, Mitsubishi, Omron but don’t have as many sample programs.

      There is also a website at that has a free download of plc software that allows you to simulate I/O. It looks pretty generic so it would apply somewhat to any platform.

      Let me know what platform you prefer and I will see what I can find to send as an example.

  2. I think “Ladder Logic 101: Where do I start? at AutomationPrimer – An Industrial and Factory Automation Resource” is a useful post and you do a great job of posting detailed information. This is useful for beginners like me. Thom –

  3. Hi Phranc,

    First off, thanks for the great website, it’s exactly what I’ve been looking for.
    So I’m a mechanical guy with limited programming experience. I’ve worked for a custom automation shop and now work for a manufacturing company working on automation projects. I was wondering if you could help me with the project planning and design phase? More specifically going from mechanical concept drawings to a process flow chart and to outlining the ladder program. As you mentioned, I would really appreciate any examples of this you might have. As well as any example templates like the ones you’ve mentioned in your posts about programming.
    I’m working on a project now that is in the concept phase where this would really help me. I think we will be using a Koyo PLC for this.


    • Hi Doug, I will try and round up some templates and samples and send them in the next week or so. In addition I might cover this a little more in this Sunday’s post.

      In general, here is a procedure I generally follow for my projects:
      1. Kick-off meeting and discussion with design team. If a machine layout is available I usually use that and mark it up by hand, taking notes. If not, I use a piece of graph paper and draw a layout myself; I have a shorthand I use. Solid dots for valves, open circles for motors, X for a prox or limit switch, E and a dotted line for a photoeye and arrows for direction of movement. I use this drawing to generate an I/O list.
      2. Timing diagram. I use Excel for this, usually this was generated by the mechanical team. This has a list of actions with a column for actuation time and bars for “on-time” for the actuators. It sort of looks like a Gantt chart with actions starting where others end. This is used as a basis for sequences.
      3. I/O List. Again, I used Excel here. This came from the previous two steps, its important that the names of actuators and devices are firmed up by this time. You can use concatenation to generate tagnames off of your original device names here, i.e. Device_pb, Device_ind, Device_extpx, Device_retpx, Device_fault, etc. If your controller doesn’t use tags, you can do the same thing assigning bit addresses and comments or descriptions. I use the same spreadsheet for fault lists, messages and data collection tags.
      4. Flow chart. I use the IEC 61131 Sequential Function Chart as a basis and create the chart in either Visio or AutoCAD. The components are Steps with their associated actions, transitions with their logic conditions and directional links between steps and transitions.
      5. Program template. This is simply a base program with some simple mode logic (Auto/Manual/Step), a single sample input rung, output rung and fault. These can be duplicated with your IO List. Your sequences are generated with the flow chart which was in turn generated with the timing diagram.

      Depending on the programming software, tags can be copied directly from your I/O list. Some software even allows XML imports which means you can use macros in Excel to actually generate Instruction List code which can be converted to ladder. This can be handy with things that are duplicated like I/O and faults.

      As I mentioned I’ll try and get some sample stuff together and send it. Thanks for checking out the site!

      • Hello Phranc,

        Could you provide an example of the Timing diagram you use. I think it could be helpful. I have the habit to write down a list of actions in order of sequence.
        It becomes dificult when we have to activate two or more actuators at the same time.

        Thanks in advance

        • Hi Gil,

          I looked through my old posts and was surprised to see that I hadn’t really covered it in depth! I did discuss what it is used for and embedded a Gantt picture on my March 25, 2012 post (Design Tools), but never did really cover it as a separate topic. I will try and do that soon.

    • If you want a book, the only choice I’ve found (and it is a good choice) is Gary Kirchof’s Cascading Logic: A Machine Control Methodology for Programmable Logic Controllers from ISA Press.

      It’s definitely pricey, but Amazon and Alibris currently have used copies for <$60.

  4. I have been working with PLC’s for several years. I would like to start writing my own programs. Can you recommend a good book or study guide.


    • There are some decent online resources but they are pretty basic. Much of the subject material can be pretty platform-dependent, i.e. Siemens is different from Koyo is different from Allen-Bradley…. Early on I got a lot out of looking at examples of other people’s programming in whatever platform I was learning. Vendor materials often have some decent examples too. I don’t know of a great generic book that covers much though. Let me know what platform you are using (or thinking of using) and maybe I can post some sample code.

    • Update: I just found a link to a free e-book here. I can’t vouch for how good it might be or whether they spam you once you give them your e-mail address, but hey, its free.

  5. Regarding the electrical schematic of the motor starter circuit (shown above), it would appear to me that the red “stopped” light and the green “running” light are reversed. In other words, the green light should be across the seal-in contacts, and the red light should be down in rung 2. Please let me know if I’m wrong about this. (Excellent PLC training !) Thanks … Bob

    • Hi Bob, and thanks for the comment! This brings up an interesting point about different industries. My background is mostly in machine control, where what you say would be correct. However in process control industries, especially oil and gas, the red light indicates “running” and the green light indicates “safe” or off. I grabbed this circuit off the web several years ago and it probably came from one of those industries. When I teach HMI classes I discuss this with students pretty thoroughly, especially when I have students from different industries in the same class. Thanks for checking out my blog!

  6. Hi Frank:

    Amazing blog, I love it! I would like to start writing my own programs from scratch so I would love to see and study some of the examples that you mention for Allen-Bradley PLCs. The articles are amazing by the way so you just got a fan of the website. Best regards


    • I’m having noise problems on the Automation Direct PLC. Please advise how-to on filtering techniques, thanks!

      • Hi Quy, nice to meet you guys last week in San Diego!

        I’ve decided to address this in two posts; one on Data Acquisition and Analysis, and the next on Data Filtering and Modification. I should have the first one done sometime this week. It will be generic as far as platform, but I’ll try and address the DL205 and its data types and instructions a bit also.

  7. i work with delta plc and i do some projects alone like plastic molding machine ,formaing cutting maching ,blow molding machine ,now isee my self beginer becouse idont know about seimens and allen bradly plc software ,can you help pls

  8. Hi frank, I’ve been trying to learn PLC programming and I end-up knowing the fundamentals and I know how to program small parts of a machine or a production line>> but I get the feeling that my logic is limited and I can not pass this stage … I wanna program bigger projects through examples … so it will be really helpful if you can send me some Sample programs to learn from them … Thanks in advance for any help you can provide.

    • Hi Ibrahim,
      The best way to learn is definitely studying programs after you have the basics down. I do have a few programs I can share, but you would have to have the software to open them. And software isn’t cheap, so people often don’t have their own copy. The only other option would be to print pdfs, which takes a bit more work, since I have to open the program and set up the print. Let me know what platform you use and I’ll see what I can do. I have a lot of Allen-Bradley, both Logix500 and Logix5000, and a decent amount of Siemens Step 7. I could possibly put something together in TIA Portal, but don’t have a lot of factory programs as its a newer platform.

      • Hi Frank,
        First, I would like to thank you for the response. I also would like you to know that i’ve been learning more and more from your articles since I commented here the last time and it helped me a lot. Now for me if I have a pdf version of the software based on a certain platform I would be very thankful for that. Because I can then translate the logic and apply it in other platforms. I’ve been learning on Delta, Siemens (Tia Portal), LS and codesys. I have their software>> so if you can send some real world projects in Pdf, I can put it all together because i’m confused about this step.