Course 6.1Lesson 2 of 3
An automated system never checks only once. It reads, compares and acts in a loop, and what the actuator does changes the next reading. This is feedback. This lesson follows a control loop step by step, draws it as a flowchart and writes it in pseudocode and in Python.
Try the code and the simulations beside the lesson.
You set a room heater to keep the room warm. The room is cold, so the heater comes on. The room warms up. After a while it is warm enough, so the heater goes off. The room slowly cools, and the heater comes on again.
The heater does not check the room once. It checks again and again for as long as it is switched on. This repeated sequence is a control loop:
Look at what happens after the heater comes on. The heater warms the room, so the next reading from the temperature sensor is higher. The output of the system has changed its own input. This is feedback.
Feedback lets the system correct itself. If the room becomes too warm, the next reading shows it, and the microprocessor switches the heater off. If the room cools, the next reading shows that too. So the temperature stays close to the stored values without anyone touching the heater.
A system with feedback is a control system. A system that only measures and records, such as a weather station, has no actuator to change what it measures, so it has no feedback of this kind.
Suppose the heater went off at and on again just below it. It would switch on and off every few seconds. Many systems therefore use two stored values: the heater comes on below a low value, such as , and goes off above a high value, such as . Between the two, nothing changes.
The flowchart uses the standard symbols of the syllabus. The rounded box (the terminator) is the start. The parallelogram (input/output) is the reading of the sensor. Each diamond (decision) asks one question with a Yes and a No line. The rectangles (process) switch the heater. The flow lines carry control back to the reading, so the loop repeats.
The box marked pseudocode is Cambridge pseudocode, the form used in the examination. It is shown, not run. The Python box below it does the same job, and you can run it.
CONSTANT Low ← 20
CONSTANT High ← 23
WHILE TRUE DO
INPUT Temperature
IF Temperature < Low
THEN
OUTPUT "Heater on"
ENDIF
IF Temperature > High
THEN
OUTPUT "Heater off"
ENDIF
ENDWHILEIf the reading is between the two values, neither IF is true, so the heater stays as it was.
The program runs the loop for 30 minutes. In each minute the heater warms the room by or the room cools by . That change is the feedback: it decides the next reading.
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.