Optimize timer multiplexing and increase stepTimerQuantum
Avoid calling PulseGen::Step() on idle axes by checking for a non-zero queue size (which is more efficient to compute). Increase stepTimerQuantum to 128us to ensure acceleration can be computed in realtime for 3 axes at the same time. Fix the logic of the static assertion, which was flipped: we need to create slices larger than the maximal step frequency in order to ensure no axis is starved while moving.pull/108/head
parent
d23ed53f3c
commit
9c3b31756e
|
|
@ -68,9 +68,10 @@ static constexpr uint8_t blockBufferSize = 2;
|
||||||
/// Step timer frequency divider (F = F_CPU / divider)
|
/// Step timer frequency divider (F = F_CPU / divider)
|
||||||
static constexpr uint8_t stepTimerFrequencyDivider = 8;
|
static constexpr uint8_t stepTimerFrequencyDivider = 8;
|
||||||
|
|
||||||
/// Smallest stepping ISR scheduling slice (T = F_CPU / divider * quantum)
|
/// Smallest stepping ISR scheduling slice (T = 1 / (F_CPU / divider) * quantum)
|
||||||
/// 16 = 8us (25us is the max frequency interval per maxStepFrequency)
|
/// 25us is the max frequency interval per maxStepFrequency attainable for a single axis
|
||||||
static constexpr uint8_t stepTimerQuantum = 16;
|
/// while accelerating: with 3 axes this yields a required minimum of 75us
|
||||||
|
static constexpr uint16_t stepTimerQuantum = 256; // 256 = 128us
|
||||||
|
|
||||||
/// Pulley axis configuration
|
/// Pulley axis configuration
|
||||||
static constexpr AxisConfig pulley = {
|
static constexpr AxisConfig pulley = {
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,14 @@ st_timer_t Motion::Step() {
|
||||||
for (uint8_t i = 0; i != NUM_AXIS; ++i) {
|
for (uint8_t i = 0; i != NUM_AXIS; ++i) {
|
||||||
timers[i] = axisData[i].residual;
|
timers[i] = axisData[i].residual;
|
||||||
if (timers[i] <= config::stepTimerQuantum) {
|
if (timers[i] <= config::stepTimerQuantum) {
|
||||||
timers[i] += axisData[i].ctrl.Step(axisParams[i].params);
|
if (timers[i] || !axisData[i].ctrl.QueueEmpty()) {
|
||||||
|
if (st_timer_t next = axisData[i].ctrl.Step(axisParams[i].params)) {
|
||||||
|
timers[i] += next;
|
||||||
|
|
||||||
// axis has been moved, run the tmc2130 Isr for this axis
|
// axis has been moved, run the tmc2130 Isr for this axis
|
||||||
axisData[i].drv.Isr(axisParams[i].params);
|
axisData[i].drv.Isr(axisParams[i].params);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ using pulse_gen::st_timer_t;
|
||||||
// Check for configuration invariants
|
// Check for configuration invariants
|
||||||
static_assert(
|
static_assert(
|
||||||
(1. / (F_CPU / config::stepTimerFrequencyDivider) * config::stepTimerQuantum)
|
(1. / (F_CPU / config::stepTimerFrequencyDivider) * config::stepTimerQuantum)
|
||||||
< (1. / config::maxStepFrequency / 2),
|
> (1. / config::maxStepFrequency),
|
||||||
"stepTimerQuantum must be smaller than the maximal stepping frequency interval");
|
"stepTimerQuantum must be larger than the maximal stepping frequency interval");
|
||||||
|
|
||||||
/// Main axis enumeration
|
/// Main axis enumeration
|
||||||
struct AxisParams {
|
struct AxisParams {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue