Skip to content
Tactiverge

School/△ Builder/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?

About 45 min · 3 goals · Checked by automated tests

1.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.

2.Predict

Which requirement can you actually test in the simulator?

Guess first. Being wrong here is how the surprise works.

3.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

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.

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.

4.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.

Can't use the interactive? Read a description instead

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.

5.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Which is the best requirement for the project?

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

Your thermometer could fail and read −40 °C. What should the controller do?

Practice 3 · a fresh version every time

A 10-bit ADC with a 5 V reference reads 602. Using volts = count × Vref ÷ 2^n, what voltage is that, in volts?

V

Practice 4 · a fresh version every time

In ice water (0 °C) your sensor reads 104 counts; in boiling water (100 °C) it reads 874 counts. A new reading is 682 counts. Assuming a straight line, what temperature is that, in °C?

°C

Practice 5 · a fresh version every time

A temperature sensor outputs 0 mV at 0 °C and rises by 10 mV for every 1 °C. It reads 280 mV. What temperature is it measuring, in °C?

°C

Practice 6

The thermometer jitters by ±0.3 °C. Which design choice most directly stops the heater chattering?

7.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.

Open BUILD 007: Design a Smart Greenhouse →

8.Reflect

Concepts: The sense–think–act loop · Super-loops and finite state machines · Open-loop and closed-loop control · How sensors measure