Posted 24 February 2005 - 10:29 AM
I already had in mind how I wanted to tackle it mechanically so the build was fast, 4 or 5 hours. The programming was about another hour.
The code is relatively simple. I set up two tasks (runinning in parallel) which act as servo tasks for the two axes (z and y). Encoder position of the axis is compared to a position variable which I change in the main task to specify the desired position for that axis. If the task notices a difference between where it is, and where i should be, the axis will calculate a move and decelerate to acheive the final position.
So after those are written (which isn't as hard as it sounds, I'm not doing PID or anything crazy like that), it's just in the main task a series of z and y moves to reach the different positions. After a flag in the servo task identifies that each axis is at the correct position, the main task steps to the next position command. And so on.
The knockoff unit which removes the duck from the end of the robot is another sub that just runs at the end of the main task when the robot goes over to the side there after each one is built.
-Iain