I've just realised the stepper I'm using has 200 not 48 steps, plus I can get a 32-microstep controller.
I can make use of this additional precision*
But it means my delay between steps will only be about 68ms. Right in the nasty transition between the ms and uS counters.
But the relative in accuracy of microsteps isn't a big deal in proportion, its more about keeping the platform in steady motion than absolute precision and it always averages out per full step.
I have come up with a 'simplified Bressenham' algorithm to apply a sub-microsecond correction to any arbitary accuracy that just uses integers:
- The theoretical duration between pulses is 68.341 milliseconds.
- Every 68milliseconds I apply a pulse and add 341 to a counter.
- If the counter exceeds 1000, I wait an extra millisecond and subtract 1000 from the counter.
What is really neat about this is that I can fine-tune the platform speed just by changing the value added to the counter. It's also easy to make a routine to allow for the counter value reducing below zero.
Delays of 68.34 will follow the sun, and 68.53 the stars. If you have the wrong rate it's visible as drift of the star field so being able to adjust to 0.01 ms at least shoudl be aimed for.