XIC or XIO
The instruction is not picked from the symbol on the print. It is picked from what the input bit will be when the machine is in the state that should run the output. The device, then how it is wired, then the bit, then the instruction. Always in that order.
XIC: true when the bit is 1
The contacts wired to that input are closed, 24 V DC reaches the input terminal and the input light is on.bit 1 = XIC true
XIO: true when the bit is 0
The contacts are open, nothing reaches the terminal and the input light is off. bit 0 = XIO true
The bit follows the contact
An NO contact closes when the device is actuated. An NC contact is closed at rest and opens when the device is actuated. The PLC only sees closed or open.
The method
For each device: the state that must run the output, then whether its contact is closed or open in that state. Closed is XIC. Open is XIO.
| Wired | Device | Contact | Input bit | XIC | XIO |
|---|---|---|---|---|---|
| NO | at rest | open | 0 | false | true |
| NO | actuated | closed | 1 | true | false |
| NC | at rest | closed | 1 | true | false |
| NC | actuated | open | 0 | false | true |
An example. A clamp solenoid must energize when the guard limit switch, wired NO, is held; the low air pressure switch, wired NC, has not tripped; and the jog pushbutton, wired NO, is not pressed. The guard switch is closed when held: XIC. The air switch at rest is an NC contact, closed: XIC. The jog button at rest is an NO contact, open: XIO.
The hardwired circuit had an NC stop, an NO start and an auxiliary contact sealing in around the start. On the PLC the stop's NC contact goes to I:1/0 and the start's NO contact to I:1/1. At rest the stop is closed, so I:1/0 is 1 and the stop is programmed as an XIC. It still breaks the rung when it is pressed: pressing it opens the contact, the bit goes to 0 and the XIC goes false.
I:1/0 stop PB, NC · I:1/1 start PB, NO · O:2/0 motor starter
The panel was just changed over to the PLC and the operator reports the motor won't start. The I:1/0 light is on with nobody touching anything, and I:1/1 comes on when start is pressed, so the field wiring is good. The program is the problem: both pushbuttons were programmed as XIO, copied from the symbols on the old print.
At rest I:1/0 is 1, so XIO I:1/0 is false and the rung can never be made from the start button: pressing start makes I:1/1 a 1, which makes its XIO false too. Oddly, holding the stop runs the motor (stop bit 0 and start bit 0 make both XIOs true), and it drops out the moment stop is let go. The fix is XIC on both inputs.
Fail-Safe Wiring
Anything that has to stop a machine is wired with an NC contact: stop buttons, overtravel limits, high-level floats, high-pressure and high-temperature switches. A broken wire, a loose terminal or a blown field fuse opens the circuit, and an open circuit reads exactly like the device asking for a stop. The failure stops the machine instead of hiding.
The high-level float switch is wired NC to I:1/2. Below the high level the contact is closed, the bit is 1 and XIC I:1/2 lets the pump run. When the tank fills, the float lifts, the contact opens and the pump stops.
I:1/2 high-level float, NC · O:2/1 fill pump
Counters
A counter counts false-to-true transitions of its rung, not how long the rung is true. A box that sits in front of the photo eye for a minute is one count. The counter keeps its count with the rung false and through a power cycle; only a reset clears it.
CTU and CTD
CTU adds one to the accumulated value on each false-to-true transition. CTD takes one away. CTD does not stop at zero; it goes negative.
PRE and ACC
PRE is the count you are after. ACC is the count so far. Counting carries on past the preset.
CU and CD
CU is true while the CTU rung is true, the same idea as a timer's EN bit. CD does the same for CTD. The counter uses them to tell a new transition from a rung that is still true.
DN
On whenever ACC is at or above PRE.DN = ACC >= PRE
RES
Clears ACC to zero and turns off DN, CU and CD. It is a rung of its own, usually a reset button or the counter's own DN.
Lights from a counter
XIC on DN: on once the count is reached. XIO on DN: on from the reset until the count is reached, then off. An equal compare of ACC with 0: on only while the count is zero.
I:1/3 photo eye · I:1/4 reset PB · O:2/2 batch done light · O:2/3 filling light
A CTU and a CTD can share one address. Here an eye where parts come onto a conveyor counts C5:1 up and an eye where they leave counts it down, so ACC is the number of parts on the belt right now.
I:1/5 in eye · I:1/6 out eye · O:2/4 conveyor full light
ACC = what it read before + parts in - parts out. Starting from 4 with 9 on and 6 off, ACC is 7. The DN bit is shared too: here it lights the conveyor full light once 20 parts are on the belt.
One-Shots and Self-Resetting Counters
An ONS passes power for one scan when the conditions in front of it go from false to true, then blocks until they go false and true again. Its address is a storage bit that remembers last scan's state; every ONS gets a bit of its own, never shared.
Twelve parts to a case. The counter's own DN bit resets it so it is ready for the next case. The trouble is that RES clears CU along with ACC. If the twelfth part is still in front of the eye on the next scan, the counter sees a true rung with CU off and counts that same part again: the next case starts at 1 instead of 0. The ONS in front of the CTU makes the rung true for one scan per part, so a part that sits at the eye is counted once.
I:1/3 photo eye · B3:0/0 one-shot storage bit · O:2/5 case full
DN is on for one scan only, from the counter rung to the RES rung. Anything that needs it goes between those two rungs, as O:2/5 does here. A rung after the RES never sees it. One scan is far too short to pull in a contactor, so use it to latch something or start a timer.
Timer Patterns
The timer bits themselves are in Timers, with a bench to run them and the timer programs running live. This section is the short version you need to read a ladder: how long a preset is, and how to recognise the four patterns.
Preset times time base
The preset is a count of time-base ticks. Preset 1000 at 1.0 s is 1000 s. Preset 1000 at 0.01 s is 10 s.time = PRE x time base
Retentive or not
TON and TOF reset their ACC when their rung changes over. RTO keeps its ACC with the rung false and needs a RES to clear it.
Timed contacts
On a TON, XIC on DN is the NOTC contact and XIO on DN is NCTO. On a TOF, XIC on DN is NOTO and XIO on DN is NCTC. The tables are here.
Spot it by each timer's DN sitting in the other one's rung. T4:0 times the off, T4:1 times the on, and T4:1's DN going true drops T4:0, which drops T4:1. At a 0.1 s time base, 5 and 5 is half a second off, half a second on.
A position switch starts a TON and the TT holds the output for the dwell. The drill reaches the bottom limit at I:1/7 and O:2/7 keeps it cutting for 30 at 0.1 s, 3 seconds. When DN comes on, TT drops and the drill stops.
A TON on the raw input, and the rest of the program uses the DN, or a bit it drives, instead of the input. A bounce resets the TON, so B3:0/1 only comes on after the input has stayed made for 5 at 0.01 s, 50 milliseconds.
The run request starts a TON and the motor waits on its DN. While it times, XIO on DN sounds the horn. At a 1.0 s time base that is 10 seconds of horn before the conveyor moves.
T4:5 resets itself with its own DN, so it makes a pulse every cycle, and C5:3 counts the pulses. The motor runs until C5:3 is done: 600 at 0.1 s is 60 s a cycle, times a counter preset of 30, is 1800 s, 30 minutes. The counter stretches a timer past what one preset can hold. The first rung matters: pressing start resets C5:3. Without it, DN stays on after the first run and XIO C5:3/DN keeps the motor from ever starting again.
I:1/9 start · O:2/10 motor
Input Devices
Everything wired to an input card is one of three kinds: something a person works, something the machine pushes on, or a sensor that sees without touching. On this site they all run on 24 V DC field power.
Manual
Toggle switches, pushbuttons (momentary) and selector switches (maintained positions). A person changes their state.
Mechanical
Limit switches (a part or a cam moves the arm), float switches (level), pressure switches and temperature switches (a setpoint). The process changes their state by touching or pushing.
Inductive prox
Senses metal only, at short range. A plastic part goes past it unseen.
Capacitive prox
Senses metal and non-metal: plastic, wood, grain, liquid through a tank wall. Its sensitivity is adjusted for the target.
Reed switch
Two reeds in a glass tube pulled together by a magnetic field. On an air cylinder it senses the magnet in the piston.
Overload contacts
Not a sensor you choose: they belong to the overload relay on the starter. The NC overload contact is wired in the control circuit and drops the starter coil when the motor draws too much current for too long.
Through-beam
The emitter on one side, a separate receiver on the other. The part breaks the beam. Longest range, two devices to wire and line up.
Retroreflective
Emitter and receiver in one housing, aimed at a reflector. The light goes to the reflector and back; the part breaks it.
Diffuse
The light bounces off the object itself back to the receiver. Shortest range, and the color and finish of the part matter.
A four-wire DC sensor has power on brown (+24 V DC) and blue (0 V), and two outputs: black is the NO output and white is the NC output. Pick the output by the same rule as section 1: which state should make the bit a 1. A photo eye also has a light-operate or dark-operate setting that decides whether its NO output is on with the beam made or broken, so check it before you decide on XIC or XIO.
The Scan and the Image Tables
The program never reads an input terminal directly. Each scan the processor copies the input states into the input image table, solves the program against that copy, and then writes the output image table out to the output terminals. Then it does it again.
1. Input scan
The state of every input terminal is copied into the input image table: 1 for voltage present, 0 for none.
2. Program scan
The rungs are solved top to bottom, left to right, using the image table. Outputs are written to the output image table, not to the terminals yet.
3. Output scan
The output image table is copied to the output terminals, and the output lights change.
What it means on the floor
An input that changes during the program scan is not seen until the next scan. An input that comes and goes between two input scans is never seen at all.
A pulse longer than one whole scan is always caught by an input scan. A shorter one is a matter of luck. The input card's filter time also has to pass before the terminal even reads as on. A fast part on a fast belt is the usual case: slow the belt, move the eye so the part blocks it longer, or use a high-speed counter input.
Practice
Four choices, one right. Picking XIC or XIO from the wiring, presets and time bases, up and down counts on one address, and a timer feeding a counter. Every question is new, and Show the work goes through it step by step.