Week 7 · Lesson 4 · 55 minutes

Keep control when the connection fails

Connect sensors feedback local control and cloud storage.

Planned lesson. Follow your teacher’s teaching order.

Source workbook pages: 45.

Resources

Vocabulary

Vocabulary
sensor: A component that measures a condition; actuator: A component that makes a physical change; feedback: A new measurement used to adjust the next action
55-minute lesson sequence
  1. 0–5 · Answer the retrieval alone. Compare one reason.
  2. 5–15 · Teacher models the example. Students predict each next step.
  3. 15–40 · Build, trace and test the main tasks. Work alone first; compare after a checkpoint.
  4. 40–50 · Check results. Explain a test and repair one error. Use the extension only if ready.
  5. 50–55 · Complete the exit alone. Save the evidence for the next lesson.

Try before notes

In a temperature-control system, is the temperature sensor an input or an output? What is the fan?

Build the idea

Keep the feedback loop and report upload as separate responsibilities. A local sensor-controller-actuator path can continue when a remote dashboard is unavailable. This only works if the rule and necessary inputs are available locally.

Persistent local logs can preserve readings during a network outage. Later upload needs an order, a retry policy and a way to avoid losing or duplicating records. A cloud copy is not automatically a tested independent backup.

A test list simulates inputs but does not simulate the full physical world. Explain that a real fan changes temperature and later measurements close the loop; a list of numbers alone does not demonstrate that physical effect.

sensor → local controller → fan → room
  ↑______________________________|
local log → pending uploads → cloud

See the method

Simulation rule: fan on when temperature >= 25. Read 24 → off. Read 26 → on. Measure again after the fan acts. Using the new reading is feedback. A fixed timer with no temperature measurement is open-loop. The test list simulates readings, not real heat flow.

for temperature in [24, 26, 23]:
    fan = temperature >= 25
    print(temperature, fan)

Predict then reveal

A cooling rule is temp>=30 and not service_mode. Network is down, temp=31, service_mode=False. What should local control and reporting do?

Reveal reasoning

The local rule gives True, so the simulated fan runs. The report should be saved or queued locally for later upload under the stated design. Network failure does not change this local decision.

The fan runs but the sensor never takes another measurement. What is missing from a claimed feedback system?

Reveal reasoning

There is no new measurement of the action’s effect. The system must measure the changed process and use that reading in a later decision to demonstrate closed-loop control.

Work one step together

Read the first task. Each learner predicts the first step privately. Compare the method, then complete one intermediate row or one code iteration together. Do not display a finished workbook answer.

Practice

  1. Build decide_fan(temperature, maintenance), using the rule hot means temperature >= 25 and maintenance stops the fan. Test (24, False), (25, False), (26, True). Draw the full feedback path from temperature to sensor to controller to fan to changed temperature.

Your turn

Complete the remaining steps of task 1 alone, then the next tasks. Predict before running code. Save your own evidence before comparing.

Practice

  1. Build decide_fan(temperature, maintenance), using the rule hot means temperature >= 25 and maintenance stops the fan. Test (24, False), (25, False), (26, True). Draw the full feedback path from temperature to sensor to controller to fan to changed temperature.
  2. Build four decision rows: network up/down and reading below/at 25. Maintenance is off. The fan must work locally; reports upload when possible. State fan and upload actions in each row. Why must this design not require a cloud reply?
  3. Choose storage for non-personal reports: kiosk only, cloud only, or both. Give two reasons and one remaining risk. Is a cloud copy automatically a safe backup?

Check and explain

Cloud reporting and physical feedback are different paths; a dashboard is not what closes the control loop.

Point to the first step, row, condition or requirement that supports your answer. If results differ, find the first different state and repair one cause.

Show what you know

What makes the fan example closed-loop rather than only input-process-output?

HL challenge when ready

The temperature alternates 24, 25, 24, 25. What problem can the simple rule cause? Suggest one idea, not a complete program.

Week 7 homework

Show working. Keep code and output. Stop at 25 minutes and mark where you reached.

  1. Make one revision card with three short parts. Convert decimal 46 to eight-bit binary and hex. Give the output of True AND NOT True. Name the CPU register holding the next instruction address.
  2. A saved log has values [24, 25, 26]. Write the result of count_high(values, 25). Explain how a local controller can keep working when cloud access fails.
  3. Choose the one revision-map area with the weakest evidence. Create one question and a checked answer for that area. Use only content already taught.

Source workbook pages: 47.

Weekly homework (Word)

Python practice · two short prompts

Spend about 3 minutes on each during practice time. Predict, run, change one thing, then explain. These prompts do not add homework.

A starter is runnable code to explore or complete. If the playground restores your saved code, the linked starter is selected in Example: use Load example when ready. Download your work before confirming replacement.

Prompt 1

Select a safe message for missing data, keeping it distinct from a valid low reading.

No imports needed.

Hint and starter code

Missing is not the same as zero; choose the actual actuator response with the teacher for the system.

# Missing is not the same as zero; choose the actual actuator response with the teacher for the system.
reading = None
if reading is None:
    print("check sensor")
else:
    print("measured", reading)
Open this starter in Python playground →
Prompt 2

Limit an offline queue to three recent readings. Explain which evidence is discarded.

No imports needed.

Hint and starter code

A negative slice counts from the end; this policy keeps newest readings and loses the oldest.

# A negative slice counts from the end; this policy keeps newest readings and loses the oldest.
pending = [24, 25, 26]
pending.append(27)
pending = pending[-3:]
print(pending)
Open this starter in Python playground →