B69DIFF AMP
The task
P0 and P1 read two signals on CH1 and CH2. Amplify the difference between them.
Set P2 to 50 plus 4 times (P0 minus P1). R1 and C1 smooth it onto CH3.
Words hold minus 128 to 127. The PWM pin clamps a duty to the range 0 to 100.
The board
- Sources
- V1 0.6 V sine at 5 Hz, V2 2.5 V, V3 2.25 V, and V4 0.5 V square at 3.125 Hz
- Resistors
- R1 10 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1, CH2, and CH3
Key idea
The difference is small, so four times it, plus 50, stays well inside a word.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Subtract first, then multiply, then add 50.
Hint 2Show
IN P1, MOV B, A, IN P0, SUB B, MUL 4, ADD 50, OUT P2.
Solution
Reveal the Full SolutionThe complete program for DIFF AMP. 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.
Subtract, then gain, then the offset.
u1SC-2 standard
IN P1
MOV B, A
IN P0
SUB B
MUL 4
ADD 50
OUT P2- CYCLES
- 2400
- at par
- ENERGY
- 4800
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 7
- at par