B98CRUISE CONTROL
The task
P0 is a PWM pin feeding the output on CH1 through R1. R2 loads it, and V1 adds a load step.
Hold the output at 50 with two terms. On each tick of P2, read P1: the error is 50 minus it.
Add the error DIV 4 to a running total in B. Set the duty to that total plus the error.
The board
- Sources
- V1 5 V square at 10 Hz
- Resistors
- R1 1 kΩ, R2 4.7 kΩ, and R3 2.2 kΩ
- Capacitors
- C1 10 µF
- Probes
- CH1
Key idea
The total alone finds the right duty slowly; the error term reacts the moment the load moves.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
B holds the total, so read P1 a second time to get the error again for the duty.
Hint 2Show
IN P2, IN P1, NEG, ADD 50, DIV 4, ADD B, MOV B, A; then the error again, ADD B, OUT P0.
Solution
Reveal the Full SolutionThe complete program for CRUISE CONTROL. 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.
Proportional plus integral: a running total and the error itself.
u1SC-2 standard
IN P2
IN P1
NEG
ADD 50
DIV 4
ADD B
MOV B, A
IN P1
NEG
ADD 50
ADD B
OUT P0- CYCLES
- 1991
- at par
- ENERGY
- 3982
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 12
- at par