stepper.c now has 90% of acelleration support built in except for the planner, still som known conflicts to mark rough spots that need attention later

This commit is contained in:
Simen Svale Skogsrud
2011-01-03 00:36:33 +01:00
parent 48b596c2fe
commit e0f3dcbe43
3 changed files with 176 additions and 155 deletions

View File

@@ -21,18 +21,18 @@
// Estimate the maximum speed at a given distance when you need to reach the given
// target_velocity with max_accelleration.
double estimate_max_speed(double max_accelleration, double target_velocity, double distance) {
float estimate_max_speed(float max_accelleration, float target_velocity, float distance) {
return(sqrt(-2*max_accelleration*distance+target_velocity*target_velocity))
}
// At what distance must we start accellerating/braking to reach target_speed from current_speed given the
// specified constant accelleration.
double estimate_brake_distance(double current_speed, double target_speed, double acceleration) {
float estimate_brake_distance(float current_speed, float target_speed, float acceleration) {
return((target_speed*target_speed-current_speed*current_speed)/(2*acceleration));
}
// Calculate feed rate in length-units/second for a single axis
double axis_feed_rate(double steps_per_stepping, uint32_t stepping_rate, double steps_per_unit) {
float axis_feed_rate(float steps_per_stepping, uint32_t stepping_rate, float steps_per_unit) {
if (stepping_rate == 0) { return(0.0); }
return((TICKS_PER_MICROSECOND*1000000)*steps_per_stepping/(stepping_rate*steps_per_unit));
}
@@ -40,23 +40,22 @@ double axis_feed_rate(double steps_per_stepping, uint32_t stepping_rate, double
// The 'swerve' of a joint is equal to the maximum accelleration of any single
// single axis in the corner between the outgoing and the incoming line. Accelleration control
// will regulate speed to avoid excessive swerve.
double calculate_swerve(struct Line* outgoing, struct Line* incoming) {
double x_swerve = abs(
float calculate_swerve(struct Line* outgoing, struct Line* incoming) {
float x_swerve = abs(
axis_feed_rate(
((double)incoming->steps_x)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[X_AXIS])
((float)incoming->steps_x)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[X_AXIS])
- axis_feed_rate(
((double)incoming->steps_x)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[X_AXIS]));
double y_swerve = abs(
((float)incoming->steps_x)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[X_AXIS]));
float y_swerve = abs(
axis_feed_rate(
((double)incoming->steps_y)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[Y_AXIS])
((float)incoming->steps_y)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[Y_AXIS])
- axis_feed_rate(
((double)incoming->steps_y)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[Y_AXIS]));
double z_swerve = abs(
((float)incoming->steps_y)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[Y_AXIS]));
float z_swerve = abs(
axis_feed_rate(
((double)incoming->steps_z)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[Z_AXIS])
((float)incoming->steps_z)/incoming->maximum_steps, incoming->rate, settings.steps_per_mm[Z_AXIS])
- axis_feed_rate(
((double)incoming->steps_z)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[Z_AXIS]));
((float)incoming->steps_z)/incoming->maximum_steps, outgoing-> rate, settings.steps_per_mm[Z_AXIS]));
return max(x_swerve, max(y_swerve, z_swerve));
}