View Single Post
  #4   Spotlight this post!  
Unread 17-02-2007, 16:07
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Problem using VEX shaft encoder

I have successfully used the vex encoders. I think that the biggest cause of your inaccuracy is that you are not using an interrupt for your input (a special kind of digital input). (Am I correct?)

Let's do the math to see why an interrupt is necessary:

100 RPM x 100 pulses per revolution is 10,000 pulses per minute

10,000/60 = 167 per second

So frequency is 167 Hz.

Period is 1/freq. = 6 ms per pulse.

Now remember that if you are polling, the pulse will only be high for 3ms out of the 6ms period. So if you see that the signal is low on this pass through the loop and then come back 4ms later and it is still low, a 3ms pulse could occur that you would miss.

Try bringing the signal in on an interrupt line ( digital inputs 1-6 ). Interrupts 1 & 2 are edge triggered, 3-6 fire on each transition. See the Kevin
Watson encoder sample to help with the interrupt code.
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010