View previous topic :: View next topic |
Author |
Message |
login Guest
|
two quadrature encoders, one 18f4431, is it possible? |
Posted: Mon Jan 19, 2009 8:26 pm |
|
|
The topic is pretty straightforward, is it possible to read the count of two optical quadrature encoder with only one 18f4431? If yes how?
Thanks a lot to all of you |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Tue Jan 20, 2009 8:30 am |
|
|
I don't use that processor, but if it works the same as the 16F series PICs, you could bring all four input lines (two from each encoder) to pins of Port B, and use the interrupt-on-change feature. Obviously there would have to be some logic to determine which encoder changed, or if in fact both did. And a lot depends on how fast the encoders might be running. But in theory it seems workable. |
|
|
login Guest
|
|
Posted: Tue Jan 20, 2009 12:24 pm |
|
|
John P wrote: | I don't use that processor, but if it works the same as the 16F series PICs, you could bring all four input lines (two from each encoder) to pins of Port B, and use the interrupt-on-change feature. Obviously there would have to be some logic to determine which encoder changed, or if in fact both did. And a lot depends on how fast the encoders might be running. But in theory it seems workable. |
I was thinking about that, the 4431 has a built-in encoder reader but it only has one...Do you think the processor is fast enough to handle the interrupts on Port B and do other things at the same time?
THanks |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
|
Posted: Tue Jan 20, 2009 2:57 pm |
|
|
login wrote: | ...the 4431 has a built-in encoder reader but it only has one...Do you think the processor is fast enough to handle the interrupts on Port B and do other things at the same time?
|
As John P said, it depends on the speed of your encoders. I would say that if you have at least 200 instruction times between transitions on either encoder, then a tight ISR could be written to follow the transitons on two encoders. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
satishmunot
Joined: 28 Dec 2008 Posts: 12 Location: INDIA
|
TWO QEI |
Posted: Tue Jan 27, 2009 10:16 pm |
|
|
Hi,
During my some project long before I was use AT89C52 MCU for tiny
application. In which I use AT16V8 for qurature encoder logic and source code from Microchip for 16v8 (application Note from MICROCHIP for SERVO MOTOR). I use TIMER 2 IN UPDOWN MODE for one motor intrface and INTERRUPT INT0 for CLK and one Port pin for DIRECTION.
and I write code for in ISR of INT0 for UPDOWN counting for other MOTOR.
I think u can use similar type of method.
regards
satish munot _________________ HI |
|
|
Briany
Joined: 06 Jan 2009 Posts: 15
|
|
Posted: Tue Jan 27, 2009 10:44 pm |
|
|
I think you can.
1 using the QEI function, and the other one using CCP1 and CCP2.
then I think you have to write the code for the CCP part. |
|
|
satishmunot
Joined: 28 Dec 2008 Posts: 12 Location: INDIA
|
CCP1 and CCP2? |
Posted: Wed Jan 28, 2009 12:46 am |
|
|
hi
hello briany
how CCP1 and CCP2. will do up down counting when motor goes FWD/REV?
regards
satish _________________ HI |
|
|
Briany
Joined: 06 Jan 2009 Posts: 15
|
|
Posted: Wed Jan 28, 2009 3:25 am |
|
|
I've never tried it, but the idea's been in my head for a bit.
What I was thinking is:
since quad encoders rely on the phase diff to differentiate the direction, you can have signal A connected to CCP1 and signal B connected to CCP2. (both set to trigger at rising edge, or falling edge)
You then compare the two rising edge to see if they are first, 90 degree out of phase and which one is leading, then compare with previous history to find the frequency, then work out the speed.
It's a bit of calculation, and you need a small array to save the history. (namely to differentiate forward/rev from the history array - if previous phase difference > current phase difference, take current phase difference) and I think the challenging part is to keep the ISR for both CCP1 and 2 small to prevent missing a pulse.
I hope someone has a better idea, but I think mine will work. |
|
|
satishmunot
Joined: 28 Dec 2008 Posts: 12 Location: INDIA
|
ccp |
Posted: Wed Jan 28, 2009 4:01 am |
|
|
hello briany
You mean one for up and other for down counting
regards
satish _________________ HI |
|
|
Briany
Joined: 06 Jan 2009 Posts: 15
|
Re: ccp |
Posted: Wed Jan 28, 2009 4:10 am |
|
|
satishmunot wrote: | hello briany
You mean one for up and other for down counting
regards
satish |
no, I mean both on rising edge counting. but CCP1 for signal A, and CCP2 for signal B. |
|
|
|