Syscall 2: Firmware, home

BenchChapter 7: Frames and loops

B48LIMITER

The task

P0 reads a sine wave. Pass it on to CH2 through the PWM pin P1, but clip it:

never above 3.5 volts and never below 1.5 volts.

The board

The chip of LIMITERChip u1 with 2 ports: P0 analog in, reaching V1, CH1; P1 pwm out, reaching R1, C1, CH2.u1CHIP SC-2P0ANALOG INV1, CH1P1PWM OUTR1, C1, CH2
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 2.4 V sine at 25 Hz and V2 2.5 V
Resistors
R1 1 kΩ
Capacitors
C1 1 µF
Probes
CH1 and CH2

Key idea

3.5 and 1.5 volts are 70 and 30 percent.

Hints

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

Hint 1Show

Test the top first, then the bottom, and pass everything else as it is.

Hint 2Show

A reading over 70 goes out as 70, and one under 30 goes out as 30.

Solution

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

Pass the wave, clipped to 1.5 and 3.5 volts.

u1SC-2 standard

IN P0
SUB 70
JG HI
ADD 40
JL LO
ADD 30
JMP W
HI: MOV A, 70
JMP W
LO: MOV A, 30
W: OUT P1
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
11
at par