Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B29SCHMITT

The task

P0 reads a slow sine wave with a fast ripple on top.

One threshold would flicker as the ripple crosses it, so use two:

turn the LED on P1 on at 3.5 volts, and off only once the input falls to 1.5 volts.

The board

The chip of SCHMITTChip u1 with 2 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, D1, 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 0.5 V square at 500 Hz, V2 2 V sine at 25 Hz, and V3 2.5 V
Resistors
R1 330 Ω
LEDs
D1 yellow
Probes
CH1 and CH2

Key idea

3.5 and 1.5 volts read as 70 and 30 percent.

Hints

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

Hint 1Show

Two waiting loops: one waits for the reading to reach 70, the other for it to drop to 30.

Hint 2Show

Between the loops, switch the LED. JL and JG keep each loop going.

Solution

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

On at 3.5 volts, off at 1.5 volts.

u1SC-2 standard

L: IN P0
SUB 70
JL L
MOV A, 1
OUT P1
H: IN P0
SUB 30
JG H
MOV A, 0
OUT P1
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
10
at par