Syscall 2: Firmware, home

BenchChapter 4: Stars and hubs

B21ATTENUATOR

The task

R1 and R2 form a divider: CH1 gets half of what P0 puts out. C1 smooths the PWM.

P1 ticks every 40 cycles. Alternate CH1 between 1 volt and 2 volts, one level per tick.

The board

The chip of ATTENUATORChip u1 with 2 ports: P0 pwm out, reaching R1, R2, C1, CH1; P1 timer 40 cycles.u1CHIP SC-2P0PWM OUTR1, R2, C1, CH1P1TIMER 40 CYCLES
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.
Resistors
R1 1 kΩ and R2 1 kΩ
Capacitors
C1 2.2 µF
Probes
CH1

Key idea

Without the divider, 1 volt would take 20 percent duty. With it, it takes twice that.

Hints

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

Hint 1Show

A duty of 100 percent gives 2.5 volts on CH1, the most it can reach.

Hint 2Show

Sleep, set the duty to 40, sleep, set it to 80.

Solution

Reveal the Full SolutionThe complete program for ATTENUATOR. 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.

1 volt and 2 volts behind a divider that halves the output.

u1SC-2 standard

IN P1
MOV A, 40
OUT P0
IN P1
MOV A, 80
OUT P0
CYCLES
28
at par
ENERGY
56
at par
NODES
1
at par
INSTRUCTIONS
6
at par