Skip to content

Commit

Permalink
homing 3 axis
Browse files Browse the repository at this point in the history
  • Loading branch information
Strooom committed Sep 8, 2022
1 parent da56d36 commit 15deb6f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
9 changes: 6 additions & 3 deletions lib/maincontroller/homing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ void homingController::start() {
}

bool homingController::nextAxis() {
homingSequenceIndex++;
return selectAxis();
if (homingSequenceIndex < theMachineProperties.nmbrHomingAxis) {
homingSequenceIndex++;
return selectAxis();
}
return false;
}

bool homingController::selectAxis() {
while (homingSequenceIndex < nmbrAxis) {
while (homingSequenceIndex < theMachineProperties.nmbrHomingAxis) {
currentHomingAxis = theMachineProperties.homingSequence[homingSequenceIndex];
currentHomingAxisIndex = static_cast<uint32_t>(currentHomingAxis);
if (static_cast<uint32_t>(currentHomingAxis) < nmbrAxis) {
Expand Down
11 changes: 2 additions & 9 deletions lib/maincontroller/homing.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
Next Steps :
* nextAxis should skip axis which can't home





* add timeouts in case motors are not running
Todo : think about how to handle errors
* not reaching the closing or opening of a switch (in time / in space)
* receiving events on other switches than the one monitoring


Todo : homing uses gcode to generate motions, however, it should not change the modal state of the machine. So we must save the modal state and afterwards restore it..

ToDo : we need to capture the position on the opening of the switch as the ZERO
TODO : we need to capture the position on the opening of the switch as the ZERO


9 changes: 5 additions & 4 deletions lib_target/cnc3axis/general/machineproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class machineProperties {
} motors;

struct Limits {
bool hasLimitsMax[nmbrAxis]{true, false, true}; // limit switches towards the positive direction of the Axis
bool hasLimitsMax[nmbrAxis]{true, true, true}; // limit switches towards the positive direction of the Axis
uint32_t limitMaxIndex[nmbrAxis]{1, 2, 0}; // index into myInputs[] telling which input is the matching limit switch
bool hasLimitsMin[nmbrAxis]{false, true, false}; // limit switches towards the negative direction of the Axis
bool hasLimitsMin[nmbrAxis]{false, false, false}; // limit switches towards the negative direction of the Axis
uint32_t limitMinIndex[nmbrAxis]{0, 2, 4}; // index into myInputs[] telling which input is the matching limit switch
float maxLimitswitchTravel{2.0F}; // [mm]
} limits;
Expand All @@ -71,8 +71,9 @@ class machineProperties {
float vHoming{10}; // faster homing speed, towards switch closing
float vHomingSlow{1}; // slower homing, towards opening limitswitch

axis homingSequence[nmbrAxis]{axis::Z, axis::X, axis::Y}; // in which sequence do we want to home axis.
bool homingDirection[nmbrAxis]{true, false, true}; // in which direction do we want to home : true = positive, false = negative
static constexpr uint32_t nmbrHomingAxis{3U}; // how many axis do have homing
axis homingSequence[nmbrHomingAxis]{axis::Z, axis::X, axis::Y}; // in which sequence do we want to home axis.
bool homingDirection[nmbrAxis]{true, true, true}; // in which direction do we want to home : true = positive, false = negative
double homingOffset[nmbrAxis]{3.0, 3.0, 3.0}; // after homing, what distance from the limitswitches do we set the machine zero. Needs to be positive

// static constexpr float t = limits.maxLimitswitchTravel * 6.0 / motors.jMax;
Expand Down
2 changes: 1 addition & 1 deletion src/cnc3axis/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ inputs allSwitchAndButtons;
debouncedInput myInputs[nmbrInputs] = {
debouncedInput(event::limitSwitchZMaxClosed, event::limitSwitchZMaxOpened),
debouncedInput(event::limitSwitchXMaxClosed, event::limitSwitchXMaxOpened),
debouncedInput(event::limitSwitchYMinClosed, event::limitSwitchYMinOpened),
debouncedInput(event::limitSwitchYMaxClosed, event::limitSwitchYMaxOpened),
debouncedInput(event::limitSwitchYMinClosed, event::limitSwitchYMinOpened),
debouncedInput(event::limitSwitchZMinClosed, event::limitSwitchZMinOpened),
debouncedInput(event::limitSwitchXMinClosed, event::limitSwitchXMinOpened),
debouncedInput(event::emergencyStopButtonPressed, event::emergencyStopButtonReleased),
Expand Down

0 comments on commit 15deb6f

Please sign in to comment.