B76SET POINT
The task
P2 reads the set point from a dial on CH1. P0 heats C1 through R1, and R2 leaks heat away.
P1 reads the temperature on CH2. Sample both on each tick of P3.
Heat while the temperature is more than 10 under the set point; stop when more than 10 over.
The board
- Sources
- V1 0.5 V square at 12.5 Hz, V2 1 V square at 6.25 Hz, and V3 1.5 V
- Resistors
- R1 10 kΩ and R2 47 kΩ
- Capacitors
- C1 2.2 µF
- Probes
- CH1 and CH2
Key idea
Inside the band, from 10 under to 10 over, leave the heater as it is.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Subtract the set point from the temperature, then test the difference against minus 10 and 10.
Hint 2Show
The dial moves in steps, so the band moves with it.
Solution
Reveal the Full SolutionThe complete program for SET POINT. 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 band of 10 either side of the dial.
u1SC-2 standard
L: IN P3
IN P2
MOV B, A
IN P1
SUB B
ADD 10
JL ON
SUB 20
JG OFF
JMP L
ON: MOV A, 1
OUT P0
JMP L
OFF: MOV A, 0
OUT P0- CYCLES
- 1000
- at par
- ENERGY
- 2000
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 15
- at par
Another way: Short nop
A second program that also passes, by a different road, at a cost on CYCLES and ENERGY.
The short form with a pause after the tick.
u1SC-2 standard
L: IN P3
NOP
IN P2
MOV B, A
IN P1
SUB B
ADD 10
JL ON
SUB 20
JG OFF
JMP L
ON: OUT P0
JMP L
OFF: MOV A, 0
OUT P0- CYCLES
- 1082
- over par
- ENERGY
- 2164
- over par
- NODES
- 1
- at par
- INSTRUCTIONS
- 15
- at par
Another way: Short
A second program that also passes, and beats par on CYCLES, ENERGY, and INSTRUCTIONS.
A negative difference is nonzero, so it lights the heater as it is.
u1SC-2 standard
L: IN P3
IN P2
MOV B, A
IN P1
SUB B
ADD 10
JL ON
SUB 20
JG OFF
JMP L
ON: OUT P0
JMP L
OFF: MOV A, 0
OUT P0- CYCLES
- 983
- under par
- ENERGY
- 1966
- under par
- NODES
- 1
- at par
- INSTRUCTIONS
- 14
- under par