MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.22k stars 19.22k forks source link

[BUG] [1.1.x] Jerky behavior at start/end of a movement #13793

Closed timkostka closed 5 years ago

timkostka commented 5 years ago

Description

Jerky behavior when transitioning from stopped to moving on any stepper motor.

Steps to Reproduce

  1. Install latest [v1.1.9] or [v1.1.x bugfix] Marlin on Arduino Mega2560 board, without any modifications.
  2. Set jerk limit to 0mm/s.
  3. Look at STEP/DIR signal outputs while executing g-code to move from 0mm to 1mm and back on an axis.
  4. Postprocess results to examine position vs time and velocity vs time curves.

Expected behavior:

Velocity vs time should resemble a trapezoid, with a period of constant acceleration, then a period of constant velocity, then a period of constant deceleration.

Actual behavior:

Velocity vs time has a large jump at the beginning and end of a movement. It outputs 1 pulse on STEP, then pauses for a while, then jumps up to 9.8mm/s, then proceeds smoothly along the expected trapezoid curve. When it hits the end of a movement the same thing happens as it slows down.

Additional Information

The attached image shows results from the following g-code:

G21 ; set units to mm
G90 ; set mode to absolute
M92 X80 Y80 Z400 E93 ; set steps/mm
M203 X250 Y250 Z50 E250 ; set max feed rate (mm/s)
M204 P1000 R1000 T1000 ; set acceleration (mm/s^2)
M205 X0 Y0 Z0 T0 ; set jerk in (mm/s)
M121 ; disable endstops
G92 E0 X0 Y0 Z0 ; set position to origin
G0 X1
G0 X0
G0 Y1
G0 Y0
G0 Z1
G0 Z0
M400

c3d_results2

Note the large jumps in velocity at the beginning and start of a movement. Are these expected? A jump from ~0mm/s to 9mm/s with standard settings (80 steps/mm for X and Y, 400 steps/mm for Z) seems like poor performance. The dwell near 0mm is unexpected as well. For reference, the max velocity reached here is 25mm/s for X and Y (despite the settings being 250mm/s, not sure why on that either).

This happens with both v1.1.x and v1.1.x bugfix.

I can provide more information or testing if there is consensus that this is in fact an issue and there is a desire to find a solution.

p3p commented 5 years ago

This looks like standard jerk behaviour, although I'm unsure why it happens when you seem to have zeroed jerk, it's like its still enabled.

Marlin 1.1.x no longer gets fundamental changes only mission critical fixes, so if it is an issue it's unlikely this will be fixed unless the problem is the same in 2.0.x.

timkostka commented 5 years ago

The behavior in 2.0.x is identical, same steps to reproduce.

p3p commented 5 years ago

Does the jerk act correctly for other values of jerk than zero?

timkostka commented 5 years ago

If I bump it up to around 10mm/s, it acts as expected. But between 0 and 10mm/s, it acts like a combination somewhere between the two. I'll produce plots showing that in a few hours.

timkostka commented 5 years ago

Here are plots of X position and velocity at various jerk settings. Note that the 5mm/s and 10 mm/s are basically perfect, but the 0mm/s and 2mm/s have odd behavior.

I also did the same measurements on a Duet board (Reprap firmware) at 0mm/s jerk. This is the expected behaviour.

jerk_behavior

shitcreek commented 5 years ago

This is the expected behavior as stated in the documentation: http://marlinfw.org/docs/configuration/configuration.html#acceleration - it's just below this section, I've submitted a commit to make Jerk an anchor link

I'm guessing between 0 and 4mm/s is too slow / indistinguishable (shallow) for non 32 bit boards

timkostka commented 5 years ago

@shitcreek I don't see where in the jerk section it would explain this is the expected behavior. I wouldn't have expected jerk values below ~5mm/s to behave this poorly.

I had thought it may be due to the speed being too slow, but if I slow the movements down, Marlin is perfectly happy chugging along smoothly at well under 1 mm/s.

If I slow the acceleration down on this channel, the jump in velocity diminishes proportionally as well.

boelle commented 5 years ago

will close this one as it work as expected, we can always reopen if its not the case

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.