PulseGen: store/return the last segment speed
parent
60c83b0af2
commit
d18143dff2
|
|
@ -216,6 +216,14 @@ public:
|
||||||
return axisData[axis].ctrl.SetJerk(max_jerk);
|
return axisData[axis].ctrl.SetJerk(max_jerk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch the target rate of the last planned segment for the requested axis, or the
|
||||||
|
/// current effective rate when the move has been aborted.
|
||||||
|
/// @param axis axis affected
|
||||||
|
/// @returns last rate
|
||||||
|
steps_t Rate(Axis axis) const {
|
||||||
|
return axisData[axis].ctrl.Rate();
|
||||||
|
}
|
||||||
|
|
||||||
/// State machine doing all the planning and stepping. Called by the stepping ISR.
|
/// State machine doing all the planning and stepping. Called by the stepping ISR.
|
||||||
/// @returns the interval for the next tick
|
/// @returns the interval for the next tick
|
||||||
st_timer_t Step();
|
st_timer_t Step();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ namespace pulse_gen {
|
||||||
PulseGen::PulseGen(steps_t max_jerk, steps_t acceleration) {
|
PulseGen::PulseGen(steps_t max_jerk, steps_t acceleration) {
|
||||||
// Axis status
|
// Axis status
|
||||||
position = 0;
|
position = 0;
|
||||||
|
last_rate = 0;
|
||||||
this->max_jerk = max_jerk;
|
this->max_jerk = max_jerk;
|
||||||
this->acceleration = acceleration;
|
this->acceleration = acceleration;
|
||||||
|
|
||||||
|
|
@ -107,9 +108,10 @@ bool PulseGen::PlanMoveTo(pos_t target, steps_t feed_rate) {
|
||||||
block->acceleration_rate = block->acceleration * (rate_t)((float)F_CPU / (F_CPU / config::stepTimerFrequencyDivider));
|
block->acceleration_rate = block->acceleration * (rate_t)((float)F_CPU / (F_CPU / config::stepTimerFrequencyDivider));
|
||||||
|
|
||||||
// Perform the trapezoid calculations
|
// Perform the trapezoid calculations
|
||||||
CalculateTrapezoid(block, max_jerk, max_jerk);
|
CalculateTrapezoid(block, entry_speed, end_rate);
|
||||||
|
last_rate = block->final_rate;
|
||||||
|
|
||||||
// Move forward
|
// Move forward and update the state
|
||||||
block_index.push();
|
block_index.push();
|
||||||
position = target;
|
position = target;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ public:
|
||||||
/// @param x position to set
|
/// @param x position to set
|
||||||
void SetPosition(pos_t x) { position = x; }
|
void SetPosition(pos_t x) { position = x; }
|
||||||
|
|
||||||
|
/// Fetch the target rate of the last planned segment, or the current effective rate
|
||||||
|
/// when the move has been aborted.
|
||||||
|
steps_t Rate() const { return last_rate; }
|
||||||
|
|
||||||
/// @returns true if all planned moves have been finished
|
/// @returns true if all planned moves have been finished
|
||||||
bool QueueEmpty() const { return block_index.empty(); }
|
bool QueueEmpty() const { return block_index.empty(); }
|
||||||
|
|
||||||
|
|
@ -173,6 +177,7 @@ private:
|
||||||
pos_t position; ///< Current axis position
|
pos_t position; ///< Current axis position
|
||||||
steps_t max_jerk; ///< Axis jerk (could be constant)
|
steps_t max_jerk; ///< Axis jerk (could be constant)
|
||||||
steps_t acceleration; ///< Current axis acceleration
|
steps_t acceleration; ///< Current axis acceleration
|
||||||
|
steps_t last_rate; ///< Target speed at the last junction
|
||||||
|
|
||||||
// Step parameters
|
// Step parameters
|
||||||
rate_t acceleration_time, deceleration_time;
|
rate_t acceleration_time, deceleration_time;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue