Resolution in positioning math
mrehorstdmd last edited by
I want to set up a test in which I will be checking bed movement when power cycles in my printer. The Z axis uses 16:1 ustepping, and moves 20 um per full step. I'd like to step the bed in 1 ustep increments (1.25 um) through at least 4 full steps to see where the Z motor (and the bed) jumps when power is cycled.
If I specify Z ordinates in 1.25 um increments, will it step one ustep at a time? I realize the motor may not move with a single ustep, but will the driver at least push the current for 1 ustep?
I'd be specifying the Z ordinate like Z5.000, Z5.00125, Z5.0025, etc. Is 5 digits to the right of the decimal going to work?
bot last edited by bot
Yes. The display is often truncated and/or rounded, but the underlying math uses single precision floats, which guarantee, in most cases, 6 or 7 significant digits of floating point. This means that the translation from base-10, to binary, and back to base-10 does not change the value of those 6 digits. Beyond that, there will be small errors.
In practice, this means that if you are specifying 5.0025 as a value, you still have an extra digit. If you specify 100.0025, that last 5 is not guaranteed to translate to binary and back cleanly (though, in some cases you are guaranteed 7 digits), it might turn out as 100.00250244140625 or something. That said, since it would be close enough, the step generator would likely round it to the intended value and there may be no problem whatsoever.
This nifty calculator helps illustrate what happens: https://www.h-schmidt.net/FloatConverter/IEEE754.html
I guess you're not always guaranteed to have 6 digits, as in the case of 1.02, but it's close enough and you're guaranteed to NOT have precision past 7 digits.