formatting + moved current position getter to planner

This commit is contained in:
Simen Svale Skogsrud 2011-02-11 00:44:18 +01:00
parent 07f8623098
commit 6dc81b41c9
5 changed files with 14 additions and 13 deletions

View File

@ -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) int axis_linear, double feed_rate, int invert_feed_rate)
{ {
int32_t position[3]; int32_t position[3];
st_get_position_steps(&position); plan_get_position_steps(&position);
int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); 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 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)); double millimeters_of_travel = hypot(angular_travel*radius, labs(linear_travel));

View File

@ -61,6 +61,9 @@
#include "config.h" #include "config.h"
#include "wiring_serial.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 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_head; // Index of the next block to be pushed
volatile int block_buffer_tail; // Index of the block to process now 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(); st_wake_up();
} }
void plan_get_position_steps(int32_t (*vector)[3]) {
memcpy(vector, position, sizeof(position)); // vector[] = position[]
}

View File

@ -26,9 +26,6 @@
#include <inttypes.h> #include <inttypes.h>
// 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 // 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. // the source g-code and may never actually be reached if acceleration management is active.
typedef struct { 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. // 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); 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. // availible for new blocks.
inline void plan_discard_current_block(); inline void plan_discard_current_block();
// Gets the current block. Returns NULL if buffer empty // Gets the current block. Returns NULL if buffer empty
inline block_t *plan_get_current_block(); 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); void plan_set_acceleration_manager_enabled(int enabled);
// Is acceleration-management currently enabled? // Is acceleration-management currently enabled?
int plan_is_acceleration_manager_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 #endif

View File

@ -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 // "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. // 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. // It is supported by The Stepper Port Reset Interrupt which it uses to reset the stepper port after each pulse.

View File

@ -27,9 +27,6 @@
// Initialize and start the stepper motor subsystem // Initialize and start the stepper motor subsystem
void st_init(); 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 // Block until all buffered steps are executed
void st_synchronize(); void st_synchronize();