Time to use everything you have learned. We will design a small but realistic system the way it is done in industry: specification first, program second, testing third.
1. The specification
A storage tank is filled by a pump and emptied by the process (the “demand”). Write down what must happen in plain language before you touch the software:
- In AUTO mode, when the level falls to the LOW switch, start the pump.
- Keep the pump running until the level reaches the HIGH switch, then stop it.
- Between the two switches, the pump keeps doing whatever it was doing (no short-cycling).
- If the HIGH switch is active, show a high-level lamp.
- When AUTO is off, the pump never runs.
2. The I/O list
| Address | Symbol | Device | Notes |
|---|---|---|---|
| X0 | AUTO_SW | Selector switch on panel | 1 = auto |
| X1 | DEMAND | Process valve open (simulated) | Drains the tank |
| X2 | LS_LOW | Level switch, low | 1 = level at or below low |
| X3 | LS_HIGH | Level switch, high | 1 = level at or above high |
| Y0 | PUMP | Pump contactor coil | Via contactor, never direct |
| Y1 | LAMP_HIGH | Red pilot lamp | High level |
3. The program
The pump rung is a seal-in circuit from lesson 7, with the low switch as “start” and the high switch as “stop”:
LD X0 ; AUTO
LD X2 ; LOW level reached ...
OR Y0 ; ... or pump already running (seal-in)
ANB ; AND the two blocks
ANI X3 ; NOT high level
OUT Y0 ; PUMP
LD X3 ; HIGH level
OUT Y1 ; high-level lamp
The gap between the two switches is called hysteresis, or a deadband. Without it, a pump controlled by a single switch would start and stop many times a minute as the water ripples, wearing out the contactor and the motor. Switch on AUTO and DEMAND below, watch the level fall to LOW, the pump start, and the level rise to HIGH:
Program listing (IL)
LD X0
LD X2
OR Y0
ANB
ANI X3
OUT Y0
LD X3
OUT Y14. Testing it properly
Test every line of the specification, and the things that should not happen:
| Test | Expected |
|---|---|
| AUTO off, level low | Pump stays off |
| AUTO on, level falls to LOW | Pump starts |
| Level rises past LOW but below HIGH | Pump keeps running (seal-in) |
| Level reaches HIGH | Pump stops, lamp on |
| Level falls from HIGH towards LOW | Pump stays off until LOW |
| AUTO switched off while pumping | Pump stops at once |
| HIGH and LOW both on (faulty switch) | Pump off; on a real job, raise a “level switch fault” alarm |
That last line is the kind of test that separates a working program from a reliable one. Ask “what if a sensor fails?” for every input.
5. Troubleshooting like a technician
When a real machine misbehaves, work from the outside in:
- Look at the PLC status lights. RUN on? ERR off? If the CPU is in STOP or fault, read the diagnostic buffer first.
- Check the input LEDs. Operate the device and watch its LED. No LED: the problem is the device, its wiring or its supply.
- Go online with the software and watch the rung. Power flow is highlighted, just like the Ladder Lab. Find the first contact that does not pass power: that is your answer, or the next clue.
- Use cross-reference to find every place a bit is written and read. Duplicate coils show up here.
- Check the output LED, then the field device. Output LED on but the motor is off? Check the contactor coil, the overload relay and the fuse.
Forcing is dangerous. Software lets you force an input or output on, whatever the program says. On a live machine this can move equipment without any of the program’s interlocks. Only force with the machine made safe, and never leave forces on: most PLCs show a FORCE light for this reason.
6. Where to go next
You now understand the foundations that every PLC brand is built on. Good next steps:
- Other IEC 61131-3 languages. Ladder (LD) is one of five. Structured Text (ST) is great for maths and data handling; Function Block Diagram (FBD) suits process control; Sequential Function Chart (SFC) structures step-by-step machines. Instruction List (IL) has been deprecated in the latest edition of the standard.
- A real software package. Free options include OpenPLC Editor and CODESYS; manufacturers offer trial or starter editions of their software.
- Communication. Modbus RTU and TCP are the best first protocols to learn, followed by your region’s common Ethernet networks such as PROFINET or EtherNet/IP.
- HMIs and SCADA to give operators screens, alarms and trends.
- Hands-on hardware. A small compact PLC, a 24 V supply, a few push buttons, a proximity sensor and a pilot lamp will teach you more in a weekend than any amount of reading.
When you have marked every lesson complete, scroll to the course page to claim your certificate of completion. Well done for getting here.
Frequently asked questions
What is hysteresis in level control?
A gap between the start and stop points, here the LOW and HIGH switches. The pump starts at one level and stops at another, which prevents rapid on/off cycling.
What is the first thing to check when a PLC-controlled machine stops?
The PLC status lights and the input LEDs. They tell you within seconds whether the problem is the controller, the field wiring or the program logic.
