Skip to content

Commit

Permalink
change init logic - remove params from initFOC
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Unger committed Jun 24, 2023
1 parent d57d32d commit 5231e5e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 28 deletions.
9 changes: 1 addition & 8 deletions src/BLDCMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,13 @@ void BLDCMotor::enable()
FOC functions
*/
// FOC initialization function
int BLDCMotor::initFOC( float zero_electric_offset, Direction _sensor_direction) {
int BLDCMotor::initFOC() {
int exit_flag = 1;

motor_status = FOCMotorStatus::motor_calibrating;

// align motor if necessary
// alignment necessary for encoders!
if(_isset(zero_electric_offset)){
// abosolute zero offset provided - no need to align
zero_electric_angle = zero_electric_offset;
// set the sensor direction - default CW
sensor_direction = _sensor_direction;
}

// sensor and motor alignment - can be skipped
// by setting motor.sensor_direction and motor.zero_electric_angle
_delay(500);
Expand Down
2 changes: 1 addition & 1 deletion src/BLDCMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BLDCMotor: public FOCMotor
* Function initializing FOC algorithm
* and aligning sensor's and motors' zero position
*/
int initFOC( float zero_electric_offset = NOT_SET , Direction sensor_direction = Direction::CW) override;
int initFOC() override;
/**
* Function running FOC algorithm in real-time
* it calculates the gets motor angle and sets the appropriate voltages
Expand Down
9 changes: 1 addition & 8 deletions src/StepperMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,13 @@ void StepperMotor::enable()
FOC functions
*/
// FOC initialization function
int StepperMotor::initFOC( float zero_electric_offset, Direction _sensor_direction ) {
int StepperMotor::initFOC() {
int exit_flag = 1;

motor_status = FOCMotorStatus::motor_calibrating;

// align motor if necessary
// alignment necessary for encoders!
if(_isset(zero_electric_offset)){
// abosolute zero offset provided - no need to align
zero_electric_angle = zero_electric_offset;
// set the sensor direction - default CW
sensor_direction = _sensor_direction;
}

// sensor and motor alignment - can be skipped
// by setting motor.sensor_direction and motor.zero_electric_angle
_delay(500);
Expand Down
6 changes: 1 addition & 5 deletions src/StepperMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ class StepperMotor: public FOCMotor
* and aligning sensor's and motors' zero position
*
* - If zero_electric_offset parameter is set the alignment procedure is skipped
*
* @param zero_electric_offset value of the sensors absolute position electrical offset in respect to motor's electrical 0 position.
* @param sensor_direction sensor natural direction - default is CW
*
*/
int initFOC( float zero_electric_offset = NOT_SET , Direction sensor_direction = Direction::CW) override;
int initFOC() override;
/**
* Function running FOC algorithm in real-time
* it calculates the gets motor angle and sets the appropriate voltages
Expand Down
8 changes: 2 additions & 6 deletions src/common/base_classes/FOCMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ class FOCMotor
* and aligning sensor's and motors' zero position
*
* - If zero_electric_offset parameter is set the alignment procedure is skipped
*
* @param zero_electric_offset value of the sensors absolute position electrical offset in respect to motor's electrical 0 position.
* @param sensor_direction sensor natural direction - default is CW
*
*/
virtual int initFOC(float zero_electric_offset = NOT_SET , Direction sensor_direction = Direction::CW)=0;
virtual int initFOC()=0;
/**
* Function running FOC algorithm in real-time
* it calculates the gets motor angle and sets the appropriate voltages
Expand Down Expand Up @@ -209,7 +205,7 @@ class FOCMotor
// sensor related variabels
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; //!< if sensor_direction == Direction::CCW then direction will be flipped to CW
Direction sensor_direction = Direction::CW; //!< default is CW. if sensor_direction == Direction::CCW then direction will be flipped compared to CW. Set to UNKNOWN to set by calibration

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

0 comments on commit 5231e5e

Please sign in to comment.