CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Built-in Quadrature interface in some PICs

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
valemike
Guest







Built-in Quadrature interface in some PICs
PostPosted: Tue Mar 22, 2005 8:42 pm     Reply with quote

I currently have a PIC18F448 used in a motor control application, where I have two TTL signals coming from hall effects into RB0 (interrupt), and another general i/o pin. Obviously, when RB0 interrupts, i look at the other i/o pin and i can determine direction. My ISR also does counting into an 'unsigned long' variable in RAM.

This is too CPU intensive, especially for frequent encoder interrupts, right?

So now, i'm looking into using a PIC (or DsPIC) with "Quadrature Interface and noise filter". However, such modules require 3 lines: A,B,and Index.

Is "Index" really required? Or can i get away with just having two hall effect signals going into A and B? (Then would I tie the Index to ground or Vdd?)

I guess i don't really understand the quad interface module enough Rolling Eyes
bluetooth



Joined: 08 Jan 2005
Posts: 74

View user's profile Send private message

PostPosted: Tue Mar 22, 2005 9:12 pm     Reply with quote

There are a number of ways to do this. They all require that your signals are in "quadrature", i.e., 90 degrees out of phase with each other so that direction can be detected.

I have one application where I take the a/b outputs from a quadrature encoder, run them through a couple of D flip-flops, and feed them into timer0 and timer1 via the external clock inputs. Timer0 counts up for CW, and Timer1 counts up for CCW. Put them in 16 bit mode (18 series parts) and with some simple math you can derive a 16 bit (or larger) position that goes up and down based on direction. One way to extend the size of your position variable is to enable timer overflow interrupts. Note that you'll only interrupt every 64k counts - not on every one! The other way just involves arithmetic. Both work well.

You can also use the QEI that's found in the 2x31 and dsPIC parts - it has filtering and the ability to multiply the counts by four (looking at all the edges). But most of the 18 parts with the QEI have limited ROM resources, and the dsPIC isn't ready for (CCS) primetime (hopefully soon!).

You really only need the index if you need a reference point around the circle - it typically gives you a pulse once per revolution. Some applications do and some don't.

Hope this helps.

BTW - Microchip has an appnote on using Timer0/1 for an encoder interface, I believe. Search their website for it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group