honya96 wrote: ↑Jan 21 2018 10:02am

simply said, if you set low P1 value you dont get full motor rpm. even when display is set at 72 you get less.

no one will notice with gear motor but direct has lower P1 so you dont get full motor rpm until you set P1 higher, then you get full rpm range but wrong speed reading

Ok, now I understand. And the code that uses P1 value and sets the max speed for motor conttoller, may have a bug and here is the code -- I need to think about it:

Code: Select all

```
// (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: Select all

```
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: Select all

`#define MOTOR_SPEED_CONTROLLER_KP 2 // x << 5`