Today has no practice yet.0/30 daily XP0 Sparks0 XP

Crossover mission · Silicon Lab × Robot Lab

A proportional controller in Verilog

Robot controllers often run as hardware, not software, so they react every clock cycle. Here the controller is a Verilog module: a is the target position, b is the measured position, and y is the motor command. All three are 8-bit numbers.

Shifting right by n divides by 2ⁿ, so the shift sets the gain Kp. A large gain overshoots past the target, and a small one stops short, because the command rounds down to 0 before the error reaches 0.

Choose a shift so the motor stops within 4 counts of the target at 200 and overshoots by no more than 3 counts.

Simplified: a first-order motor model with lag, no friction and a perfect encoder.

Best after Silicon Lab Level 5, Robot Lab Level 3.

module student_core(input [7:0] a, input [7:0] b, output [7:0] y);

control stepposition (counts)