I've been distracted up this interesting byway, and am confused by the maths. John's paper compares ideal delays compared with those produced by Equation 13.
![steperror.jpg steperror.jpg](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==)
For 15 steps, my implementation produces the ramp:
0.60, 0.47, 0.39, 0.35, 0.32, 0.29, 0.27, 0.25, 0.24, 0.23, 0.22, 0.21, 0.20, 0.19, 0.19, 0.18, 0.18, 0.17, 0.17, 0.16, End
The ramp looks reasonable in that gap between steps gets progressively shorter as wanted for acceleration, but apart from starting at 0.60, my values don't follow the table. Nor do I understand how the numbers in the table correspond to an acceleration. I must be missing something again!
The complete Arduino program is:
![fp.jpg fp.jpg](data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==)
My main goal is comparing the performance of Fixed Point maths versus Arduino floats, because the latter, while easy to use, are slow because most Arduinos don't have a hardware floating point accelerator. But I haven't got that far because I'm not sure my code is producing the right answers. Can anyone see if I've miscoded Equation 13, or any other blunders, or – if I've got the sums right – explain why the table is different?
I'm fairly sure the issue is me. I'm reasonably confident of my nextDelay() function, fairly confident the code for my interpretation of Equation 13 is OK, and very much less confident I've interpreted the equation properly. I sort of follow the paper, but my understanding is foggy. For instance, I've guessed the ramp's start value is 1.0 for no good reason.
Actual code driving a stepper motor needs a bit more thought. For example, in my code there's nothing to stop Equation 13 recommending inter-step delays too fast for a real motor to cope with. A practical driver would likely need to enforce a minimum inter-step delay to avoid losing steps. Though nothing else occurs to me, possibly other considerations. As when I try to use Q-format Fixed Point arithmetic, where the user has to keep a close eye on their range and accuracy limitations.
Dave