this->tick_info[m].plateau_rate= STEPTICKER_TOFP((this->maximum_rate * aratio) / STEP_TICKER_FREQUENCY);
}
}
+
+// returns current rate (steps/sec) for the given actuator
+float Block::get_trapezoid_rate(int i) const
+{
+ // convert steps per tick from fixed point to float and convert to steps/sec
+ // FIXME steps_per_tick can change at any time, potential race condition if it changes while being read here
+ return STEPTICKER_FROMFP(tick_info[i].steps_per_tick) * STEP_TICKER_FREQUENCY;
+}
void clear();
void prepare();
+ float get_trapezoid_rate(int i) const;
+
std::array<uint32_t, k_max_actuators> steps; // Number of steps for each axis for this block
uint32_t steps_event_count; // Steps for the longest axis
float nominal_rate; // Nominal rate in steps per second
}
}
- // figure out the ratio of its speed, from 0 to 1 based on where it is on the trapezoid
- // FIXME steps_per_tick can change at any time, potential race condition if it changes while being read here
- float ratio= (float)block->tick_info[pm].steps_per_tick / block->tick_info[pm].plateau_rate;
+ // figure out the ratio of its speed, from 0 to 1 based on where it is on the trapezoid,
+ // this is based on the fraction it is of the requested rate (nominal rate)
+ float ratio= block->get_trapezoid_rate(pm) / block->nominal_rate;
return ratio;
}