Permalink
Browse files

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
  • Loading branch information...
1 parent 48b596c commit e0f3dcbe43beb10cd9f53512824c4f0cdecf9d56 @simen simen committed Jan 2, 2011
Showing with 176 additions and 155 deletions.
  1. +13 −14 acceleration.c
  2. +7 −6 motion_control.c
  3. +156 −135 stepper.c
View
@@ -21,42 +21,41 @@
// 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));
}
// 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));
}
View
@@ -59,14 +59,15 @@ void mc_line(double x, double y, double z, float feed_rate, int invert_feed_rate
steps[axis] = target[axis]-position[axis];
}
+ // Ask old Phytagoras to estimate how many mm our next move is going to take us
+ double millimeters_of_travel = sqrt(
+ square(steps[X_AXIS]/settings.steps_per_mm[0]) +
+ square(steps[Y_AXIS]/settings.steps_per_mm[1]) +
+ square(steps[Z_AXIS]/settings.steps_per_mm[2]));
if (invert_feed_rate) {
- st_buffer_line(steps[X_AXIS], steps[Y_AXIS], steps[Z_AXIS], lround(ONE_MINUTE_OF_MICROSECONDS/feed_rate));
+ st_buffer_line(steps[X_AXIS], steps[Y_AXIS], steps[Z_AXIS], lround(ONE_MINUTE_OF_MICROSECONDS/feed_rate),
+ millimeters_of_travel);
} else {
- // Ask old Phytagoras to estimate how many mm our next move is going to take us
- double millimeters_of_travel = sqrt(
- square(steps[X_AXIS]/settings.steps_per_mm[0]) +
- square(steps[Y_AXIS]/settings.steps_per_mm[1]) +
- square(steps[Z_AXIS]/settings.steps_per_mm[2]));
st_buffer_line(steps[X_AXIS], steps[Y_AXIS], steps[Z_AXIS],
lround((millimeters_of_travel/feed_rate)*1000000), millimeters_of_travel);
}
Oops, something went wrong. Retry.

0 comments on commit e0f3dcb

Please sign in to comment.