Reply to Firmware

By electric_vehicle_lover,
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):

if (
(abs(_adc_phase_a_current) > ADC_MOTOR_OVER_CURRENT_LIMIT) ||
(abs(_adc_phase_b_current) > ADC_MOTOR_OVER_CURRENT_LIMIT) ||
(abs(_adc_phase_c_current) > ADC_MOTOR_OVER_CURRENT_LIMIT))
over_current_fault_counter += 10;

if (over_current_fault_counter > 1000) { motor_over_current_action(); }
if (over_current_fault_counter > 0) { over_current_fault_counter -= 1; }

void motor_over_current_action (void)
// disable PWM / motor!!
disable_phase_a ();
disable_phase_b ();
disable_phase_c ();

buzzer_on ();

// infinite loop: block here, user will need to reset the system
while (1) ;