What you learn today
- Transfer values over distance
- Sender and receiver
- Limits of remote control
The outpost is far away from the base. Running a data cable out there is tedious. The logic transmitter (StructureLogicTransmitter) transfers values without a cable.
Two modes
A logic transmitter has two modes that you switch on the device:
| Mode | value | job |
|---|---|---|
| Active | TransmitterMode.Active = 1 | sender: holds a value of its own in Setting |
| Passive | TransmitterMode.Passive = 0 | receiver: is linked to an active sender with the screwdriver |
That is what the game code says: an active sender adds itself to a list of all senders. On the passive receiver you pick one of them with the screwdriver. The code checks no distance limit while doing so.
Mirroring
The passive receiver mirrors its counterpart: every value you read on the receiver really comes from there. If a chip at the outpost reads the receiver, it gets the Setting of the sender at the base. If it writes something into it, it ends up at the sender:
sbn RADIO HASH("Funk Basis") Setting charge # base: into the sender
l value radio Setting # outpost: read the receiver
Only the receiver needs power for this (50 W according to the game data). When reading and writing, the code checks only whether the receiver has power. The Setting of an active sender goes through even when the sender itself has no power.
Limits of remote control
A sender carries one value. For more values you need more sender pairs, or you pack several values into one number, which comes later in the course. The failures matter more:
- Without power the receiver returns 0 and reports itself as not readable. An
lorlbnon it then stops withIncorrectLogicType. Whatever you write into it without power, the game silently drops. - Without a linked sender the receiver is not readable either.
- If you switch the mode on the device, the link is gone and
Settingis 0. Linking with the screwdriver also sets the sender'sSettingto 0.
That is why the receiver goes on a pin, and you check it before every read:
bdns radio no_radio # device gone?
bdnvl radio Setting no_radio # not readable? (power, link)
l value radio Setting
A radio value can be stale without you noticing. If the chip at the base stops, the last Setting stays in the sender. For anything important, let the sender transmit a counter as well, which the receiver checks for change. That comes back with the watchdog.
Only control by radio what stays safe without radio too. The outpost must go into a safe state with its own chip when the link breaks.
Diagram
Exercise
Task
At the outpost a passive logic transmitter hangs on d0. It mirrors the base's charge level in percent.
- Check the receiver with
bdnsandbdnvlbefore reading. - Wall lights “Postenlicht” only on if the base has more than 30 %.
- LED “Basisladung” shows the value, −999 without radio. Without radio the light is off.
Hints
Hint 1
Set charge to NOVALUE first – then the value is right when a check jumps.
Hint 2
bdns radio no_radio and bdnvl radio Setting no_radio before the l.
Hint 3
−999 is not greater than 30, so without radio the light stays off by itself.
Quiz
5 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