Meridian Works
ENTR
Open the simulator
Taking Over

Lesson 1

PLC Basics: Contacts, Coils, NO/NC Inputs and the Scan Cycle

What a PLC replaced, how the scan cycle works, why a stop button is wired NC, and how contacts and coils make a ladder rung.

From Usta's field manual in Meridian Works, a story-driven PLC course: chapter 1, “Current, Contacts & Coils”. Everything the gatehouse needs is here, and nothing more.

A wall of relays

Sit down. Before you touch a terminal, you need to know what is in front of you.

For fifty years this trade was wiring. A machine's logic lived in a steel panel full of relays. There were hundreds of coils, springs and contacts, and each one was a small decision made of metal. Want the motor to stop when the guard opens? You ran a wire. If you changed your mind a week later, you opened the panel, pulled the wire, connected it again and labelled it again.

Relays worked. But over time their contacts stuck, they wore out and they collected dust. Every change cost somebody a shift.

A PLC (Programmable Logic Controller) moved that panel into a program. The wiring did not disappear; it moved to the edges. Each button is wired once to an input terminal. Each lamp and contactor is wired once to an output terminal. Software makes every decision in between. If you change your mind, you change a line in the program, not a wire.

The PLC won for three reasons. The logic became editable. It became copyable: the same program runs identically on twenty machines. And it became observable: instead of guessing with a meter, you watch every contact live on the screen.

The PLC did not win by being clever. It won by being completely predictable. It does the same work in the same order a hundred times a second. That order is called the scan. We will get to it shortly.

A relay panel gives its faults away by the smell. A PLC gives nothing away. That is why you will write everything down.

Inputs: NO, NC and safety

The PLC knows only what reaches its input terminals. Each input answers one question: is there voltage on this terminal? The answer is 1 or 0. Nothing else gets in.

Three kinds of device give that answer:

  • Pushbuttons are momentary. They give voltage only while pressed.
  • Selector and key switches are maintained. They keep their position when you let go.
  • Sensors are the machine's eyes and skin: proximity sensors, photo-eyes, limit switches, pressure and level switches.

Here is what really matters. Each of these devices is built either normally open (NO) or normally closed (NC). "Normally" means: while nobody is touching it.

An NO device is open when untouched. No current flows and the PLC reads 0. Press it, it closes, and the PLC reads 1.

An NC device is closed when untouched. Current flows and the PLC reads 1 all day. Press it, it opens, and the PLC reads 0.

+24V +24V Start_PB = 0 Stop_PB = 1 NO start button, released NC stop button, released

This is a property of the hardware. It is not something you type in the program. It is chosen when the part is ordered, and the choice has a reason.

The golden rule: stop buttons, emergency stops, guard switches and every device that protects a person are wired NC.

I want you to know why. Wires break. Terminals work loose, connectors corrode, a forklift snags a cable, a mouse chews one. Now imagine the stop button wired NO. If the wire in that circuit breaks, what the PLC sees is exactly the same as "nobody is pressing stop". The machine keeps running and no fault shows. One day somebody really presses that button, and it does nothing.

Wire the same button NC and the broken wire looks like "stop is pressed". The machine stops at once and everybody notices. The fault shows itself the moment it happens. A fault you can see does not hurt anyone.

The principle is called de-energize to trip. The safe state is the state that needs no power to reach.

There is one consequence at the bench. Every apprentice loses a week before learning it: a healthy NC device reads TRUE. A stop button nobody is pressing is TRUE. Here TRUE means "all is well". It does not mean "pressed".

Outputs: a small current controls a big one

Now the other side of the box. An output is a switch the processor closes on command. What you connect to it is your decision.

  • A signal lamp: the cheapest indicator in the plant. Most of the time nobody looks at it.
  • A contactor coil: this is the important one.
  • A solenoid valve: the PLC energises the coil, compressed air does the work.

A PLC output is small: twenty-four volts and half an amp to two amps. The gate motor in this zone draws a hundred times that when it starts. So the output does not run the motor directly. It energises the coil of a contactor, and the contactor's heavy contacts carry the motor current. A small current controls a big one. That is the core of the trade, and it has not changed since the relay panels.

When you write a coil in the program, the processor energises that terminal at the end of the scan and keeps it energised. When you stop writing it, the terminal drops. Copper remembers nothing.

A warning. Energising a coil does not prove anything happened in the field. The contactor coil may be burnt out. Its contacts may be stuck, a fuse may have blown, or the overload may have tripped. The program believes the motor is running while the motor is standing still. That is why a good panel wires the contactor's auxiliary contact back to an input, and a good program looks at that input.

A coil is a promise. Feedback is proof. Do not confuse the two.

The scan

The processor does three jobs and repeats them without stopping.

  1. It reads every input and writes the values into a snapshot. That snapshot is called the process image.
  2. It executes the program line by line, top to bottom, looking at that snapshot.
  3. It writes the results to the outputs.
READ EXECUTE WRITE every input rungs, top to bottom every output one trip = one scan

One trip round is called a scan. On real hardware a scan takes one to ten milliseconds. In this simulator it is always exactly ten. So a three-second delay here is exactly three hundred scans, and it behaves the same on every run.

From now on, keep four consequences in mind.

The program never looks at a terminal. It looks at the snapshot taken at the start of the scan. If a signal comes and goes between two snapshots, the PLC never sees it. Contact bounce shorter than one scan is invisible too.

Inputs do not change while the program runs. In one scan, line 1 and line 40 see the same value. That is what makes the program repeatable. Relay panels never had this.

Outputs do not change mid-scan either. They are all written at the end of the scan. If two lines write the same coil, the output gets only the value from the lower line. This is called last write wins, and it gives no warning. The upper line behaves as if it did not exist. The rule is simple: each coil is written in one place in the program. Start that habit today.

Top to bottom is real. A result calculated on line 3 reaches line 4 in the same scan. A result calculated on line 20 reaches line 5 only on the next scan. Usually this causes no trouble. Sometimes it is the cause of the bug you hunt for two days.

Ladder is a drawing of a circuit

Ladder was not invented to look elegant. It was invented so that electricians who wired relay panels could read a program on their first day. A ladder is a drawing of a circuit. Keep reading it as one.

There are two vertical lines. These are the rails: the left rail is the supply, the right rail is the return. The horizontal lines between them are called rungs. That is where the name comes from.

Gate_Switch Stop_PB Gate_Lamp NO contact NC contact coil power flow

Power leaves the left rail and moves right through the elements on the rung. If it reaches the coil, the coil energises. That is the whole idea.

  • Elements placed side by side must all conduct. That is a series connection and it means AND.
  • Elements split into branches need only one branch to conduct. That is a parallel connection and it means OR.
  • A branch inside a branch is allowed. But it usually means you should write two separate rungs.

Let us be honest about one thing: there is no real current here. The rails are imaginary. What we call "power" is a logic value the processor calculates. Think in terms of current anyway. That way of thinking stops you writing wrong rungs, and every electrician on site thinks the same way.

This editor has two rules. Real programs have the same ones.

Rungs run top to bottom, once per scan. Their order is part of the program.

Coils sit at the right-hand end of the rung. Nothing comes after a coil on the same path. If you want a contact after a coil, you need a new rung.

Contacts ask, coils write

Two symbols carry most of the work in this trade. Apprentices lose their first weeks learning the difference between them.

A contact asks a question. A coil writes.

Start_PB Gate_Motor Gate_Motor Run_Lamp this coil DECIDES Gate_Motor this contact only ASKS

A contact on Gate_Motor asks: is Gate_Motor on right now? A contact only reads and changes nothing. Put fifty contacts in the program and the machine is not affected.

A coil on Gate_Motor writes. Every scan it sets Gate_Motor to whatever power flow reached it. That is an assignment, not a comparison. A healthy program has exactly one coil for each signal.

Remind yourself before every rung: contacts ask, coils write. If a machine seems to "decide on its own", there is usually a coil where a contact should be.

The two platforms name these elements differently. Siemens draws them as normally open and normally closed contacts. In Rockwell the normally open contact is called XIC (Examine If Closed), the normally closed contact XIO (Examine If Open), and the coil OTE. They behave the same.

Now the second confusion. There is an NC contact in the program. There is also an NC device in the field. They are not the same thing.

  • An NO contact (XIC) conducts when the bit is 1.
  • An NC contact (XIO) conducts when the bit is 0.

Both of them ask only about the bit. They do not know what device is wired in the field. Put the field device and the program contact together and you get four cases. Learn this table well:

In the field Bit at the input NO contact in the program NC contact in the program
NO button, released 0 blocks conducts
NO button, pressed 1 conducts blocks
NC button, released 1 conducts blocks
NC button, pressed 0 blocks conducts

Read the third row twice. An NC stop button that nobody is pressing gives 1. So the contact that means "movement is allowed" in the run circuit is an NO contact on Stop_PB.

Apprentices see an NO contact drawn for Stop_PB and think it is a mistake. It is not. The real mistake is the other one: put an NC contact there and the gate runs only while somebody holds the stop button down. It stops the moment they let go.

The device decides what the wire carries. The contact decides what you ask. If either one is wrong, the machine is wrong.

Addresses, tags and two platforms

Every terminal has an address. That is the only way the processor knows which terminal you mean. The two platforms write that address differently.

In Siemens an address looks like %I0.0. I is the input area, the first 0 is the byte number and the second 0 is the bit number. A byte has eight bits. The first input card uses %I0.0 to %I0.7, then comes %I1.0. Outputs are in the Q area: %Q0.0. There is also an M area. M bits are used like inputs and outputs but are not wired to any terminal. They are the processor's scratch paper.

In Rockwell a tag has no address. When you add a module to the project, its tags are created for you, such as Local:1:I.Data.0. Here 1 is the slot the module sits in, I means input and Data.0 is the first channel. A memory bit needs no address either. You simply create a tag of type BOOL.

On both platforms we do not write programs with addresses. We give each signal a name. In Siemens the name is bound to an address in the tag table. In Rockwell the name is an alias tag that points at the module tag. The purpose is the same:

Name Siemens Rockwell Comment
Stop_PB %I0.1 Local:1:I.Data.1 NC — TRUE when healthy
Jam_Clear %I0.2 Local:1:I.Data.2 NC light curtain — TRUE when the path is clear
Gate_Motor %Q0.0 Local:2:O.Data.0 Gate contactor K1

There are two practical reasons for names. When the line stops at three in the morning, %I0.4 tells you nothing, but Emergency_Exit_2 tells you everything. And when the panel builder moves a wire to a spare terminal, you do not search forty rungs. You change one line.

Name a signal for what it is, not for what you want it to do. Gate_Open_SW is a good name: it is a switch and it is TRUE when the gate is open. Open_Gate is a bad name: it sounds like a command. In six months nobody will remember whether it is an input or an output.

Fill in the comment column too. Above all, write whether it is NO or NC. A note saying "NC — TRUE when healthy" saves the next person an hour with a meter. One day that person will be you.

In most work orders the tag list comes ready and locked. Then do not rename anything, because the plant is checked by name. In some jobs the table starts empty, and you build it from the I/O list in the field documents. This chapter's paperwork job (1.D) is one of them. Enter each name, type and address exactly as the list has it. You can switch between the S7 and Logix views from the top bar. In the Logix view no % address is shown, because a Logix tag has no address of its own. There you write the module point the tag points at instead, such as Local:1:I.Data.6.

The panel forgets. Drawings go out of date. The tag list is the only document you can trust. Keep it trustworthy.