Skip to content

Commit

Permalink
Add emergency endstop support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Basov (NeedleFile) committed Dec 23, 2021
1 parent bf781ca commit 9a5864f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion PETCTL.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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); // режим поддержания скорости
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions PETCTL_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a5864f

Please sign in to comment.