Skip to content

Commit c0bb291

Browse files
Merge pull request #368 from runger1101001/dev
expose result of PP check
2 parents 1bad770 + 3bcb9af commit c0bb291

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/BLDCMotor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ int BLDCMotor::alignSensor() {
259259
sensor_direction = Direction::CW;
260260
}
261261
// check pole pair number
262-
if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher!
262+
pp_check_result = !(fabs(moved*pole_pairs - _2PI) > 0.5f); // 0.5f is arbitrary number it can be lower or higher!
263+
if( pp_check_result==false ) {
263264
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
264265
} else {
265266
SIMPLEFOC_DEBUG("MOT: PP check: OK!");

src/StepperMotor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ int StepperMotor::alignSensor() {
175175
}
176176
// check pole pair number
177177
float moved = fabs(mid_angle - end_angle);
178-
if( fabs(moved*pole_pairs - _2PI) > 0.5f ) { // 0.5f is arbitrary number it can be lower or higher!
178+
pp_check_result = !(fabs(moved*pole_pairs - _2PI) > 0.5f); // 0.5f is arbitrary number it can be lower or higher!
179+
if( pp_check_result==false ) {
179180
SIMPLEFOC_DEBUG("MOT: PP check: fail - estimated pp: ", _2PI/moved);
180181
} else {
181182
SIMPLEFOC_DEBUG("MOT: PP check: OK!");

src/common/base_classes/FOCMotor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ class FOCMotor
206206
float sensor_offset; //!< user defined sensor zero offset
207207
float zero_electric_angle = NOT_SET;//!< absolute zero electric angle - if available
208208
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
209+
bool pp_check_result = false; //!< the result of the PP check, if run during loopFOC
209210

210211
/**
211212
* Function providing BLDCMotor class with the

0 commit comments

Comments
 (0)