Split hall calibration into polarity and offset calibration, full calibration sequence only includes hall polarity cal

This commit is contained in:
PAJohnson
2020-12-01 21:44:07 -05:00
parent ee06628e4c
commit 39570ecbf4
4 changed files with 25 additions and 7 deletions
+15 -3
View File
@@ -465,6 +465,8 @@ void Axis::run_state_machine_loop() {
task_chain_[pos++] = AXIS_STATE_IDLE;
} else if (requested_state_ == AXIS_STATE_FULL_CALIBRATION_SEQUENCE) {
task_chain_[pos++] = AXIS_STATE_MOTOR_CALIBRATION;
if (encoder_.config_.mode == ODriveIntf::EncoderIntf::MODE_HALL)
task_chain_[pos++] = AXIS_STATE_ENCODER_HALL_POLARITY_CALIBRATION;
if (encoder_.config_.use_index)
task_chain_[pos++] = AXIS_STATE_ENCODER_INDEX_SEARCH;
task_chain_[pos++] = AXIS_STATE_ENCODER_OFFSET_CALIBRATION;
@@ -503,13 +505,23 @@ void Axis::run_state_machine_loop() {
status = encoder_.run_direction_find();
} break;
case AXIS_STATE_ENCODER_HALL_CALIBRATION: {
case AXIS_STATE_ENCODER_HALL_POLARITY_CALIBRATION: {
if (!motor_.is_calibrated_)
goto invalid_state_label;
status = encoder_.run_hall_polarity_calibration();
if (status)
status = encoder_.run_hall_phase_calibration();
} break;
case AXIS_STATE_ENCODER_HALL_OFFSET_CALIBRATION: {
if (!motor_.is_calibrated_)
goto invalid_state_label;
if (!encoder_.config_.hall_polarity_calibrated) {
encoder_.set_error(ODriveIntf::EncoderIntf::ERROR_HALL_NOT_CALIBRATED_YET);
goto invalid_state_label;
}
status = encoder_.run_hall_phase_calibration();
} break;
case AXIS_STATE_HOMING: {
+7 -2
View File
@@ -1163,8 +1163,13 @@ valuetypes:
brief: Run axis homing function.
doc:
Endstops must be enabled to use this feature.
EncoderHallCalibration:
brief: Rotate the motor in lockin and calibrate hall states
EncoderHallPolarityCalibration:
brief: Rotate the motor in lockin and calibrate hall polarity
doc:
ODrive assumes 120 degree electrical hall spacing. This routine determines if that
is the case and sets the polarity if the halls are on 60 degree electrical spacing
EncoderHallOffsetCalibration:
brief: Rotate the motor for 30s to calibrate hall sensor edge offsets
doc:
The phase offset is not calibrated at this time, so the map is only relative
+1 -1
View File
@@ -9,7 +9,7 @@
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${command:python.pythonPath}",
"python": "${command:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
+2 -1
View File
@@ -35,7 +35,8 @@ AXIS_STATE_CLOSED_LOOP_CONTROL = 8
AXIS_STATE_LOCKIN_SPIN = 9
AXIS_STATE_ENCODER_DIR_FIND = 10
AXIS_STATE_HOMING = 11
AXIS_STATE_ENCODER_HALL_CALIBRATION = 12
AXIS_STATE_ENCODER_HALL_POLARITY_CALIBRATION = 12
AXIS_STATE_ENCODER_HALL_OFFSET_CALIBRATION = 13
# ODrive.Encoder.Mode
ENCODER_MODE_INCREMENTAL = 0