What you learn today
- Values via radio
- Commands back
- Safety
The ice mine is two kilometres away from the base. Out there a chip controls the pumps, and in the base's control room another one operates it. How the values travel over the distance you saw in remote control. Today is about the side that commands – and about how it notices that something is wrong out there.
The interface
Both chips share a few Logic Memories:
| Memory | written by | content |
|---|---|---|
| “Fern_Puls” | outpost | heartbeat, counts up every tick |
| “Fern_Druck” | outpost | a reading, here the tank pressure |
| “Fern_Befehl” | control room | desired pump state, 0 or 1 |
| “Fern_Nr” | control room | running number of the command |
| “Fern_Quittung” | outpost | number of the last command executed |
Every address has exactly one writer. That way no chip ever overwrites what the other one just reported.
Values over the radio link: is the link alive?
A reading alone does not tell you whether it is fresh. If the radio link stands still, the memory simply shows the last value forever. That is why the outpost counts a heartbeat up, and the control room measures how long it has not moved:
lbn puls SPEICHER HASH("Fern_Puls") Setting Average
seq tmp puls oldPulse # 1 = no new heartbeat
add age age 1
mul age age tmp # new heartbeat: age 0
move oldPulse puls
slt link age TIMEOUT
Without a link the control room no longer shows the pressure, but −1. An old value that looks like a current one is more dangerous than none at all.
Commands back
A command gets a number. The outpost executes it and writes the same number back as an acknowledgement. As long as the two numbers differ, the command is on its way or stuck:
sne tmp ack nr # outpost has not executed yet
add pending pending 1
mul pending pending tmp
sgt tmp pending WARTEN
After a restart the control room reads the number from the memory instead of starting at 0 again. Otherwise the outpost would take the next command for an old one.
Safety
- No commands without a link. A button press into the void would otherwise be executed by surprise later, once the link is back.
- A warning without acknowledgement. Then the operator knows he has to go and look.
- The outpost decides about its own safety. On link loss it goes into its safe state, no matter what the control room wanted last.
Exercise
Task
Build the control room. Light “Verbindung”: on while “Fern_Puls” changes within 10 passes. The button “Pumpe_Schalten” toggles “Fern_Befehl” between 0 and 1 and increases “Fern_Nr” – only with a link. After a restart the chip continues with the number in the memory. Flashing light “Quittung_fehlt”: on when “Fern_Quittung” has not matched the number for more than 6 passes. The display “Fern_Druck” shows the value from the memory of the same name, -1 without a link.
Hints
Hint 1
Heartbeat: seq tmp pulse oldPulse, add age age 1, mul age age tmp – a new value resets the age to 0.
Hint 2
Button: rising edge with sgt tmp button oldButton, then and with link, toggle with seqz command command.
Hint 3
Before start: read the number from “Fern_Nr” and replace NaN with 0.
Quiz
4 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- 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