S-Curve/ sinusoidal , Jerk +acceleration
-
You are quite right of course, jerk is the third derivative of position. I started writing one thing and ended up writing another, without editing what I had already written.
I remain of the opinion that implementing smoothly-varying acceleration is of dubious value unless we first deal with the elephant in the room i.e. discontinuous commanded velocity changes, aka jerk in the 3D printing sense.
-
@mak:
non-poliginal vector STL files? in a perfect world
i mean surely it can be implemented without that
seems lars figured it out. maybe with some sort of approximation technique?im hoping he publicizes his documentation maybe you can take a look at it?
STEP files.
-
does duet firmware not handle jerk as-well as marlin?
-
don't get Ian started
Thank you Tony for bringing this into (at least) my focus!
Very interesting thread!
I learned to not make things more complex then they need to be! -
@mak:
does duet firmware not handle jerk as-well as marlin?
Very old versions if RRF (about 2.5 years old) didn't handle jerk very well. I don't think Marlin handled jerk properly at that time either.
-
Alden Hart
4 years ago
Acceleration is performed using a piecewise linear representation of a constant-jerk equation. This is the 3rd derivative of position instead of the 2nd derivative (constant acceleration) that is commonly used. The pulse rate is computed for each of the S-curve segments. Each axis is run as a "minor axis" of the 50 Khz clock rate. This minimizes jitter and aliasing - at the expense of running a fast clock rate all the time. The code is on github under tinyg if you want to take a look.perhaps look here.
Id donate for you to take a serious look at this but something about your intellect tells me you're good for money dc42
source:
-
Yes I know there is code out there to do S-curve acceleration. What I am saying is that it's pointless using it in 3D printing unless we do something about the requirement to command instantaneous velocity changes in 3D printing, which is necessitated by the approximation of curves by straight line segments together with the need to avoid stop/start motion for each line segment.
Commanding instantaneous velocity changes is likely to be far worse than commanding instantaneous acceleration changes, because it's asking for infinite acceleration. I could implement S-curve acceleration, but unless you set maximum jerk to a very low value, you would still excite vibrations when printing curves. And if you did set jerk to zero, it would print the curves very slowly and jerkily.
S-curve acceleration may make more sense for CNC machines for two reasons. The G2 and G3 commands are more commonly used to print arcs, rather than approximating curves using line segments. Speeds are much lower, so jerk can be set very low, perhaps even to zero.
I'm not saying that I won't implement S-curve acceleration in the future, I am saying that it has limited value in the context of 3D printing. OK for printing straight lines, useless for printing curves. If it was easy to do it properly, I would probably have done it already. But doing it properly requires the solution of cubic equations to calculate the step pulse times (currently RRF solves quadratic equations to calculate them).
So I would rather focus on a solution to jerk first, probably by deliberately deviating the tool path from the commanded path a little. When that's sorted, I can look at S-curve acceleration.
It would be interesting to calculate the forces generated in a typical 3D print due to to jerk and step changes in acceleration, then take the Fourier transform and see what the various contributions are in the most important frequency bands.
-
I wonder if you can put an accelerometer onto tool head and input on the duet, to record the feedback,
you perhaps could use that data… and the real time data to create a PID tuning system to dampen out the oscillation real-time.. perfect printing. also you could use that accelerometer to judge if there have been skipped steps or nozzle crashes..
?
...imagine having that setup then somebody mounts their accelerometers off axis and the whole printer goes haywire correcting wrong values lol
alright Thanks for hearing me out Dc42- I hear you’re doing exciting things with duet. Keep up the good work- best wishes.
the struggles to get rid of belt wobble are real. -
So a few weeks late to the party but…
So I would rather focus on a solution to jerk first, probably by deliberately deviating the tool path from the commanded path a little. When that's sorted, I can look at S-curve acceleration.
I think this is the best solution and could greatly help out. Machine tools that use Fanuc controllers have an option to use a technique called Smoothing/Nano smoothing that does exactly what you are proposing. Many modern day CAM packages approximate complex curves as straight lines, same as our slicers do with STL files. There are some high performance machine tools that can approach 3d printing speeds while machining. Fanuc's answer was to allow deviations in the tool path by using look-ahead and building a NURBS curve. It is even intelligent enough to automatically turn off when the movement vector exceeds a specified angle.
https://www.fanucamerica.com/home/products-services/cnc/cnc-technology/high-precision-machining
-
Both AMF and OBJ file formats support curve approximation in different ways. It seems that Microsoft's 3MF does too. Doesn't mean any common CAD software actually properly exports that feature of the file formats. I understand that there aren't any slicers which would properly handle this yet either.
Looks like Cosine Additive has some G2/G3 stuff figured out. I know this is already implemented in Firmware. It's beyond my capabilities but maybe a post processor could bridge the gap between current slicer capabilities and what the firmware is capable of?
https://www.cosineadditive.com/blog/2015/7/1/g2-g3-vector-based-printing -
Curve approximation as straight segments would really be fine if there was hardware accurate/precise enough to create artifacts in FDM prints just from the "error" of microstepping, right? Polyjet machines are amazing because they show stl roughness. We still don't have proper pressure regulation within hotends. Nor do we have common methods for modeling kinematics (which may follow with the dissemination of higher order movement planning in desktop printing platforms). Perhaps a feature like s-curve movements will drive better hardware. It should lift the acceleration/payload and velocity ceilings a bit. I'd like to know if s-curves even match to "advance" behavior in a standard hotend like a titan aero.
-
@mak said in S-Curve/ sinusoidal , Jerk +acceleration:
Bottom is a square wave, not a trapezoid. You'd see 4 sploshing events if it were a trapezoid.
-
I have ready 3D printing s-curve velocity profile. And continuing velocity to next move in tangential directiin. Support corner shape to move without stop to next directiin and start from 0. Now i rewrite code to custom moderboard with pic32mz 200mhz. On pic24hj128gp202 calculate next move is abow 4us. . Now i must write communication protokol to support g code. In this moment i have G0 G1 G2 G3 and G4. Hi this pass for testing.
-
While I was on vacation I did a Fourier analysis of the effects of trapezoidal and S-curve acceleration on exciting ringing. My conclusion was that whether S-curve acceleration helps or not depends on the relationship between the time spent accelerating or decelerating and the frequency of the ringing that you are trying to avoid.
Here is the summary. Let T be the time spent accelerating or decelerating, and let F be the frequency of ringing that you want to avoid.
- If F << 1/T then constant acceleration and S-curve acceleration are equally bad.
- Otherwise, if F < 1.3/T then constant acceleration is better than S-curve (triangular profile) acceleration. In particular, when F = 1/T then constant acceleration will hardly excite the ringing at all; whereas S-curve acceleration will excite it greatly.
- When F > 1.3T, S-curve acceleration wins at most frequencies. The higher F is, the better S-curve acceleration is - although the tendency to excite ringing when using constant acceleration also falls with rising F.
Here is a chart to compare how the two acceleration profiles excite ringing at different frequencies.
Based on this analysis, I discussed how to adjust the acceleration time to reduce ringing in this thread https://forum.duet3d.com/topic/5951/periodicity-of-ringing/39 and received reports that it worked. Today I found time to do my own beer-sloshing tests (see the video I posted to that thread), and they too have confirmed the theory for constant acceleration (trapezoidal) motion.
So before you decide that you must have S-curve acceleration, you really need to know the frequency of the ringing that you are trying to eliminate. If the ringing frequencies are high enough, then S-curve acceleration will help. But if they are low, then it will probably be better to use trapezoidal motion, and cancel out the lowest ringing frequency by choosing the acceleration carefully.
I'll write up the maths in a blog post when I find time.
-
Hi, it is not too surprising that there is a certain time between the acceleration changes, which causes to increase or reduce ringing.
Every time the acting force (acceleration) changes the system gets bumped and stars to oscillate. So every acceleration change introduces one oscillation and all oscillations together get super-positioned, meaning the waves can amplify or cancel each other. If the big bumps (ramp start and end) are spaced in time in a way the big waves overlap, the ringing will be maximized and vice versa. This effect will appear at multiple acceleration times (it is periodic).
But it is surprising, that a more gentle change of acceleration will increase the problem anywhere. More gentle means less dominant waves and less chance of amplifying these dominant waves. Maybe it is just bad luck or a bad coincidence. At least in theory it seems hard to find a not too academic explanation for that behavior.
Which s-curve profile did you use ? How big was the maximum acceleration using s-curve compared to the constant ramp acceleration ? How much was it higher ? Was the max speed or speed at the end the same ?
What also should help to avoid amplifying interference is to use different acceleration changing shapes at start and end of a ramp. E.g. start with d(acceleration)/dt <> 0 and end with d(acceleration)/dt == 0.
-
The S-curve profile I used was triangular, i.e. ramp up the acceleration linearly to its peak value, then immediately ramp it down towards zero again. The peak acceleration in the S-curve case has to be twice the steady acceleration of the trapezoidal case in order to keep the total acceleration time the same.
S-curve profiles that are in between the two (i.e. including a steady acceleration part) will give excitation factors in between the two curves plotted above. I'll plot some specific examples when I have time.
-
@dc42: i cannot see any chart what do i do wrong ?
below
Here is a chart to compare how the two acceleration profiles excite ringing at different frequencies.
is nothing (at least for me)
-
@vp said in S-Curve/ sinusoidal , Jerk +acceleration:
@dc42: i cannot see any chart what do i do wrong ?
below
Here is a chart to compare how the two acceleration profiles excite ringing at different frequencies.
is nothing (at least for me)
Try refreshing the page?
-
i can see the chart on my tablet, but not on my PC, something seems to block the url/domain on my PC. Thanks.
Some well working theory/basics:
Given a spring mass system with mass m and spring stiffness c and force excitation it follows:-
If the acceleration (force) is changed stepwise by amount k1, the amplitude a1 of the oscillation caused by this step is directly proportional to the step size k1.
-
If the acceleration is changed like a ramp with ramp rate k2, the amplitude a2 of the oscillation caused by the ramp start is directly proportional to the ramp rate k2.
It follows that a2 / a1 == k2 * sqrt(m / c) * k1. [EDIT: typo correction -> m/c corrected to sqrt(m/c)]
So depending on the ramp rate (or step size) and also on m/c, the generated oscillation has a bigger or smaller amplitude for a step wise change or a ramp - it depends on the system (m & c) and tuning settings (k1 & k2).
I didn´t include damping because with damping the results are by far not as obvious and beautiful - but in principle it is exactly the same. A real fdm printer is also a combination of mass/spring/damper systems, but one frequency will dominate (ringing) and the above is also still valid.The frequency (sqrt(stiffness/mass)) is naturally the same for ramp and step.
So in case one big wave is generated (ramp start) compared to a lot of smaller waves (s-curve), it must be bad timing if the ringing is worse with s-curve OR it might come from a2 / a1 = k2 * sqrt(m / c) * k1.
E.g. if one big wave is generated at acceleration start and the next bump/wave start follows at acceleration end with an unlucky phase shift, it will superposition and amplify (triangular s-curve). It is easy to add one big wave to another big wave, so that they amplify each other. But it is much harder to superposition many smaller amplitude varying waves (real s-curve) in a way that they amplify each other - which doesn´t mean it is not possible in principle.In the end the triangular acceleration profile might be an unlucky profile to compare s-curve with the step wise acceleration change !
So depending on the above the ringing test results may vary. In general, many fdm printers will have comparable m/c and k2/k1 (k1 and k2 can be set anyhow). I didn´t check if this can be a game changer for some fdm printers. But there are very stiff and light (m/c is very small) as well as heavy and soft printers (m/c very high) out there....
-
-
@vp said in S-Curve/ sinusoidal , Jerk +acceleration:
Given a spring mass system with mass m and spring stiffness c and force excitation it follows:
-
If the acceleration (force) is changed stepwise by amount k1, the amplitude a1 of the oscillation caused by this step is directly proportional to the step size k1.
-
If the acceleration is changed like a ramp with ramp rate k2, the amplitude a2 of the oscillation caused by the ramp start is directly proportional to the ramp rate k2.
It follows that a2 / a1 == k2 * m / c * k1.
Only if the proportionality constant is the same in both cases. Is it?
The frequency (sqrt(stiffness/mass)) is naturally the same for ramp and step.
So in case one big wave is generated (ramp start) compared to a lot of smaller waves (s-curve), it must be bad timing if the ringing is worse with s-curve OR it might come from a2 / a1 = k2 * m / c * k1.
Yes, it is bad timing. With stepwise acceleration, the first frequency at which the oscillations produced by the start and end of the step cancel each other out is when 1/T where T is the length of the step. With triangular profile S-curve acceleration, it is 2/T where T is the total length of the triangular pulse.
In the end the triangular acceleration profile might be an unlucky profile to compare s-curve with the step wise acceleration change !
I am fairly sure that a trapezoidal acceleration profile will give results between the step case and the triangle case (because at the extremes it becomes one or the other), but I haven't done the maths yet.
-