diff --git a/motion_control.c b/motion_control.c index 109f20b..2d01eb2 100644 --- a/motion_control.c +++ b/motion_control.c @@ -55,7 +55,7 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr int axis_linear, double feed_rate, int invert_feed_rate) { int32_t position[3]; - st_get_position_steps(&position); + plan_get_position_steps(&position); int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); plan_set_acceleration_manager_enabled(FALSE); // disable acceleration management for the duration of the arc double millimeters_of_travel = hypot(angular_travel*radius, labs(linear_travel)); diff --git a/planner.c b/planner.c index ed2c633..8878390 100644 --- a/planner.c +++ b/planner.c @@ -61,6 +61,9 @@ #include "config.h" #include "wiring_serial.h" +// The number of linear motions that can be in the plan at any give time +#define BLOCK_BUFFER_SIZE 20 + block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions volatile int block_buffer_head; // Index of the next block to be pushed volatile int block_buffer_tail; // Index of the block to process now @@ -407,3 +410,7 @@ void plan_buffer_line(double x, double y, double z, double feed_rate, int invert st_wake_up(); } +void plan_get_position_steps(int32_t (*vector)[3]) { + memcpy(vector, position, sizeof(position)); // vector[] = position[] +} + diff --git a/planner.h b/planner.h index f6281a1..007cba4 100644 --- a/planner.h +++ b/planner.h @@ -26,9 +26,6 @@ #include -// Pick a suitable block-buffer size -#define BLOCK_BUFFER_SIZE 20 // Atmega 328 has one full kilobyte of extra RAM! - // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { @@ -64,16 +61,20 @@ void plan_init(); // rate is taken to mean "frequency" and would complete the operation in 1/feed_rate minutes. void plan_buffer_line(double x, double y, double z, double feed_rate, int invert_feed_rate); -// Call when the current block is no longer needed. Discards the block and makes the memory +// Called when the current block is no longer needed. Discards the block and makes the memory // availible for new blocks. inline void plan_discard_current_block(); // Gets the current block. Returns NULL if buffer empty inline block_t *plan_get_current_block(); -// Enables acceleration-management for upcoming blocks +// Enables or disables acceleration-management for upcoming blocks void plan_set_acceleration_manager_enabled(int enabled); + // Is acceleration-management currently enabled? int plan_is_acceleration_manager_enabled(); + +// Copy the current absolute position in steps into the provided vector +void plan_get_position_steps(int32_t (*vector)[3]); #endif \ No newline at end of file diff --git a/stepper.c b/stepper.c index a75f4e1..131aa0a 100644 --- a/stepper.c +++ b/stepper.c @@ -112,10 +112,6 @@ inline void trapezoid_generator_tick() { } } -void st_get_position_steps(int32_t (*vector)[3]) { - memcpy(vector, position, sizeof(position)); // vector[] = position[] -} - // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse of Grbl. It is executed at the rate set with // config_step_timer. It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately. // It is supported by The Stepper Port Reset Interrupt which it uses to reset the stepper port after each pulse. diff --git a/stepper.h b/stepper.h index 3172e6c..66cc77d 100644 --- a/stepper.h +++ b/stepper.h @@ -27,9 +27,6 @@ // Initialize and start the stepper motor subsystem void st_init(); -// Copy the current absolute position in steps into the provided vector -void st_get_position_steps(int32_t (*vector)[3]); - // Block until all buffered steps are executed void st_synchronize();