Skip to content

Commit

Permalink
acceleration-Grbl now works with atmega 168 by disabling arc motion
Browse files Browse the repository at this point in the history
  • Loading branch information
simen committed Feb 20, 2011
1 parent 5eddbab commit 67d7607
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,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;
Expand Down Expand Up @@ -264,6 +266,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) {
/*
Expand Down Expand Up @@ -394,6 +397,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
}
}

Expand Down
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,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)
{
Expand Down
2 changes: 2 additions & 0 deletions motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 2 additions & 0 deletions motion_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
// NOTE: Although this function structurally belongs in this module, there is nothing to do but
// to forward the request to the planner. For efficiency the function is implemented with a macro.

#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
// axis in axis_l which will be the axis for linear travel if you are tracing a helical motion.
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);
Expand Down
6 changes: 5 additions & 1 deletion planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
#include "wiring_serial.h"

// The number of linear motions that can be in the plan at any give time
#define BLOCK_BUFFER_SIZE 20
#ifdef __AVR_ATmega328P__
#define BLOCK_BUFFER_SIZE 20
#else
#define BLOCK_BUFFER_SIZE 5
#endif

static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
static volatile int block_buffer_head; // Index of the next block to be pushed
Expand Down
6 changes: 5 additions & 1 deletion wiring_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#define RX_BUFFER_SIZE 200
#ifdef __AVR_ATmega328P__
#define RX_BUFFER_SIZE 256
#else
#define RX_BUFFER_SIZE 64
#endif

unsigned char rx_buffer[RX_BUFFER_SIZE];

Expand Down

0 comments on commit 67d7607

Please sign in to comment.