@@ -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);
0 commit comments