Quote
o_lampe
22 pulses difference doesn't sound like a binary error ( 8-16-32 pulses would be a hint ), but nevertheless did you try to store the stepcounts in an array instead of using the same register back and forth?
BTW: Is the microswitch debounced in hardware or software manners?
I think I have found it by looking at what is happening on an encoder that I connected to look at the stepper motor.
In each of the two round trips there are several changes of direction, most of which are from a standstill to a low(ish) speed. The speed at which the stepper could pull in was determined by trial and error and the figure used is 2/5 of the reliable pull in speed. The apparent cause of the error is that there is one transition in each round trip where the speed changes from 66.7pps in one direction to 66.7pps in the other direction - a change of 133.3pps. This seems to be reliable if going from clockwise to counterclockwise but misses steps going from counterclockwise to clockwise. Only the end of the "jiggle" is effected as all other transitions have a short delay between stop in one direction and start in the other. Mug-shot of the accused below.
[attachment 108694 Foundit.jpg]
This does not seem to be the whole of the answer as it doesn't account for the non-jiggle halves being equal, but it is possible to see that the direction transition is poor one way and good the other.
On your other point, I use no debounce at all - devilishly avant-garde I know but the only point where this may be a problem is the forward part of the jiggle and the reverse to MS detect which has a long delay due to the number of pulses in the jiggle - a sort of debounce of the serendipidous kind.