Patch to stop DDA timer before Dwell timer to address Issue #193

This commit is contained in:
Alden Hart
2016-12-03 08:50:40 -05:00
parent e5056174fd
commit 7624933194
6 changed files with 21 additions and 25 deletions
Executable → Regular
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
Executable → Regular
+2 -2
View File
@@ -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
+7 -7
View File
@@ -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
-5
View File
@@ -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();
}
};
+8 -7
View File
@@ -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<MOTORS; motor++) {
@@ -282,7 +282,7 @@ void dda_timer_type::interrupt()
return;
}
// The following code would work, but it's faster to loop unroll it
// The following code would work, but it's faster on the M3 to loop unroll it. Perhaps not on the M7
// for (uint8_t motor=0; motor<MOTORS; motor++) {
// if ((st_run.mot[motor].substep_accumulator += st_run.mot[motor].substep_increment) > 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
}