From 9cabc915ef9096b470e236679db70834f6fc9e7a Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Sun, 4 Nov 2012 10:48:57 -0700 Subject: [PATCH] Runtime command pinned out! Re-organized coolant pins. - Pinned out cycle start(A2), feed hold(A1), and reset(A0) runtime commands. These pins are held high with the internal pull-up resistor enabled. All you have to do is connect a normally-open switch to the pin and ground. That's it. - Moved the coolant control pins to A3 (and the optional mist control to A4). - Moved all of the MASK defines into the config.h file to centralize them. --- config.h | 23 +++++++++++++++++++++-- limits.h | 1 - protocol.c | 27 +++++++++++++++++++++++++++ report.c | 4 ++-- stepper.h | 6 ------ 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/config.h b/config.h index f27a4b7..ae48023 100755 --- a/config.h +++ b/config.h @@ -35,10 +35,14 @@ #define X_DIRECTION_BIT 5 // Uno Digital Pin 5 #define Y_DIRECTION_BIT 6 // Uno Digital Pin 6 #define Z_DIRECTION_BIT 7 // Uno Digital Pin 7 +#define STEP_MASK ((1< +#include #include "protocol.h" #include "gcode.h" #include "serial.h" @@ -41,6 +42,11 @@ void protocol_init() char_counter = 0; // Reset line input iscomment = false; report_init_message(); // Welcome message + + PINOUT_DDR &= ~(PINOUT_MASK); // Set as input pins + PINOUT_PORT |= PINOUT_MASK; // Enable internal pull-up resistors. Normal high operation. + PINOUT_PCMSK |= PINOUT_MASK; // Enable specific pins of the Pin Change Interrupt + PCICR |= (1 << PINOUT_INT); // Enable Pin Change Interrupt } // Executes user startup script, if stored. @@ -59,6 +65,27 @@ void protocol_execute_startup() } } +// Pin change interrupt for pin-out commands, i.e. cycle start, feed hold, and reset. Sets +// only the runtime command execute variable to have the main program execute these when +// its ready. This works exactly like the character-based runtime commands when picked off +// directly from the incoming serial data stream. +ISR(PINOUT_INT_vect) +{ + // Enter only if any pinout pin is actively low. + if ((PINOUT_PIN & PINOUT_MASK) ^ PINOUT_MASK) { + if (bit_isfalse(PINOUT_PIN,bit(PIN_RESET))) { + mc_alarm(); + sys.execute |= EXEC_RESET; // Set as true + } + if (bit_isfalse(PINOUT_PIN,bit(PIN_FEED_HOLD))) { + sys.execute |= EXEC_FEED_HOLD; + } + if (bit_isfalse(PINOUT_PIN,bit(PIN_CYCLE_START))) { + sys.execute |= EXEC_CYCLE_START; + } + } +} + // Executes run-time commands, when required. This is called from various check points in the main // program, primarily where there may be a while loop waiting for a buffer to clear space or any // point where the execution time from the last check point may be more than a fraction of a second. diff --git a/report.c b/report.c index 42456bf..d336677 100644 --- a/report.c +++ b/report.c @@ -65,7 +65,7 @@ void report_status_message(uint8_t status_code) case STATUS_HARD_LIMIT: printPgmString(PSTR("Limit triggered")); break; case STATUS_SETTING_DISABLED: - printPgmString(PSTR("Grbl setting disabled")); break; + printPgmString(PSTR("Setting disabled")); break; case STATUS_SETTING_VALUE_NEG: printPgmString(PSTR("Set value must be > 0.0")); break; case STATUS_SETTING_STEP_PULSE_MIN: @@ -75,7 +75,7 @@ void report_status_message(uint8_t status_code) case STATUS_HOMING_ERROR: printPgmString(PSTR("Must be idle to home")); break; case STATUS_ABORT_CYCLE: - printPgmString(PSTR("Abort during cycle. Position may be lost")); break; + printPgmString(PSTR("Abort during cycle. Position maybe lost")); break; case STATUS_PURGE_CYCLE: printPgmString(PSTR("Can't purge buffer during cycle")); break; } diff --git a/stepper.h b/stepper.h index a72546f..84fe8c0 100755 --- a/stepper.h +++ b/stepper.h @@ -25,15 +25,9 @@ #include // Some useful constants -#define STEP_MASK ((1<