What you learn today
- Leader chip with two followers
- Watchdog
- Shared memory
Two living zones, two follower chips each heating its zone, and a leader chip in the control room. If one follower fails, the other should take over its zone as well – the heaters of both zones are on both networks. This is the chip network from this week in one plant.
The setup
| Device | Prefab | Name | Purpose |
|---|---|---|---|
| Dial | StructureLogicDial | “Soll” | target temperature in °C |
| IC housing | StructureCircuitHousing | “Folger1”, “Folger2” | command in Setting |
| Logic memory | StructureLogicMemory | “Puls1”, “Puls2” | heartbeats of the followers |
| Logic memory | StructureLogicMemory | “Wert1”, “Wert2” | measured temperature of the zone |
| LED display | StructureConsoleLED5 | “Mittel” | average of the living zones |
| Wall light | StructureWallLight | “Ausfall” | a follower has failed |
The protocol
The command to a follower is packed: bits 0–7 the setpoint in °C, bit 8 means “take over the other zone as well”. Follower 1 gets bit 8 when follower 2 is dead, and vice versa.
Milestones
- Both followers get the setpoint from the dial, 20 °C without the dial.
- The display shows the average of the reported temperatures.
- If a pulse stands still for more than 10 ticks, the light comes on and the other follower gets bit 8.
- The average only counts living followers. When a pulse comes back, everything is normal again.
- If a pulse memory is missing, the follower counts as failed at once.
The two watchdogs are the same code with different registers. If you want to save lines, make a subroutine of it – then old, still and dead have to be copied before and after the call. With two followers the duplicated block is clearer.
select tmp alive tmp 0 instead of mul tmp tmp alive: a dead follower can return NaN, and NaN times 0 stays NaN. select, on the other hand, throws the value away cleanly.
Diagram
Project task
Task
Build the leader chip following the milestones above. The defines and aliases are already there.
Milestones
- Milestone 1: setpoint to both
- Milestone 2: averaging results
- Milestone 3: watchdog and handover
- Milestone 4: follower returns
- Milestone 5: failures
Hints
Hint 1
Two watchdog blocks as on Thursday, one per pulse memory.
Hint 2
Command: move cmd target, then ins cmd dead2 8 1 for follower 1 – and the other way round.
Hint 3
Average: per follower seqz alive dead, read the value, select tmp alive tmp 0, add up, divide at the end.
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