PLC inputs and outputs are the terminals where the controller meets the machine. Inputs bring in field signals such as a sensor switching on or a transmitter sending 4 to 20 mA, and outputs send commands back to valves, contactors and drives.
In lesson 1 you saw that the CPU only works on the input and output image tables. This lesson follows a signal from the field terminal into that table and back out, for both digital and analog I/O, and ends with scaling a real analog reading.
PLC inputs and outputs (I/O) are the modules that turn field signals into data and data back into field signals.
- Digital I/O is on or off, for example 24 V DC from a sensor or to a solenoid.
- Analog I/O is a range, usually 4 to 20 mA or 0 to 10 V.
- An analog input gives the program a raw count that you scale to units such as bar or °C.
Step 1: Sort every signal into one of four I/O types
Every wire that lands on a PLC belongs to one of four groups. The group decides which module it needs and how the program treats it.
| Type | Direction | Typical field devices | Signal |
|---|---|---|---|
| Digital input (DI) | Field to PLC | Push buttons, limit switches, proximity sensors | On or off, often 24 V DC |
| Digital output (DO) | PLC to field | Contactor coils, solenoid valves, lamps | On or off |
| Analog input (AI) | Field to PLC | Pressure, level and temperature transmitters | 4 to 20 mA, 0 to 10 V |
| Analog output (AO) | PLC to field | Control valve positioners, drive speed references | 4 to 20 mA, 0 to 10 V |
A digital signal is stored as one bit in the image table. An analog signal is stored as a number, usually a 16-bit word.
How many modules of each kind a project needs, and how much spare to add, is worked through in PLC hardware selection.
Step 2: Wire digital inputs to the right input type
IEC 61131-2 defines three types of 24 V DC digital input. Each has its own on-state voltage and current window, so a sensor and an input card from different makers work together.
| IEC 61131-2 type | On voltage | On current | Suits |
|---|---|---|---|
| Type 1 | 15 to 30 V | 2 to 15 mA | Mechanical contacts, 3-wire sensors |
| Type 2 | 11 to 30 V | 6 to 30 mA | 2-wire semiconductor sensors |
| Type 3 | 11 to 30 V | 2 to 15 mA | 2-wire and 3-wire sensors, lower heat |
The current window matters as much as the voltage. A 2-wire sensor takes its own supply from the same two wires, so it leaks a small current even when off, and the input must not read that as on.
The second wiring check is current direction. A PNP sensor sources current, so it needs a sinking input; an NPN sensor needs a sourcing input. The hardware selection FAQ explains the pairing. Every input module also has a filter delay, which is part of the response time you calculated in lesson 1.
Step 3: Choose the digital output for the load
A digital output module switches a load on or off when its bit in the output image table changes. The three common switching elements are relay, transistor and triac outputs.
- Relay outputs switch AC or DC and are isolated, but they are slower and wear out.
- Transistor outputs switch DC only, are fast and have long life.
- Triac outputs switch AC loads without contact wear.
The comparison table and the per-point and per-group current checks are in PLC hardware selection. For programming, the rule from lesson 1 still holds: the terminal only changes at the output write stage of the scan, after the rung has been solved.
Step 4: Understand the 4 to 20 mA analog input
The most common process signal is a 4 to 20 mA DC current, the range IEC 60381-1 sets for process control signals. Current is used rather than voltage because the same current flows all round a series loop, so cable resistance does not change the reading.
A 2-wire transmitter is powered by the loop itself. The 24 V DC supply, the transmitter and the PLC input sit in one series circuit, and the transmitter sets the current from 4 mA (bottom of range) to 20 mA (top of range).
The 4 mA live zero has a second job: fault detection. NAMUR NE 43 treats a current at or below 3.6 mA, or at or above 21 mA, as a failure signal, so the program can raise a wire break or transmitter fault alarm instead of reading a false zero.
Step 5: Scale raw counts to engineering units
Inside the analog input module an analog to digital converter (ADC) turns the current into a number. The program sees that number, the raw value, not milliamps or bar.
The raw range depends on the module. Siemens S7 analog modules, for example, represent the nominal 4 to 20 mA range as 0 to 27648, with higher values kept for overrange. The scaling is a straight line through two points:
Value = Low + (Raw - RawMin) / (RawMax - RawMin) × (High - Low)
Here Low and High are the engineering range of the transmitter, and RawMin and RawMax are the counts at 4 mA and 20 mA. The same line, run backwards, gives the raw value an analog output needs for a given command.
Most PLCs have a scaling instruction for this, and the ladder logic lesson shows where compare and math instructions sit in a rung.
Step 6: Work out the resolution you really have
Resolution is the change in the measured value for one count. You can work it out from the scaling line for any module and transmitter.
With 0 to 27648 counts over 16 mA, one count is 16 / 27648 = 0.000579 mA, about 0.58 µA. On a 0 to 10 bar transmitter, one count is 10 / 27648 = 0.000362 bar, or 0.36 mbar.
That is the display step, not the accuracy. The overall accuracy also depends on the transmitter, the module accuracy figure in its datasheet and the installation, so quote it from those documents.
Worked example: reading a pressure transmitter
Given: a 2-wire pressure transmitter, range 0 to 10 bar, output 4 to 20 mA, on an analog input that maps 4 to 20 mA to 0 to 27648 counts. The input image table shows a raw value of 15206.
Find: the loop current and the pressure.
Assumptions: linear transmitter and module, no offset or calibration error, signal inside the nominal range.
Solution
- Fraction of span = 15206 / 27648 = 0.54999.
- Current = 4 + 0.54999 × 16 = 12.80 mA.
- Pressure = 0 + 0.54999 × (10 - 0) = 5.50 bar.
- Check: 12.8 mA should give (12.8 - 4) / 16 × 27648 = 15206.4 counts, and the module stores the whole number 15206. The result agrees.
Answer: the loop carries 12.80 mA and the pressure is 5.50 bar.
Limitations: real modules have offset, gain and linearity errors listed in their datasheets, and the raw range differs between PLC makers. Use your module manual for the actual counts.
Practice task: temperature input and valve output
A temperature transmitter has a range of 0 to 150 °C and a 4 to 20 mA output. It is wired to the same type of analog input (4 to 20 mA = 0 to 27648). An analog output with the same raw range drives a 4 to 20 mA control valve positioner.
- The input raw value is 20736. What are the current and the temperature?
- The program wants the valve at 60 % open. What raw value must it write, and what current flows?
- A 2-wire inductive proximity sensor must be added. Which IEC 61131-2 input types can take it?
Answer
- 20736 / 27648 = 0.75. Current = 4 + 0.75 × 16 = 16.0 mA. Temperature = 0.75 × 150 = 112.5 °C.
- Raw = 0.60 × 27648 = 16588.8, so write 16589. Current = 4 + 0.60 × 16 = 13.6 mA.
- Type 2 or Type 3. Type 1 is for mechanical contacts and 3-wire sensors.
PLC inputs and outputs: common mistakes
- Wiring a PNP sensor to a sourcing input. The sensor lamp lights, but the PLC input never turns on.
- Scaling with the wrong raw range, for example assuming 0 to 32767 on a module that uses 0 to 27648. Every reading is then about 16 % low.
- Ignoring the live zero. A broken wire reads as 0 bar instead of raising an alarm.
- Using a relay output for fast DC pulsing, where it is slow and wears out quickly.
Related reading
Frequently asked questions
Can I connect a 2-wire proximity sensor to any 24 V DC PLC input?
No. A 2-wire semiconductor sensor needs a Type 2 or Type 3 input as defined in IEC 61131-2. A Type 1 input is meant for mechanical contacts and 3-wire sensors, and a 2-wire sensor's leakage and current needs may not suit it.
Why does a 4 to 20 mA signal start at 4 mA and not at 0 mA?
The live zero lets the PLC tell a real zero reading (4 mA) from a broken wire or dead transmitter (near 0 mA). It also leaves enough loop current to power a 2-wire transmitter at the bottom of its range. NAMUR NE 43 uses currents at or below 3.6 mA and at or above 21 mA as failure signals.
Is 0 to 27648 the raw range on every PLC?
No. It is the nominal range Siemens S7 analog modules use. Other brands use ranges such as 0 to 32767, 0 to 4095 or values already in engineering units. Always read the raw range from your module manual before writing the scaling logic.
References
- IEC 61131-2:2017 Programmable controllers, Part 2: Equipment requirements and tests
- IEC 60381-1:1982 Analogue signals for process control systems, Part 1: Direct current signals
- NAMUR NE 43, Standardization of the signal level for the failure information of digital transmitters
- Siemens, Compliance of digital input modules with IEC 61131-2 (Industry Online Support, entry 109477921)
- Siemens, SIMATIC S7-300 Module Data Manual, Chapter 5: Analog value representation
- F. D. Petruzella, Programmable Logic Controllers, 5th ed., McGraw-Hill
- W. Bolton, Programmable Logic Controllers, 6th ed., Newnes
Get one engineering email a week
New articles, worked examples and study notes every week. Free, no spam, unsubscribe any time.