Control & automation
PLCs, control loops, robots and CNC: how machines are controlled in factories, with demos you can play with.
PLC control
A PLC (programmable logic controller) is a rugged industrial computer. It reads inputs (buttons, sensors), runs its program in a repeating loop called the scan, and switches outputs (motors, valves, lamps).
Ladder logic looks like an electrical wiring diagram, so electricians and engineers can read it easily. It is one of the standard PLC programming languages.
Siemens SIMATIC S7
S7-1200 and S7-1500 controllers, programmed in TIA Portal with ladder (LAD), function blocks (FBD) or structured text (SCL). Common in factories and process plants.
AutomationDirect CLICK
A low-cost PLC programmed in ladder with the free CLICK software. Popular for small machines, workshops and learning. Same ideas, simpler tools.
Ladder logic: try it
Press and release Start, then Stop. The motor seals itself in. The conveyor starts 3 seconds later (an on-delay timer). Trip the overload to cut everything.
Hold to press
Typical example. Syntax and addresses vary by model and software.
How to read it
Power flows left to right. A normally-open contact passes power when its input is on; a normally-closed contact passes power when its input is off. The motor’s own contact is in parallel with Start: that is the seal-in. The PLC repeats the whole program every few milliseconds.
PLC inputs and outputs: typical voltages
Press Start, then Stop. See the real voltage on every wire: a 24 V DC input card reads the buttons, the ladder decides, and the output card drives the contactor and the lamp. Change the output type to see 24 V DC, 230 V AC or 120 V AC.
The Stop button is wired normally closed, so its input reads 24 V until you press it. That is why the ladder uses an ordinary contact for Stop. A broken wire also reads 0 V and stops the motor: fail-safe.
| Type | Typical level |
|---|---|
| Digital input | 24 V DC. ON: 15 to 30 V. OFF: 0 to 5 V. |
| Transistor output | 24 V DC, about 0.5 A per output. |
| Relay output | Up to 250 V AC or 30 V DC, about 2 A. |
| Analog input | 4 to 20 mA or 0 to 10 V from a sensor. |
Ladder logic: switch a light on and off
Press the switch. When the contact closes, power flows along the rung and the coil turns the lamp on. Press again to turn it off.
Contact %I0.0 is the input. Coil %Q0.0 is the output. A green line means power is flowing.
Ladder logic: a 4-way traffic junction
A normal working-day cycle. North–South gets green, then amber, then all red for a moment, then East–West gets its turn. Six steps, each timed by a timer, repeating all day.
Only one step is active at a time. When its timer finishes, the next step starts. The number beside each light is the seconds until it changes.
Counters and latches
Boxes pass a photo-eye. The counter counts to 5, then the pack is full and the conveyor stops. Press Reset to start a new pack. The Jam button sets an alarm latch that stays on until you press Acknowledge.
CTU counts each pulse from the sensor. The SET coil turns the alarm on and it stays on even after you let go. Only the RESET coil turns it off.
Analog input: a 4–20 mA tank level
A level sensor sends 4 mA (empty) to 20 mA (full). The PLC turns that into a number, scales it to litres, and switches the pump on at 800 L and off at 200 L. Open the inlet valve to fill the tank. Break the wire to see why 4 mA, not 0 mA, is the lowest signal.
Because empty is 4 mA, a reading near 0 mA can only mean a broken wire or a dead sensor, so the PLC stops the pump. This is called a live zero.
Safety circuits: emergency stop and two-hand control
Safety uses two channels that must agree. Press the E-stop: both channels open and the machine stops. Weld one channel (a fault) and the safety relay sees the channels disagree, stops the machine and will not restart. Switch to two-hand control: both buttons must be pressed within half a second and held.
Safety relays are certified for this job. To clear the fault: untick the weld, press the E-stop so both channels open, release it, then press Reset.
Build your own ladder
Flip the inputs A, B and C, and build rungs with the menus. Each rung has a main row and an optional parallel row (OR). The coil turns on when either row is fully true. Try the examples.
Contacts can use the inputs A, B, C or the outputs Y1, Y2. Rungs are checked from top to bottom, like a real PLC scan.
Where PLCs are used
Conveyors & packaging
Start/stop sequences, counting and sorting on production lines.
Pumps & water
Level control, pump alternation and alarms in water and wastewater plants.
Machine tools
Interlocks, tool changers and safety circuits around CNC machines.
Building systems
Lighting, HVAC and lift control in large buildings.
Robot cells
Coordinating robots, fixtures, sensors and guards in one safe sequence.
Batch processing
Mixing, heating and filling in food, chemical and pharma lines.
Control: tune a PID loop
A controller compares what you want (the setpoint) with what you get (the measurement) and adjusts its output to close the gap. PID is the most common kind: P reacts to the error now, I removes leftover error, D calms fast changes.
Try the sliders. More P is faster but overshoots, more I removes the steady error but can oscillate, more D adds damping. The plant here behaves like a spring, for example a motor positioning an arm.
FANUC robots
FANUC is a Japanese maker of industrial robots, CNC controls and servo motors. Its robots are articulated arms with six axes, taught with a handheld teach pendant and programmed in the TP language (or KAREL for advanced work).
The sketch below is a simplified flat model of an arm. Move the joints and the tool position is calculated with forward kinematics.
Typical applications
- Spot and arc welding
- Material handling
- Palletising
- Machine tending (loading CNC machines)
- Painting and dispensing
Six-axis arm drawn in 3D: drag the picture to look around. Ranges are typical; real limits depend on the model. Simplified, not a real robot.
Teach pendant program
Move the sliders, press Teach point to save the position, add gripper and wait steps, then Run. The gripper picks up a box if it closes next to it. Or try a ready-made program.
FANUC robot families
A few of the robot families FANUC makes. Model names belong to FANUC; see their website for pictures and full specifications.
CRX series (e.g. CRX-10iA)
Collaborative robots that can work next to people without a safety fence and are easy to teach by hand.
CR series (e.g. CR-35iB)
Collaborative robots for heavier loads, such as palletising and machine tending.
LR Mate series
Compact six-axis robots for small parts, assembly and inspection.
M series (e.g. M-10iD, M-20iD)
General-purpose six-axis robots for handling, welding and machine tending.
M-410iC and heavy robots
Strong robots that stack boxes and heavy loads on pallets.
P series (e.g. P-250iB)
Painting robots built for coating booths.
SCARA (e.g. SR-3iA)
Fast, flat-moving arms for assembly and pick-and-place.
Delta robots (M-1iA, DR-3iB)
Parallel-arm robots for very fast picking of small items such as food and parts.
CNC machining
CNC (computer numerical control) machines move a tool along paths written as G-code. A line such as G01 X40 Y10 F300 means: move in a straight line to X40 Y10 at feed 300.
Edit the program and press Run to see the toolpath. G00 is a rapid move, G01 a straight cut, G02 and G03 are clockwise and counter-clockwise arcs.
Where CNC is used
Milling
Pockets, slots and 3D surfaces in aluminium, steel and plastic.
Turning
Shafts, pins and threads made on a lathe.
Routing & cutting
Wood, sheet and composite parts, plus plasma and laser cutting.
Controls
FANUC and Siemens SINUMERIK are two widely used CNC controls.
Motor drives: how a VFD sets motor speed
A variable-frequency drive (VFD) changes the frequency and voltage it sends to an AC motor, and speed follows frequency. Set a frequency and press Start: the drive ramps up smoothly instead of slamming on. Add load and the motor slips a little behind its synchronous speed.
V/f control keeps voltage in proportion to frequency up to the motor's rated 50 Hz, so the magnetic field stays constant. Above 50 Hz the voltage cannot rise any more, so torque falls. This is a 4-pole, 400 V, 50 Hz motor.
Stepper motor: moving in exact steps
A stepper moves one fixed step for every pulse it receives, with no feedback. Raise the pulse rate to go faster. Add load and speed until the motor cannot keep up: it loses steps and the controller never knows. Tick the encoder to see how feedback fixes it.
A full-step motor turns 1.8° per pulse (200 per turn). Microstepping divides each step for smoother, finer movement. Open-loop steppers are cheap and simple; add feedback when losing steps would be a problem.
Let’s build something
Looking for an intern or have a project idea? Get in touch.
kenith [at] kenith.net