What you learn today
- Assign pins with the screwdriver
- Use db as a device of its own
- Show Setting on the housing
Six slots and a value of its own: the IC housing is more than a holder for the chip. Before your program can read a sensor, the housing has to know which sensor is meant.
Assigning pins
- The housing has the pins d0 to d5. Each pin points to a device on the same data network.
- You assign them with the screwdriver: aim at the pin on the housing and cycle through the devices the network knows.
- A pin remembers one specific device. If you tear down the sensor and rebuild it, it is a new device for the housing – then you set the pin again.
- A free pin is no problem as long as the program does not use it.
l r0 d0 Pressure # sensor on d0
l r1 d1 Pressure # second sensor on d1
If the chip reads from a pin without a device, it reports DeviceNotFound and stays on that line. As soon as the device is assigned again, it carries on.
db: the housing itself
db needs no screwdriver, it is always there. The housing has LogicTypes of its own:
| LogicType | read/write | Meaning |
|---|---|---|
Setting | both | a free-to-use value, the housing displays it |
Error | read | 1 if the chip currently has an error |
On | both | housing switched on |
Power | read | housing has power |
Setting as a display
The value in db Setting appears on the housing's small screen. For a quick look you do not need a display of your own:
l r0 d0 Temperature
sub r0 r0 273.15
s db Setting r0 # housing shows degrees C
With l r1 db Setting you read the value back. Other chips and devices on the network can read it as well – that becomes important later when chips talk to each other.
The housing is your test bench. If you do not trust a value, write it to db Setting and look at what the chip really sees.
In a later lesson you learn alias. An alias on a pin, such as alias Sensor d0, then also shows at the housing's screw.
Diagram
Exercise
Task
An inside gas sensor is attached to d0, an outside one to d1. The housing should show how many kPa the inside pressure is above the outside pressure:
db Setting = inside pressure − outside pressure
Hints
Hint 1
Two l with Pressure, one per pin.
Hint 2
The difference with sub, the result onto the housing with s db Setting ….
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