@ -100,15 +101,6 @@ In all FOC control modes, the controller features maximum motor speed and maximu
- The controller parameters are given in [this table](https://github.com/EmanuelFeru/bldc-motor-control-FOC/blob/master/02_Figures/paramTable.png)
- The controller parameters are given in [this table](https://github.com/EmanuelFeru/bldc-motor-control-FOC/blob/master/02_Figures/paramTable.png)
### Diagnostics
Each motor is constantly monitored for errors. These errors are:
- **Error 001**: Hall sensor not connected
- **Error 002**: Hall sensor short circuit
- **Error 004**: Motor NOT able to spin (Possible causes: motor phase disconnected, MOSFET defective, operational Amplifier defective, motor blocked)
The error codes above are reported for each motor in the variables **rtY_Left.z_errCode** and **rtY_Right.z_errCode** for Left motor (long wired motor) and Right motor (short wired motor), respectively. In case of error, the motor power is reduced to 0, while an audible (fast beep) can be heard to notify the user.
---
---
## Example Variants
## Example Variants
@ -208,6 +200,20 @@ platformio run –target upload -e VARIANT_####
```
```
If you have set default_envs in [platformio.ini](/platformio.ini) you can ommit -e parameter
If you have set default_envs in [platformio.ini](/platformio.ini) you can ommit -e parameter
---
## Diagnostics
The errors reported by the board are in the form of audible beeps:
- **1 beep (low pitch)**: Motor error (see [possible causes](https://github.com/EmanuelFeru/bldc-motor-control-FOC#diagnostics))
- **2 beeps (low pitch)**: ADC timeout
- **3 beeps (low pitch)**: Serial communication timeout
- **4 beeps (low pitch)**: General timeout (PPM, PWM, Nunchuck)
- **5 beeps (low pitch)**: Mainboard temperature warning
- **1 beep fast (medium pitch)**: Low battery voltage <35V
- **1 beep slow (medium pitch)**: Low battery voltage <36V
- **1 beep fast (high pitch)**: Backward spinning motors
---
---
## Troubleshooting
## Troubleshooting
First, check that power is connected and voltage is >36V while flashing.
First, check that power is connected and voltage is >36V while flashing.
shortBeep(6);// make 2 beeps indicating the motor enable
beepShort(6);// make 2 beeps indicating the motor enable
shortBeep(4);HAL_Delay(100);
beepShort(4);HAL_Delay(100);
steerFixdt=speedFixdt=0;// reset filters
steerFixdt=speedFixdt=0;// reset filters
enable=1;// enable motors
enable=1;// enable motors
consoleLog("-- Motors enabled --\r\n");
consoleLog("-- Motors enabled --\r\n");
@ -348,7 +345,7 @@ int main(void) {
if((distance/1345.0)-setDistance>0.5&&(lastDistance/1345.0)-setDistance>0.5){// Error, robot too far away!
if((distance/1345.0)-setDistance>0.5&&(lastDistance/1345.0)-setDistance>0.5){// Error, robot too far away!
enable=0;
enable=0;
longBeep(5);
beepLong(5);
#ifdef SUPPORT_LCD
#ifdef SUPPORT_LCD
LCD_ClearDisplay(&lcd);
LCD_ClearDisplay(&lcd);
HAL_Delay(5);
HAL_Delay(5);
@ -460,29 +457,26 @@ int main(void) {
// ####### BEEP AND EMERGENCY POWEROFF #######
// ####### BEEP AND EMERGENCY POWEROFF #######
if((TEMP_POWEROFF_ENABLE&&board_temp_deg_c>=TEMP_POWEROFF&&speedAvgAbs<20)||(batVoltage<BAT_DEAD&&speedAvgAbs<20)){// poweroff before mainboard burns OR low bat 3
if((TEMP_POWEROFF_ENABLE&&board_temp_deg_c>=TEMP_POWEROFF&&speedAvgAbs<20)||(batVoltage<BAT_DEAD&&speedAvgAbs<20)){// poweroff before mainboard burns OR low bat 3
poweroff();
poweroff();
}elseif(rtY_Left.z_errCode||rtY_Right.z_errCode){// disable motors and beep in case of Motor error - fast beep
}elseif(rtY_Left.z_errCode||rtY_Right.z_errCode){// 1 beep (low pitch): Motor error, disable motors