More drift debugging

A project log for Garden Shed CNC

Making a CNC machine as cheaply as I can with things I have in my shed

penleekipenleeki 09/20/2015 at 11:090 Comments

I had an idea as to why the X axis might be drifting. Because it is moving faster than the other two axes, I thought that if the code was operating slowly enough it might be clicking the switch in and back out before I could check for a change of state. Then if calculating the curve was taking longer than a straight line that would explain the drift getting worse during curves.

curve calculation: 0ms --- operation 117ms
curve calculation: 1ms  --- operation 149ms

straight line calculation: 1ms ---- operation 151ms
straight line calculation: 0ms ---- operation 178ms
Unfortunately the data doesn't back that lovely elegant theory up at all. The time it takes to move 0.1mm and click the switch is 117ms and above, and the time it takes my completely unoptimized code to do all the calculations in between is somewhere between 0ms and 1ms. That is nowhere near enough time for an extra click to slip through. Foiled by the marvels of modern microcontrollers!

I also added code to the Arduino Sketch to check if the switch was being clicked whilst the servo was supposed to be turned off, in case the motor wasn't stopping right away when it was told to, but got no results.

Back to deep thought on the matter. At least I'm finding lots of things that aren't wrong with my project!