diff --git a/src/BLDCMotor.cpp b/src/BLDCMotor.cpp index c3d34f30..b72728bc 100644 --- a/src/BLDCMotor.cpp +++ b/src/BLDCMotor.cpp @@ -167,7 +167,7 @@ int BLDCMotor::initFOC() { exit_flag *= alignCurrentSense(); } } - else SIMPLEFOC_DEBUG("MOT: No current sense."); + else { SIMPLEFOC_DEBUG("MOT: No current sense."); } } if(exit_flag){ @@ -252,10 +252,11 @@ int BLDCMotor::alignSensor() { // check pole pair number if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher! SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved); - } else + } else { SIMPLEFOC_DEBUG("MOT: PP check: OK!"); + } - } else SIMPLEFOC_DEBUG("MOT: Skip dir calib."); + } else { SIMPLEFOC_DEBUG("MOT: Skip dir calib."); } // zero electric angle not known if(!_isset(zero_electric_angle)){ @@ -276,7 +277,7 @@ int BLDCMotor::alignSensor() { // stop everything setPhaseVoltage(0, 0, 0); _delay(200); - }else SIMPLEFOC_DEBUG("MOT: Skip offset calib."); + } else { SIMPLEFOC_DEBUG("MOT: Skip offset calib."); } return exit_flag; } @@ -305,8 +306,8 @@ int BLDCMotor::absoluteZeroSearch() { voltage_limit = limit_volt; // check if the zero found if(monitor_port){ - if(sensor->needsSearch()) SIMPLEFOC_DEBUG("MOT: Error: Not found!"); - else SIMPLEFOC_DEBUG("MOT: Success!"); + if(sensor->needsSearch()) { SIMPLEFOC_DEBUG("MOT: Error: Not found!"); } + else { SIMPLEFOC_DEBUG("MOT: Success!"); } } return !sensor->needsSearch(); } diff --git a/src/StepperMotor.cpp b/src/StepperMotor.cpp index 3b103033..491a20ee 100644 --- a/src/StepperMotor.cpp +++ b/src/StepperMotor.cpp @@ -114,7 +114,7 @@ int StepperMotor::initFOC() { // added the shaft_angle update sensor->update(); shaft_angle = sensor->getAngle(); - }else SIMPLEFOC_DEBUG("MOT: No sensor."); + } else { SIMPLEFOC_DEBUG("MOT: No sensor."); } if(exit_flag){ SIMPLEFOC_DEBUG("MOT: Ready."); @@ -177,10 +177,13 @@ int StepperMotor::alignSensor() { float moved = fabs(mid_angle - end_angle); if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher! SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved); - } else + } else { SIMPLEFOC_DEBUG("MOT: PP check: OK!"); + } - }else SIMPLEFOC_DEBUG("MOT: Skip dir calib."); + } else { + SIMPLEFOC_DEBUG("MOT: Skip dir calib."); + } // zero electric angle not known if(!_isset(zero_electric_angle)){ @@ -200,7 +203,7 @@ int StepperMotor::alignSensor() { // stop everything setPhaseVoltage(0, 0, 0); _delay(200); - }else SIMPLEFOC_DEBUG("MOT: Skip offset calib."); + } else { SIMPLEFOC_DEBUG("MOT: Skip offset calib."); } return exit_flag; } @@ -229,7 +232,7 @@ int StepperMotor::absoluteZeroSearch() { // check if the zero found if(monitor_port){ if(sensor->needsSearch()) SIMPLEFOC_DEBUG("MOT: Error: Not found!"); - else SIMPLEFOC_DEBUG("MOT: Success!"); + else { SIMPLEFOC_DEBUG("MOT: Success!"); } } return !sensor->needsSearch(); } diff --git a/src/common/base_classes/FOCMotor.cpp b/src/common/base_classes/FOCMotor.cpp index 7f48037f..d1427bcf 100644 --- a/src/common/base_classes/FOCMotor.cpp +++ b/src/common/base_classes/FOCMotor.cpp @@ -82,8 +82,10 @@ float FOCMotor::electricalAngle(){ // function implementing the monitor_port setter void FOCMotor::useMonitoring(Print &print){ monitor_port = &print; //operate on the address of print + #ifndef SIMPLEFOC_DISABLE_DEBUG SimpleFOCDebug::enable(&print); SIMPLEFOC_DEBUG("MOT: Monitor enabled!"); + #endif } // utility function intended to be used with serial plotter to monitor motor variables