소스 검색

with Router elevator object

master
Flo Smilari 3 년 전
부모
커밋
91ca8be6ba
4개의 변경된 파일14개의 추가작업 그리고 34개의 파일을 삭제
  1. 1
    27
      Fraestisch_SFTools.ino
  2. 10
    4
      RouterElevator.cpp
  3. 2
    2
      RouterElevator.h
  4. 1
    1
      sloeber.ino.cpp

+ 1
- 27
Fraestisch_SFTools.ino 파일 보기

@@ -50,10 +50,8 @@ static const int RotEnc_Clk_Pin = 32;
static const int RotEnc_Dta_Pin = 33;

static const int MOVE_DOWNWARD = -1; // motor rotation counter clock wise
//static const int MOVE_UPWARD = 1; // motor rotation clock wise
//static const int MOVE_UPWARD = 1; // motor rotation clock wise

//byte limitSwitchState = 1;
//int previousDirection = 0;
int nullingTLS_intermediateState = 0;

ExEzButton RedButton(RedBtn_Pin, false, 2000);
@@ -84,7 +82,6 @@ void printStatus(String actualStatus) {
//*** Limit switch interrupt routine
//**********************************
void limitSwitchHandler() {
// limitSwitchState = digitalRead(LIMIT_SWITCH);
Router_Elevator.limitSwitchHandler();
}

@@ -192,8 +189,6 @@ void loop() {
case NULLING:
printStatus("NULLING");
if (RedButton.isPressed()) {
// Stepper.setCurrentPositionInMillimeters(0);
// Stepper.setTargetPositionRelativeInMillimeters(0);
Router_Elevator.setZeroPosition();
actualStatus = IDLE;
}
@@ -204,7 +199,6 @@ void loop() {
if (nullingTLS_intermediateState == 0) {
printStatus("NULLING_TLS,0");
//Move elevator to lowest point (lower limit switch triggers)
// Stepper.setTargetPositionRelativeInMillimeters(300 * MOVE_DOWNWARD);
Router_Elevator.moveToLowerLimitSwitch();
actualStatus = MOVING_ELEVATOR;
nullingTLS_intermediateState = 1;
@@ -212,7 +206,6 @@ void loop() {
printStatus("NULLING_TLS,1");
if (RedButton.isPressed()) {
//Move elevator until it touch the TLS (WLS_PIN goes HIGH)
// Stepper.setTargetPositionRelativeInMillimeters(300 * MOVE_UPWARD);
Router_Elevator.moveToUpperLimitSwitch();
actualStatus = MOVING_ELEVATOR;
nullingTLS_intermediateState = 2;
@@ -228,8 +221,6 @@ void loop() {
} else { // nullingTLS_intermediateState is 3
printStatus("NULLING_TLS,3");
//Set the 0-Position as actual position
// Stepper.setCurrentPositionInMillimeters(0);
// Stepper.setTargetPositionRelativeInMillimeters(0);
Router_Elevator.setZeroPosition();
actualStatus = IDLE;
nullingTLS_intermediateState = 0;
@@ -254,32 +245,17 @@ void loop() {

case MOVING_ELEVATOR:
printStatus("MOVING_ELEVATOR");
// if (limitSwitchState == LOW) {
if (Router_Elevator.isLimitSwitchTriggerd()) {
// this will cause to stop any motion that is currently going on and block further movement in the same direction as long as the switch is active
// Stepper.setLimitSwitchActive(Stepper.LIMIT_SWITCH_COMBINED_BEGIN_AND_END);
delay(200);
actualStatus = RELEASE_SWITCH;
} else { // limitSwitchState is HIGH
// if (Stepper.getDistanceToTargetSigned() == 0) {
if (Router_Elevator.isTargetPositionReached()) {
Serial.println("isTargetPositionReached");
actualStatus = originStatus;
delay(200);
} else if (Router_Elevator.isWLSTriggerd()) {
// } else if (WlsDetect.isConnected()) {
// if (Wls.isPlugged()) {
// Serial.println("The Tool is away from WLS");
// Stepper.clearLimitSwitchActive();
// } else if (Wls.isUnplugged()) {
// Serial.println("The Tool touched the WLS");
// Stepper.setLimitSwitchActive(Stepper.LIMIT_SWITCH_COMBINED_BEGIN_AND_END);
actualStatus = originStatus;
delay(200);
// }
}
// Stepper.clearLimitSwitchActive();
// previousDirection = Stepper.getDirectionOfMotion();
Router_Elevator.clearLimitSwitch();
Router_Elevator.checkDirection();
}
@@ -287,9 +263,7 @@ void loop() {

case RELEASE_SWITCH:
printStatus("RELEASE_SWITCH");
// if (limitSwitchState == LOW) {
if (Router_Elevator.isLimitSwitchTriggerd()) {
// Stepper.moveRelativeInMillimeters(0.05 * previousDirection * -1); // move in opposite direction (away from switch)
Router_Elevator.tryReleaseLimitSwitch();
} else {
actualStatus = originStatus;

+ 10
- 4
RouterElevator.cpp 파일 보기

@@ -8,9 +8,9 @@
#include "RouterElevator.h"
RouterElevator::RouterElevator(ESP_FlexyStepper &_Stepper, Display &_display, WLS &_WlsDetect, WLS &_Wls, int _LimitSwitch, int _DOWNWARD_DIR) :
WlsDetect(_WlsDetect), Wls(_Wls) {
Stepper = _Stepper;
display = _display;
Stepper(_Stepper), display(_display), WlsDetect(_WlsDetect), Wls(_Wls) {
// Stepper = _Stepper;
// display = _display;
// WlsDetect = _WlsDetect;
// Wls = _Wls;
LimitSwitch = _LimitSwitch;
@@ -68,7 +68,13 @@ bool RouterElevator::isWLSTriggerd() {
void RouterElevator::limitSwitchHandler() {
limitSwitchState = digitalRead(LimitSwitch);
Stepper.setLimitSwitchActive(Stepper.LIMIT_SWITCH_COMBINED_BEGIN_AND_END);
if (limitSwitchState == LOW) {
// this will cause to stop any motion that is currently going on and block further movement in the same direction as long as the switch is active
Stepper.setLimitSwitchActive(Stepper.LIMIT_SWITCH_COMBINED_BEGIN_AND_END);
} else {
// clear the limit switch flag to allow movement in both directions again
clearLimitSwitch();
}
}
void RouterElevator::checkDirection() {

+ 2
- 2
RouterElevator.h 파일 보기

@@ -17,8 +17,8 @@
class RouterElevator {
private:
ESP_FlexyStepper Stepper;
Display display;
ESP_FlexyStepper &Stepper;
Display &display;
int previousDirection = 0;
byte limitSwitchState = 1;
int LimitSwitch;

+ 1
- 1
sloeber.ino.cpp 파일 보기

@@ -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-02-13 02:49:42
//This file has been generated on 2022-02-13 17:01:01

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

Loading…
취소
저장