refactored compile time settings back into a new file called config.h

This commit is contained in:
Simen Svale Skogsrud 2011-02-05 00:55:37 +01:00
parent d00947a23a
commit 6d3ff506e8
8 changed files with 112 additions and 86 deletions

90
config.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@ -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;

View File

@ -23,6 +23,7 @@
#include "gcode.h"
#include "wiring_serial.h"
#include "settings.h"
#include "config.h"
#include <math.h>
#include "nuts_bolts.h"
#include <avr/pgmspace.h>
@ -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();
}

View File

@ -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;
}

View File

@ -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 <math.h>
#include <inttypes.h>
// 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

View File

@ -20,6 +20,7 @@
#include "spindle_control.h"
#include "settings.h"
#include "config.h"
#include <avr/io.h>

View File

@ -23,6 +23,7 @@
by David A. Mellis */
#include "stepper.h"
#include "config.h"
#include "settings.h"
#include <math.h>
#include <stdlib.h>

View File

@ -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