diff --git a/config.h b/config.h new file mode 100644 index 0000000..962acd9 --- /dev/null +++ b/config.h @@ -0,0 +1,90 @@ +/* + config.h - compile time configuration + Part of Grbl + + Copyright (c) 2009-2011 Simen Svale Skogsrud + + Grbl is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Grbl is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Grbl. If not, see . +*/ + +#ifndef config_h +#define config_h + +#define BAUD_RATE 9600 + +// Updated default pin-assignments from 0.6 onwards +// (see bottom of file for a copy of the old config) + +#define STEPPERS_ENABLE_DDR DDRB +#define STEPPERS_ENABLE_PORT PORTB +#define STEPPERS_ENABLE_BIT 0 + +#define STEPPING_DDR DDRD +#define STEPPING_PORT PORTD +#define X_STEP_BIT 2 +#define Y_STEP_BIT 3 +#define Z_STEP_BIT 4 +#define X_DIRECTION_BIT 5 +#define Y_DIRECTION_BIT 6 +#define Z_DIRECTION_BIT 7 + +#define LIMIT_DDR DDRB +#define LIMIT_PORT PORTB +#define X_LIMIT_BIT 1 +#define Y_LIMIT_BIT 2 +#define Z_LIMIT_BIT 3 + +#define SPINDLE_ENABLE_DDR DDRB +#define SPINDLE_ENABLE_PORT PORTB +#define SPINDLE_ENABLE_BIT 4 + +#define SPINDLE_DIRECTION_DDR DDRB +#define SPINDLE_DIRECTION_PORT PORTB +#define SPINDLE_DIRECTION_BIT 5 + +// The temporal resolution of the acceleration management subsystem. Higher number +// give smoother acceleration but may impact performance +#define ACCELERATION_TICKS_PER_SECOND 20L + +#endif + +// Pin-assignments from Grbl 0.5 + +// #define STEPPERS_ENABLE_DDR DDRD +// #define STEPPERS_ENABLE_PORT PORTD +// #define STEPPERS_ENABLE_BIT 2 +// +// #define STEPPING_DDR DDRC +// #define STEPPING_PORT PORTC +// #define X_STEP_BIT 0 +// #define Y_STEP_BIT 1 +// #define Z_STEP_BIT 2 +// #define X_DIRECTION_BIT 3 +// #define Y_DIRECTION_BIT 4 +// #define Z_DIRECTION_BIT 5 +// +// #define LIMIT_DDR DDRD +// #define LIMIT_PORT PORTD +// #define X_LIMIT_BIT 3 +// #define Y_LIMIT_BIT 4 +// #define Z_LIMIT_BIT 5 +// +// #define SPINDLE_ENABLE_DDR DDRD +// #define SPINDLE_ENABLE_PORT PORTD +// #define SPINDLE_ENABLE_BIT 6 +// +// #define SPINDLE_DIRECTION_DDR DDRD +// #define SPINDLE_DIRECTION_PORT PORTD +// #define SPINDLE_DIRECTION_BIT 7 + diff --git a/motion_control.c b/motion_control.c index 7890ad9..738a782 100644 --- a/motion_control.c +++ b/motion_control.c @@ -115,7 +115,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr double target[3]; int i; // Initialize the linear axis - target[axis_linear] = position[axis_linear]/Z_STEPS_PER_MM; + target[axis_linear] = position[axis_linear]/settings.steps_per_mm[axis_linear]; for (i=0; i<=segments; i++) { target[axis_linear] += linear_per_segment; theta += theta_per_segment; diff --git a/serial_protocol.c b/serial_protocol.c index 665ea41..d62bb3b 100644 --- a/serial_protocol.c +++ b/serial_protocol.c @@ -23,6 +23,7 @@ #include "gcode.h" #include "wiring_serial.h" #include "settings.h" +#include "config.h" #include #include "nuts_bolts.h" #include @@ -54,7 +55,7 @@ void sp_init() { beginSerial(BAUD_RATE); printPgmString(PSTR("\r\nGrbl ")); - printPgmString(PSTR(VERSION)); + printPgmString(PSTR(GRBL_VERSION)); printPgmString(PSTR("\r\n")); prompt(); } diff --git a/settings.c b/settings.c index a8095ae..f72c7cd 100644 --- a/settings.c +++ b/settings.c @@ -1,5 +1,5 @@ /* - settings.c - eeprom and compile time configuration handling + settings.c - eeprom configuration handling Part of Grbl Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -40,14 +40,14 @@ typedef struct { } settings_v1_t; void reset_settings() { - settings.steps_per_mm[0] = X_STEPS_PER_MM; - settings.steps_per_mm[1] = Y_STEPS_PER_MM; - settings.steps_per_mm[2] = Z_STEPS_PER_MM; - settings.pulse_microseconds = STEP_PULSE_MICROSECONDS; + settings.steps_per_mm[0] = DEFAULT_X_STEPS_PER_MM; + settings.steps_per_mm[1] = DEFAULT_Y_STEPS_PER_MM; + settings.steps_per_mm[2] = DEFAULT_Z_STEPS_PER_MM; + settings.pulse_microseconds = DEFAULT_STEP_PULSE_MICROSECONDS; settings.default_feed_rate = DEFAULT_FEEDRATE; - settings.default_seek_rate = RAPID_FEEDRATE; + settings.default_seek_rate = DEFAULT_RAPID_FEEDRATE; settings.acceleration = DEFAULT_ACCELERATION; - settings.mm_per_arc_segment = MM_PER_ARC_SEGMENT; + settings.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT; settings.invert_mask = DEFAULT_STEPPING_INVERT_MASK; settings.max_jerk = DEFAULT_MAX_JERK; } diff --git a/settings.h b/settings.h index 218faab..35ddd76 100644 --- a/settings.h +++ b/settings.h @@ -1,5 +1,5 @@ /* - settings.h - eeprom and compile time configuration handling + settings.h - eeprom configuration handling Part of Grbl Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -21,76 +21,11 @@ #ifndef settings_h #define settings_h -#define VERSION "0.6b" + #include #include -// Settings that can only be set at compile-time: - -#define BAUD_RATE 9600 -//#define BAUD_RATE 115200 - -// Default pin-assignments from Grbl 0.5 - -// #define STEPPERS_ENABLE_DDR DDRD -// #define STEPPERS_ENABLE_PORT PORTD -// #define STEPPERS_ENABLE_BIT 2 -// -// #define STEPPING_DDR DDRC -// #define STEPPING_PORT PORTC -// #define X_STEP_BIT 0 -// #define Y_STEP_BIT 1 -// #define Z_STEP_BIT 2 -// #define X_DIRECTION_BIT 3 -// #define Y_DIRECTION_BIT 4 -// #define Z_DIRECTION_BIT 5 -// -// #define LIMIT_DDR DDRD -// #define LIMIT_PORT PORTD -// #define X_LIMIT_BIT 3 -// #define Y_LIMIT_BIT 4 -// #define Z_LIMIT_BIT 5 -// -// #define SPINDLE_ENABLE_DDR DDRD -// #define SPINDLE_ENABLE_PORT PORTD -// #define SPINDLE_ENABLE_BIT 6 -// -// #define SPINDLE_DIRECTION_DDR DDRD -// #define SPINDLE_DIRECTION_PORT PORTD -// #define SPINDLE_DIRECTION_BIT 7 -// -// - - -// Updated default pin-assignments from 0.6 onwards - -#define STEPPERS_ENABLE_DDR DDRB -#define STEPPERS_ENABLE_PORT PORTB -#define STEPPERS_ENABLE_BIT 0 - -#define STEPPING_DDR DDRD -#define STEPPING_PORT PORTD -#define X_STEP_BIT 2 -#define Y_STEP_BIT 3 -#define Z_STEP_BIT 4 -#define X_DIRECTION_BIT 5 -#define Y_DIRECTION_BIT 6 -#define Z_DIRECTION_BIT 7 - -#define LIMIT_DDR DDRB -#define LIMIT_PORT PORTB -#define X_LIMIT_BIT 1 -#define Y_LIMIT_BIT 2 -#define Z_LIMIT_BIT 3 - -#define SPINDLE_ENABLE_DDR DDRB -#define SPINDLE_ENABLE_PORT PORTB -#define SPINDLE_ENABLE_BIT 4 - -#define SPINDLE_DIRECTION_DDR DDRB -#define SPINDLE_DIRECTION_PORT PORTB -#define SPINDLE_DIRECTION_BIT 5 - +#define GRBL_VERSION "0.6b" // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl // when firmware is upgraded. Always stored in byte 0 of eeprom @@ -121,18 +56,15 @@ void store_setting(int parameter, double value); // Default settings (used when resetting eeprom-settings) #define MICROSTEPS 8 -#define X_STEPS_PER_MM (94.488188976378*MICROSTEPS) -#define Y_STEPS_PER_MM (94.488188976378*MICROSTEPS) -#define Z_STEPS_PER_MM (94.488188976378*MICROSTEPS) -#define STEP_PULSE_MICROSECONDS 30 -#define MM_PER_ARC_SEGMENT 0.1 -#define RAPID_FEEDRATE 480.0 // in millimeters per minute +#define DEFAULT_X_STEPS_PER_MM (94.488188976378*MICROSTEPS) +#define DEFAULT_Y_STEPS_PER_MM (94.488188976378*MICROSTEPS) +#define DEFAULT_Z_STEPS_PER_MM (94.488188976378*MICROSTEPS) +#define DEFAULT_STEP_PULSE_MICROSECONDS 30 +#define DEFAULT_MM_PER_ARC_SEGMENT 0.1 +#define DEFAULT_RAPID_FEEDRATE 480.0 // in millimeters per minute #define DEFAULT_FEEDRATE 480.0 #define DEFAULT_ACCELERATION (DEFAULT_FEEDRATE/100.0) #define DEFAULT_MAX_JERK 50.0 #define DEFAULT_STEPPING_INVERT_MASK 0 -// The temporal resolution of the acceleration management subsystem -#define ACCELERATION_TICKS_PER_SECOND 20L - #endif diff --git a/spindle_control.c b/spindle_control.c index 509ee83..0dc48c8 100644 --- a/spindle_control.c +++ b/spindle_control.c @@ -20,6 +20,7 @@ #include "spindle_control.h" #include "settings.h" +#include "config.h" #include diff --git a/stepper.c b/stepper.c index fa70a34..f8e73f3 100644 --- a/stepper.c +++ b/stepper.c @@ -23,6 +23,7 @@ by David A. Mellis */ #include "stepper.h" +#include "config.h" #include "settings.h" #include #include diff --git a/stepper_plan.c b/stepper_plan.c index 3e56513..4b62d03 100644 --- a/stepper_plan.c +++ b/stepper_plan.c @@ -58,6 +58,7 @@ #include "nuts_bolts.h" #include "stepper.h" #include "settings.h" +#include "config.h" #include "wiring_serial.h" block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions