View Single Post
  #3   Spotlight this post!  
Unread 01-02-2009, 00:36
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: analog input help

I'm guessing you mean sawtooth wave instead of sine wave, and you're using a magnetic absolute position sensor. Perhaps something like the MA3 from US Digital. Its output is very similar to a continuous-rotation potentiometer, but with no "dead spot".

We used one for sensing our arm position last year, so all we needed was the raw analog value. For motor speeds, we've used quadrature encoders. While I don't have any working example code to help, I think I can suggest some ways to get what you want.

Sample the analog voltage often, looking for a large transition. If it went from high to low, it's spinning one way. If it went from low to high, it's spinning the other way. Record the time when the transition occurred, and subtract it at the next transition; that will give you the period. Add to or subtract from a running counter each transition; that will give you the number of rotations.
Reply With Quote