
📢 New Tutorial: Getting Started with Siemens TIA Portal — Read it now on PLCBlog!
PLC Programming
Answers to the questions we get most often about PLC programming, commissioning, and the tools we build for engineers in the field.
1. What is a PLC and what is it used for?
A PLC (Programmable Logic Controller) is an industrial computer hardened for the factory floor. It reads inputs from sensors and switches, runs a deterministic program on every scan, and drives outputs to motors, valves, and indicators. PLCs are the backbone of almost every automated machine — bottling lines, conveyors, presses, water treatment plants, building HVAC, and so on.
2. What languages can I program a PLC in?
The IEC 61131-3 standard defines five: Ladder Diagram (LD), Structured Text (ST), Function Block Diagram (FBD), Sequential Function Chart (SFC), and Instruction List (IL, now deprecated). In practice most plants run on Ladder for discrete logic and Structured Text for math, string handling, and complex sequencing. Function Block is common for process and drive control.
3. Which PLC brand should I learn first?
Pick the one that runs in your industry. Rockwell (Allen-Bradley / Studio 5000) dominates North American manufacturing. Siemens (TIA Portal, S7-1200/1500) dominates Europe and the process industries. Mitsubishi and Omron are strong in Asia. CODESYS-based platforms (Wago, Beckhoff, Schneider M-series) are the most portable. The concepts transfer between vendors — only the syntax and the IDE change.
4. What is the scan cycle and why does it matter?
A PLC runs in an endless loop: read all inputs, execute the program once top-to-bottom, write all outputs, handle communications, repeat. Typical scan times are 1–20 ms. Because outputs only update at the end of the scan, the order of instructions matters — a coil energized on rung 5 won't be visible to a contact on rung 3 until the next scan. Most race conditions in PLC code come from forgetting this.
5. What's the difference between digital and analog I/O?
Digital I/O is on/off — a 24 VDC sensor, a relay output, a pushbutton. Analog I/O is a continuous signal — a 4–20 mA pressure transmitter, a 0–10 V potentiometer, an RTD. Analog signals arrive at the CPU as raw integer counts (e.g. 0–32767 on Rockwell, 0–27648 on Siemens) and have to be scaled into engineering units. That's exactly what our Analog Scaling Calculator does.
6. Why is 4–20 mA preferred over 0–10 V in industrial signals?
Three reasons. Current loops are immune to voltage drop on long cable runs, so a transmitter 200 m away reads the same as one next to the panel. They reject electromagnetic interference far better than voltage signals. And because the live zero is 4 mA, a reading of 0 mA can only mean a broken wire or dead transmitter — the fault is automatically detectable, like wiring an E-stop normally-closed.
7. What are XIC, XIO, OTE, OTL and OTU?
These are Rockwell's ladder instructions. XIC (eXamine If Closed) is a normally-open contact — true when the bit is 1. XIO (eXamine If Open) is normally-closed — true when the bit is 0. OTE (OuTput Energize) is a non-latching coil that follows the rung. OTL and OTU are set/reset latches: OTL turns a bit on and leaves it, OTU turns it off. Latches survive a power cycle if the data is retentive, which is why E-stop logic almost never uses them.
8. When should I use Ladder vs Structured Text?
Ladder is unbeatable for discrete machine logic: interlocks, permissives, motor starters, anything an electrician needs to troubleshoot at 2 AM. Structured Text wins for math, loops, string handling, recipe management, and complex state machines. Most real programs are a mix — Ladder for the I/O layer, ST inside Add-On Instructions or function blocks for the heavy lifting.
9. What's a timer and how do TON, TOF, and RTO differ?
A TON (Timer On Delay) starts counting when its input goes true and sets its DN bit when it hits the preset; it resets to zero when the input goes false. TOF (Timer Off Delay) is the inverse — it counts while the input is false. RTO (Retentive Timer) accumulates while the input is true and keeps its value when the input drops; you reset it explicitly with a RES instruction. Use RTO for run-hour meters and maintenance counters.
10. How do I prevent race conditions in ladder logic?
Remember that outputs only update at the end of the scan. Don't read a coil's bit on a later rung expecting it to reflect a write on an earlier rung — it will, but only one scan late. Avoid driving the same output bit from multiple rungs (last one wins). For sequence steps, use a dedicated step register or SFC rather than chained latches. And keep one-shots (ONS/OSR) for edge-triggered actions instead of relying on scan timing.
11. What is HMI and how does it talk to the PLC?
An HMI (Human-Machine Interface) is the operator's touchscreen. It polls tags from the PLC over a fieldbus — EtherNet/IP for Rockwell, Profinet for Siemens, Modbus TCP for most others — and updates its screens with the live values. The HMI doesn't run the logic; it just visualizes and writes setpoints. A good HMI never owns safety: interlocks live in the PLC, where deterministic scanning guarantees response time.
12. What is a SCADA system?
SCADA (Supervisory Control and Data Acquisition) sits above the HMI layer. It collects data from many PLCs across a plant or pipeline, archives it in a historian, runs alarms and reports, and gives engineers a plant-wide view. Common platforms include Ignition, Wonderware/AVEVA, FactoryTalk View SE, and WinCC. SCADA is what turns individual machines into a connected operation.
13. How do I commission a new PLC analog input?
Wire the transmitter, configure the channel for the right signal type (4–20 mA, 0–10 V, RTD…), then scale the raw counts to engineering units. With the transmitter at 0% you should read the EU minimum; at 100% you should read the EU maximum. If the numbers don't line up, check the signal type, the raw range for that card family, and whether the channel needs the live-zero offset. Our Analog Scaling Calculator generates the scaling code for Rockwell, Siemens, and CODESYS in one click.
14. What's the difference between safety PLCs and standard PLCs?
A safety PLC is certified to IEC 61508 / ISO 13849 and runs every instruction on redundant hardware paths, comparing results every scan. It catches single-point failures — a stuck output, a corrupted bit, a CPU fault — and forces the system to a safe state. Use a safety PLC (or a safety relay) for E-stops, light curtains, two-hand controls, and machine guarding. A standard PLC handling safety functions will fail an audit, regardless of how well the code is written.
15. How do I back up and version-control PLC code?
Export the project to a flat file the IDE can re-import — L5X for Rockwell, AP-format archives for Siemens TIA, .projectarchive for CODESYS — and commit it to Git like any other source. Tag every commissioning. For binary-heavy projects, also keep a versioned export of the symbol/tag list, since diffs at the tag level are far more readable than diffs of the IDE's native binary. Never edit code online without committing first.