Hey @Pipe
Please use the motor.shaft_angle
and motor.shaft_velocity
when using the sensor with FOC.
When the sensor is used for some standalone application then it makes sense to call getAngle
and getVelocity
. But when using it with FOC the sensor variables are used in the algorithm and the motor variables are updated with them, calling the sensor getAngle
and getVelocity
outside the algorithm can result in some strange behavior, as you’ve already seen.
So I’d suggest you add this in your loop:
Serial.print(motor.shaft_angle);
Serail.print("\t");
Serial.print(motor.shaft_velocity);
Serail.print("\t");
Serial.println(motor.voltage.q);
Or even better is using the monitoring:
void setup(){
....
// comment out if not needed
motor.useMonitoring(Serial);
motor.monitoring_downsample=1;
motor.monitor_variables = _MON_VOLT_Q | _MON_VEL | _MON_ANGLE;
....
}
void loop(){
....
motor.monitor();
....
}