B81LOW PASS
The task
P0 reads a slow swing with a coarse ripple on CH1. P1 is a fast PWM pin, filtered onto CH2.
Keep a running value in B. On each tick of P2, move it a quarter of the way to the reading.
Write the running value as the duty.
The board
- Sources
- V1 2 V square at 250 Hz, V2 1 V sine at 5 Hz, and V3 1.5 V
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1 and CH2
Key idea
A quarter of the way is the reading minus the value, DIV 4, added to the value.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
The ripple changes every two ticks, so each step only follows it a little.
Hint 2Show
IN P2, IN P0, SUB B, DIV 4, ADD B, MOV B, A, OUT P1.
Solution
Reveal the Full SolutionThe complete program for LOW PASS. 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.
An exponential average, a quarter of the way each tick.
u1SC-2 standard
IN P2
IN P0
SUB B
DIV 4
ADD B
MOV B, A
OUT P1- CYCLES
- 1394
- at par
- ENERGY
- 2788
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 7
- at par