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 CCS Technical Support

two quadrature encoders, one 18f4431, is it possible?

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







two quadrature encoders, one 18f4431, is it possible?
PostPosted: Mon Jan 19, 2009 8:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 20, 2009 8:30 am     Reply with quote

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







PostPosted: Tue Jan 20, 2009 12:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 20, 2009 2:57 pm     Reply with quote

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

View user's profile Send private message Send e-mail

TWO QEI
PostPosted: Tue Jan 27, 2009 10:16 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jan 27, 2009 10:44 pm     Reply with quote

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

View user's profile Send private message Send e-mail

CCP1 and CCP2?
PostPosted: Wed Jan 28, 2009 12:46 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 28, 2009 3:25 am     Reply with quote

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

View user's profile Send private message Send e-mail

ccp
PostPosted: Wed Jan 28, 2009 4:01 am     Reply with quote

hello briany
You mean one for up and other for down counting
regards
satish
_________________
HI
Briany



Joined: 06 Jan 2009
Posts: 15

View user's profile Send private message

Re: ccp
PostPosted: Wed Jan 28, 2009 4:10 am     Reply with quote

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.
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