Implemented motor over current and works!! Now I am almost ready to use this board and firmware on my electric bicycle. Before that I want to put the firmware looking at board temperature (reading temperature sensor on the MPU6050) and warn the user and limit the power when it reaches 65ºC. The electric unicycle application need to have also this temperature limit feature.
When getting at motor over current, the motor will coast and the buzzer will stay on in loop. User will need to power off the EUC.
Over current is currently defined for 25 Amps (MW 30B4 board should handle 30A). This over current will protect the board from burning, any possible damage to the motor and battery pack. I saw some reports of Gotways EUCs boards that got faulty when they were blocked a bit of time on the sand, the motor over current limit/protection should avoid this situations!
The code is simple to understand, on FOC fast loop (every 50us):