Lite / Building Machines That Respond / Week 27
Project: design a greenhouse that responds
A cold night, a noisy thermometer and a vent someone forgot to close. Can your controller keep the seedlings alive, and can you prove it?
Why should I care?
This is where the whole term joins up: a sensor pipeline (week 21–22), decisions as a state machine (week 23), an actuator driven with timing (weeks 24–25) and feedback (week 26). Engineers call this a system design, and the evidence you collect is what makes it engineering rather than guessing.
- Design a simulated machine that reads a noisy sensor, decides with a state machine or threshold and acts.
- Write testable requirements and trace each one to a design decision.
- Draw a complete state diagram with every transition labelled and no stuck states.
Predict
Which requirement can you actually test in the simulator?
- The plants should be happy
- The air must stay between 16 and 24 °C for all but 10 minutes of the night
- The heater should be clever
Guess first, then reveal
A testable requirement names a quantity, a limit and how long: anyone can run the night and check pass or fail. 'Happy' and 'clever' are wishes until you turn them into numbers.
Discover
Run the default night first and write down what fails. Then sketch your controller on paper (states, thresholds, smoothing) BEFORE you change any setting, and only then try it. Keep a log of every run.
What the interactive shows (text version)
Smart Greenhouse Level 3 simulates a cold night with the vent open from 22:00 to 01:00 and a noisy thermometer. You set an on/off thermostat (switch-on and switch-off temperatures and optional smoothing). Results report minutes outside 16–24 °C, heater switchings and energy, so each run can be logged against the project's requirements.
Understand
Requirements first
Start with a short list of must requirements, each with a number and a test: 'Air temperature must stay within 16–24 °C for all but 10 minutes of the simulated night.' 'The heater must switch no more than 80 times a night.' Add should requirements for nice-to-haves, such as lower energy. Every later decision should point back to a requirement.
The system on one page
Draw the pipeline: thermometer → ADC → calibration → (optional smoothing) → decision → heater driver → heater, and the greenhouse's heat loss closing the loop. Label each arrow with its units (°C, mV, counts, %, W). Note where noise enters, and how your design copes with it (a hysteresis band wider than the noise, or averaging).
A complete state diagram
Even a thermostat is a state machine: HEATING and IDLE, with transitions 'temp < on-threshold' and 'temp > off-threshold'. Add a FAULT state for an impossible reading (say below −20 °C or above 60 °C) that switches the heater off and raises an alarm. Check every state has an exit and every event is handled or deliberately ignored.
Explain it another way
Intuitive
Before building a treehouse, you agree what it must hold, draw it, and decide what happens if a branch snaps. Then you build, and test it against what you agreed.
Technical
This is a lightweight version of systems engineering: requirements → architecture → detailed design → verification. Traceability (each requirement linked to a design element and a test) is how real teams prove a system does what it should.
Applied
Commercial greenhouse controllers combine exactly these parts, with more sensors (humidity, light, CO₂) and more actuators (vents, screens, misting), each specified with numbered requirements and tests.
Worked example 1
Turn 'the heater shouldn't wear out' into a testable requirement.
'The heater relay should switch no more than 80 times in the simulated night.' It names a quantity (switchings), a limit (80) and a test window (one night).
Common mix-ups
You design by trying settings until it passes.
✓ Trying is part of it, but engineers predict first, record every run and explain why the final design works.A thermostat is too simple to need a state diagram.
✓ Drawing it reveals the missing fault state and the behaviour inside the hysteresis band.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Term project, part 1: write your requirements (at least three musts with numbers), draw the system diagram with units on every arrow, and draw the full state diagram including a FAULT state. Then design your first controller settings and predict, in writing, how many switchings and minutes outside the band you expect.
Reflect
Which requirement was hardest to make testable, and how did you do it?
Write your answer on paper or in your own notes. Lite never stores what you write.