From 9a5864f6335e9db313e2039a424d614769712e95 Mon Sep 17 00:00:00 2001 From: "Mikhail Basov (NeedleFile)" Date: Fri, 24 Dec 2021 00:11:14 +0300 Subject: [PATCH] Add emergency endstop support --- PETCTL.ino | 21 ++++++++++++++++++++- PETCTL_cfg.h | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/PETCTL.ino b/PETCTL.ino index 606c70d..024a933 100644 --- a/PETCTL.ino +++ b/PETCTL.ino @@ -64,6 +64,7 @@ void setup() { #endif //SERIAL_DEBUG_STEPPER pinMode(CFG_ENDSTOP_PIN, INPUT_PULLUP); + pinMode(CFG_EMENDSTOP_PIN, INPUT_PULLUP); pinMode(CFG_SOUND_PIN, OUTPUT); stepper.setRunMode(KEEP_SPEED); // режим поддержания скорости @@ -93,7 +94,7 @@ void setup() { oled.println("PETCTL"); oled.setScale(1); oled.setCursor(20, 7); - oled.print("mvb V 0.9"); + oled.print("mvb V 0.10"); delay(3000); oled.clear(); @@ -233,6 +234,24 @@ void loop() { oled.println(" "); finalLength = 0; } + + oled.setCursorXY(112, 24); + if(!digitalRead(CFG_EMENDSTOP_PIN)) { + if(!runMotor) { + oled.setScale(2); + oled.println("X"); + } else { + runMotor = false; + motorCTL(-1); + Heat = false; + printHeaterStatus(Heat); + beepI(); + beepI(); + } + } else { + oled.setScale(2); + oled.println(" "); + } } void debugTemp(float temp, int out) { diff --git a/PETCTL_cfg.h b/PETCTL_cfg.h index 00a7d1b..ec05461 100644 --- a/PETCTL_cfg.h +++ b/PETCTL_cfg.h @@ -36,6 +36,8 @@ #define CFG_ENDSTOP_PIN 8 /* Extra length to pull after end stop triggered [m] */ #define CFG_PULL_EXTRA_LENGTH 0.07 +/* Which pin emergency endstop connected to */ +#define CFG_EMENDSTOP_PIN 11 /* PID regulator coefficients */ //PID p: 12.69 PID i: 0.71 PID d: 57.11 #define CFG_PID_P 12.69