Code:
// (ui8_max_speed * 1000 * (ui8_motor_characteristic / 2)) / (3600 * f_wheel_size)
ui32_temp = ((uint32_t) lcd_configuration_variables->ui8_max_speed) * 1000; // in meters/hour
ui32_temp *= ((uint32_t) (lcd_configuration_variables->ui8_motor_characteristic >> 1));
f_temp = 3600.0 * f_wheel_perimeter;
f_temp = ((float) ui32_temp) / f_temp;
motor_controller_set_speed_erps_max ((uint16_t) f_temp);
I think that code works well.
For a 46 magnets motor like yours, for a wheel of 26'' and wheel speed of 25km/h, the max erps will be: 77.
For a Q85 geared motor, for a wheel of 26'' and wheel speed of 25km/h, the max erps will be: 343.
That is a big difference... and that value will set the variable
ui16_target_erps and on the speed controller MOTOR_SPEED_CONTROLLER_KP:
Code:
i16_error = ui16_target_erps - i16_motor_speed_erps;
i16_output = i16_error * MOTOR_SPEED_CONTROLLER_KP;
the i16_error in speed will be multiplied for the constant K MOTOR_SPEED_CONTROLLER_KP. A geared motor will always a bigger output value on that calculation...
The ratio is: 343 / 77 = 4.54. So, you can edit on main.h file and change from 2 to 9 or maybe even a little higher value:
Code:
#define MOTOR_SPEED_CONTROLLER_KP 2 // x << 5