stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 104

Day 104 of 365 · Advanced · Month 4: Network in detail

Project: device scanner

A chip that counts its own pins, shows the number on the housing and raises an alarm when the main sensor is missing.

Project 25 min Week 15

What you learn today

  • Check all pins
  • Show the number of connected devices
  • Report a missing device

This week you learned to address devices directly, check whether they are present and pick pins through a register. The project puts it all together: a device scanner for the control cabinet.

The setup

PinDevice
d0main sensor (gas sensor)
d1–d4further devices, any kind
d5warning light

The scanner counts how many of the pins d0 to d4 are in use and writes the number to the housing (db, value Setting). If the main sensor on d0 is missing, the warning light goes on.

Pins in a loop

Instead of writing sdse five times you take the pin from a register. dr2 means: the pin whose number is currently in r2.

move i 0
count:
sdse present dr2  # pin number i in use?
add total total present
add i i 1
blt i PINS count
Warning

With dr2 the register number is part of the name, not the alias. Even if i is an alias for r2, the pin is still called dr2. If someone changes the alias, dr2 has to follow.

Milestones

  1. All five pins in use: the housing shows 5, the warning light is off.
  2. Two devices are removed: the housing shows 3.
  3. The main sensor is missing: housing 4, warning light on.
  4. Everything gone except the warning light: housing 0, warning light on – and no error.
Tip

Reset the counter to 0 at the start of every pass. Otherwise the chip keeps counting up every tick.

Diagram

Reading with l, writing with s Gas sensor (d0) Temperature 293.15 IC10 r0 = 293.15 Wall light (d1) On 1 l r0 d0 Temperature device → register s d1 On 1 value → device
Six pins, one housing: the scanner checks d0 to d4 one after another, d5 is the warning light.

Project task

Task

Count how many of the pins d0 to d4 are in use and write the number as Setting to the housing (db). If the main sensor on d0 is missing, switch on the warning light on d5, otherwise off. The chip must never stop with an error.

Milestones

  1. Milestone 1: all five pins in use
  2. Milestone 2: two devices removed
  3. Milestone 3: main sensor missing
  4. Milestone 4: only the warning light left

Hints

Hint 1

move count 0 and move i 0 right after the yield.

Hint 2

Inside the loop: sdse present dr2, add up, increase i, jump back with blt i PINS counting.

Hint 3

Afterwards s db Setting count, then sdns for the warning light.

Quiz

3 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

Esc
↑ ↓ selectEnter open/ opens search anywhere