50 PLC Programming Practice Exercises (Beginner to Advanced)
Fifty hands-on PLC practice exercises organized by difficulty — basic logic, timers and counters, sequencing, analog control, and full project briefs — each with the concept it drills and hints for ladder logic and structured text.
How to use these exercises
Reading about PLC programming doesn't make you a PLC programmer — writing programs does. The fifty exercises below work in any environment: ladder logic or structured text, Siemens, Allen-Bradley, Codesys, OpenPLC, or a browser simulator. The logic is the point, not the brand.
Do them in order — each level builds on the last, and the project briefs at the end combine everything. For every exercise, write the I/O list first: name your inputs and outputs before you touch a rung. That single habit separates programmers who plan from programmers who flail.
If you're setting up an environment from scratch, see how to practice PLC programming at home. When an exercise has a fully worked solution on this site, it's linked — but attempt it yourself first. You can also browse the full library of worked PLC examples and run everything in one of the free PLC simulators we've reviewed.
Level 1: Basic logic (exercises 1–12)
These drill the fundamentals: contacts, coils, and the boolean thinking behind every PLC program ever written.
Exercise 1 — Start/stop with seal-in. A momentary Start_PB starts Motor_Run; a momentary Stop_PB stops it. The motor must stay running after Start_PB is released. Concept drilled: the seal-in (latching) rung — the single most common pattern in industrial control.
Exercise 2 — AND logic. Conveyor_Run energises only when Guard_Closed AND Material_Present AND Start_PB are all true. Concept drilled: series contacts / the AND operator.
Exercise 3 — OR logic. Alarm_Horn sounds when Temp_High OR Pressure_High OR Manual_Test_PB is true. Concept drilled: parallel branches / the OR operator.
Exercise 4 — NOT and combinations. Heater_On energises when Thermostat_Demand is true AND Door_Open is false AND (Day_Mode OR Override_SW) is true. Concept drilled: combining AND, OR, and NOT in one rung.
Exercise 5 — NC versus NO thinking. Rewrite Exercise 1 assuming Stop_PB is a physically normally-closed pushbutton wired to the input. The motor must stop if the stop-button wire breaks. Concept drilled: fail-safe wiring versus program logic — why stop circuits use NC contacts.
Exercise 6 — Mutual exclusion interlock. Motor_A_Run and Motor_B_Run each have their own start/stop buttons, but they must never run at the same time. Starting one while the other runs does nothing. Concept drilled: cross-interlocking with each output's contact in the other's rung.
Exercise 7 — Two-out-of-three voting. Three sensors Sensor_1, Sensor_2, Sensor_3 watch the same condition. Trip_Output energises when any two or more agree. Concept drilled: voting logic — used in safety and redundant instrumentation.
Exercise 8 — Latch and unlatch. Fault_Lamp is set by a momentary Fault_Input pulse and stays on until Reset_PB is pressed, using set/reset (latch/unlatch) instructions instead of a seal-in. Concept drilled: SET/RESET coils and how they differ from a seal-in across power cycles.
Exercise 9 — Rising-edge one-shot. Each press of Count_PB produces exactly one scan of Pulse_Out, no matter how long the button is held. Concept drilled: edge detection (one-shot / R_TRIG) and scan-cycle awareness.
Exercise 10 — Alternating outputs on one button. A single Toggle_PB alternates Lamp_Out on, off, on, off with each press. Concept drilled: toggle (flip-flop) logic built from a one-shot and a feedback bit.
Exercise 11 — Alarm with acknowledge. When Level_High goes true, Alarm_Horn and Alarm_Lamp both energise. Ack_PB silences the horn but the lamp stays on until the condition clears. Concept drilled: separating annunciation state from process state — basic alarm handling.
Exercise 12 — Guard-door permissive and lamp test. Machine_Enable requires Guard_Closed and EStop_Healthy. Add a Lamp_Test_PB that forces every indicator lamp in the program on simultaneously without affecting machine outputs. Concept drilled: permissive chains and the universal lamp-test pattern. Bonus: add jog versus run — Jog_PB runs the motor only while held, bypassing the seal-in.
Level 2: Timers and counters (exercises 13–24)
Almost every real machine is full of timers. These twelve exercises cover the patterns you'll use weekly on the job.
Exercise 13 — Delayed start (TON). Pressing Start_PB energises Warning_Beacon immediately and Conveyor_Run 5 seconds later. Concept drilled: on-delay timer driving a staged start.
Exercise 14 — Run-on fan (TOF). Fan_Run follows Heater_On, but keeps running for 60 seconds after the heater turns off to purge residual heat. Concept drilled: off-delay timer behaviour.
Exercise 15 — Flasher. Beacon_Out flashes 0.5 s on / 0.5 s off whenever Fault_Active is true. Build it from two timers, not a built-in pulse generator. Concept drilled: the classic two-timer oscillator.
Exercise 16 — Star-delta starter timing. Inputs: Start_PB, Stop_PB. Outputs: Main_Contactor, Star_Contactor, Delta_Contactor. On Start_PB: energise Main_Contactor and Star_Contactor; after 8 seconds drop Star_Contactor, wait 100 ms, then energise Delta_Contactor. Star and delta must be interlocked against each other. Pressing Stop_PB at any point de-energises all three contactors immediately. Concept drilled: timed sequencing with a transition deadband — a real motor-starter requirement.
Exercise 17 — Pulse stretcher. Photo_Eye pulses may be as short as 20 ms. Produce Detect_Out that holds true for at least 2 seconds per detection. Concept drilled: capturing fast inputs and stretching them for slow downstream logic.
Exercise 18 — Parts counter with reset. Count rising edges of Part_Sensor into Parts_Count. Batch_Done energises at 24 parts; Reset_PB zeroes the count. Concept drilled: CTU basics and counter reset discipline.
Exercise 19 — Room occupancy (CTU/CTD pair). Entry_Sensor increments and Exit_Sensor decrements Occupancy_Count. Lights_On is true whenever the count is above zero; Full_Lamp at 50. Concept drilled: up/down counting against the same accumulator.
Exercise 20 — Reject counter with batch limit. Count Reject_Sensor pulses. If rejects reach 5 within a single batch (batch ends on Batch_Complete), latch Quality_Fault and stop Line_Run. Concept drilled: counters combined with latching fault logic.
Exercise 21 — Hour meter. Accumulate total running time of Motor_Run in Run_Hours, persisting across motor stop/start. Trigger Service_Due at 500 hours. Concept drilled: cascading a timer into a retentive counter or accumulator.
Exercise 22 — Watchdog timeout alarm. Heartbeat_In from a remote device should pulse at least every 3 seconds. If it doesn't, latch Comms_Fail_Alarm. Concept drilled: a timer that's continuously reset by a healthy signal — the watchdog pattern.
Exercise 23 — Debounce. Limit_Switch chatters mechanically. Produce Limit_Debounced that only changes state after the raw input has been stable for 200 ms in either direction. Concept drilled: symmetric debounce with two timers.
Exercise 24 — Cycle-time measurement. Measure the time between consecutive rising edges of Cycle_Start and store it in Cycle_Time_ms. Flag Slow_Cycle if it exceeds 12 seconds. Concept drilled: using a free-running timer as a stopwatch and capturing its value on an event.
Level 3: Sequencing and state logic (exercises 25–34)
This is where beginners plateau. Machines are state machines; learn to program them as such instead of stacking seal-ins until nothing works.
Exercise 25 — Traffic light. A single intersection light cycles green 20 s → yellow 4 s → red 24 s, forever, starting on System_Enable. Outputs: Green_Lamp, Yellow_Lamp, Red_Lamp. Compare your attempt against the worked solution. Concept drilled: a timed circular state machine with a step register.
Exercise 26 — Pedestrian request extension. Extend Exercise 25: Ped_Request_PB causes the next red phase to include a Walk_Lamp period of 10 s. Requests during the walk phase are remembered for the next cycle, not lost. Concept drilled: request memory feeding a state machine.
Exercise 27 — Conveyor photo-eye sort. Height_Eye detects tall products on a running conveyor; a downstream Diverter_Sol must fire when that specific product arrives 1.5 s later. Check the worked solution after your attempt. Concept drilled: time-based tracking between detection point and action point.
Exercise 28 — Batch mixer sequence. On Batch_Start: open Valve_A until Level_Mid, then Valve_B until Level_High, run Mixer_Motor 90 s, then open Drain_Valve until Level_Empty. Any EStop aborts to a safe state. Worked through fully in the worked solution. Concept drilled: sequential function thinking — steps, transitions, and abort paths.
Exercise 29 — Parking gate state machine. Ticket_Taken raises Gate_Up; Vehicle_Loop clearing after passage lowers it. The gate must never lower onto a vehicle present on the loop. See the worked solution. Concept drilled: explicit states (closed, opening, open, closing) with guarded transitions.
Exercise 30 — Shift-register product tracking. Products on an indexing conveyor pass Inspect_Station (sets a reject flag) and reach Reject_Station four index positions later, where Reject_Pusher fires only for flagged products. Each rising edge of Index_Pulse advances the shift register one position. Concept drilled: bit shift registers synchronised to machine movement — the position-based alternative to Exercise 27's timing approach.
Exercise 31 — First-out alarm annunciator. Four fault inputs Fault_1–Fault_4 each drive a lamp, but the lamp of whichever fault occurred first flashes while the others burn steady. Reset_PB clears everything once all faults are gone. Concept drilled: capturing event order — essential for root-cause troubleshooting.
Exercise 32 — Sequence with step timeout fault. Take your Exercise 28 mixer and add a per-step timeout: if any step fails to reach its transition condition within its expected time, latch Seq_Fault with Fault_Step_Num recording where it stalled. Concept drilled: making sequences self-diagnosing instead of silently hanging.
Exercise 33 — Manual/auto mode transfer. Mode_Auto_SW selects between automatic sequencing and manual pushbutton control of each actuator. Transfer must be bumpless: switching to auto mid-cycle must not jump actuators or restart the sequence from step one. Concept drilled: mode management — one of the hardest things to retrofit, so practise it early.
Exercise 34 — Recipe step skip. Add a Recipe_Select integer to the mixer: recipe 1 runs all steps; recipe 2 skips the Valve_B addition entirely. The sequence logic must handle the skipped step without stalling. Concept drilled: data-driven sequences and conditional transitions.
Level 4: Analog and process control (exercises 35–43)
Discrete logic gets you a job; analog handling keeps it. These exercises cover scaling, signal conditioning, and closed-loop control.
Exercise 35 — Scale 4–20 mA to engineering units. AI_Raw reads 0–27648 (or your platform's range) for a 4–20 mA pressure transmitter spanning 0–10 bar. Compute Pressure_Bar as a REAL. Concept drilled: linear scaling — the y = mx + c of every analog input.
Exercise 36 — Out-of-range sensor fault. Extend Exercise 35: if AI_Raw corresponds to under 3.6 mA or over 20.5 mA, latch Sensor_Fault and substitute a configurable fallback value into Pressure_Bar. Concept drilled: broken-wire detection and fail-safe substitution on analog channels.
Exercise 37 — Tank level hysteresis control. Start Fill_Pump when Tank_Level drops below 20% and stop it above 80%. No relay chatter near either threshold. Compare with the worked solution. Concept drilled: hysteresis (deadband on/off control) — the simplest closed loop there is.
Exercise 38 — PID flow loop. Control Pump_Speed_Out (0–100%) so Flow_PV tracks Flow_SP using your platform's PID instruction. Include manual mode with bumpless transfer back to auto. The worked solution walks through tuning. Concept drilled: configuring and tuning a PID block on a fast loop.
Exercise 39 — Deadband on a noisy signal. Temp_PV jitters ±0.3 °C. Produce Temp_Display that only updates when the input moves more than 0.5 °C from the last displayed value. Concept drilled: deadband filtering for HMI and alarm stability.
Exercise 40 — Rate-of-change limit. Setpoint_In may step instantly, but Setpoint_Ramped must move toward it at no more than 2.0 units per second. Concept drilled: ramping — protecting equipment from step changes, and a building block of every soft-start.
Exercise 41 — INT↔REAL conversion and rounding. Take Weight_Real (e.g. 12.3456 kg), produce Weight_Display as an INT in grams, correctly rounded, and detect overflow if the value exceeds the INT range. Concept drilled: type conversion, rounding versus truncation, and overflow traps.
Exercise 42 — Flow totalizer. Integrate Flow_PV (m³/h) into Total_m3, accumulating every scan or on a fixed time base. Total_Reset_PB zeroes it; the total must survive a power cycle. Concept drilled: numerical integration on a scan-based controller and retentive data.
Exercise 43 — Alarm bands. From Level_PV generate Level_H at 80%, Level_HH at 92%, and Level_L at 15%, each with 2% hysteresis and a 3-second on-delay to ride through splashing. Level_HH latches until acknowledged. Concept drilled: layered analog alarming with hysteresis and time qualification.
Level 5: Project briefs (exercises 44–50)
These are full mini-projects. Write the I/O list, sketch the state diagram, then program it. Budget an evening each.
Exercise 44 — Car wash sequence. Inputs: Vehicle_In_Position, Token_Accepted, Start_PB, EStop. Outputs: Pre_Soak_Valve, Brush_Motor, Rinse_Valve, Dryer_Fan, Exit_Lamp. Run pre-soak 15 s, brushes 40 s, rinse 20 s, dryer 30 s, then light Exit_Lamp. The cycle starts only with a token and a vehicle in position; EStop aborts everything; a new cycle can't start until the vehicle leaves position. Concept drilled: a complete timed sequence with start permissives and abort handling.
Exercise 45 — Pedestrian crossing with button memory. Inputs: Ped_PB_North, Ped_PB_South, System_Enable. Outputs: Traffic_Green, Traffic_Yellow, Traffic_Red, Walk_Lamp, Dont_Walk_Lamp, Dont_Walk_Flash. Traffic holds green until a pedestrian request, then yellow 4 s, red, walk 8 s, flashing don't-walk 6 s, back to green. Requests during any phase are remembered; a minimum green of 20 s prevents constant interruption. Concept drilled: request queuing against a minimum-dwell state machine.
Exercise 46 — Silo fill with dust-purge interlock. Inputs: Tanker_Connected, Silo_Level_HH, Filter_DP_High, Fill_Request_PB. Outputs: Fill_Valve, Purge_Fan, Fill_Permit_Lamp, HH_Horn. Filling is permitted only when the tanker is connected, the purge fan has run for 30 s beforehand, and Silo_Level_HH is clear. Silo_Level_HH or Filter_DP_High during filling closes Fill_Valve immediately and sounds the horn; the fan runs on 60 s after any fill. Concept drilled: pre-conditions, run-on, and hard process interlocks layered on one operation.
Exercise 47 — Duty/standby pump alternation. Inputs: Demand_On, Pump_1_Fault, Pump_2_Fault. Outputs: Pump_1_Run, Pump_2_Run, Both_Fault_Alarm. One pump runs on demand; the lead role alternates on every new demand cycle to equalise wear. A faulted pump is skipped and the healthy one takes over mid-run; both faulted raises the alarm. Concept drilled: role swapping, fault failover, and run-time balancing.
Exercise 48 — HVAC zone control. Inputs: Zone_Temp (analog), Occupancy_Sensor, Window_Open_SW. Outputs: Heating_Valve (0–100%), Cooling_Valve (0–100%), Fan_Run. Maintain 21 °C occupied / 17 °C setback unoccupied, with a dead zone so heating and cooling never fight, and full lockout while the window is open. Attempt it, then study the worked solution. Concept drilled: dual-actuator analog control with mode-dependent setpoints.
Exercise 49 — 3-floor elevator logic. Inputs: Call_PB_1–Call_PB_3, Floor_Sensor_1–Floor_Sensor_3, Door_Closed_SW. Outputs: Motor_Up, Motor_Down, Door_Open_Cmd, Floor_Lamp_1–Floor_Lamp_3. Service calls in the current direction of travel before reversing; never move with the door open; remember calls pressed while moving; time the door open for 5 s at each served floor. Concept drilled: directional request arbitration — a classic that exercises everything from Levels 1–3 at once.
Exercise 50 — Bottling line with reject station. Inputs: Bottle_Present_Eye, Fill_Level_Eye, Cap_Present_Eye, Line_Start_PB, Line_Stop_PB. Outputs: Conveyor_Run, Filler_Valve, Capper_Sol, Reject_Pusher, Reject_Full_Alarm. Index bottles through fill and cap stations; track underfilled or uncapped bottles in a shift register to the reject station three positions downstream; count rejects and alarm at 10 in the reject bin. Concept drilled: the full package — sequencing, shift-register tracking, counting, and alarming in one machine.
What to do when you're stuck
Every exercise here will fight back at some point. When it does, debug methodically instead of randomly editing rungs.
First, simulate inputs one at a time and watch what each rung actually does — not what you think it does. Most "broken" programs are doing exactly what they were told. Second, think in scan cycles: the PLC evaluates top to bottom, and a bit you write in rung 40 isn't seen by rung 3 until the next scan. One-shots, toggles, and shift registers all live or die on this. If that model is fuzzy, read the PLC scan cycle explainer before going further. Third, split complex rungs: move each condition to its own internal bit, watch the bits live, and the failing condition identifies itself.
For a deeper systematic method — including how to attack hardware-side problems once your logic is clean — work through the complete PLC troubleshooting guide.
FAQ
What order should I do these in?
Straight through, 1 to 50. The levels are cumulative: timers assume solid contact logic, sequencing assumes timers and one-shots, and the project briefs assume all of it. If a Level 3 exercise feels impossible, that's a signal to redo a few Level 1–2 exercises until the patterns are automatic, not a reason to skip ahead.
Should I practice in ladder logic or structured text?
Start in ladder — it's still the dominant language on plant floors and the one you'll troubleshoot in. Once an exercise works in ladder, rewriting it in structured text is excellent second-pass practice: the analog exercises (35–43) in particular are often cleaner in ST. Knowing both makes you more employable than mastering either alone.
Where can I run these without a PLC?
You don't need hardware for any of these. A browser-based simulator gets you writing rungs in minutes with zero installation, and desktop options like Codesys or OpenPLC are free for personal use. We've compared the realistic options — what each one simulates well and where each falls short — in our roundup of free PLC simulators.


