Tuned opening on StepperTest

This commit is contained in:
Nis Wechselberg 2022-10-20 20:28:57 +02:00
parent 4b2c0478a2
commit 76911cf9fe

View file

@ -75,34 +75,39 @@ void setPosition() {
Serial.println(currentPosition[2]);
if (currentPosition[2] != nextPosition[2]) {
rotateCcwTo(nextPosition[2]);
rotateCcwTo(nextPosition[2]);
rotateCcwTo(nextPosition[2]);
rotateCcwTo(nextPosition[2]);
rotateCcwTo(nextPosition[2], false);
rotateCcwTo(nextPosition[2], true);
rotateCcwTo(nextPosition[2], true);
rotateCcwTo(nextPosition[2], true);
currentPosition[1] = -1;
}
if (currentPosition[1] != nextPosition[1]) {
rotateCwTo(nextPosition[1]);
rotateCwTo(nextPosition[1]);
rotateCwTo(nextPosition[1]);
rotateCwTo(nextPosition[1], false);
rotateCwTo(nextPosition[1], true);
rotateCwTo(nextPosition[1], true);
currentPosition[0] = -1;
}
if (currentPosition[0] != nextPosition[0]) {
rotateCcwTo(nextPosition[0]);
rotateCcwTo(nextPosition[0]);
rotateCcwTo(nextPosition[0], false);
rotateCcwTo(nextPosition[0], true);
}
rotateCwTo(10);
if (stepperPosition <= 10) {
rotateCwTo(0, true);
}
rotateCwTo(10, false);
currentPosition[0] = nextPosition[0];
currentPosition[1] = nextPosition[1];
currentPosition[2] = nextPosition[2];
}
void rotateCwTo(int pos) {
void rotateCwTo(int pos, boolean forceFullRotation) {
Serial.print("CW to ");
Serial.println(pos);
if (stepperPosition == pos) {
if (stepperPosition == pos && forceFullRotation) {
// make sure we actually move one whole turn
stepper.move(-200 * microStepsFactor);
stepper.runToPosition();
@ -112,10 +117,10 @@ void rotateCwTo(int pos) {
}
}
void rotateCcwTo(int pos) {
void rotateCcwTo(int pos, boolean forceFullRotation) {
Serial.print("CCW to ");
Serial.println(pos);
if (stepperPosition == pos) {
if (stepperPosition == pos && forceFullRotation) {
// make sure we actually move one whole turn
stepper.move(200 * microStepsFactor);
stepper.runToPosition();