View Single Post
  #4   Spotlight this post!  
Unread 25-03-2002, 16:50
Skabana159's Avatar
Skabana159 Skabana159 is offline
Robotics and Field Hockey
AKA: Jesse C. Owens
#0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2000
Location: Ft. Collins, CO
Posts: 92
Skabana159 is on a distinguished road
Send a message via AIM to Skabana159
Our team had a very similar problem last year, when we were trying to write our autobalancing code. We tried about a billion different meathods, my favorites being: a pedulum on a pot, and stopping the motors when the pot was 127; magnetic switches on one wheel as well as the frame next to it, and counting the number of trips of that switch (we found that this did not have good enough resolution, since we had to be within a few inches), but finally, we simply decided on this: We use a gyrochip to measure when it starts tilting, after this moment, we run the motors backward for a certain amount of loops. This gave us a resolution of 1/40 of a second, more than enough. This is nice because you can debug it really nice:

RUNTIME con (# of loops)
counter var byte
counter = 0

serin ...
other code here
serout ...

serin ...
pwm1 = 150
pwm2 = pwm1
counter = counter + 1
if counter = RUNTIME then mainloop
serout ...

This way, we could calibrate in a second to any bridge at the comp during the practice round by adjusting RUNTIME at the top of our code. This gives you the resolution you need. You could put it in your mainloop as well, if you want to.
__________________
"What most people do not understand is that the Buddha, the Godhead, resides just as comfortably in gears and circuits as in hills and trees. To believe otherwise is to dilute the Godhead."
-Robert Pirsig, Zen and the Art of Motorcycle Maintenance