Skip to content
Browse files

Minor changes.

- Changed some names up and removed a plan_reset() function that is
never used.
  • Loading branch information...
1 parent 5e7c25d commit 53286744d539adaebd8e77bc42ef106e44047b5a @chamnit chamnit committed Jan 6, 2013
Showing with 10 additions and 18 deletions.
  1. +1 −1 config.h
  2. +3 −8 planner.c
  3. +0 −3 planner.h
  4. +6 −6 stepper.c
View
2 config.h
@@ -125,7 +125,7 @@
#define ACCELERATION_TICKS_PER_SECOND 120L
// NOTE: Make sure this value is less than 256, when adjusting both dependent parameters.
-#define INTERRUPTS_PER_ACCELERATION_TICK (ISR_TICKS_PER_SECOND/ACCELERATION_TICKS_PER_SECOND)
+#define ISR_TICKS_PER_ACCELERATION_TICK (ISR_TICKS_PER_SECOND/ACCELERATION_TICKS_PER_SECOND)
// The Ranade algorithm can use either floating point or long integers for its counters, but for
// integers the counter values must be scaled since these values can be very small (10^-6). This
View
11 planner.c
@@ -32,7 +32,7 @@
#include "protocol.h"
#define SOME_LARGE_VALUE 1.0E+38 // Used by rapids and acceleration maximization calculations. Just needs
- // to be larger than any feasible mm/min or mm/sec^2 value.
+ // to be larger than any feasible (mm/min)^2 or mm/sec^2 value.
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
@@ -52,12 +52,6 @@ typedef struct {
static planner_t pl;
-void plan_init()
-{
- plan_reset_buffer();
- memset(&pl, 0, sizeof(pl)); // Clear planner struct
-}
-
// Returns the index of the next block in the ring buffer
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
static uint8_t next_block_index(uint8_t block_index)
@@ -342,11 +336,12 @@ static void planner_recalculate()
// }
}
-void plan_reset_buffer()
+void plan_init()
{
block_buffer_tail = block_buffer_head;
next_buffer_head = next_block_index(block_buffer_head);
// block_buffer_planned = block_buffer_head;
+ memset(&pl, 0, sizeof(pl)); // Clear planner struct
}
inline void plan_discard_current_block()
View
3 planner.h
@@ -73,9 +73,6 @@ void plan_set_current_position(int32_t x, int32_t y, int32_t z);
// Reinitialize plan with a partially completed block
void plan_cycle_reinitialize(int32_t step_events_remaining);
-// Reset buffer
-void plan_reset_buffer();
-
// Returns the status of the block ring buffer. True, if buffer is full.
uint8_t plan_check_full_buffer();
View
12 stepper.c
@@ -182,7 +182,7 @@ ISR(TIMER2_COMPA_vect)
// Initialize Ranade variables
st.d_counter = current_block->d_next;
st.delta_d = current_block->initial_rate;
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK/2;
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK/2;
// Initialize ramp type.
if (st.step_events_remaining == current_block->decelerate_after) { st.ramp_type = DECEL_RAMP; }
@@ -203,7 +203,7 @@ ISR(TIMER2_COMPA_vect)
// Tick acceleration ramp counter
st.ramp_count--;
if (st.ramp_count == 0) {
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK; // Reload ramp counter
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK; // Reload ramp counter
if (st.ramp_type == ACCEL_RAMP) { // Adjust velocity for acceleration
st.delta_d += current_block->rate_delta;
if (st.delta_d >= current_block->nominal_rate) { // Reached cruise state.
@@ -232,7 +232,7 @@ ISR(TIMER2_COMPA_vect)
if (sys.state == STATE_HOLD) {
if (st.ramp_type != DECEL_RAMP) {
st.ramp_type = DECEL_RAMP;
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK/2;
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK/2;
}
if (st.delta_d <= current_block->rate_delta) {
st_go_idle();
@@ -279,9 +279,9 @@ ISR(TIMER2_COMPA_vect)
st.ramp_type = DECEL_RAMP;
if (st.step_events_remaining == current_block->decelerate_after) {
if (st.delta_d == current_block->nominal_rate) {
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK/2; // Set ramp counter for trapezoid
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK/2; // Set ramp counter for trapezoid
} else {
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK-st.ramp_count; // Set ramp counter for triangle
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK-st.ramp_count; // Set ramp counter for triangle
}
}
}
@@ -373,7 +373,7 @@ void st_cycle_reinitialize()
// Replan buffer from the feed hold stop location.
plan_cycle_reinitialize(st.step_events_remaining);
st.ramp_type = ACCEL_RAMP;
- st.ramp_count = INTERRUPTS_PER_ACCELERATION_TICK/2;
+ st.ramp_count = ISR_TICKS_PER_ACCELERATION_TICK/2;
st.delta_d = 0;
sys.state = STATE_QUEUED;
} else {

0 comments on commit 5328674

Please sign in to comment.
Something went wrong with that request. Please try again.