B88FAN CURVE
The task
P0 reads the temperature on CH1. P1 drives the fan with PWM, smoothed onto CH2.
Under 30 the fan is off, and from 70 up it runs at 100.
Between, the duty is 2.5 times the reading minus 30.
Words hold minus 128 to 127, and the PWM pin clamps a duty under 0 to 0.
The board
- Sources
- V1 2 V sine at 5 Hz and V2 2.5 V
- Resistors
- R1 10 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1 and CH2
Key idea
60 times 5 does not fit in a word, so deal with the top of the range before you scale.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Twice a number plus half of it is 2.5 times it, and every step stays small.
Hint 2Show
Over 70, write 100. Otherwise keep the reading minus 30 in B and add B, B, and B DIV 2.
Solution
Reveal the Full SolutionThe complete program for FAN CURVE. 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 clamped linear curve, scaled without overflow.
u1SC-2 standard
L: IN P2
IN P0
SUB 70
JG F
ADD 40
MOV B, A
DIV 2
ADD B
ADD B
OUT P1
JMP L
F: MOV A, 100
OUT P1- CYCLES
- 925
- at par
- ENERGY
- 1850
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 13
- at par