Skip to content
Snippets Groups Projects
Commit a642e4ca authored by Jake Read's avatar Jake Read
Browse files

checks for exceptional rates

parent 3bbda1f3
Branches
No related tags found
No related merge requests found
...@@ -49,8 +49,13 @@ void SmoothieRoll::checkMaxRates(void){ ...@@ -49,8 +49,13 @@ void SmoothieRoll::checkMaxRates(void){
// we also have per-axis steps per unit, and max rates, // we also have per-axis steps per unit, and max rates,
// if rate * spu exceeds the tick frequency, we are in trouble: // if rate * spu exceeds the tick frequency, we are in trouble:
for(uint8_t m = 0; m < SR_NUM_MOTORS; m ++){ for(uint8_t m = 0; m < SR_NUM_MOTORS; m ++){
if(actuators[m]->get_max_rate() * actuators[m]->get_steps_per_mm() > SR_TICK_FREQ){ float maxTick = actuators[m]->get_max_rate() * actuators[m]->get_steps_per_mm();
sysError("motor " + String(m) + " exceeds max rate"); if(maxTick > SR_TICK_FREQ){
sysError("motor " + String(m) + " exceeds max tick, " + String(maxTick));
// new rate should be old rate * rate /
float newMax = actuators[m]->get_max_rate() * (SR_TICK_FREQ / maxTick);
sysError("old max velocity: " + String(actuators[m]->get_max_rate()) + " new: " + String(newMax));
actuators[m]->set_max_rate(newMax);
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment