Setup current and speed limits - EFeru/hoverboard-firmware-hack-FOC GitHub Wiki

:zap: Current Limit

I_MOT_MAX parameter is the maximum single motor current limit in Amps. It uses the phase current and is only valid for FOC control type. I_DC_MAX parameter is the maximum stage 2 DC Link current limit in Amps. It uses the DC current and is the only current protection for Commutation and Sinusoidal control types. Above this value, current chopping is applied.

To avoid both current limitation to compete when using FOC, set I_DC_MAX to I_MOT_MAX + 2A.

Some boards are missing the components to measure the DC Link current, so the current measured on PC0/PC1 will be zero, this means current limiting won't work with Commutation and Sinusoidal, FOC control type should be used in this case.

⚠ Current and speed limits will be stored in flash memory if you set them up on the go or if you do the auto-calibration, so changing it in config.h file won't have any effect anymore. It will be only erased from flash memory if you fully delete memory before flashing. An alternative to bypass those settings is to change FLASH_WRITE_KEY in config.h.

:o: Speed Limit

You can adjust N_MOT_MAX in config.h file to decrease/increase the speed limit(RPMs).

⚠ Current and speed limits will be stored in flash memory if you set them up on the go or if you do the auto-calibration, so changing it in config.h file won't have any effect anymore. It will be only erased from flash memory if you fully delete memory before flashing. An alternative to bypass those settings is to change FLASH_WRITE_KEY in config.h.

This is only limiting the speed, the speed you will actually reach depends on:

  • The battery you are using, higher voltage will result in higher speed
  • Control type/Control mode, FOC is slower than Sinusoidal Control Type as it limits PWM duty cycle to ~90% for current measurement, but it's more efficient and makes freewheeling possible
  • Phase advance/Field weakening can help operate the motor at higher than rated speed, but it also consumes a lot more current as it's less efficient, and can trigger the overvoltage protection of your BMS when braking
  • Type of wheel/wiring and wiring, Delta wiring will result in higher speed
  • The input calibration, proper calibration will make sure you use the full input range
  • Speed coefficient
  • Current limit

Be aware that the firmware has a hard limit of 2000 RPMs to prevent overflows. This issue explains how to reach high speeds, but use it at your own risk. The speed can overshoot the limit, this is a known issue.

:gear: Setting up the Current and Speed limits on the go

This feature lets you change the Max Current(I_MOT_MAX) and Max Speed(N_MOT_MAX) on the go without having to modify config.h and flash the board

  • press the power button for more than 5 sec and immediately after the beep sound press one more time shortly
  • move and hold the pots to a desired limit position for Max Current(INPUT1) and Max Speed(INPUT2), maximum being the values you have put in config.h
  • press the power button to confirm or wait for the 10 sec timeout

⚠ Current and speed limits will be stored in flash memory if you set them up on the go or if you do the auto-calibration, so changing it in config.h file won't have any effect anymore. It will be only erased from flash memory if you fully delete memory before flashing. An alternative to bypass those settings is to change FLASH_WRITE_KEY in config.h.

:keyboard: Debug Protocol

Another way to change those settings without flashing the board is the debug protocol. You will be able to change the settings via commands through the serial port.