Skip to content

Commit

Permalink
Merge pull request #368 from runger1101001/dev
Browse files Browse the repository at this point in the history
expose result of PP check
  • Loading branch information
runger1101001 authored Jan 20, 2024
2 parents 1bad770 + 3bcb9af commit c0bb291
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/BLDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ int BLDCMotor::alignSensor() {
sensor_direction = Direction::CW;
}
// check pole pair number
if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher!
pp_check_result = !(fabs(moved*pole_pairs - _2PI) > 0.5f); // 0.5f is arbitrary number it can be lower or higher!
if( pp_check_result==false ) {
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
} else {
SIMPLEFOC_DEBUG("MOT: PP check: OK!");
Expand Down
3 changes: 2 additions & 1 deletion src/StepperMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ int StepperMotor::alignSensor() {
}
// check pole pair number
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!
pp_check_result = !(fabs(moved*pole_pairs - _2PI) > 0.5f); // 0.5f is arbitrary number it can be lower or higher!
if( pp_check_result==false ) {
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
} else {
SIMPLEFOC_DEBUG("MOT: PP check: OK!");
Expand Down
1 change: 1 addition & 0 deletions src/common/base_classes/FOCMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class FOCMotor
float sensor_offset; //!< user defined sensor zero offset
float zero_electric_angle = NOT_SET;//!< absolute zero electric angle - if available
Direction sensor_direction = Direction::UNKNOWN; //!< default is CW. if sensor_direction == Direction::CCW then direction will be flipped compared to CW. Set to UNKNOWN to set by calibration
bool pp_check_result = false; //!< the result of the PP check, if run during loopFOC

/**
* Function providing BLDCMotor class with the
Expand Down

0 comments on commit c0bb291

Please sign in to comment.