View Single Post
  #11   Spotlight this post!  
Unread 30-03-2004, 16:58
TedP TedP is offline
Registered User
#1014
 
Join Date: Mar 2004
Location: Dublin, OH
Posts: 19
TedP will become famous soon enough
Re: Offloading intterupts to a counter

Quote:
Originally Posted by KenWittlief
I know that most PIC processors have internal counters that can count transistions on input pins - I dont know if they are available on the one in the RC - if so it would be much easier to use than an external device - and the counters dont need interrupts for each count - only when they have reached their terminal count.
Digital inputs 1 through 6 are already tied to the low priority interrupt handler in the default IFI code. Transitions from 0 to 1 are detected. This is actually how we're doing our encoding -- we just detect beam breaks. At every break, the interrupt triggers and increments a counter.

Everyone seems to love talking about quadrature encoders, but in this particular type of application where you usually have some gear reduction between the motors and the wheels, it just seems silly. If I'm driving the motors forward and the wheels are moving backwards despite the gearing connecting the motors to the wheels, I have a BIG PROBLEM. Thus, just use one bit for encoding and keep track of what direction you're driving your motor to tell you which direction you're going in.

And because I gazed ahead and noticed a question about terminal count... When the external counter reaches the highest number it can count to, it will have to raise a flag indicating it has reached it's "terminal count." This can be done internally in the PIC to keep track of time. If counters external raise a terminal count every, for example, 1024 ticks, then the PIC will be able to increment a counter internally indicating that the counter has moved another 1024 ticks.