Skip to content

Commit 5b7c7b4

Browse files
author
Richard Unger
committed
HybridStepper changes for 2.3.1 release
1 parent 3819e04 commit 5b7c7b4

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/motors/HybridStepperMotor/HybridStepperMotor.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,14 @@ void HybridStepperMotor::enable()
9494
}
9595

9696
/**
97-
FOC functions
98-
*/
99-
// FOC initialization function
100-
int HybridStepperMotor::initFOC(float zero_electric_offset, Direction _sensor_direction)
97+
* FOC functions
98+
*/
99+
int HybridStepperMotor::initFOC()
101100
{
102101
int exit_flag = 1;
103102

104103
motor_status = FOCMotorStatus::motor_calibrating;
105104

106-
// align motor if necessary
107-
// alignment necessary for encoders!
108-
if (_isset(zero_electric_offset))
109-
{
110-
// abosolute zero offset provided - no need to align
111-
zero_electric_angle = zero_electric_offset;
112-
// set the sensor direction - default CW
113-
sensor_direction = _sensor_direction;
114-
}
115-
116105
// sensor and motor alignment - can be skipped
117106
// by setting motor.sensor_direction and motor.zero_electric_angle
118107
_delay(500);
@@ -148,8 +137,7 @@ int HybridStepperMotor::alignSensor()
148137
SIMPLEFOC_DEBUG("MOT: Align sensor.");
149138

150139
// if unknown natural direction
151-
if (!_isset(sensor_direction))
152-
{
140+
if(sensor_direction==Direction::UNKNOWN) {
153141
// check if sensor needs zero search
154142
if (sensor->needsSearch())
155143
exit_flag = absoluteZeroSearch();
@@ -411,8 +399,14 @@ void HybridStepperMotor::setPhaseVoltage(float Uq, float Ud, float angle_el)
411399
float _sa = _sin(angle_el);
412400
float center;
413401

414-
switch (foc_modulation)
415-
{
402+
switch (foc_modulation) {
403+
case FOCModulationType::Trapezoid_120:
404+
case FOCModulationType::Trapezoid_150:
405+
// not handled
406+
Ua = 0;
407+
Ub = 0;
408+
Uc = 0;
409+
break;
416410
case FOCModulationType::SinePWM:
417411
// C phase is fixed at half-rail to provide bias point for A, B legs
418412
Ua = (_ca * Ud) - (_sa * Uq);

src/motors/HybridStepperMotor/HybridStepperMotor.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,8 @@ class HybridStepperMotor : public FOCMotor
5151
/**
5252
* Function initializing FOC algorithm
5353
* and aligning sensor's and motors' zero position
54-
*
55-
* - If zero_electric_offset parameter is set the alignment procedure is skipped
56-
*
57-
* @param zero_electric_offset value of the sensors absolute position electrical offset in respect to motor's electrical 0 position.
58-
* @param sensor_direction sensor natural direction - default is CW
59-
*
6054
*/
61-
int initFOC(float zero_electric_offset = NOT_SET, Direction sensor_direction = Direction::CW) override;
55+
int initFOC() override;
6256

6357
/**
6458
* Function running FOC algorithm in real-time

0 commit comments

Comments
 (0)