Closed Tacha-S closed 1 year ago
I haven't tried it, but maybe something like this will fix it.
motor_hall_ppr = 3 * num_motor_pole_pairs_;
target_pulse_ += target_velocity * motor_hall_ppr / (2 * M_PI) / control_rate_ / gear_ratio_;
velocity_sens_ += this->counterTD(current_pulse, false) * 2.0 * M_PI / motor_hall_ppr * gear_ratio_ * control_rate_;
There are three hall-effect-sensor on the stator. One pair of poles on the rotor should trigger 2 counts on the rise and fall in one rotation.
I think 6 is correct unless vesc divides by half internally.
I would like to name it rotor_pole_pairs
instead of motor_pole_pairs
.
Ok, so vesc_hw_interface assumes that you are using FOC and hall sensors. Here, vesc_interface's getPosition function returns vesc's tachometer, which is the number of steps the motor has rotated (different from the usual tachometer definition?) as described in https://github.com/vedderb/bldc/blob/50e1aee9c929e0e43afbd332e5a9a29df933e795/motor/mcpwm_foc.c#L1298-L1307
Reading the function description (and personally testing), the relation between vesc's tachometer and revolution is probably
revolution = vesc tachometer / (number of hall sensors * number of rotor poles)
where the number of hall sensors
is usually 3 and number of rotor poles
is the number of poles, not pole pairs. Therefore, we can convert revolution to radians (including gear_ratio) with the following:
rad = revolution * 2 * pi * gear_ratio
With that said, I believe @nyxrobotics approach is correct, motor_hall_ppr = 3 * num_motor_pole_pairs
will fix it (6 if we use number of poles instead of pairs)
motor_hall_ppr = 3 * num_rotor_poles
or motor_hall_ppr = 6 * num_rotor_pole_pairs
Abstract
Motor does not rotate at correct speed even though
gear_ratio
andnum_motor_pole_pairs
are set correctly.How to Reproduce the Bug
Problem due to the Bug
Factors
Suggestion