Single Push Button Toggle
One momentary button turns a light on with the first press and off with the next, like the push-on, push-off work light on a lathe. The hard part is the pulse. A plain contact of the button is TRUE on every scan you hold it, and a 150 ms press on a 10 ms scan is 15 scans, so the light would flip 15 times and stop wherever it happened to be. Rungs 1 and 2 build a one-shot from two memory bits: M0.1 holds what the button was on the previous scan, so M0.0 is TRUE only on the scan where the button has just gone ON. Rung 3 uses that pulse to flip Q0.0. Rung order is the trap. Move rung 2 above rung 1 and M0.1 is already TRUE when rung 1 reads it, so the pulse never fires. The P contact in TIA Portal, ONS in Studio 5000 and the R_TRIG block each do the job of rungs 1 and 2 in one element.
TRY ITSwitch I0.0 ON: the light comes on. Switch I0.0 OFF and nothing changes. Switch it ON again and the light goes off. M0.1 follows the button, written after rung 1 has used it. M0.0 is TRUE for exactly one scan. The card scans every 100 ms, so it only flickers; on a real PLC with a 10 ms scan you would never see it lit.
AND Logic Gate
Contacts in series are an AND: power reaches the coil only when every contact in the line is closed. Here a discharge gate under a bin opens only when a truck is in position below the chute (I0.0) and the operator asks for a discharge (I0.1). Each extra condition is one more contact in the line, which is why rungs on a real machine often carry six or eight in a row. When one of those rungs will not energise, go online and find the first contact from the left that is not passing power. That is the missing condition, and it is usually quicker than reading the logic.
TRY ITSwitch on I0.0 alone, then I0.1 alone, then both. Only the last case energises Q0.0. With both on, switch either one off and the coil drops at once.
OR Logic Gate
Branches in parallel are an OR: the coil energises when any one branch closes. The usual reason is two places to do the same thing, such as a jog button on the main panel and a second one on a pendant at the far end of a long conveyor. The coil does not record which branch carried the power. If you need to know who asked, for an event log or a fault message, give each input its own rung and its own bit.
TRY ITSwitch on I0.0 alone and watch the power take the top branch. Switch it off and try I0.1. Then turn both on: the coil looks exactly as it did with one, so the output cannot tell you which input did it.
Seal-In (Latch) Circuit
The three-wire start/stop, the same circuit an electrician builds with a contactor and its auxiliary contact. START is a normally open button, so I0.0 is TRUE only while you press it. The parallel contact of Q0.0 keeps the rung powered after you let go; that is the seal. STOP is a normally closed button, so I0.1 is TRUE while nobody touches it, and the rung reads it with a normally open contact. Pressing STOP, a broken wire and a blown input fuse all make I0.1 FALSE, and all three stop the motor. The contact symbol says how the program reads the bit, not how the button is built: draw STOP as an NC contact here and the motor would run only while STOP is held down. After a power cut the motor stays off, because Q0.0 comes up FALSE and the seal has nothing to hold.
TRY ITSwitch I0.1 ON first: that is the stop button, closed and healthy. Tap START and let go (I0.0 ON, then OFF). The motor stays on because the coil now feeds its own rung through the seal-in contact. Switch I0.1 OFF to press STOP and back ON again: the motor stays off until you press START.
Set / Reset Coils: Latch Without a Seal-In
The same start/stop as the seal-in rung, written with a set coil and a reset coil. A set coil writes TRUE when its rung has power and writes nothing when it has not, so the bit stays TRUE after START is released. A reset coil writes FALSE the same way. STOP is again a normally closed button, so the reset rung reads I0.1 with an NC contact: it resets the motor when the input is FALSE, which covers a pressed button and a broken wire alike. When both rungs have power in the same scan, the bit ends the scan with whatever the lower rung wrote, so put the reset below the set if stop must win. Studio 5000 calls these OTL and OTU. On a large program the trap is a bit set in one place and reset in three others; when a motor will not stop, open the cross-reference and find every write to it.
TRY ITSwitch I0.1 ON first (stop button healthy). Tap START and let go: the motor stays on with no seal-in contact anywhere. Switch I0.1 OFF to stop it. Then leave I0.0 ON and switch I0.1 OFF again: the motor stays off, because the reset rung runs last.
Safety Interlock
On this press the e-stop buttons and the guard switch are wired to a safety relay, and the relay's safety outputs sit in the motor contactor's coil circuit. That hardware is the safety function, designed and validated to ISO 13849-1 or IEC 62061; this rung is not. The PLC reads one status signal from the relay on I0.0 and uses it to drop the run latch. Without it, Q0.0 would stay TRUE through an e-stop, and the press would restart the moment someone reset the relay. With I0.0 in series, the latch drops when the safety circuit opens and the operator has to press START again. Every input here is read with a normally open contact because each one is TRUE when healthy: the relay status is ON while the safety circuit is closed, and STOP is an NC button. A cut wire makes any of them FALSE and drops the rung. That fail-safe behaviour comes from the field wiring; draw NC contacts in the program instead and a cut wire would look like a permit.
TRY ITSwitch I0.0 and I0.1 ON (safety circuit closed, stop button healthy), then tap START on I0.2. Switch I0.0 OFF, as an e-stop press would, and back ON as the reset: the motor stays off until you press START again.
Pump Start and Run Permissives
A permissive is a condition the logic needs before it runs something, and where you put its contact decides when it is checked. The discharge-valve-closed switch sits in the START branch, next to the button, so it is checked only at the moment of starting. A radial centrifugal pump started against a closed discharge valve draws the least power during run-up, and once the seal-in branch carries the rung the valve can open without stopping the pump. The suction-level switch sits in series after the branches, so it is checked on every scan, and the pump stops before it runs dry. Put the valve contact in series by mistake and the pump trips the moment the operator opens the valve. When the level comes back the pump stays off, because the seal has gone. A pump that has just lost suction should wait for someone to look at it.
TRY ITSwitch on I0.1 (stop healthy), I0.3 (suction level OK) and I0.2 (valve closed), then tap START on I0.0. Switch I0.2 OFF as the valve opens: the pump keeps running. Switch I0.3 OFF: it stops, and switching I0.3 back ON does not restart it.
Forward / Reverse Motor Interlock
A reversing starter swaps two phases with a second contactor, and if both contactors close together they short those two phases. Each rung here carries an NC contact of the other direction's output, so the PLC never asks for reverse while forward is on. That is half the interlock. The other half is in the panel: an auxiliary NC contact of each contactor wired in series with the other contactor's coil, and usually a mechanical interlock between the pair. Keep both. The PLC sees its own output bit, not the contactor, and a contactor with welded tips stays closed while Q0.0 reads FALSE. With this logic the operator has to press STOP before changing direction, which also saves a conveyor gearbox from being thrown from full speed one way straight into the other. If both buttons arrive in the same scan, forward wins: rung 1 runs first, and rung 2 already sees Q0.0 TRUE.
TRY ITSwitch I0.2 ON (stop healthy) and tap FWD on I0.0. Now tap REV on I0.1: nothing happens, because the NC contact of Q0.0 is open in rung 2. Switch I0.2 OFF to stop, back ON, and tap REV again: reverse starts.
First-Out Trip Alarm
When a compressor trips, one fault stops it and others follow. Oil pressure falls as the machine runs down, so a panel that latches every alarm shows LOW OIL PRESSURE beside the real cause, and someone changes an oil pump that was fine. A first-out latches only the first trip. Each set rung carries NC contacts of all three first-out lamps, so once any lamp is on, no other can set. Two trips that arrive in the same scan go to the higher rung; if that is not good enough, the trips need time-stamping at the input card. In this example each input is TRUE while its trip is active. On a real panel trip switches usually open on a fault, so you would read them with NC contacts, and the first-out logic stays the same. Acknowledge after the trips have cleared: with a trip still active, the first-out latches again as soon as ACK is released.
TRY ITSwitch I0.1 ON (high temperature trips first), then I0.0 and I0.2. Only Q0.1 lights. Switch all three trips OFF and tap ACK on I0.3 to clear it, then trip them in a different order.
TON Timer: On-Delay Motor Start
TON makes a condition prove itself for a set time before anything happens. Here the motor starts only after the run request on I0.0 has been TRUE for 5 s without a break. While IN is TRUE, ET counts up; when ET reaches PT, Q goes TRUE and stays TRUE for as long as IN does. Drop IN for a single scan and ET goes back to zero, so a flickering signal never gets there. The same rung debounces a float switch that splashes, and gives a lube pump time to build pressure before the main drive starts. The trap is wanting the time to add up across interruptions: TON cannot do that. You need a retentive timer, TONR in TIA Portal or RTO in Studio 5000.
TRY ITGo online (the OFFLINE button in the header), switch I0.0 ON and watch ET climb toward 5 s. Switch it OFF at about 3 s: ET drops to zero. Switch it ON again and leave it: Q0.0 comes on at 5 s and goes off the moment I0.0 does.
CTU Counter: Part Counter
A proximity sensor gives one pulse per part, and CTU adds one to CV on each rising edge at CU. When CV reaches PV (10 here), Q goes TRUE: the box is full, change it. CU counts edges, so a part that stops in front of the sensor counts once however long it sits there. R puts CV back to zero, usually from the box-change sensor or an operator reset. CV does not stop at PV; it keeps counting until something resets it. Test the full box with Q, which stays TRUE from 10 upwards. A comparison of CV = 10 goes FALSE again when part 11 arrives. Also watch for a sensor that bounces on a shiny or ribbed part: it gives two edges and counts two parts.
TRY ITGo online. Switch I0.0 ON and OFF ten times and watch CV climb; Q0.0 comes on at 10. Leave I0.0 ON for a while and CV does not move. Count past 10 and CV keeps going while Q0.0 stays on. Switch I0.1 ON to reset.
R_TRIG: Rising Edge Detection
A button held for half a second is TRUE for 50 scans of a 10 ms program. R_TRIG turns that into one TRUE scan at the moment of the press: Q is TRUE when CLK is TRUE now and was FALSE on the previous scan. Use the pulse wherever something must happen once per press, such as adding one to a total, moving a sequence on one step or taking one sample. Each instance keeps its own memory of the previous scan, so give every signal its own R_TRIG instance. Call one instance from two places and each call overwrites the memory the other relies on, and edges go missing. The card holds the pulse on screen for a few ticks so you can see it; in a PLC it lasts exactly one scan.
TRY ITGo online and switch I0.0 ON. M0.0 flashes once and goes out while I0.0 is still ON. Switch I0.0 OFF: nothing happens. Only the next OFF to ON change fires it again.
TOF Timer: Off-Delay Fan Cooldown
TOF is the run-on timer. Q goes TRUE as soon as IN does. When IN drops, ET starts counting, and Q stays TRUE until ET reaches PT (10 s here). If IN comes back before then, ET resets, and the full run-on starts again the next time IN drops. Here the motor-run signal keeps a cooling fan going for 10 s after the motor stops, to carry away the heat that soaks out of the windings. Dust extraction on a saw works the same way, running on to clear the duct. At power-up TOF's Q is FALSE, so there is no run-on until IN has been TRUE at least once.
TRY ITGo online. Switch I0.0 ON: the fan starts at once. Switch it OFF and watch ET count while Q0.1 stays on, then drops at 10 s. Run it again and switch I0.0 back ON halfway through the run-on: ET goes back to zero.
CTUD Counter: Bi-directional Parking Counter
Cars driving in cross a loop detector on CU (I0.0) and cars driving out cross one on CD (I0.1), so CV is the number of cars inside. QU goes TRUE when CV reaches PV, 50 spaces here, and lights the FULL sign. QD is TRUE while CV is zero or less. R (I0.2) clears the count to zero and beats every other input while it is held. CV does not stop at PV: a CTUD keeps counting up to the limit of its data type with QU still TRUE, so a car park that lets a car in past FULL still knows how many are inside. The trap is drift: one missed loop pulse or one double count and CV is wrong until someone corrects it. That is what the LD input is for: it loads PV into CV, and an HMI entry can set PV to the number of cars actually inside.
TRY ITGo online. Pulse I0.0 a few times to bring cars in, then pulse I0.1 to let some out, and watch CV follow. Switch I0.2 ON and pulse I0.0: CV stays at 0 while the reset is held.
Timer + Counter: Timed Batch with Auto-Reset
A heat sealer has to hold its jaws shut for 2 s to make a good seal. The jaws-closed switch drives a TON, and the TON's Q is the CU input of a counter, so the counter counts only seals that lasted the full dwell. A seal cut short never produces a Q and is never counted. After five good seals Q0.0 says the batch is done. The timer resets itself each time the jaws open, because a TON goes back to zero when IN drops, so every seal is timed from zero. The counter does not reset itself: I0.1 clears it for the next batch. Jaws held shut for 10 s still count as one seal, since CU counts the rising edge of the timer's Q and not how long it stays TRUE.
TRY ITGo online. Switch I0.0 ON, wait for the timer to finish (CV goes to 1), then switch it OFF. Do it again but switch OFF after one second: CV does not move. Five full seals light Q0.0; I0.1 clears the count.
F_TRIG: Falling Edge Detection
F_TRIG is R_TRIG in the other direction: one TRUE scan when CLK goes from TRUE to FALSE. Use it when the moment that counts is the end of something. The trailing edge of a carton leaving a photo-eye is where a label applicator fires, because by then the whole carton has passed the sensor. A falling edge also fires when a signal is lost through a broken wire or a tripped input fuse, so if a wire fault on that input would do harm, check the signal's health as well before acting on the edge. One instance per signal, as with R_TRIG.
TRY ITGo online. Switch I0.0 ON and leave it: nothing happens. Switch it OFF: M0.0 pulses once.
TP Timer: Pulse Generator
TP turns a rising edge into a pulse of fixed length. When IN goes TRUE, Q goes TRUE for exactly PT (3 s here) whatever IN does next: a short tap still gives 3 s, and another press during the pulse does not restart it. That makes it the timer for outputs that must last the same time every cycle, such as a 3 s warning horn before a conveyor starts or an air blast to clear a chute. If IN is still TRUE when the pulse ends, Q goes FALSE and stays FALSE until IN drops and rises again. Because TP never retriggers, it cannot keep something running while parts keep arriving; for that you want a TOF.
TRY ITGo online, switch I0.0 ON and straight back OFF: Q0.0 still runs the full 3 s. Then switch I0.0 ON and leave it on: the pulse ends at 3 s anyway.
CTD Counter: Countdown Dispenser
CTD counts down. LD loads CV with PV (8 here), each rising edge at CD takes one off, and Q is TRUE while CV is zero or less. Here a dispenser filled with eight doses counts one off per dispense, and REFILL REQ comes on when it is empty. Use CTD when the number the operator wants is what is left. The trap is the start: after a power-up or a download CV is 0, so Q is TRUE and the refill request is on before anything has been dispensed. Load the counter when the dispenser is refilled and the request clears.
TRY ITGo online: REFILL REQ comes on straight away, because CV starts at 0. Switch I0.1 ON and OFF to load 8. Then pulse I0.0 eight times and watch CV fall to 0 and REFILL REQ come back.
GT Comparison: Over-Temperature Alarm
A comparison box is how an analog value reaches a rung of contacts. GT passes power when IN1 is greater than IN2. Here IW0 holds an oil temperature in tenths of a degree, so 850 means 85.0 °C, and the alarm comes on above that. The box compares plain numbers and knows nothing about units, so check the input's scaling before you trust the limit: a Siemens analog input in its nominal range reads 0 to 27648, not 0 to 100. The trap is a reading that hovers on the limit. One or two counts of noise make the alarm chatter on and off. Give it hysteresis (a second, lower limit to clear) or an on-delay.
TRY ITGo online and switch I0.0 ON. Set IW0 to 850: no alarm, because 850 is not greater than 850. Set 851 and Q0.0 comes on.
ADD: Speed Offset Calculation
Math boxes work on whole words. ADD puts IN1 + IN2 on OUT: here a base speed in MW10 plus an operator trim in MW12, the trim a line uses to keep two conveyors in step. The rung contact is the box's enable. While I0.0 is TRUE the box calculates on every scan; while it is FALSE the box does nothing and OUT keeps its last value. That catches people out, because dropping the enable does not zero the speed reference. If the output must go to zero when the line stops, write a 0 to it in another rung. The coil after the box shows ENO, which is TRUE when the box ran without an error. An INT holds -32768 to 32767, so a bigger sum overflows on a PLC; this simulator does not model that.
TRY ITGo online and switch I0.0 ON. Set MW10 to 1200 and MW12 to 50: OUT shows 1250. Switch I0.0 OFF and change MW12: OUT stays at 1250.
MOV: Register Transfer
MOVE copies IN to OUT while the rung has power. It is how a value gets to the place that reads it: a recipe setpoint into a temperature controller's setpoint word, a preset into a timer, a selected speed into a drive. Put MOVE boxes on two rungs with different enables and you have a selector, because whichever rung has power writes the destination. If both have power in one scan the lower rung wins, and if neither does, the destination keeps the last value written. TIA Portal calls the box MOVE and Studio 5000 calls it MOV.
TRY ITGo online, set MW20 to 75 and switch I0.0 ON: OUT shows 75. Switch I0.0 OFF and change MW20 to 90: OUT keeps 75 until the rung has power again.
SUB + LT: Low Level Detection
Two boxes on one rung: SUB works out what is left in a day tank and LT judges it. MW30 is the level in litres when the batch started and MW32 is what has been drawn off since. LevelCalc.OUT is the difference, and LT passes power when that is below 100 L. The value travels along the rung from one box to the next, which is the shape of most analog logic: calculate, then compare. The trap is the enable in front. When I0.0 is FALSE neither box runs and the alarm is off, whatever is in the tank. Think hard before you put an enable contact ahead of an alarm.
TRY ITGo online, switch I0.0 ON, set MW30 to 500 and raise MW32. At 401 the remainder is 99 and LOW ALARM comes on. Switch I0.0 OFF: the alarm goes out although the tank is still low.
MUL: Speed Scaling
MUL puts IN1 × IN2 on OUT. Here MW10 is a speed setpoint in rpm and MW12 a whole-number ratio, and OUT is the speed the next axis should run at. Integer maths is where this goes wrong. A ratio of 3.5 cannot live in an INT, so either work in REAL or multiply by 35 and then divide by 10, multiplying first so the fraction is not lost. And an INT stops at 32767: 1500 rpm × 30 is 45000, which overflows on a PLC. The simulator shows 45000, so do the range check yourself.
TRY ITGo online, switch I0.0 ON, set MW10 to 1500 and MW12 to 3: OUT shows 4500. Then set MW12 to 30 and work out why a real INT could not hold the answer.
DIV: Flow Rate Calculation
DIV puts IN1 / IN2 on OUT: the litres delivered in MW20 divided by the minutes it took in MW22 gives litres per minute. When IN2 is zero there is no answer, and the box reports it by switching ENO off, so CALC OK drops while I0.0 is still ON. What a real CPU does beyond that depends on the vendor and the data type, and some stop or log a fault. Do not find out on site: guard the divisor, as the ST below does. With INT operands the remainder is dropped, so 125 / 4 gives 31, here and on a PLC.
TRY ITGo online, switch I0.0 ON, set MW20 to 600 and leave MW22 at 0: CALC OK stays off. Set MW22 to 5: OUT shows 120 and CALC OK comes on.
EQ: Setpoint Match
EQ passes power only while IN1 equals IN2 exactly. That is the right test for numbers that move in whole steps: a sequence step, a recipe number, the station an indexing table has stopped at. Here MW40 is the station the indexer reports and MW42 the one the program wants, and AT POSITION tells the next step it may start. Do not use EQ on a measurement. A tank level from a 4–20 mA transmitter reads 499, 501, 500, 502 and may never be exactly 500 on the scan you test it. Use GE or LE, or a band between two comparisons.
TRY ITGo online, switch I0.0 ON and set MW40 and MW42 both to 3: Q0.0 comes on. Change MW40 to 4 and it drops.
NE: Recipe Change Detect
NE passes power while IN1 and IN2 differ. Here MW40 is the recipe the machine is running and MW42 the one selected on the HMI. While they differ, RECIPE CHANGED is on: the cue to load the new parameters, or to hold the start until the operator confirms. Once the load copies MW42 into MW40, the two match and the flag clears by itself. The trap is a cold start. Both words come up at 0, so they match and the flag is off although no recipe has been loaded. Writing an impossible number such as -1 into the running recipe at startup forces the first load.
TRY ITGo online and switch I0.0 ON. Both registers start at 0, so there is no flag. Set MW42 to 2: RECIPE CHANGED comes on. Set MW40 to 2, as the load would, and it clears.
GE: Minimum Pressure Guard
GE passes power when IN1 is greater than or equal to IN2. MW50 is the pressure of a hydraulic power pack in bar, and PRESS OK lets the cylinders move once it has built 200 bar. GE and GT differ only at exactly 200, but with integer readings 200 is a value the system can sit on, so decide which side it belongs to. The specification usually says: "at least 200 bar" is GE, "above 200 bar" is GT. I0.0 stands for the transmitter being healthy. If the 4–20 mA loop breaks, the reading means nothing and the permit has to drop with it.
TRY ITGo online, switch I0.0 ON and set MW50 to 199, then 200. Q0.1 comes on at 200. GT would have waited for 201.
LE: Temperature Limit
LE passes power while IN1 is less than or equal to IN2. MW60 is the air temperature inside a drive cabinet in tenths of a degree, so 350 is 35.0 °C, and TEMP OK stays on up to and including that value. Written as LE, the bit states the healthy condition: TRUE means fine, like every other permissive in a chain, so a rung of permissives reads as "all of these OK". You could write GT for "too hot" and use an NC contact of it further on, but then one condition in the chain reads backwards and someone fault-finding at night will misread it. This is process protection for the drives. Anything that protects people belongs in the safety circuit.
TRY ITGo online, switch I0.0 ON and set MW60 to 350: TEMP OK is on. Set 351 and it drops.
SR: Set-Dominant Latch
SR is the set-dominant latch: S1 sets Q1, R resets it, and when both are TRUE, Q1 stays TRUE. The usual use is an alarm. The fault sets the alarm and the operator's acknowledge resets it, and because set wins, holding ACK while the fault is still there clears nothing. The lamp goes out only once the fault has gone and ACK is pressed. Watch the box names on a Siemens CPU: TIA Portal's SR box has inputs S and R1 and is reset-dominant, the opposite of the IEC SR. Read which input carries the 1; that one wins.
TRY ITGo online. Switch I0.0 ON (the fault) and OFF again: the alarm stays latched. Switch I0.0 ON, then I0.1 ON as well: the alarm stays on. Switch I0.0 OFF with I0.1 still ON and it clears.
RS: Reset-Dominant Latch
RS is the reset-dominant latch: S sets Q1, R1 resets it, and when both are TRUE, Q1 goes FALSE. Here it fills a tank between two level switches, both of which close at their level. The low switch opens the fill valve, the valve stays open as the level rises past it, and the high switch closes it. If the low switch sticks closed, both inputs are TRUE when the tank reaches the top, and reset dominance shuts the valve instead of overflowing the tank. Use RS wherever the reset is the stop, the same reason the stop contact goes in series in a seal-in. On a Siemens CPU the box with this behaviour is the one called SR (inputs S and R1). A tank that could hurt someone if it overflowed also needs an independent high-high switch that does not pass through this logic.
TRY ITGo online. Switch I0.0 ON and OFF: the valve opens and stays open. Switch I0.1 ON: it closes. Now switch I0.0 ON as well, as a stuck low switch would be: the valve stays shut.