View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 28 Jul 2014 Posts: 38
|
qei on 18f4620 |
Posted: Mon Apr 15, 2019 10:30 pm |
|
|
How can i count qei pulses in 18f4620 ic ? It does not have in built qei module. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9272 Location: Greensville,Ontario
|
|
Posted: Tue Apr 16, 2019 5:47 am |
|
|
Use an external device ! US Digital make several. I used them 25 years ago for realtime control of a 3DOF helicopter among other things |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Tue Apr 16, 2019 7:47 am |
|
|
I've done something where I hooked up the two phases of the encoder to separate timer inputs before... Don't remember exactly what I did, but it worked. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19592
|
|
Posted: Tue Apr 16, 2019 11:29 am |
|
|
You have to add a little external logic to do this, but it can work well.
A web search will find the gates needed. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9272 Location: Greensville,Ontario
|
|
Posted: Tue Apr 16, 2019 2:56 pm |
|
|
depending on application, you can use a PS2 mouse.. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19592
|
|
Posted: Wed Apr 17, 2019 1:19 am |
|
|
Like most things in programming/PIC's, huge amounts depend on other
factors:
1) How fast the QEI pulses are going to be?.
2) Whether you need to decode all four phases or just one or two?.
3) What interrupts need to be handled on the chip at the same time?.
(this is vital - to decode QEI using interrupt on change for example,
requires this interrupt to be able to be accessed without fail on every
QEI edge - if there are other interrupts needed and any of the handlers
for these take noticeable time, this slows the maximum rate that can be
handled.....).
4) Clock speed of PIC?.
With these factors given, it allows you then to choose a number of
possible solutions:
1) Interrupt on change QEI decoding - simplest, but lowest performance.
2) 'Logic' QEI decoding. With this you add an external flip-flop and
can generate two pulse trains - one is the 'up' counts, and the other
the 'down'. These can then be fed into two PIC timers. Add timer overflow
interrupts, and your 'position', is the delta between these two counts.
There are also chips to do this logic on the market (LS7083/4).
3) Hardware QEI. Another poster has already mentioned in a recent
thread the US Digital chips, and these are very easy to use. Other
manufacturers also produce chips to do this.
Like most things 'PIC' there are a lot of 'answers'..... |
|
|
|