Controllers and interfaces
A controller is the brain: a PLC, a microcontroller board or a PC. It needs interfaces to connect to the real world.
- Analogue input (ADC): turns a smooth voltage or current from a sensor (for example 4 to 20 mA) into a number.
- Analogue output (DAC): turns a number into a voltage to set a valve or motor speed.
- Digital input/output: ON/OFF signals from switches and to relays and lamps.
- Signal conditioning: amplifying, filtering and isolating a weak or noisy signal before the controller reads it.
- Communication ports: serial (RS-485), Ethernet, USB or wireless, to join a network.
Sensors measure, actuators act. See Sensors for how a quantity becomes a signal.
Control programs
A control program repeats one loop forever: read inputs, decide, write outputs. The plan can be shown as a flowchart before coding.
Tiny example (in plain words):
- Read the temperature.
- If it is higher than the limit, switch the fan ON.
- Otherwise switch the fan OFF.
- Send the reading to the operator screen.
- Wait 1 second. Go back to step 1.
Good programs use variables for limits (so you can change them without rewriting), a timer for the loop speed, alarms for values out of range, and a safe state (for example fan ON, valve closed) if a sensor or cable fails.
Languages: ladder logic for PLCs, and C, C++ or Python for microcontrollers and PCs.
Networked measurement and control systems
Instead of one cable per device, all devices share a network.
- Address: every node has a unique ID, so the controller knows who sent what.
- Packet: a small block of data with a header (who it is for and from), the data itself (such as 31°C) and a check code to detect errors.
- Fieldbus in a factory: Modbus, PROFIBUS, CAN or Industrial Ethernet, using one twisted cable for many devices.
- Wireless: Wi-Fi, LoRa or mobile data for places where cables are hard to lay.
- SCADA (supervisory control and data acquisition): a central screen that collects readings from many PLCs, draws trends, raises alarms and lets an operator send commands.
- IoT: ordinary devices with sensors that send data over the internet.
Why network? less wiring, easy to add devices, remote monitoring, data stored for study. Care needed: delay (latency), lost packets, cable faults and security (use passwords, separate networks and updates).
Try it: draw your own network
Choose a place you know: a school, a farm or your home. List three sensors, one controller and two actuators. Draw them with one shared cable. Give each sensor an ID. Write a 4-line control program. In the 3D, set the limit just below the temperature, send a reading and predict whether the fan will start before you look.
Key formulas and definitions
- Control loop: read → decide → write → repeat
- Cables needed: separate wiring = n, shared bus = 1 (+ short drops)
- Packet = header (address) + data + check code
- ADC: number = voltage / full scale × (2^bits − 1)
- Update rate (Hz) = 1 / loop time (s)
Worked examples
1. A plant has 12 sensors. How many long cables to the controller are needed with separate wiring, and with one bus?
Separate wiring: 12 cables. One bus: 1 long cable (plus short drop wires).
2. A 10-bit ADC reads 5 V full scale. The input is 2.5 V. What number does it give?
Number = 2.5/5 × 1023 ≈ 512.
3. A control loop waits 0.5 s each turn. How many readings per second?
1 / 0.5 = 2 readings per second.
4. Fan ON if temperature > 38°C. The reading is 44°C. What does the program do?
44 > 38 is true, so it sends the fan-ON command.
5. A 4–20 mA sensor reads 12 mA for a 0–100°C range. What is the temperature?
(12 − 4)/(20 − 4) × 100 = 8/16 × 100 = 50°C.
6. A packet of 120 bits is sent on a 9600 bit/s link. How long does it take?
120 / 9600 = 0.0125 s = 12.5 ms.
Common mistakes
- Thinking a network means the internet. A factory bus can be a small local network.
- Forgetting addresses. Without IDs the controller cannot tell sensors apart.
- Ignoring delay and lost packets. Safety actions must not depend on a slow link.
- Leaving out a safe state. If a cable is cut, the machine should go to a safe condition.