Frame squareness using accelerometer

Can the same accelerometer used to calibrate input shaper be used to electronically “square up” a printer that may not have been mechanically put together well? Ie if the x and y axis are not perfectly perpendicular, it could be corrected in firmware, either real time or after a one-time calibration?

Skew correction is possible, but it requires printing a test object and measuring it precisely.

https://www.klipper3d.org/skew_correction.html

Is it possible just using the accelerometer?

If say the print head was supposed to move purley in the X direction, Wouldn’t the print head then be able to detect that it is incorrectly moving slightly in the Y direction if it was equipped with an accelerometer and correct for it?

Brian

No, it’s not possible.

Not currently or not possible? Seems like a feature request to me.

Not currently possible, and I don’t personally see a reason to spend the time implementing it. The only way to verify the results would be to print the test object and measure.

I personally would like it on my coreXY printer as they can go out of alignment of belt tension is not perfect. It would also aid in frame assembly which can be tricky to get square. It would also help detect if the print head got caught on bubbly plastic or something like that and was knocked out of place

2 Likes

Measuring skew with accelerometer would rely on the accelerometer being precisely aligned in the first place. If you had a printer in perfect alignment you could possible calibrate the accelerometer to detect it becoming skewed, but it could not do the initial alignment.

Good point. Measuring skew could be a diagnostic tool for troubleshooting issues as it would indicate/confirm that printer’s alignment has not changed but not as alignment tool itself.

If you did some movement in X Then some movement in Y, couldn’t you measure that they are orthoginal? Same for Voron in Z where it has belt drive. For printers with screws for Z i bet it is too slow.

It should be possible. The IMU would need to take a reading while stationary to determine it’s Z vector based on gravity. Then measure the Xaxis. I don’t know how to subtract the gravity influence out of the Xaxis measurement, but a quick search on Google shows it is a real thing that can be done. I would assume its as simple as literally subtracting the X Y and Z values.
The crossvector of the Z and X axis vectors becomes the nominal Y axis vector. Now a measurement in the Y is required. Again gravity influence would need to be subtracted out.
Heck, writing this, I realize that there is no need to even know the Y nominal.
Now that we have our X and Y raw vectors, we need to determine IJK as a unit of one.
For the remainder of this post, I’ll call the following set of equations VEC.
I = X / SQRT(SUMSQ(X, Y, Z))
J = Y / SQRT(SUMSQ(X, Y, Z))
K = Z / SQRT(SUMSQ(X, Y, Z))
We’ll represent the vectors as Xaxis as xI, xJ, xK. Yaxis as yI, yJ, yK
Now to calculate the angle. This is pretty simple. ACOS(xI * yI + xJ * yJ + xK * yK)
Let’s call this equation VECDELTA.

I haven’t messed with my printer since installing Klipper - work has gotten in the way - but I know Skew correction in Marlin calculates as the tangent of the Y Deviation. Ah, so this is probably where we would need that Y nominal from earlier.
Crossvectors can be hard to find the equations for IJK style online. Here that is. We’re assuming an input of two be vectors. We’ll call those ‘a’ and ‘b’.
I’m defining the following set of equations will be defined as CROSSVEC
I = (aJ * bK) - (aK * bJ)
J = (aK * bI) - (aI * bK)
K = (aI * bJ) - (aJ * bI)

Let’s call our raw measurements Xmeas,Ymeas, and Zmeas.
Zvec = VEC(Zmeas)
Xvec = VEC(Xmeas - Zmeas)
Yvec = VEC(Ymeas - Zmeas)
Ynom = CROSSVEC(Zvec, Xvec)
SKEW = TAN(VECDELTA(Ynom, Yvec))

I haven’t proofread any of this. Outside of subtracting gravity out of the X an Y measurements, I’m confident in my math, as my job requires me to do vector math on a daily basis.

FYI, it’s theoretically possible to measure skew with an adxl345. Dmitry has, in effect, done this as part of adxl345: Added automatic accelerometer calibration by dmbutyugin · Pull Request #4931 · Klipper3d/klipper · GitHub . However, in practice, the accelerometer is not precise enough to be used for skew correction.

-Kevin

1 Like