diff --git a/.gitignore b/.gitignore
index 1102503..a764af3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.hex
*.o
-*.elf
\ No newline at end of file
+*.elf
+.DS_Store
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 90742cc..ab41f34 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ DEVICE = atmega328p
CLOCK = 16000000
PROGRAMMER = -c avrisp2 -P usb
OBJECTS = main.o motion_control.o gcode.o spindle_control.o wiring_serial.o serial_protocol.o stepper.o \
- eeprom.o config.o
+ eeprom.o config.o accelleration.o
# FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m
FUSES = -U hfuse:w:0xd2:m -U lfuse:w:0xff:m
diff --git a/accelleration.h b/accelleration.h
new file mode 100644
index 0000000..ab73d6d
--- /dev/null
+++ b/accelleration.h
@@ -0,0 +1,51 @@
+/*
+ accelleration.h - accelleration management support
+ Part of Grbl
+
+ Copyright (c) 2009 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 accelleration_h
+#define accelleration_h
+
+// Unless someone else defined AC_TICKS_PER_SECOND, we define a sensible default
+#ifndef AC_TICKS_PER_SECOND
+#define AC_TICKS_PER_SECOND 10
+#endif
+
+struct AccellerationProfile {
+ float initial_scaler;
+ float final_scaler;
+ float accelleration_delta;
+ float decelleration_delta;
+ uint32_t accellerate_ticks;
+ uint32_t plateau_ticks;
+};
+
+struct AccellerationProfileSegment {
+ float v_entry[3];
+ float v_ideal[3];
+ float v_exit[3];
+ float distance;
+ float f_entry, f_exit;
+};
+
+struct AccellerationProfileBuilder {
+ AccellerationProfileSegment segment[3];
+ uint8_t current;
+};
+
+#endif
\ No newline at end of file
diff --git a/config.c b/config.c
index e8af99d..13be1de 100644
--- a/config.c
+++ b/config.c
@@ -32,11 +32,19 @@ void reset_settings() {
settings.steps_per_mm[2] = Z_STEPS_PER_MM;
settings.pulse_microseconds = STEP_PULSE_MICROSECONDS;
settings.default_feed_rate = DEFAULT_FEEDRATE;
+<<<<<<< Updated upstream
settings.default_seek_rate = RAPID_FEEDRATE;
settings.dead_feed_rate = DEFAULT_FEEDRATE/5;
settings.acceleration = DEFAULT_FEEDRATE/100;
settings.mm_per_arc_segment = MM_PER_ARC_SEGMENT;
settings.invert_mask = STEPPING_INVERT_MASK;
+=======
+ settings.seek_rate = DEFAULT_SEEKRATE;
+ settings.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT;
+ settings.invert_mask = 0;
+ settings.max_jerk = DEFAULT_MAX_JERK;
+ settings.accelleration = DEFAULT_ACCELLERATION;
+>>>>>>> Stashed changes
}
void dump_settings() {
@@ -51,7 +59,10 @@ void dump_settings() {
printPgmString(PSTR(" (mm/sec^2 max acceleration)\r\n$9 = ")); printFloat(settings.acceleration);
printPgmString(PSTR(" (mm/arc segment)\r\n$10 = ")); printInteger(settings.invert_mask);
printPgmString(PSTR(" (step port invert mask. binary = ")); printIntegerInBase(settings.invert_mask, 2);
- printPgmString(PSTR(")\r\n\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
+ printPgmString(PSTR(")\n\r$8 = ")); printFloat(settings.max_jerk);
+ printPgmString(PSTR(" (max jerk in delta mm/second)\r\n$9 = ")); printFloat(settings.accelleration);
+ printPgmString(PSTR(" (accelleration in mm/second^2)"));
+ printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
}
int read_settings() {
@@ -77,11 +88,19 @@ void store_setting(int parameter, double value) {
settings.steps_per_mm[parameter] = value; break;
case 3: settings.pulse_microseconds = round(value); break;
case 4: settings.default_feed_rate = value; break;
+<<<<<<< Updated upstream
case 5: settings.default_seek_rate = value; break;
case 6: settings.dead_feed_rate = value; break;
case 8: settings.mm_per_arc_segment = value; break;
case 9: settings.acceleration = value; break;
case 10: settings.invert_mask = trunc(value); break;
+=======
+ case 5: settings.seek_rate = value; break;
+ case 6: settings.mm_per_arc_segment = value; break;
+ case 7: settings.invert_mask = trunc(value); break;
+ case 8: settings.max_jerk = value; break;
+ case 9: settings.accelleration = fabs(value); break;
+>>>>>>> Stashed changes
default:
printPgmString(PSTR("Unknown parameter\r\n"));
return;
diff --git a/config.h b/config.h
index 68ac922..1e3d79b 100644
--- a/config.h
+++ b/config.h
@@ -22,6 +22,8 @@
#define config_h
#define VERSION "0.51"
+#include
+#include
// Settings that can only be set at compile-time:
@@ -69,6 +71,10 @@ struct Settings {
double default_seek_rate;
uint8_t invert_mask;
double mm_per_arc_segment;
+<<<<<<< Updated upstream
+=======
+ double max_jerk;
+>>>>>>> Stashed changes
double accelleration;
};
struct Settings settings;
@@ -94,6 +100,8 @@ void store_setting(int parameter, double value);
#define RAPID_FEEDRATE 480.0 // in millimeters per minute
#define DEFAULT_FEEDRATE 480.0
+#define DEFAULT_MAX_JERK 10.0
+#define DEFAULT_ACCELLERATION 0.1
// Use this line for default operation (step-pulses high)
#define STEPPING_INVERT_MASK 0
diff --git a/nuts_bolts.h b/nuts_bolts.h
index f27f4c6..cc6664d 100644
--- a/nuts_bolts.h
+++ b/nuts_bolts.h
@@ -41,4 +41,10 @@
#define Y_AXIS 1
#define Z_AXIS 2
+void scale_vector(float *target, float *source, float multiplier) {
+ target[0] = source[0]*multiplier;
+ target[1] = source[1]*multiplier;
+ target[2] = source[2]*multiplier;
+}
+
#endif
diff --git a/stepper.c b/stepper.c
index e6a1f99..603ab89 100644
--- a/stepper.c
+++ b/stepper.c
@@ -40,6 +40,7 @@
#define LINE_BUFFER_SIZE 10
#endif
+<<<<<<< Updated upstream
struct Line {
uint32_t steps_x, steps_y, steps_z;
int32_t maximum_steps;
@@ -75,6 +76,41 @@ void update_accelleration_plan() {
int initial_buffer_tail = line_buffer_tail;
}
+=======
+#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<>>>>>> Stashed changes
// Add a new linear movement to the buffer. steps_x, _y and _z is the signed, relative motion in
// steps. Microseconds specify how many microseconds the move should take to perform. To aid accelleration
@@ -83,6 +119,7 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
// Calculate the buffer head after we push this byte
int next_buffer_head = (line_buffer_head + 1) % LINE_BUFFER_SIZE;
// If the buffer is full: good! That means we are well ahead of the robot.
+<<<<<<< Updated upstream
// Nap until there is room in the buffer.
while(line_buffer_tail == next_buffer_head) { sleep_mode(); }
// Setup line record
@@ -94,6 +131,26 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
// Bail if this is a zero-length line
if (line->maximum_steps == 0) { return; };
line->rate = (TICKS_PER_MICROSECOND*microseconds)/line->maximum_steps;
+=======
+ // Rest here until there is room in the buffer.
+ while(block_buffer_tail == next_buffer_head) { sleep_mode(); }
+ // Prepare to set up new block
+ struct Block *block = &block_buffer[block_buffer_head];
+ // Number of steps for each axis
+ block->steps_x = labs(steps_x);
+ block->steps_y = labs(steps_y);
+ block->steps_z = labs(steps_z);
+ block->maximum_steps = max(block->steps_x, max(block->steps_y, block->steps_z));
+ // Bail if this is a zero-length block
+ if (block->maximum_steps == 0) { return; };
+ // Rate in steps/second for each axis
+ double rate_multiplier = 60.0*1000000.0/microseconds;
+ block->rate_x = round(block->steps_x*rate_multiplier);
+ block->rate_y = round(block->steps_y*rate_multiplier);
+ block->rate_z = round(block->steps_z*rate_multiplier);
+ block->rate = microseconds/block->maximum_steps;
+ // Compute direction bits for this block
+>>>>>>> Stashed changes
uint8_t direction_bits = 0;
if (steps_x < 0) { direction_bits |= (1<direction_bits = direction_bits;
line->average_millimeters_per_step_event = millimeters/line->maximum_steps
// Move buffer head
+<<<<<<< Updated upstream
line_buffer_head = next_buffer_head;
// enable stepper interrupt
TIMSK1 |= (1<>>>>>> Stashed changes
#ifdef TIMER1_COMPA_vect
SIGNAL(TIMER1_COMPA_vect)
#else
@@ -123,7 +191,7 @@ SIGNAL(SIG_OUTPUT_COMPARE1A)
STEPPING_PORT = (STEPPING_PORT & ~DIRECTION_MASK) | (out_bits & DIRECTION_MASK);
// Then pulse the stepping pins
STEPPING_PORT = (STEPPING_PORT & ~STEP_MASK) | out_bits;
- // Reset step pulse reset timer so that SIG_OVERFLOW2 can reset the signal after
+ // Reset step pulse reset timer so that The Stepper Port Reset Interrupt can reset the signal after
// exactly settings.pulse_microseconds microseconds.
TCNT2 = -(((settings.pulse_microseconds-2)*TICKS_PER_MICROSECOND)/8);
@@ -222,7 +290,7 @@ void st_init()
TCCR2B = (1<