B75REGULATOR
The task
P0 is a PWM pin feeding the output on CH1 through R1. R2 loads it, and V1 adds a load step.
On each tick of P2, read the output on P1 and add a quarter of the error to the duty.
The error is 50 minus the reading, and a quarter is the error DIV 4.
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
Keep the duty in B, so each tick only adds the correction to it.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Below 50 the error is positive and the duty grows; above 50 it shrinks.
Hint 2Show
IN P2, IN P1, NEG, ADD 50, DIV 4, ADD B, MOV B, A, OUT P0.
Solution
Reveal the Full SolutionThe complete program for REGULATOR. 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.
Integral control: each tick adds a quarter of the error to the duty.
u1SC-2 standard
IN P2
IN P1
NEG
ADD 50
DIV 4
ADD B
MOV B, A
OUT P0- CYCLES
- 1593
- at par
- ENERGY
- 3186
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 8
- at par