@@ -101,7 +101,8 @@ int BLDCMotor::initFOC( float zero_electric_offset, Direction _sensor_direction
101
101
if (sensor){
102
102
exit_flag *= alignSensor ();
103
103
// added the shaft_angle update
104
- shaft_angle = sensor->updateSensor ();
104
+ sensor->updateSensor ();
105
+ shaft_angle = sensor->getAngle ();
105
106
}else if (monitor_port) monitor_port->println (F (" MOT: No sensor." ));
106
107
107
108
// aligning the current sensor - can be skipped
@@ -164,14 +165,16 @@ int BLDCMotor::alignSensor() {
164
165
_delay (2 );
165
166
}
166
167
// take and angle in the middle
167
- float mid_angle = sensor->updateSensor ();
168
+ sensor->updateSensor ();
169
+ float mid_angle = sensor->getAngle ();
168
170
// move one electrical revolution backwards
169
171
for (int i = 500 ; i >=0 ; i-- ) {
170
172
float angle = _3PI_2 + _2PI * i / 500 .0f ;
171
173
setPhaseVoltage (voltage_sensor_align, 0 , angle);
172
174
_delay (2 );
173
175
}
174
- float end_angle = sensor->updateSensor ();
176
+ sensor->updateSensor ();
177
+ float end_angle = sensor->getAngle ();
175
178
setPhaseVoltage (0 , 0 , 0 );
176
179
_delay (200 );
177
180
// determine the direction the sensor moved
@@ -201,7 +204,8 @@ int BLDCMotor::alignSensor() {
201
204
// set angle -90(270 = 3PI/2) degrees
202
205
setPhaseVoltage (voltage_sensor_align, 0 , _3PI_2);
203
206
_delay (700 );
204
- zero_electric_angle = _normalizeAngle (_electricalAngle (sensor_direction*sensor->updateSensor (), pole_pairs));
207
+ sensor->updateSensor ();
208
+ zero_electric_angle = _normalizeAngle (_electricalAngle (sensor_direction*sensor->getAngle (), pole_pairs));
205
209
_delay (20 );
206
210
if (monitor_port){
207
211
monitor_port->print (F (" MOT: Zero elec. angle: " ));
0 commit comments