|
|
View previous topic :: View next topic |
Author |
Message |
valemike Guest
|
Built-in Quadrature interface in some PICs |
Posted: Tue Mar 22, 2005 8:42 pm |
|
|
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 |
|
|
bluetooth
Joined: 08 Jan 2005 Posts: 74
|
|
Posted: Tue Mar 22, 2005 9:12 pm |
|
|
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. |
|
|
|
|
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
|