Browse Source

Read limit switch on Initialize to avoid motor movement if limit switch is already pressed (e.g. due to previous Power Off when switch was pressed)

master
Flo Smilari 3 years ago
parent
commit
caa0668907
4 changed files with 11 additions and 3 deletions
  1. 5
    2
      Fraestisch_SFTools.ino
  2. 4
    0
      RouterElevator.cpp
  3. 1
    0
      RouterElevator.h
  4. 1
    1
      sloeber.ino.cpp

+ 5
- 2
Fraestisch_SFTools.ino View File

@@ -120,6 +120,7 @@ void Initialize() {
}

if (isPowerOn && Router_Setup.isToolChangOnPowerOn()) {
Router_Elevator.readLimitSwitch();
SetActualStatus(TOOL_CHANGE);
isPowerOn = false;
} else {
@@ -189,8 +190,10 @@ void loop() {
RotaryControler.loop();
originStatus = TOOL_CHANGE;
if (intermediateState == 0) {
Router_Elevator.moveToUpperLimitSwitch();
SetActualStatus(MOVING_ELEVATOR);
if (!Router_Elevator.isLimitSwitchTriggerd()) {
Router_Elevator.moveToUpperLimitSwitch();
SetActualStatus(MOVING_ELEVATOR);
}
intermediateState = 1;
} else if (intermediateState == 1) {
Router_Elevator.setZeroPosition();

+ 4
- 0
RouterElevator.cpp View File

@@ -94,6 +94,10 @@ void RouterElevator::limitSwitchHandler() {
}
}
void RouterElevator::readLimitSwitch() {
limitSwitchState = digitalRead(LimitSwitch);
}
void RouterElevator::checkDirection() {
previousDirection = Stepper.getDirectionOfMotion();
}

+ 1
- 0
RouterElevator.h View File

@@ -49,6 +49,7 @@ class RouterElevator {
bool isWLSTriggerd(void);
bool isTargetPositionReached(void);
void limitSwitchHandler(void);
void readLimitSwitch(void);
void checkDirection(void);
ValueMode getMode() const;
void setMode(ValueMode mode);

+ 1
- 1
sloeber.ino.cpp View File

@@ -2,7 +2,7 @@
//This is a automatic generated file
//Please do not modify this file
//If you touch this file your change will be overwritten during the next build
//This file has been generated on 2022-03-04 21:14:46
//This file has been generated on 2022-04-15 16:36:20

#include "Arduino.h"
#include <Arduino.h>

Loading…
Cancel
Save