Control Systems, Sensors and Feedback

IB Computer Science · Control (HL)

The components of a control system. A sensor is an input transducer: it converts a physical quantity such as temperature, light, pressure or position into an electrical signal. A microprocessor compares that reading with a stored set point and decides what to do. An actuator is an output device that changes the physical world — a motor, a heating element, a valve, a relay. A transducer is the general term for any device converting energy from one form to another, so sensors and many actuators are both transducers. Precision of vocabulary is marked here.

Open and closed loop. An open-loop system acts on its instructions without measuring the result: a sprinkler that runs for twenty minutes at six o'clock waters the garden whether or not it rained overnight. It is cheap, simple and adequate when the outcome is predictable from the input. A closed-loop system measures the output with a sensor and feeds the reading back, so the controller acts on the error between set point and actual value. Its decisive advantage is that any disturbance — a window opened, a load added, a component ageing — appears in the measurement and is compensated automatically, without anyone having to program for that specific situation.

Negative feedback. The feedback must be negative: the measured value is subtracted from the set point, so the closer the system gets to target the weaker the correcting action becomes. That is what produces stability. Positive feedback, in which the measurement increases the driving signal, causes the system to run away. In practice a dead band is also needed: if a thermostat switched on the instant the temperature fell below target and off the instant it rose above, it would cycle rapidly and wear out the equipment, so real systems switch on below target minus a margin and off above target plus a margin.

Real-time constraints. A control system is usually a real-time system, meaning correctness depends on timing as well as on the answer. In a hard real-time system a missed deadline is a failure — an airbag controller, an anti-lock braking system, a pacemaker. In a soft real-time system a missed deadline degrades quality but does not constitute failure, as with a dropped frame in video streaming. This distinction determines how a system must be designed and tested: hard real-time systems must have a provable worst-case response time, not merely a good average one.

OPEN LOOP VERSUS CLOSED LOOP — DIFFERENT BY ONE WIRE OPEN LOOP — no feedback path SET COMMAND turn the oven on for 30 minutes CONTROLLER counts time ACTUATOR turns on the heating element TEMPERATURE The controller DOES NOT KNOW the real temperature — if the door is open or it is cold outside, it still does exactly the same thing CLOSED LOOP — has a feedback path SETPOINT want 22 degrees - so sánh MICROPROCESSOR computes the error ACTUATOR turns the oven on or off ROOM real temperature temperature SENSOR NEGATIVE FEEDBACK PATH: the real temperature is SUBTRACTED from the setpoint, so the larger the error, the stronger the action The MINUS sign at the comparison circle is what creates stability — POSITIVE feedback would make the system lose control
The only difference between the two diagrams is the blue wire running backward from the output to the input, and the whole answer to every question about control systems lies in that wire. An open loop does not measure the result. The controller does exactly what it is commanded — turn the oven on for 30 minutes — and has no idea what the real temperature is. If a window is open, if it is unusually cold, or if the oven itself is broken, the system still does exactly the same thing. An open loop is cheap, simple and sufficient when the result can be predicted from the input, for example a plant-watering system running on a timer. A closed loop measures the result and corrects itself. The sensor reads the real temperature; that value is SUBTRACTED from the setpoint to give the error; the microprocessor uses the error to decide whether to turn the actuator on or off. Because every disturbance — an open door, people entering the room, a change in weather — shows up in the measured temperature, the system compensates by itself without anyone programming for each situation separately. This is the core advantage and it must be stated exactly like this in the exam. The minus sign at the comparison circle is the most important detail. Negative feedback means the measured result reduces the control signal: the closer to the setpoint, the weaker the action, so the system settles. If it were connected as positive feedback — the result increases the control signal — the system would amplify itself and lose control. Every stable control system relies on negative feedback. A practical detail that is often asked in addition: if the controller turns the oven on the moment the temperature falls below 22 and turns it off the moment it exceeds 22, it will switch on and off continuously around the setpoint and damage the equipment. So real systems use a dead band: turn on when below 21.5 and turn off only when above 22.5.

Worked example: Designing a control system for a greenhouse, stating all three components

A greenhouse needs to keep its temperature between 20 and 24 degrees and keep soil moisture above a threshold. State the sensors, actuators and control logic, then explain why a closed loop is mandatory here.

Solution

Sensors — the input component. A temperature sensor reads the air temperature. A soil moisture sensor reads the amount of water in the soil. A light sensor should be added to distinguish day from night, because the control strategy differs between the two. Each sensor is an input transducer: it converts a physical quantity into an electrical signal that the microprocessor can read.

Actuators — the output component. A heating element for heating. A motor that opens and closes the roof vents to lower the temperature. A solenoid valve that opens the irrigation water. A motor that pulls a shade curtain could be added. Each actuator only receives an on or off command, or receives a power level, and itself knows nothing about the goal.

Control logic, written with a dead band. If the temperature falls below 20, turn on the heater and close the vents; turn the heater off only when the temperature exceeds 21, not immediately at 20. If the temperature exceeds 24, turn off the heater and open the vents; close them again only when the temperature falls below 23. If the soil moisture falls below the threshold, open the valve for a period of time and then wait before measuring again — because water needs time to soak in, and measuring right after watering gives a value that does not yet reflect reality.

Why a dead band is needed. If the heater is turned on at exactly 20 and off at exactly 20, then every small fluctuation around the threshold would make the relay open and close continuously. This causes mechanical wear, causes electrical spikes, and makes the temperature fluctuate more, not less. A one-degree dead band solves this problem completely, at the cost of a slightly larger temperature oscillation amplitude.

Why a closed loop is mandatory here, not merely better. The temperature in a greenhouse is affected by variables that the system cannot know in advance: the intensity of sunshine changing with clouds, wind, the outdoor temperature, the number of people coming and going, and even the heat given off by the plants and soil themselves. An open-loop system running on a schedule — for example heating for three hours every morning — would be right on one particular day and wrong on every other day. A closed-loop system does not need to know why the temperature is off; it only needs to measure that it is off and compensate. This is exactly the general answer: a closed loop handles any disturbance without needing to know the list of those disturbances in advance.

A note on watering, a mark-earning detail. The irrigation control loop has a large delay between action and measured result. If the controller keeps watering because it has not yet seen the moisture rise, it will water too much and only then see the consequence. So systems with a large delay must water in a fixed dose and then wait, rather than controlling continuously according to the error.

Worked example: Why some systems must be hard real-time

Compare the timing requirements of three systems: (a) a car airbag controller; (b) an online music streaming application; (c) a fingerprint time-clock system. State the type of real-time and the consequences for design.

Solution

(a) Airbag controller — HARD real-time. After the acceleration sensor detects a collision, the airbag must be deployed within a few tens of milliseconds; later than that and the driver has already hit the steering wheel and the airbag bursting out then causes additional injury. Here a missed deadline is a failure, not an inconvenience.

Design consequences, and this is the part that is marked. It is not permitted to prove only that the AVERAGE response time is good; you must prove that the response time in the worst case is still within the deadline. This brings a series of constraints: a dedicated microprocessor running only this task; no dynamic memory allocation because its timing is unpredictable; limited or forbidden nested interrupts; and usually redundant hardware together with a self-test mechanism at startup.

(b) Music streaming application — SOFT real-time. If a data packet arrives late, the audio is interrupted for a very short moment. Quality falls, the user may be annoyed, but the system does not fail and no one is in danger. Design consequences: use a buffer to absorb latency fluctuations, use UDP to avoid retransmission cost, and have a mechanism to conceal gaps when data is missing. The goal is to optimize average quality, not to guarantee the worst case.

(c) Fingerprint time clock — NOT a real-time system. The point to recognize is that not every system with a speed requirement is a real-time system. Here, if recognition takes two seconds instead of half a second the result is still entirely correct and the user is just slightly impatient. There is no deadline beyond which the result becomes worthless. This is a system that needs good performance, not one that needs a timing guarantee.

How to tell them apart to answer with certainty in the exam. Ask: if the result arrives later than the deadline, does it still have value. If the result becomes worthless or harmful, it is hard real-time. If it still has value but quality falls, it is soft real-time. If it still has full value, it is not a real-time system.

Common mistake

Trap 1 — mixing up sensor, actuator and transducer. A sensor is an INPUT transducer that converts a physical quantity into an electrical signal; an actuator is an OUTPUT device that changes the physical world; transducer is the general term. This topic is marked on precise vocabulary.
Trap 2 — describing a closed loop but forgetting the NEGATIVE sign of the feedback. The measured value must be SUBTRACTED from the setpoint; that is what creates stability. Positive feedback makes the system amplify itself and lose control.
Trap 3 — treating every system that needs a fast response as real-time. The right question is: if the result arrives later than the deadline, does it still have value. Worthless or harmful means hard; reduced quality means soft; still valuable means not a real-time system.

Key takeaway

Lesson 1 wrap-up. Four things to take into the exam room. One, the three components: sensor, microprocessor compared with the setpoint, actuator — name them correctly and give their roles correctly. Two, a closed loop handles any disturbance without needing to know the list of disturbances in advance; this is the general answer to every question about why feedback is needed. Three, feedback must be negative, and real systems also need a dead band so they do not switch on and off continuously around the setpoint. Four, the three levels of timing requirement are distinguished by asking whether a result that arrives late still has value, and a hard real-time system must prove the worst case, not the average.

← Dedicated Operating Systems, Embedded Devices and Hiding Complexity · All IB Computer Science lessons · Practice IB Computer Science questions (free, instant scoring) · Centralised and Distributed Control, Automation and Its Consequences →