acceleration-Grbl now works with atmega 168 by disabling arc motion

This commit is contained in:
Simen Svale Skogsrud 2011-02-20 22:00:12 +01:00
parent d5d6298de3
commit 2c913a00bd
6 changed files with 19 additions and 3 deletions

View File

@ -148,8 +148,10 @@ uint8_t gc_execute_line(char *line) {
switch(int_value) { switch(int_value) {
case 0: gc.motion_mode = MOTION_MODE_SEEK; break; case 0: gc.motion_mode = MOTION_MODE_SEEK; break;
case 1: gc.motion_mode = MOTION_MODE_LINEAR; break; case 1: gc.motion_mode = MOTION_MODE_LINEAR; break;
#ifdef __AVR_ATmega328P__
case 2: gc.motion_mode = MOTION_MODE_CW_ARC; break; case 2: gc.motion_mode = MOTION_MODE_CW_ARC; break;
case 3: gc.motion_mode = MOTION_MODE_CCW_ARC; break; case 3: gc.motion_mode = MOTION_MODE_CCW_ARC; break;
#endif
case 4: next_action = NEXT_ACTION_DWELL; break; case 4: next_action = NEXT_ACTION_DWELL; break;
case 17: select_plane(X_AXIS, Y_AXIS, Z_AXIS); break; case 17: select_plane(X_AXIS, Y_AXIS, Z_AXIS); break;
case 18: select_plane(X_AXIS, Z_AXIS, Y_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], 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); (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode);
break; break;
#ifdef __AVR_ATmega328P__
case MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC: case MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC:
if (radius_mode) { 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], 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); (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode);
break; break;
#endif
} }
} }

6
main.c
View File

@ -32,9 +32,9 @@
#include "settings.h" #include "settings.h"
#include "wiring_serial.h" #include "wiring_serial.h"
#ifndef __AVR_ATmega328P__ // #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')" // # 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 // #endif
int main(void) int main(void)
{ {

View File

@ -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. // 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. // 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 // 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. // 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, 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); plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled);
} }
#endif
void mc_go_home() void mc_go_home()
{ {

View File

@ -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) #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, // 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 // 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 // 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, 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); int axis_linear, double feed_rate, int invert_feed_rate, double *position);
#endif
// Dwell for a couple of time units // Dwell for a couple of time units
void mc_dwell(uint32_t milliseconds); void mc_dwell(uint32_t milliseconds);

View File

@ -32,7 +32,11 @@
#include "wiring_serial.h" #include "wiring_serial.h"
// The number of linear motions that can be in the plan at any give time // The number of linear motions that can be in the plan at any give time
#ifdef __AVR_ATmega328P__
#define BLOCK_BUFFER_SIZE 16 #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 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 static volatile uint8_t block_buffer_head; // Index of the next block to be pushed

View File

@ -31,7 +31,11 @@
// using a ring buffer (I think), in which rx_buffer_head is the index of the // 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 // location to which to write the next incoming character and rx_buffer_tail
// is the index of the location from which to read. // is the index of the location from which to read.
#ifdef __AVR_ATmega328P__
#define RX_BUFFER_SIZE 256 #define RX_BUFFER_SIZE 256
#else
#define RX_BUFFER_SIZE 64
#endif
unsigned char rx_buffer[RX_BUFFER_SIZE]; unsigned char rx_buffer[RX_BUFFER_SIZE];