What you learn today
- Heating and cooling with a dead band
- Traffic-light display
- Alarm when limits are exceeded
The greenhouse on Mars is freezing in the morning and too warm at noon. This week you built everything it needs. Now it comes together in one chip.
The devices
| Device | Name |
|---|---|
| gas sensor | “Klima” |
| wall heater | “Klimaheizung” |
| wall cooler | “Klimakuehler” |
| LED display | “Klimaanzeige” |
| klaxon | “Klimaalarm” |
The rules
Temperature: target 21 °C. Heater on below 19 °C, off from 20 °C. Cooler on above 23 °C, off from 22 °C downwards. Never both at once.
Display: temperature in °C, Mode Celsius. Colour:
| Situation | Colour |
|---|---|
| 19 to 23 °C | green |
| otherwise | yellow |
| alarm | red |
Alarm: below 15 °C, above 30 °C or sensor gone. Then red on the display and the klaxon on, sound Sound.Danger.
How to go about it
- Compute the limits from the target before the loop – as in the dead band lesson.
- The two hystereses including the interlock.
- The alarm: two comparisons, one
snan, twoor. - The colour as a select cascade: green, then yellow, then red for the alarm.
- Output.
For the traffic-light band you need the distance to the target without a sign:
sub tmp temp TARGET
abs tmp tmp
sgt tmp tmp 2 # more than 2 degrees off
select colour tmp Color.Yellow colour
Milestones
- Cold: heater on, cooler off.
- Hot: cooler on, heater off.
- In the dead band: both off, display green.
- Display in °C, Mode Celsius.
- Yellow outside 19 to 23 °C.
- Alarm on frost and heat: klaxon on, display red.
- Sensor gone: heater and cooler off, alarm.
The program gets a good 50 lines long. Number the sections, then on a red test you find the right spot right away.
Diagram
Project task
Task
Build the climate control from the lesson. Devices: gas sensor “Klima”, wall heater “Klimaheizung”, wall cooler “Klimakuehler”, LED display “Klimaanzeige”, klaxon “Klimaalarm”.
- Dead band around 21 °C: heater 19/20 °C, cooler 23/22 °C, never both.
- Display: °C, Mode Celsius; green 19–23 °C, otherwise yellow, red on alarm.
- Alarm below 15 °C, above 30 °C or without sensor: klaxon on with
Sound.Danger.
Milestones
- Milestone 1: cold – heater on
- Milestone 2: hot – cooler on
- Milestone 3: dead band – both off, green
- Milestone 4: display in °C
- Milestone 5: yellow outside 19 to 23 °C
- Milestone 6: alarm on frost and heat
- Milestone 7: sensor gone – all off, alarm
Hints
Hint 1
Limits and sound before start: – as in the dead band lesson.
Hint 2
Alarm: slt alarm temp FROST, sgt for HEAT, snan, an or each.
Hint 3
Colour: green, yellow beyond 2 degrees, red on alarm – in that order.
Quiz
2 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed all milestones of the project
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in