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.
This commit is contained in:
Sonny Jeon 2012-11-04 10:48:57 -07:00
parent 8c0106c247
commit 9cabc915ef
5 changed files with 50 additions and 11 deletions

View File

@ -35,10 +35,14 @@
#define X_DIRECTION_BIT 5 // Uno Digital Pin 5 #define X_DIRECTION_BIT 5 // Uno Digital Pin 5
#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6 #define Y_DIRECTION_BIT 6 // Uno Digital Pin 6
#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7 #define Z_DIRECTION_BIT 7 // Uno Digital Pin 7
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
#define STEPPING_MASK (STEP_MASK | DIRECTION_MASK) // All stepping-related bits (step/direction)
#define STEPPERS_DISABLE_DDR DDRB #define STEPPERS_DISABLE_DDR DDRB
#define STEPPERS_DISABLE_PORT PORTB #define STEPPERS_DISABLE_PORT PORTB
#define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8 #define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8
#define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
#define LIMIT_DDR DDRB #define LIMIT_DDR DDRB
#define LIMIT_PIN PINB #define LIMIT_PIN PINB
@ -49,6 +53,7 @@
#define LIMIT_INT PCIE0 // Pin change interrupt enable pin #define LIMIT_INT PCIE0 // Pin change interrupt enable pin
#define LIMIT_INT_vect PCINT0_vect #define LIMIT_INT_vect PCINT0_vect
#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register #define LIMIT_PCMSK PCMSK0 // Pin change interrupt register
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
#define SPINDLE_ENABLE_DDR DDRB #define SPINDLE_ENABLE_DDR DDRB
#define SPINDLE_ENABLE_PORT PORTB #define SPINDLE_ENABLE_PORT PORTB
@ -60,15 +65,29 @@
#define COOLANT_FLOOD_DDR DDRC #define COOLANT_FLOOD_DDR DDRC
#define COOLANT_FLOOD_PORT PORTC #define COOLANT_FLOOD_PORT PORTC
#define COOLANT_FLOOD_BIT 0 // Uno Analog Pin 0 #define COOLANT_FLOOD_BIT 3 // Uno Analog Pin 3
// #define ENABLE_M7 // Mist coolant disabled by default. Uncomment to enable. // #define ENABLE_M7 // Mist coolant disabled by default. Uncomment to enable.
// NOTE: Uno analog pins 4 and 5 are reserved for an i2c interface, and may be installed at
// a later date if flash and memory space allows.
#ifdef ENABLE_M7 #ifdef ENABLE_M7
#define COOLANT_MIST_DDR DDRC #define COOLANT_MIST_DDR DDRC
#define COOLANT_MIST_PORT PORTC #define COOLANT_MIST_PORT PORTC
#define COOLANT_MIST_BIT 1 // Uno Analog Pin 1 #define COOLANT_MIST_BIT 4 // Uno Analog Pin 4
#endif #endif
#define PINOUT_DDR DDRC
#define PINOUT_PIN PINC
#define PINOUT_PORT PORTC
#define PIN_RESET 0 // Uno Analog Pin 0
#define PIN_FEED_HOLD 1 // Uno Analog Pin 1
#define PIN_CYCLE_START 2 // Uno Analog Pin 2
#define PINOUT_INT PCIE1 // Pin change interrupt enable pin
#define PINOUT_INT_vect PCINT1_vect
#define PINOUT_PCMSK PCMSK1 // Pin change interrupt register
#define PINOUT_MASK ((1<<PIN_RESET)|(1<<PIN_FEED_HOLD)|(1<<PIN_CYCLE_START))
// Default settings (used when resetting eeprom-settings) // Default settings (used when resetting eeprom-settings)
// TODO: Begin to fill these out for various as-built machines, i.e. config_sherline5400.h // TODO: Begin to fill these out for various as-built machines, i.e. config_sherline5400.h
#define MICROSTEPS 4 #define MICROSTEPS 4

View File

@ -21,7 +21,6 @@
#ifndef limits_h #ifndef limits_h
#define limits_h #define limits_h
#define LIMIT_MASK ((1<<X_LIMIT_BIT)|(1<<Y_LIMIT_BIT)|(1<<Z_LIMIT_BIT)) // All limit bits
#define MICROSECONDS_PER_ACCELERATION_TICK (1000000/ACCELERATION_TICKS_PER_SECOND) #define MICROSECONDS_PER_ACCELERATION_TICK (1000000/ACCELERATION_TICKS_PER_SECOND)
// initialize the limits module // initialize the limits module

View File

@ -20,6 +20,7 @@
*/ */
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h>
#include "protocol.h" #include "protocol.h"
#include "gcode.h" #include "gcode.h"
#include "serial.h" #include "serial.h"
@ -41,6 +42,11 @@ void protocol_init()
char_counter = 0; // Reset line input char_counter = 0; // Reset line input
iscomment = false; iscomment = false;
report_init_message(); // Welcome message 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. // 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 // 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 // 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. // point where the execution time from the last check point may be more than a fraction of a second.

View File

@ -65,7 +65,7 @@ void report_status_message(uint8_t status_code)
case STATUS_HARD_LIMIT: case STATUS_HARD_LIMIT:
printPgmString(PSTR("Limit triggered")); break; printPgmString(PSTR("Limit triggered")); break;
case STATUS_SETTING_DISABLED: case STATUS_SETTING_DISABLED:
printPgmString(PSTR("Grbl setting disabled")); break; printPgmString(PSTR("Setting disabled")); break;
case STATUS_SETTING_VALUE_NEG: case STATUS_SETTING_VALUE_NEG:
printPgmString(PSTR("Set value must be > 0.0")); break; printPgmString(PSTR("Set value must be > 0.0")); break;
case STATUS_SETTING_STEP_PULSE_MIN: case STATUS_SETTING_STEP_PULSE_MIN:
@ -75,7 +75,7 @@ void report_status_message(uint8_t status_code)
case STATUS_HOMING_ERROR: case STATUS_HOMING_ERROR:
printPgmString(PSTR("Must be idle to home")); break; printPgmString(PSTR("Must be idle to home")); break;
case STATUS_ABORT_CYCLE: 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: case STATUS_PURGE_CYCLE:
printPgmString(PSTR("Can't purge buffer during cycle")); break; printPgmString(PSTR("Can't purge buffer during cycle")); break;
} }

View File

@ -25,15 +25,9 @@
#include <avr/io.h> #include <avr/io.h>
// Some useful constants // Some useful constants
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
#define STEPPING_MASK (STEP_MASK | DIRECTION_MASK) // All stepping-related bits (step/direction)
#define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
#define TICKS_PER_MICROSECOND (F_CPU/1000000) #define TICKS_PER_MICROSECOND (F_CPU/1000000)
#define CYCLES_PER_ACCELERATION_TICK ((TICKS_PER_MICROSECOND*1000000)/ACCELERATION_TICKS_PER_SECOND) #define CYCLES_PER_ACCELERATION_TICK ((TICKS_PER_MICROSECOND*1000000)/ACCELERATION_TICKS_PER_SECOND)
// Initialize and setup the stepper motor subsystem // Initialize and setup the stepper motor subsystem
void st_init(); void st_init();