Add axis homing function and AXIS state

This commit is contained in:
Unknown
2018-08-28 23:12:53 -04:00
committed by unknown
parent b96b4465ec
commit 41a590773f
4 changed files with 41 additions and 5 deletions
+19
View File
@@ -51,6 +51,25 @@ void Controller::start_anticogging_calibration() {
}
}
// Slowly drive in the negative direction at homing_speed until the min endstop is pressed
// When pressed, set the linear count to the offset (default 0), and then
bool Controller::home_axis() {
if (axis_->config_.min_endstop.enabled) {
set_vel_setpoint(-config_.homing_speed, 0.0f);
} else {
return false;
}
axis_->run_control_loop([&](){
if(axis_->min_endstop_state_){
axis_->encoder_.set_linear_count(axis_->config_.min_endstop.offset);
set_pos_setpoint(0.0f, 0.0f, 0.0f);
}
return !axis_->min_endstop_state_;
});
return true;
}
/*
* This anti-cogging implementation iterates through each encoder position,
* waits for zero velocity & position error,