From 76249331946d9f4e5109455a940daf6fe44b01c4 Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Sat, 3 Dec 2016 08:50:40 -0500 Subject: [PATCH] Patch to stop DDA timer before Dwell timer to address Issue #193 --- g2core/board/Archim/hardware.h | 4 ++-- g2core/board/ArduinoDue/hardware.h | 4 ++-- g2core/board/G2v9/hardware.h | 4 ++-- g2core/board/gquadratic/hardware.h | 14 +++++++------- g2core/planner.h | 5 ----- g2core/stepper.cpp | 15 ++++++++------- 6 files changed, 21 insertions(+), 25 deletions(-) mode change 100755 => 100644 g2core/board/Archim/hardware.h mode change 100755 => 100644 g2core/board/ArduinoDue/hardware.h mode change 100755 => 100644 g2core/board/G2v9/hardware.h mode change 100755 => 100644 g2core/board/gquadratic/hardware.h diff --git a/g2core/board/Archim/hardware.h b/g2core/board/Archim/hardware.h old mode 100755 new mode 100644 index d66cae7d..64caf475 --- a/g2core/board/Archim/hardware.h +++ b/g2core/board/Archim/hardware.h @@ -127,8 +127,8 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp -typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp +typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp // Pin assignments diff --git a/g2core/board/ArduinoDue/hardware.h b/g2core/board/ArduinoDue/hardware.h old mode 100755 new mode 100644 index 1b5bbe6b..ec8d48d5 --- a/g2core/board/ArduinoDue/hardware.h +++ b/g2core/board/ArduinoDue/hardware.h @@ -129,8 +129,8 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp -typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp +typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp // Pin assignments diff --git a/g2core/board/G2v9/hardware.h b/g2core/board/G2v9/hardware.h old mode 100755 new mode 100644 index 835dfc44..a00fb5d6 --- a/g2core/board/G2v9/hardware.h +++ b/g2core/board/G2v9/hardware.h @@ -129,8 +129,8 @@ using Motate::OutputPin; // Timer definitions. See stepper.h and other headers for setup typedef TimerChannel<3,0> dda_timer_type; // stepper pulse generation in stepper.cpp typedef TimerChannel<4,0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp -typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp +typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp // Pin assignments diff --git a/g2core/board/gquadratic/hardware.h b/g2core/board/gquadratic/hardware.h old mode 100755 new mode 100644 index 069cb2ba..5bf1a1fa --- a/g2core/board/gquadratic/hardware.h +++ b/g2core/board/gquadratic/hardware.h @@ -110,8 +110,8 @@ using Motate::OutputPin; * * The following interrupts are defined w/indicated priorities * - * 0 DDA_TIMER (3) for step pulse generation - * 1 DWELL_TIMER (4) for dwell timing + * 0 DDA_TIMER (9) for step pulse generation + * 1 DWELL_TIMER (10) for dwell timing * 2 LOADER software generated interrupt (STIR / SGI) * 3 Serial read character interrupt * 4 EXEC software generated interrupt (STIR / SGI) @@ -128,11 +128,11 @@ using Motate::OutputPin; /**** Motate Definitions ****/ // Timer definitions. See stepper.h and other headers for setup -typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp -typedef TimerChannel<10, 0> dwell_timer_type; // dwell timing in stepper.cpp -typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp -typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp -typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp +typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp +typedef TimerChannel<10, 0> dwell_timer_type; // dwell timing in stepper.cpp +typedef ServiceCall<0> load_timer_type; // request load timer in stepper.cpp +typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp +typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp // Pin assignments diff --git a/g2core/planner.h b/g2core/planner.h index 1d9357a7..83cc3757 100644 --- a/g2core/planner.h +++ b/g2core/planner.h @@ -381,23 +381,18 @@ struct mpBuffer_to_clear { length = 0.0; block_time = 0.0; override_factor = 0.0; - cruise_velocity = 0.0; exit_velocity = 0.0; - cruise_vset = 0.0; cruise_vmax = 0.0; exit_vmax = 0.0; - absolute_vmax = 0.0; junction_vmax = 0.0; - jerk = 0.0; jerk_sq = 0.0; recip_jerk = 0.0; sqrt_j = 0.0; q_recip_2_sqrt_j = 0.0; - gm.reset(); } }; diff --git a/g2core/stepper.cpp b/g2core/stepper.cpp index 9d5ef6d8..15035508 100644 --- a/g2core/stepper.cpp +++ b/g2core/stepper.cpp @@ -254,7 +254,7 @@ namespace Motate { // Must define timer interrupts inside the Motate template<> void dda_timer_type::interrupt() { - dda_timer.getInterruptCause(); // clear interrupt condition + dda_timer.getInterruptCause(); // clear interrupt condition // clear all steps from the previous interrupt // for (uint8_t motor=0; motor 0) { // Motors[motor]->stepStart(); // turn step bit on @@ -331,9 +331,10 @@ void dda_timer_type::interrupt() } #endif - // process end of segment + // Process end of segment. + // One more interrupt will occur to turn of any pulses set in this pass. if (--st_run.dda_ticks_downcount == 0) { - _load_move(); // load the next move at the current interrupt level + _load_move(); // load the next move at the current interrupt level } } // MOTATE_TIMER_INTERRUPT } // namespace Motate @@ -629,11 +630,12 @@ static void _load_move() //**** do this last **** - dda_timer.start(); // start the DDA timer if not already running + dda_timer.start(); // start the DDA timer if not already running // handle dwells } else if (st_pre.block_type == BLOCK_TYPE_DWELL) { st_run.dda_ticks_downcount = st_pre.dda_ticks; + dda_timer.stop(); // ++++ This is a stopgap. The DDA timer should have been stopped before here dwell_timer.start(); // handle synchronous commands @@ -648,7 +650,7 @@ static void _load_move() // all other cases drop to here (e.g. Null moves after Mcodes skip to here) st_pre.block_type = BLOCK_TYPE_NULL; st_pre.buffer_state = PREP_BUFFER_OWNED_BY_EXEC; // we are done with the prep buffer - flip the flag back - st_request_exec_move(); // exec and prep next move + st_request_exec_move(); // exec and prep next move } /*********************************************************************************** @@ -788,7 +790,6 @@ void st_prep_command(void *bf) void st_prep_dwell(float microseconds) { st_pre.block_type = BLOCK_TYPE_DWELL; - //st_pre.dda_period = _f_to_period(FREQUENCY_DWELL); st_pre.dda_ticks = (uint32_t)((microseconds/1000000) * FREQUENCY_DWELL); st_pre.buffer_state = PREP_BUFFER_OWNED_BY_LOADER; // signal that prep buffer is ready }