We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// Measure mechanical angle at every electrical zero for several revolutions motor.voltage_limit = 5; motor.move(a); float offset_x = 0; float offset_y = 0; float destination1 = (floor(a / _2PI) + measured_pole_pairs / 2.) * _2PI; float destination2 = (floor(a / _2PI)) * _2PI; for (; a < destination1; a += 0.4) { motor.move(a); delay(100); for (uint8_t i = 0; i < 100; i++) { encoder.update(); delay(1); } float real_electrical_angle = _normalizeAngle(a); float measured_electrical_angle = _normalizeAngle( (float)(motor.sensor_direction * measured_pole_pairs) * encoder.getMechanicalAngle() - 0); float offset_angle = measured_electrical_angle - real_electrical_angle; offset_x += cosf(offset_angle); offset_y += sinf(offset_angle); Serial.print(degrees(real_electrical_angle)); Serial.print(", "); Serial.print(degrees(measured_electrical_angle)); Serial.print(", "); Serial.println(degrees(_normalizeAngle(offset_angle))); } for (; a > destination2; a -= 0.4) { motor.move(a); delay(100); for (uint8_t i = 0; i < 100; i++) { encoder.update(); delay(1); } float real_electrical_angle = _normalizeAngle(a); float measured_electrical_angle = _normalizeAngle( (float)(motor.sensor_direction * measured_pole_pairs) * encoder.getMechanicalAngle() - 0); float offset_angle = measured_electrical_angle - real_electrical_angle; offset_x += cosf(offset_angle); offset_y += sinf(offset_angle); Serial.print(degrees(real_electrical_angle)); Serial.print(", "); Serial.print(degrees(measured_electrical_angle)); Serial.print(", "); Serial.println(degrees(_normalizeAngle(offset_angle))); } motor.voltage_limit = 0; motor.move(a); float avg_offset_angle = atan2f(offset_y, offset_x); // Apply settings motor.pole_pairs = measured_pole_pairs; motor.zero_electric_angle = avg_offset_angle + _3PI_2; The above code is about the calibration of the zero electric Angle I want to know why " motor.zero_electric_angle = avg_offset_angle + _3PI_2; "
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: