Posted by MPower

Marlin - DEFAULT_XYJERK March 07, 2013 04:02PM |
Registered: 4 years ago Posts: 195 |

Re: Marlin - DEFAULT_XYJERK March 11, 2013 07:46PM |
Registered: 4 years ago Posts: 455 |

Re: Marlin - DEFAULT_XYJERK March 11, 2013 08:02PM |
Registered: 4 years ago Posts: 195 |

Re: Marlin - DEFAULT_XYJERK March 13, 2013 01:10PM |
Registered: 4 years ago Posts: 455 |

Re: Marlin - DEFAULT_XYJERK March 13, 2013 01:52PM |
Registered: 4 years ago Posts: 142 |

"Jerk" is actually a technical term, believe it or not. It means the rate of change of acceleration. If you remember your calculus/physics, derivative of position = speed, derivative of speed = acceleration, so derivative of acceleration = jerk. Think of it this way: if you were in a car at rest and hit the gas and held it there that's kinda-sorta like a constant acceleration move (because of how internal combustion engines and transmissions work, it's not actually true, but it is, as they say, a useful lie). By having a max jerk, you are applying your foot at a steady rate (the max jerk) until it's pushed in as far as you want (the max acceleration). It can get a bit more complex when you start looking at direction changes, but I haven't actually looked at marlin's path planning to see how they implement this. In a machine dynamics class, we once talked about how you can basically play this game forever; if you control the derivative of the jerk, you'll get even smoother motion. If you control the derivative of the derivative of the jerk, you'll get even more smoother motion. If you have a very specialized machine with few motions, you can get really fancy and choose special motion functions that are C-infinite smooth (no matter how many derivatives of the path you take, there are no discontinuities), but those pretty much only exist in textbooks, and controlling any higher than the jerk rarely results in a perceptible gain.

Hope that helps!

Hope that helps!

Re: Marlin - DEFAULT_XYJERK March 13, 2013 04:57PM |
Registered: 5 years ago Posts: 934 |

In marlin and for that matter repetier Jerk isn't the methematical definition differential of accelleration.

Rather it's the instantaneous change of velocity, or rather the initial and final speed of a vector used in path planning.

For exampleif you print a square it has to reach the jerk speed at the corners, it's more complicated for none 90degree transitions.

Rather it's the instantaneous change of velocity, or rather the initial and final speed of a vector used in path planning.

For exampleif you print a square it has to reach the jerk speed at the corners, it's more complicated for none 90degree transitions.

Re: Marlin - DEFAULT_XYJERK March 13, 2013 09:43PM |
Registered: 4 years ago Posts: 195 |

So much mystery around this jerk

..that it aroused my curiosity and I had to dig into the source. So here it goes:

We set it in Configuration.h via:

which turns into max_xy_jerk in ConfigurationStore.cpp via:

and is then further used by the planner in planner.h as:

and finally in planner.cpp as:

In order to fully understand the code above, you probably need to look further and understand all the other variables involved in it, but it can be reduced to this line:

current_speed[X_AXIS]-previous_speed[X_AXIS] as one side

and

current_speed[Y_AXIS]-previous_speed[Y_AXIS] as the other side. Long story short, we have the gain in speed for the X axis on one side, the gain in speed for the Y axis on the other triangle side and the jerk as the hypotenuse of this right angle triangle. Sort of the combined gain in speed for both X and Y axis. If this jerk value exceeds the value you set in Configuration.h this happens:

..that it aroused my curiosity and I had to dig into the source. So here it goes:

We set it in Configuration.h via:

#define DEFAULT_XYJERK 20.0 // (mm/sec)

which turns into max_xy_jerk in ConfigurationStore.cpp via:

max_xy_jerk=DEFAULT_XYJERK;

and is then further used by the planner in planner.h as:

extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.(that is the actual comment you can find in the git grabbed source)

and finally in planner.cpp as:

// Start with a safe speed float vmax_junction = max_xy_jerk/2; float vmax_junction_factor = 1.0; if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) { float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2)); // if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) { vmax_junction = block->nominal_speed; // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction;

In order to fully understand the code above, you probably need to look further and understand all the other variables involved in it, but it can be reduced to this line:

float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));Pretty obvious, jerk is treated as the hypotenuse of a right angle triangle formed by:

current_speed[X_AXIS]-previous_speed[X_AXIS] as one side

and

current_speed[Y_AXIS]-previous_speed[Y_AXIS] as the other side. Long story short, we have the gain in speed for the X axis on one side, the gain in speed for the Y axis on the other triangle side and the jerk as the hypotenuse of this right angle triangle. Sort of the combined gain in speed for both X and Y axis. If this jerk value exceeds the value you set in Configuration.h this happens:

if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); }the speed factor is set to your DEFAULT_XYJERK divided to the obtained jerk from the triangle above. Other, if jerk does not exceed your set DEFAULT_XYJERK, nothing happens. Furthermore and finally, this vmax_junction_factor value is used to calculate the vmax_junction:

vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speedso the max speed at junction will be the minimum value between previous_nominal_speed and vmax_junction * DEFAULT_XYJERK / jerk.

Re: Marlin - DEFAULT_XYJERK March 15, 2013 07:48AM |
Registered: 5 years ago Posts: 258 |

If reprap-jerk is the maximum change in speed in mm/sec that than be changed in the interval between two segments, its correspondence to the "jerk" in a kinematic position/velocity/acceleration/jerk sense is sort of like acceleration.

The DEFAULT_XYJERK of 20mm/s might be understood as 20mm/s limit on delta-V across the end/beginning of a segment, so its units might be something like 20mm/s/step or maybe 20mm/s/timePerStep But since timePerStep (s/mm) depends on the junction velocity (mm/s), it isn't a constant limit on acceleration (with units of mm/s^2) or a constant limit on kinematic jerk (with units of mm/s^3).

Wouldn't different levels of microstepping need different DEFAULT_XYJERK to have the same kinematic behavior? The size of the instants in "instantaneous" change are larger for full steps than the instants for x32 microstepping.

The DEFAULT_XYJERK of 20mm/s might be understood as 20mm/s limit on delta-V across the end/beginning of a segment, so its units might be something like 20mm/s/step or maybe 20mm/s/timePerStep But since timePerStep (s/mm) depends on the junction velocity (mm/s), it isn't a constant limit on acceleration (with units of mm/s^2) or a constant limit on kinematic jerk (with units of mm/s^3).

Wouldn't different levels of microstepping need different DEFAULT_XYJERK to have the same kinematic behavior? The size of the instants in "instantaneous" change are larger for full steps than the instants for x32 microstepping.

Re: Marlin - DEFAULT_XYJERK March 15, 2013 08:06AM |
Registered: 4 years ago Posts: 195 |

I don't think it should be related to microstepping, the same way you wouldn't know if my pololu is at 1/4 or 1/8 or 1/16 when you see me move the printer head from A to B. From the printer head point of view, the speed and the acceleration are the same, no matter what microstepping the motor is at. Though, you could probably fix some steppers skipping issues by lowering the jerk.

Re: Marlin - DEFAULT_XYJERK March 15, 2013 08:26AM |
Registered: 4 years ago Posts: 142 |

Interesting. This makes more sense than using the kinematic jerk, since that would require decelerating to a full stop and then accelerating in the new direction. I think I remember reading that that method tends to result in blobs on angle changes, and curves would take forever to print.

Also, I agree with what MPower says. Since it calculates all the acceleration curves and whatnot in distances, then calculates steps from that, it shouldn't matter what your step size is. The delta-V is instantaneous, and since you can think of it as happening between steps, it doesn't matter how fast the steps are happening. 10 mm/sec is 10 mm/sec, no matter if it's coming from a 100 step/sec signal or a 1000 step/sec signal.

Also, I agree with what MPower says. Since it calculates all the acceleration curves and whatnot in distances, then calculates steps from that, it shouldn't matter what your step size is. The delta-V is instantaneous, and since you can think of it as happening between steps, it doesn't matter how fast the steps are happening. 10 mm/sec is 10 mm/sec, no matter if it's coming from a 100 step/sec signal or a 1000 step/sec signal.

Re: Marlin - DEFAULT_XYJERK March 15, 2013 06:46PM |
Registered: 4 years ago Posts: 455 |

Re: Marlin - DEFAULT_XYJERK June 01, 2017 12:00PM |
Registered: 6 months ago Posts: 3 |

I had an interesting experience with this jerk setting. I am building an XYZ stage using 3 ball screw driver linear actuators. For the longest time my motors were jamming when I went anywhere beyond 4 mm/s. Without knowing the effect, I decided to try changing the jerk setting from the default value of 20 to 1 and was able to get to the speed I wanted (5 mm/s).

Based on the above discussion it seems like the jerk is similar to acceleration, in that it is the maximum change in speed between 2 points (i.e. in gcode, if you're specifying coordinates, each point is a set of coordinates). If this is the case then what is the difference between jerk and acceleration?

Based on the above discussion it seems like the jerk is similar to acceleration, in that it is the maximum change in speed between 2 points (i.e. in gcode, if you're specifying coordinates, each point is a set of coordinates). If this is the case then what is the difference between jerk and acceleration?

Re: Marlin - DEFAULT_XYJERK June 01, 2017 09:45PM |
Registered: 4 years ago Posts: 455 |

Quotepatxystage1

I had an interesting experience with this jerk setting. I am building an XYZ stage using 3 ball screw driver linear actuators. For the longest time my motors were jamming when I went anywhere beyond 4 mm/s. Without knowing the effect, I decided to try changing the jerk setting from the default value of 20 to 1 and was able to get to the speed I wanted (5 mm/s).

Based on the above discussion it seems like the jerk is similar to acceleration, in that it is the maximum change in speed between 2 points (i.e. in gcode, if you're specifying coordinates, each point is a set of coordinates). If this is the case then what is the difference between jerk and acceleration?

Interesting indeed

My basic understanding is that jerk relates to the initial action from standstill to motion and acceleration relates to "how quickly" the end speed is reached.

I too have a couple of printers with ball screw axis and have experimented with jerk and acceleration although i've never managed to jam an axis, most probably due to my low settings to start with

My guess would be that depending on the lead screw pitch and amount of stiction, jamming could be an issue

Sorry, only registered users may post in this forum.