Hi all,
@koconnor suggested I should re-post a couple of ideas here.
Suggested improvements are written / production proofed, thought it be worth to contribute to klipper, have a couple of spare weeks to implement.
A little bit of history on myself and this project:
Original project is similar ( both in age and hardware ) as the Mechaduino, software, methodology and reason very different, I have been running it for years on my machines so I deem it production safe…
Project started off as an anti-ringing system, which inevitably made it a closed-loop one, but not necessarily…
Bit of a problem is that most people associate closed-loop controllers with precision, but that is (IMHO) a misnomer, closed loop just makes ( hopefully ) sure your motor doesn’t miss any steps / is able to catch up, ergo having it doesn’t mean motors will run more precise, as owners no doubt experienced, having a PID on-board doesn’t really help fix ringing… I’ll elaborate later, (much) more
Most of the proposed improvements can be used in both open/closed loop systems, and will actually improve print quality. I’m actually very interested how input shaping will work with this, changes are they will complement or anything but… no idea…
I myself call it adaptive closed loop or output shaping… ( maybe someone can suggest a name for this kind of process ? )
The analogy to describe it to people unfamiliar with the topic is that of of the history and development of CD-players (and their associated closed loop systems), before you had auto-focus anti skidding anti vibration etc. CD players needed to be heavy and precisely machined… it became a flimsy tray thanks to a lot of control software. It’s the same with (3D)printers and other household appliances, software allows compensating the lack of sturdiness… current cheap 400€ printers outperform 3000€ 10 year old machines…
and frankly I think we should get rid of the step/dir interface
That is what this thread will be about and much more…
Thanks @koconnor for pointing me to #1038, which is exactly what I was looking for to get starting…
Some graphs of what I will be implementing, makes it easier to explain my reasoning later on.
Motors are not linear, don’t assume all stepper driver steps being equal in distance.
Magnetic field across poles differ due to mechanical metallurgical and electrical material properties, differences in wire gauge, non matched magnets, different amount of winding on poles, different electrical properties of H bridge driver, detente torque etc…
Here’s how it looks when one maps it’s manufactured offset, the actual position of a random 200 step / rev bipolar stepper-motor.
X scale is 200 steps
Y is 32usteps/step.
Measurement is 16x over-sampled ( 8 times fwd / 8 bckw )
What you see is a cyclical and absolute error, the cyclical repeats itself 50 times and corresponds with the 4 phases.
Next are 2 sets of plots each with an abs and normalized version, both are run under the same conditions (same motor driver current gcode acc…).
1st set is normal driven motor without any of the proposed algorithms, however both sets have the above error correction applied, so the actual offset would even be bigger…
2nd set has a third curve (yellow), in the 1st set that curve is equal to the blue line, this represents the position of the magnetic field in relation ( and same scale ) to the intended path, the result is orange, the actual path this motor followed, the algorithm predicts future movements without prior knowledge.
Sample rate is 10kHz, movement is 9000mm/s2 max velocity in plotted fragment is only about 43.75mm/s (using a 32mm pulley > 16teeth gt2), motor is unloaded, belts where disconnected, the visible swing is only due to a motor’ s own inertia, loaded it is much worse…
I plotted it unloaded as the algorithms have to work harder, reaction under load is slower / easier to predict.
Horizontal scale is in 1/10000 sec.
Vertical in usteps 32/step.
blue: is position as received by stepper driver.
red: is actual position motor position
yellow: position of magnetic field ( 3rd and 4th graph ), in graph 1 & 2, this is the same as blue so I left it out.
and normalized version
Most will instantly recognize this as ringing, visible is the motor swinging around it’s course at it’s resonance frequency. One can see that the max deviation is almost a (1) full step.
( maximum is well over 40 usteps ), this is quite normal, although for some this may be hard to believe.
A lot of people think that ringing is caused by belts, but that is not the case, magnets work like springs, and some of you will have noticed that creating a bit of slack in belts can actually (up to a point) improve the effect ( due to damping of the belts ), motors barely damp.
next set is what my proposed additions do, same conditions.
the orange line is the actual motor path, as it now barely deviates from the intended course 2-3 usteps vs 32 (+40)…
The magnetic field now acts in order for the actual position to match the intended position.
This can’t be done using a step/dir interface. Neither by using a PID controller ( way to slow for this )
that’s it for now,
next post will be about PID’s why it’s not suited, and the alternatives what I replaced it with, perceptron filtering, freq / ampl modulating of wave-forms etc…