Syscall 2: Firmware, home

BenchChapter 10: Meshes

B74AUTO RANGE

The task

P0 reads a small signal on CH1. A meter shows it through P1, smoothed onto CH2.

Under 25, the meter uses its fine range: P1 gets 4 times the reading and P2 lights its LED.

From 25 up, P1 gets the reading itself and the LED is dark.

The board

The chip of AUTO RANGEChip u1 with 3 ports: P0 analog in, reaching V1, CH1; P1 pwm out, reaching R1, C1, CH2; P2 digital out, reaching R2, D1, CH3.u1CHIP SC-2P0ANALOG INV1, CH1P1PWM OUTR1, C1, CH2P2DIGITAL OUTR2, D1, CH3
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes. On a narrow screen, scroll the board sideways to see all of it.
Sources
V1 1.4 V sine at 5 Hz and V2 1.6 V
Resistors
R1 10 kΩ and R2 330 Ω
Capacitors
C1 1 µF
LEDs
D1 yellow
Probes
CH1, CH2, and CH3

Key idea

4 times anything under 25 stays under 100, so the fine range never clips.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

Test the reading against 25 first, then write both pins on each branch.

Hint 2Show

SUB 25, JL to the fine branch; add the 25 back on both sides before you write.

Solution

Reveal the Full SolutionThe complete program for AUTO RANGE. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

A gain of 4 and a lamp below 25.

u1SC-2 standard

L: IN P0
SUB 25
JL LO
ADD 25
OUT P1
MOV A, 0
OUT P2
JMP L
LO: ADD 25
MUL 4
OUT P1
MOV A, 1
OUT P2
CYCLES
2000
at par
ENERGY
4000
at par
NODES
1
at par
INSTRUCTIONS
13
at par