Skip to content

Commit

Permalink
Merge pull request #303 from runger1101001/dev
Browse files Browse the repository at this point in the history
fix errors and warnings on SIMPLEFOC_DISABLE_DEBUG
  • Loading branch information
runger1101001 authored Sep 2, 2023
2 parents 04a8a88 + 2252605 commit 4690e16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/BLDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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)){
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
}
Expand Down
13 changes: 8 additions & 5 deletions src/StepperMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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)){
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/base_classes/FOCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4690e16

Please sign in to comment.