From 2c913a00bd322d17a4280cbb3eac0faa711fc86b Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Sun, 20 Feb 2011 22:00:12 +0100 Subject: [PATCH] acceleration-Grbl now works with atmega 168 by disabling arc motion --- gcode.c | 4 ++++ main.c | 6 +++--- motion_control.c | 2 ++ motion_control.h | 2 ++ planner.c | 4 ++++ wiring_serial.c | 4 ++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gcode.c b/gcode.c index 48dc64a..cd4e504 100644 --- a/gcode.c +++ b/gcode.c @@ -148,8 +148,10 @@ uint8_t gc_execute_line(char *line) { switch(int_value) { case 0: gc.motion_mode = MOTION_MODE_SEEK; break; case 1: gc.motion_mode = MOTION_MODE_LINEAR; break; +#ifdef __AVR_ATmega328P__ case 2: gc.motion_mode = MOTION_MODE_CW_ARC; break; case 3: gc.motion_mode = MOTION_MODE_CCW_ARC; break; +#endif case 4: next_action = NEXT_ACTION_DWELL; break; case 17: select_plane(X_AXIS, Y_AXIS, Z_AXIS); break; case 18: select_plane(X_AXIS, Z_AXIS, Y_AXIS); break; @@ -243,6 +245,7 @@ uint8_t gc_execute_line(char *line) { mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode); break; +#ifdef __AVR_ATmega328P__ case MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC: if (radius_mode) { /* @@ -373,6 +376,7 @@ uint8_t gc_execute_line(char *line) { mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode); break; +#endif } } diff --git a/main.c b/main.c index a6847d3..60349cf 100644 --- a/main.c +++ b/main.c @@ -32,9 +32,9 @@ #include "settings.h" #include "wiring_serial.h" -#ifndef __AVR_ATmega328P__ -# error "As of version 0.6 Grbl only supports atmega328p. If you want to run Grbl on an 168 check out 0.51 ('git co v0_51')" -#endif +// #ifndef __AVR_ATmega328P__ +// # error "As of version 0.6 Grbl only supports atmega328p. If you want to run Grbl on an 168 check out 0.51 ('git co v0_51')" +// #endif int main(void) { diff --git a/motion_control.c b/motion_control.c index f799cca..ebef597 100644 --- a/motion_control.c +++ b/motion_control.c @@ -42,6 +42,7 @@ void mc_dwell(uint32_t milliseconds) // axis in axis_l which will be the axis for linear travel if you are tracing a helical motion. // position is a pointer to a vector representing the current position in millimeters. +#ifdef __AVR_ATmega328P__ // The arc is approximated by generating a huge number of tiny, linear segments. The length of each // segment is configured in settings.mm_per_arc_segment. void mc_arc(double theta, double angular_travel, double radius, double linear_travel, int axis_1, int axis_2, @@ -77,6 +78,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr } plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled); } +#endif void mc_go_home() { diff --git a/motion_control.h b/motion_control.h index c205e2f..89020ad 100644 --- a/motion_control.h +++ b/motion_control.h @@ -32,6 +32,7 @@ #define mc_line(x, y, z, feed_rate, invert_feed_rate) plan_buffer_line(x, y, z, feed_rate, invert_feed_rate) +#ifdef __AVR_ATmega328P__ // Execute an arc. theta == start angle, angular_travel == number of radians to go along the arc, // positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the // circle in millimeters. axis_1 and axis_2 selects the circle plane in tool space. Stick the remaining @@ -39,6 +40,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_travel, int axis_1, int axis_2, int axis_linear, double feed_rate, int invert_feed_rate, double *position); +#endif // Dwell for a couple of time units void mc_dwell(uint32_t milliseconds); diff --git a/planner.c b/planner.c index bcc2a91..af75a06 100644 --- a/planner.c +++ b/planner.c @@ -32,7 +32,11 @@ #include "wiring_serial.h" // The number of linear motions that can be in the plan at any give time +#ifdef __AVR_ATmega328P__ #define BLOCK_BUFFER_SIZE 16 +#else +#define BLOCK_BUFFER_SIZE 5 +#endif static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions static volatile uint8_t block_buffer_head; // Index of the next block to be pushed diff --git a/wiring_serial.c b/wiring_serial.c index 5109d39..3dd67b7 100644 --- a/wiring_serial.c +++ b/wiring_serial.c @@ -31,7 +31,11 @@ // using a ring buffer (I think), in which rx_buffer_head is the index of the // location to which to write the next incoming character and rx_buffer_tail // is the index of the location from which to read. +#ifdef __AVR_ATmega328P__ #define RX_BUFFER_SIZE 256 +#else +#define RX_BUFFER_SIZE 64 +#endif unsigned char rx_buffer[RX_BUFFER_SIZE];