Searching \ for '[PIC]: Typical Quadrature Optical Encoder input sc' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=quadrature
Search entire site for: 'Typical Quadrature Optical Encoder input sc'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Typical Quadrature Optical Encoder input sc'
2003\04\21@090727 by Mccauley, Daniel H

flavicon
face
Am I safe to assume that the typical PIC implemented optical encoder scheme
is to have the INPUT A of
the optical encoder connected to RB0 (Ext INTERRUPT) of the PIC and INPUT B
of the encoder connected to another pin
such as RB1?  So that when RB0 detects a rising edge, the interrupt routine
would then check to see if INPUT B is high
or low to determine direction?

Is this standard or do they use routines that trigger off both INPUT A and
INPUT B for double resolution??? Or possible they would only do this if they
needed twice the resolution?

Thanks!

D

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\04\21@093503 by Bob Ammerman

picon face
Your assumptions and understanding are exactly correct.

You can also change the interrupt edge on the fly so that you can detect
both rising and falling edges on A. This will give you two counts per
period.

Basically there are three techniques:

- process one edge of one signal: one count per period
- process both edges of one signal: two counts per period (double
resolution)
- process both edges of both signals: four counts per period (quad
resolution)

Bob Ammerman
RAm Systems

{Original Message removed}

2003\04\21@101408 by Scott Williamson

picon face
That will work.

You could also put A and B inputs two on two of the upper four bits of port
B and interrupt on pin change.  In the interrupt concatenate the previous 2
values with the current 2 values to create a 4 bit index into a lookup table
to obtain a quick forward or backward value.  It is fast and you will
quadruple the resolution of the encoder as you will be processing every
rising and falling edge of both signals.  You will also be able to detect
when the encoders are spinning too fast or if there are errors as you will
get 00 turning into 11 for example and you could flag an error or add or
subtract 2 to your position variable based on the previous direction of
rotation in an attempt to remain accurate.

You trade processor cycles for accuracy.  You will also be limited to a top
speed about a quarter of what the other system would be capable of because
of the additional processing.  There are always trade offs.


Scott Williamson
.....SOLIDCorpKILLspamspam@spam@ameritech.net

{Original Message removed}

2003\04\21@103726 by M. Adam Davis

flavicon
face
Another option is to use the PortB interrupt on change capability.
Attach both A and B to PortB pins that trigger the interrupt on change
and you'll have a full four interrupts per period.

If you want to just use the external interrupt pin and still get four
interrupts per period, use an XOR gate to combine A and B, and when you
get an interrupt toggle the interrupt trigger from rising to falling or
falling to rising.

-Adam

Mccauley, Daniel H wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu>

2003\04\21@194001 by Dwayne Reid
flavicon
face
At 09:07 AM 4/21/03 -0400, Mccauley, Daniel H wrote:
>Am I safe to assume that the typical PIC implemented optical encoder scheme
>is to have the INPUT A of the optical encoder connected to RB0 (Ext
>INTERRUPT) of the PIC and INPUT B of the encoder connected to another pin
>such as RB1?  So that when RB0 detects a rising edge, the interrupt
>routine would then check to see if INPUT B is high or low to determine
>direction?

No - a robust decoder detects edges from BOTH inputs.  Here is why: look at
what happens if you have any position jitter while clocking from only 1
edge.  Say: you clock from phase A.  Rock the encoder back and forth a tiny
bit so that phase A jitters: goes hi and lo repeatedly.  Notice how you
have suddenly accumulated a whole bunch of erroneous pulses.

>Is this standard or do they use routines that trigger off both INPUT A and
>INPUT B for double resolution??? Or possible they would only do this if they
>needed twice the resolution?

The easiest way is to use one of those SOT-23 Tiny Logic XOR gates from
Fairchild or Toshiba - the output of that feeds RB0.  Either of the phase
lines feeds another PIC input.

That's all it takes: just 1 XOR gate to fix all the problems.

dwayne

--
Dwayne Reid   <EraseMEdwaynerspam_OUTspamTakeThisOuTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu>

2003\04\21@225630 by Sean H. Breheny

face picon face
Hi Dwayne,

I'm not sure I understand what you are suggesting, but it sounds to me as
though your solution would not fix it. If all you do is detect rising
edges, and you move the encoder a tiny bit back and forth around the
transition point of the A output, then you will see a series of rising and
falling edges of the A output, and B will remain in one state. The XOR gate
changes nothing. You need (it seems to me) to detect both rising and
falling edges of at least one output.

I must admit that I've never thought of this before. I have a circuit that
uses the XOR method and seems to work fine, although it doesn't usually
encounter situations where you rock it back and forth slightly.

Sean

At 05:28 PM 4/21/2003 -0600, you wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\04\22@082544 by Olin Lathrop

face picon face
> No - a robust decoder detects edges from BOTH inputs.  Here is why:
> look at what happens if you have any position jitter while clocking
> from only 1 edge.  Say: you clock from phase A.  Rock the encoder back
> and forth a tiny bit so that phase A jitters: goes hi and lo
> repeatedly.  Notice how you
> have suddenly accumulated a whole bunch of erroneous pulses.

A bunch of pulses, yes, but the count should still be accurate.

The biggest problem with looking at only one edge per quadrature cycle is
that the counts then occur 180 degrees out of phase with each other
between the forward and backward directions.  In other words, there is 1/2
count of position slop between rotation directions.  If this doesn't
matter to the application, then sensing 1 edge per quadrature cycle is a
perfectly valid way to save on processing time.

> The easiest way is to use one of those SOT-23 Tiny Logic XOR gates from
> Fairchild or Toshiba - the output of that feeds RB0.  Either of the
> phase lines feeds another PIC input.
>
> That's all it takes: just 1 XOR gate to fix all the problems.

You could also flip the detected edge polarity each edge interrupt, or use
the port B change interrupt.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\04\23@022557 by Dwayne Reid

flavicon
face
At 10:55 PM 4/21/03 -0400, Sean H. Breheny wrote:
>Hi Dwayne,
>
>I'm not sure I understand what you are suggesting, but it sounds to me as
>though your solution would not fix it. If all you do is detect rising
>edges, and you move the encoder a tiny bit back and forth around the
>transition point of the A output, then you will see a series of rising and
>falling edges of the A output, and B will remain in one state. The XOR gate
>changes nothing. You need (it seems to me) to detect both rising and
>falling edges of at least one output.

Sorry - implicit in my description (but not mentioned) was that the ISR
re-configures the RB0 interrupt edge select bit upon each interrupt so as
to detect the opposite edge.  In other words, RB0 is detecting both rising
and falling edges.

>I must admit that I've never thought of this before. I have a circuit that
>uses the XOR method and seems to work fine, although it doesn't usually
>encounter situations where you rock it back and forth slightly.

My first all-digital closed loop position servo had serious problems until
I dealt with this issue.  In other words, the servo reached the desired
position, stopped, then drifted away from the desired position because the
encoder was parked right on the sensitive edge.  A little mechanical
vibration caused the jitter I mentioned, which the servo promptly
corrected.  And moved the target away from the desired position.

This servo controller was built into an Altera CPLD (EP900: 24 macrocells)
and I didn't have much left for internal resources.  But a 4070 tacked on
the back of the prototype board (1 section to XOR both phases, 1 section to
generate clock pulses from both edges) fixed things quite nicely.

dwayne

--
Dwayne Reid   <spamBeGonedwaynerspamBeGonespamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...