What you learn today
- Write values to displays and db
- Read LineNumber
- add counters
The workshop heater switches. But how often? Too often, because the hysteresis is too narrow? Without measuring you are only guessing. A probe is a line that writes an intermediate value to a place where you can see it – like a meter you clip onto a wire.
Three places for a probe
| Place | Line | good for |
|---|---|---|
| Housing | s db Setting r0 | one value, without any extra device |
| LED display | sbn DISP HASH("Sonde1") Setting r0 | several values at once, with a unit via Mode |
| Logic Memory | sbn MEMORY HASH("Sonde2") Setting r0 | values a second chip should evaluate |
Write the value the way the chip sees it, before any conversion. That is exactly when NaN, Kelvin instead of Celsius and doubled sums stand out immediately.
s db Setting overwrites the setting of the housing. If another chip uses that setting as a mailbox, the probe destroys its message. Use a display of its own then.
LineNumber: where is the chip?
LineNumber of a housing is the line its chip is on right now. A second chip can read and display it. If the display shows the same line in a waiting loop for minutes, the chip is waiting there for a condition that never happens – for example for a door that is already open.
define GEHAEUSE HASH("StructureCircuitHousing") # IC housing
lbn line GEHAEUSE HASH("Schleusenchip") LineNumber Average
sbn ANZ HASH("Sonde1") Setting line
In normal operation the value changes all the time, usually it is the place where the chip waits for the next tick. LineNumber becomes meaningful when it stops moving.
Adding counters
Many questions are “how often?”: how often does the loop run, how often does the heater switch on, how long does a state last? A counter answers that.
add passes passes 1 # counts every tick
sgt edge on old # 1 only on a change from 0 to 1
add starts starts edge
move old on
The edge counter only counts switching on, not every tick with the heater running. If it rises every few seconds, the hysteresis is too narrow.
Some probes are worth keeping forever. A display with the number of switch-on events hangs next to the heater in many bases.
Diagram
Exercise
Task
The workshop heater already works. Add two probes: the housing shows the measured temperature in Kelvin (-1 if the sensor is missing), the display “Schaltzahl” counts how often the heater was switched on. The control itself stays unchanged.
Hints
Hint 1
First select tmp ok temp -1, then s db Setting tmp.
Hint 2
You detect switching on with sgt edge on old: 1 only if on is 1 now and was 0 before.
Hint 3
After counting move old on, otherwise the chip counts every tick.
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