Moteus Code Analyze
Last updated
Last updated
Using All-Digital Phase Locked Loop filter
Handled in motor_position.h
pll_filter_hz
= 400
filter.kp = 2 * 400 * 2pi
filter.ki = (400 * 2pi) ** 2
position += dt * filter.kp * error
velocity += dt * filter.ki * error
User will issue position control command
which will be handled by the ISR_DoPosition()
function in bldc_servo.cc
The service routine first will call BldcServoPosition::UpdateCommand()
in bldc_servo_position.h
If the trajectory is not done, it will call UpdateTrajectory()
which then will call DoVelocityAndAccelLimits
inside the funciton,
a
is the acceleration limit
v0
is the current velocity
vf
is the target velocity
position_relative_raw
is the target position
dx is the position error
dv is the velocity error
acceleration is calculated as: