>> why is it necessary to clock on rising and falling edge when reading a
>> quadrature encoder?
>
> Because if the encoder changes direction, you will clock on the
> wrong edge and slowly lose registration.
Ah - finally, the correct answer! It's not necessary, or event desirable,
to clock on one of the channels, but for an application where you care about
long-term accuracy, it's *essential* to clock on both the rising and falling
edges of the other channel. Magnum's explanation is exactly right!
That said, there are often times where I ignore this. Specifically, when
using a rotary encoder knob as a user interface input device (most car radio
volume controls are this way, now), an occasional "lost step" isn't really
too important, and the programming to capture the knob data is usually
greatly simplified. In fact, most processors can only be configured to
interrupt on a transition in one direction, some external logic is needed to
get both transition directions. Polling the input is another alternative,
usually not a very good one...
--
Mark Moulding
Reply by dkel...@hotmail.com●May 3, 20102010-05-03
On Apr 26, 1:59 pm, -jg <jim.granvi...@gmail.com> wrote:
> On Apr 27, 6:19 am, Spehro Pefhany <speffS...@interlogDOTyou.knowwhat>
> wrote:
>
>
>
> > If you only care about speed and not direction, one edge on one channel may be sufficient.
>
> A purist could argue, that for position, all edges should be used,
> (you can easily discard precision later) but for speed readings, only
> the same edges should be considered, as quadrature encoders are NOT
> guaranteed to have 50.00% duty cycles (or even 90.00' alignment).
>
> -jg
Hi
One problem to watch out for is to not feed an analog encoder output
in to a Schmidt triggered buffer. The problem is the levels it
switches
at eats up most of the phase margin. I've seen a couple of mouse
designs that were real flaky using a 74HC14 directly from the encoder.
As things ( led ) age, the mouse begins to fail.
You need to amplify the signal some first such that the rise and fall
phase angles are sharper than the sine/cosine of the encoder.
One could also use something like a comparator chip with less
positive feedback than the 74HC14 uses.
Dwight
Reply by Jim Stewart●April 27, 20102010-04-27
Spehro Pefhany wrote:
> On Tue, 27 Apr 2010 10:23:50 -0700, Jim Stewart<jstewart@jkmicro.com>
> wrote:
>
>> -jg wrote:
>>> On Apr 27, 6:19 am, Spehro Pefhany<speffS...@interlogDOTyou.knowwhat>
>>> wrote:
>>>>
>>>> If you only care about speed and not direction, one edge on one channel may be sufficient.
>>>
>>> A purist could argue, that for position, all edges should be used,
>>> (you can easily discard precision later) but for speed readings, only
>>> the same edges should be considered, as quadrature encoders are NOT
>>> guaranteed to have 50.00% duty cycles (or even 90.00' alignment).
>>
>> Machine-tool grade encoders had damn well better be
>> guaranteed to have accurate angular alignment.
>
> What do you reckon the accuracy of quadrature is?
>
> Here's a typical Renishaw read head datasheet:
>
> http://resources.renishaw.com/download/%28a76a7e13ca474c538f1ff1f9e301418b%29?lang=en&inline=true
>
> The only hint I see is a 4:1 "safety factor" on the counter clock
> frequency max.
In this case I would imagine the accuracy would be
determined more by the scale than the readhead.
But that's just a guess...
Reply by Spehro Pefhany●April 27, 20102010-04-27
On Tue, 27 Apr 2010 10:23:50 -0700, Jim Stewart <jstewart@jkmicro.com>
wrote:
>-jg wrote:
>> On Apr 27, 6:19 am, Spehro Pefhany<speffS...@interlogDOTyou.knowwhat>
>> wrote:
>>>
>>> If you only care about speed and not direction, one edge on one channel may be sufficient.
>>
>> A purist could argue, that for position, all edges should be used,
>> (you can easily discard precision later) but for speed readings, only
>> the same edges should be considered, as quadrature encoders are NOT
>> guaranteed to have 50.00% duty cycles (or even 90.00' alignment).
>
>Machine-tool grade encoders had damn well better be
>guaranteed to have accurate angular alignment.
> On Apr 27, 6:19 am, Spehro Pefhany<speffS...@interlogDOTyou.knowwhat>
> wrote:
>>
>> If you only care about speed and not direction, one edge on one channel may be sufficient.
>
> A purist could argue, that for position, all edges should be used,
> (you can easily discard precision later) but for speed readings, only
> the same edges should be considered, as quadrature encoders are NOT
> guaranteed to have 50.00% duty cycles (or even 90.00' alignment).
Machine-tool grade encoders had damn well better be
guaranteed to have accurate angular alignment.
Reply by Magnum●April 27, 20102010-04-27
"princekcs" <princekcs@n_o_s_p_a_m.gmail.com> wrote in message
news:Lp6dnSYNcdAENUjWnZ2dnUVZ_jidnZ2d@giganews.com...
> why is it necessary to clock on rising and falling edge when reading a
> quadrature encoder?
Because if the encoder changes direction, you will clock on the
wrong edge and slowly lose registration.
Try it for yourself as a paper exercise; keep changing direction
over a very few steps and watch your position counter slowly drift!
And it doesn't have to be a deliberate change of direction, either.
Torsional
vibration when the encoder is sitting on one of the edges will cause a
steady creep in one direction.
Let me try to phrase that a little better.
Let us suppose that you are operating bi-directionally, clocking
from the rising edge, and the encoder is sitting over what would be
your falling edge. Each vibration backwards will give you what appears
to be a rising edge, causing a downwards count, but each vibration forward
will not be registered because it is sitting on the falling edge which you
are
ignoring.
And therby hangs a tale! In a recent project I wa controlling a stepper
motor
with such an encoder and was losing accuracy for the reasons stated above!
The algorithm to avoid the problem comes from a much larger state machine
than
is normally used ... you have to consider what you are going to do if you
receive
two opposite transitions from the same input without there being a
transition on the
other input.
Reply by -jg●April 26, 20102010-04-26
On Apr 27, 6:19=A0am, Spehro Pefhany <speffS...@interlogDOTyou.knowwhat>
wrote:
>
> If you only care about speed and not direction, one edge on one channel m=
ay be sufficient.
A purist could argue, that for position, all edges should be used,
(you can easily discard precision later) but for speed readings, only
the same edges should be considered, as quadrature encoders are NOT
guaranteed to have 50.00% duty cycles (or even 90.00' alignment).
-jg
Reply by Tim Wescott●April 26, 20102010-04-26
Stef wrote:
> In comp.arch.embedded,
> Tim Wescott <tim@seemywebsite.now> wrote:
>> princekcs wrote:
>>> why is it necessary to clock on rising and falling edge when reading a
>>> quadrature encoder?
>> Homework?
>>
>> It isn't always necessary, but paying attention to all the edges gives
>> you a more robust system.
>
> But paying attention to all edges doesn't necessarely mean you have to
> *clock* on the edges. ;-)
>
Correct, and it's why I worded what I said the way I did.
It's far easier to make a little state machine (in either hardware or
software) with a pair of binary states that runs at a sample rate
guaranteed to catch every valid edge than it is to make a bit of
hardware that actually derives it's clock edges from the edges of the
incoming signals.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
Reply by Stef●April 26, 20102010-04-26
In comp.arch.embedded,
Tim Wescott <tim@seemywebsite.now> wrote:
> princekcs wrote:
>> why is it necessary to clock on rising and falling edge when reading a
>> quadrature encoder?
>
> Homework?
>
> It isn't always necessary, but paying attention to all the edges gives
> you a more robust system.
But paying attention to all edges doesn't necessarely mean you have to
*clock* on the edges. ;-)
--
Stef (remove caps, dashes and .invalid from e-mail address to reply by mail)
Depart in pieces, i.e., split.
Reply by Tim Wescott●April 26, 20102010-04-26
Spehro Pefhany wrote:
> On Mon, 26 Apr 2010 11:08:01 -0700, Tim Wescott <tim@seemywebsite.now>
> wrote:
>
>> Walter Banks wrote:
>>> princekcs wrote:
>>>
>>>> why is it necessary to clock on rising and falling edge when reading a
>>>> quadrature encoder?
>>> You can decode with one edge only. If you use both edges then
>>> the resolution of the system will double.
>> You can decode with one edge only if you don't mind if the decoding is
>> error prone and noise sensitive. There's just not complete information
>> to take in all the cases unless you pay attention to both the rising and
>> falling edges of both channels.
>
> If you only care about speed and not direction, one edge on one
> channel may be sufficient.
Yes, but* only if the encoder is known to be turning, and if it's a
technology (i.e. optical or magnetic) that doesn't bounce.
I've always been information starved, and have always used all the edges
available to me -- which doesn't mean that the next project that comes
down the pike won't work fine with a single edge on a single channel.
* I'm really not in a pissy mood today -- pedantic, maybe, but not pissy.
--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com