Rotary encoder bounce problem

On Fri, 28 May 2004 23:38:57 +0200, the renowned "Jeroen"
<dev@null.com> wrote:
it only takes 6 components to debounce the lines in hardware, and with
current sizes of components, it's not high a price to pay in term of board
space.
Hmm.. well, the ratio of 6 parts divided by 0 is rather high. ;-) ;-)

You can fit them nicely under the encoder, using almost no board
space at all. I used an encoder with a integrated push button, but I
debounce that in software, that's much easier then debouncing the encoder
part.
Yes. The timing isn't that much more demanding for the quadrature
inputs compared to the switch input on a reasonably fast micro, and
you don't have to worry about /IRQ priorities, assigning limited pins
and such like. All the inputs from a couple encoders with switches can
be debounced at once in parallel on an 8-bit micro.

Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
 
Ah! I see. For some reason I was so locked into the idea of using an IRQ on
a switch line, I didnt think of doing it that way. Yes, polling using a
timer may be better, will try it out.

The boards already have hardware debounce, so its not a problem to leave
those components there. And in fact I'm still a bit worrried about the fact
that transitions on one line cause glitches on the other one too, so a bit
of hardware RC helps.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40b834b2@duster.adelaide.on.net...
Ah! I see. For some reason I was so locked into the idea of using an IRQ
on
a switch line, I didnt think of doing it that way. Yes, polling using a
timer may be better, will try it out.

The boards already have hardware debounce, so its not a problem to leave
those components there. And in fact I'm still a bit worrried about the
fact
that transitions on one line cause glitches on the other one too, so a bit
of hardware RC helps.
Simultanious glitches on A/B should not occur, did you measure/verify that
with an oscilloscope? If you really have such glitches, you can only hope
that some RC filtering helps, or stronger pullups perhaps, if you can afford
that. Glitches/bouncing on one single channel is not a problem, it will only
make your counter go up and down by one, but it won't lose track.

Spehro made another good comment. If you have glitches/bouncing behaviour
on one channel, and it conencted to an interrupt edge sensitive input, you
have an unpredictable load on your uC. I too don't like that a bit. In
general
with hand rotated panel encoders, it is not the end of the world if you miss
a pulse or gain, but it is much nicer when it works just perfect. I tried
a couple of times to decode it with interrupts, but never got it 100%.
With the timer interrupt, it can be made perfect, even if you give the knob
a firm twist, back and forth, all day long, and it will stay spot on.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 
Adrian Jansen wrote:
Ah! I see. For some reason I was so locked into the idea of using an IRQ on
a switch line, I didnt think of doing it that way. Yes, polling using a
timer may be better, will try it out.

The boards already have hardware debounce, so its not a problem to leave
those components there. And in fact I'm still a bit worrried about the fact
that transitions on one line cause glitches on the other one too, so a bit
of hardware RC helps.
Congratulations on taking 48 hours to comprehend something even a
semi-competent individual could conceive in 100ms....
 
On Sat, 29 May 2004 15:43:50 GMT, Fred Bloggs <nospam@nospam.com>
wrote:

Adrian Jansen wrote:
Ah! I see. For some reason I was so locked into the idea of using an IRQ on
a switch line, I didnt think of doing it that way. Yes, polling using a
timer may be better, will try it out.

The boards already have hardware debounce, so its not a problem to leave
those components there. And in fact I'm still a bit worrried about the fact
that transitions on one line cause glitches on the other one too, so a bit
of hardware RC helps.


Congratulations on taking 48 hours to comprehend something even a
semi-competent individual could conceive in 100ms....
Now, now, Fred, be sweet and nice... it's a holiday weekend ;-)

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
Already answered in the other thread.

Thanks to everyone, I now have some definite things to try, and know what to
look out for in testing encoders.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
"Frank Bemelman" <f.bemelmanx@planet.invalid.nl> wrote in message
news:40b855cd$0$193$c3e8da3@news.astraweb.com...
"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40b834b2@duster.adelaide.on.net...
Ah! I see. For some reason I was so locked into the idea of using an
IRQ
on
a switch line, I didnt think of doing it that way. Yes, polling using a
timer may be better, will try it out.

The boards already have hardware debounce, so its not a problem to leave
those components there. And in fact I'm still a bit worrried about the
fact
that transitions on one line cause glitches on the other one too, so a
bit
of hardware RC helps.

Simultanious glitches on A/B should not occur, did you measure/verify that
with an oscilloscope? If you really have such glitches, you can only hope
that some RC filtering helps, or stronger pullups perhaps, if you can
afford
that. Glitches/bouncing on one single channel is not a problem, it will
only
make your counter go up and down by one, but it won't lose track.

Spehro made another good comment. If you have glitches/bouncing behaviour
on one channel, and it conencted to an interrupt edge sensitive input, you
have an unpredictable load on your uC. I too don't like that a bit. In
general
with hand rotated panel encoders, it is not the end of the world if you
miss
a pulse or gain, but it is much nicer when it works just perfect. I tried
a couple of times to decode it with interrupts, but never got it 100%.
With the timer interrupt, it can be made perfect, even if you give the
knob
a firm twist, back and forth, all day long, and it will stay spot on.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 
In article <40b855cd$0$193$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

Simultanious glitches on A/B should not occur, did you
measure/verify that with an oscilloscope? If you really have such
glitches, you can only hope that some RC filtering helps, or
stronger pullups perhaps, if you can afford that.
[snip]

I'd check to see if the switch was wired wrongly.

Take (say) a three-wire switch (two switched lines
and one Common). If the Common was swapped with a
switched line it would produce exactly the effect
described.

--
Tony Williams.
 
On Sun, 30 May 2004 07:00:37 +0100, the renowned Tony Williams
<tonyw@ledelec.demon.co.uk> wrote:

In article <40b855cd$0$193$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

Simultanious glitches on A/B should not occur, did you
measure/verify that with an oscilloscope? If you really have such
glitches, you can only hope that some RC filtering helps, or
stronger pullups perhaps, if you can afford that.
[snip]

I'd check to see if the switch was wired wrongly.

Take (say) a three-wire switch (two switched lines
and one Common). If the Common was swapped with a
switched line it would produce exactly the effect
described.
Usually the common line is the middle pin, which is grounded, but of
course pin numbering on custom footprints/schematic symbols has a
couple of chances to accumulate oopsies.

Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
 
In article <jpmjb01urepdavnktcgim852pjf183nvj3@4ax.com>,
Spehro Pefhany <speffSNIP@interlogDOTyou.knowwhat> wrote:

Take (say) a three-wire switch (two switched lines
and one Common). If the Common was swapped with a
switched line it would produce exactly the effect
described.

Usually the common line is the middle pin, which is grounded, but
of course pin numbering on custom footprints/schematic symbols
has a couple of chances to accumulate oopsies.
Shorting together pairs of pins and ohm'ing to
the third pin (whilst rotating the switch) should
find the Common. The two switch lines shorted
together and ohm'ed against the Common will produce
and entirely different On/Off pattern to the (same)
pattern that the other two combinations give.

--
Tony Williams.
 
Nope, the switch is definitely wired correctly. It is the standard type,
centre connector common, and checked that way with a meter. When I get a
chance I will post a photo of the output waveforms.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
"Tony Williams" <tonyw@ledelec.demon.co.uk> wrote in message
news:4cb70c7deatonyw@ledelec.demon.co.uk...
In article <40b855cd$0$193$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

Simultanious glitches on A/B should not occur, did you
measure/verify that with an oscilloscope? If you really have such
glitches, you can only hope that some RC filtering helps, or
stronger pullups perhaps, if you can afford that.
[snip]

I'd check to see if the switch was wired wrongly.

Take (say) a three-wire switch (two switched lines
and one Common). If the Common was swapped with a
switched line it would produce exactly the effect
described.

--
Tony Williams.
 
I posted an image of the rotary encoder bounce to
alt.binaries.schematics.electronic

Same topic as here.




--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
"Adrian Jansen" <qqv@noqqwhere.com> wrote in message
news:40ba64b7$1@duster.adelaide.on.net...
Nope, the switch is definitely wired correctly. It is the standard type,
centre connector common, and checked that way with a meter. When I get a
chance I will post a photo of the output waveforms.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
"Tony Williams" <tonyw@ledelec.demon.co.uk> wrote in message
news:4cb70c7deatonyw@ledelec.demon.co.uk...
In article <40b855cd$0$193$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

Simultanious glitches on A/B should not occur, did you
measure/verify that with an oscilloscope? If you really have such
glitches, you can only hope that some RC filtering helps, or
stronger pullups perhaps, if you can afford that.
[snip]

I'd check to see if the switch was wired wrongly.

Take (say) a three-wire switch (two switched lines
and one Common). If the Common was swapped with a
switched line it would produce exactly the effect
described.

--
Tony Williams.
 
"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40ba9483@duster.adelaide.on.net...
I posted an image of the rotary encoder bounce to
alt.binaries.schematics.electronic

Same topic as here.
The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,
but when it opens due to bouncing, it rises from 0V to 4V ????

How do you do that? Can we see a piece of schematic showing
the encoder, filter and uC inputs?

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 
In article <40ba64b7$1@duster.adelaide.on.net>,
Adrian Jansen <qqv@noqqwhere.com> wrote:
Nope, the switch is definitely wired correctly. It is the
standard type, centre connector common, and checked that way with
a meter. When I get a chance I will post a photo of the output
waveforms.
In that case try changing those 100k pullups to
something more reasonable, say 1k.

--
Tony Williams.
 
In article <40bafbce$0$311$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,

I can't see the OP's binary, but your description
sounds as though that is what should happen with
that unusually high value of pullup-R.

+-------------->Scope on here?
100k | 100k
Vcc+----/\/\----+---/\/\---+--->To uP
| |
+ |
Switch \ ===C
+ |
| |
Common +----------+--->0v

At the instant the Switch opens the junction of the
two 100k's will rise to Vcc/2, then slowly climb to
Vcc with a time-constant of (100k+100k)*C.

but when it opens due to bouncing, it rises from 0V to 4V ????
And that still feels as though the Common is not a Common.

--
Tony Williams.
 
On Mon, 31 May 2004 11:30:02 +0200, the renowned "Frank Bemelman"
<f.bemelmanx@planet.invalid.nl> wrote:

"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40ba9483@duster.adelaide.on.net...
I posted an image of the rotary encoder bounce to
alt.binaries.schematics.electronic

Same topic as here.

The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,
but when it opens due to bouncing, it rises from 0V to 4V ????

How do you do that? Can we see a piece of schematic showing
the encoder, filter and uC inputs?
I'm thinking maybe he's triggering an interrupt from the falling edge
of B, which is doing something unpleasant in sofware via both the A
and B "inputs". Is it an 8051-style pseudo-bidirectional port?

(Re?)writing the 1's to such a port (as you do for an input)will
momentarily turn on the "strong" transistor pullups for a fixed period
of time. Maybe changing any port bit (to high?) will do this (RMW on
the port), but that's more detail than I try to remember, and I've
never run into any problems to really burn the data in. ;-)

Anyway, disconnect the micro, look at the data lines, and you'll know
very quickly.

Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
 
"Tony Williams" <tonyw@ledelec.demon.co.uk> schreef in bericht
news:4cb7aaeb29tonyw@ledelec.demon.co.uk...
In article <40bafbce$0$311$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,


I can't see the OP's binary, but your description
sounds as though that is what should happen with
that unusually high value of pullup-R.

+-------------->Scope on here?
100k | 100k
Vcc+----/\/\----+---/\/\---+--->To uP
| |
+ |
Switch \ ===C
+ |
| |
Common +----------+--->0v

At the instant the Switch opens the junction of the
two 100k's will rise to Vcc/2, then slowly climb to
Vcc with a time-constant of (100k+100k)*C.
Looks indeed something like that. Goes straight to Vcc/2 and
then follows a RC curve.

but when it opens due to bouncing, it rises from 0V to 4V ????

And that still feels as though the Common is not a Common.
A/B did overlap, although they aren't exactly 50/50 duty, but that
may be some mechanical thing. Channel A didn't show any bounce at
all, expect some short 'bouncing' pulses, almost an exact copy
of the real bouncing occuring on channel B. Sorry for this fuzzy
description. The picture of the scope was posted on ABSE.

I've copied it to here:
www.planet.nl/~bemel141/images/Rotary_Encoder_bounce.jpg

There must be something really funny going on here.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 
"Spehro Pefhany" <speffSNIP@interlogDOTyou.knowwhat> schreef in bericht
news:307mb01uep8ckvien9n0itbjc3fnh69hbs@4ax.com...
On Mon, 31 May 2004 11:30:02 +0200, the renowned "Frank Bemelman"
f.bemelmanx@planet.invalid.nl> wrote:

"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40ba9483@duster.adelaide.on.net...
I posted an image of the rotary encoder bounce to
alt.binaries.schematics.electronic

Same topic as here.

The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,
but when it opens due to bouncing, it rises from 0V to 4V ????

How do you do that? Can we see a piece of schematic showing
the encoder, filter and uC inputs?

I'm thinking maybe he's triggering an interrupt from the falling edge
of B, which is doing something unpleasant in sofware via both the A
and B "inputs". Is it an 8051-style pseudo-bidirectional port?

(Re?)writing the 1's to such a port (as you do for an input)will
momentarily turn on the "strong" transistor pullups for a fixed period
of time. Maybe changing any port bit (to high?) will do this (RMW on
the port), but that's more detail than I try to remember, and I've
never run into any problems to really burn the data in. ;-)
I was actually also suspecting he is fiddling with the input pins,
in some obscure way. The fact that channel A doesn't bounce at all,
but does show the same nasties as seen on channel B is reason for
some investigation.

Anyway, disconnect the micro, look at the data lines, and you'll know
very quickly.
Good advice.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 
"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40ba9483@duster.adelaide.on.net...
I posted an image of the rotary encoder bounce to
alt.binaries.schematics.electronic

Same topic as here.




--
Regards,

Adrian Jansen
J & K MicroSystems

Adrian,

Posted a reply in the same group:

"
Peculiar picture. First impression: High pull up resistors and pretty tight
(parasetic, capacitive?) coupling. But that's not enough an explanation.
Long and not decoupled power lines may be part of the cause but I guess you
checked it out already.

Did you ever make measurements on a single encoder with low (1k) pull ups
and a good lab power supply? If you do not find the cause of this behavior
and find a way to stop it, you can program what you want to make the best
of it, but it will never become a reliable circuit.
"

petrus bitbyter


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.688 / Virus Database: 449 - Release Date: 18-5-2004
 
In article <40bb78eb$0$1764$c3e8da3@news.astraweb.com>,
Frank Bemelman <f.bemelmanx@planet.invalid.nl> wrote:

I've copied it to here:
www.planet.nl/~bemel141/images/Rotary_Encoder_bounce.jpg
Got it, thank you Frank.

There must be something really funny going on here.
Both A and B jump with the same timing. So it looks
as though the Common connection (inside the device)
is bouncing to an open-circuit at every closing edge
of B.

It might also do it on the opening edge, but A and B
are both already open-circuit at that instant, so any
open-circuit bounce of the Common would not be seen.

--
Tony Williams.
 
I can see why the slow rise after 2.5v or so on a normal transition. I have
100 k pullups direct on the encoder lines, then a series 100 k resistor to a
10 nF cap to earth, and the processor pins - which are high impedance
inputs. The scope probes were directly on the encoder lines for the picture.
So when the encoder is spun, the cap charges to around 1/2 rail on average,
and then the line is released by the encoder switch. So you get a fast rise
to the cap average voltage, then slow as the cap charges through the 100 k
resistors. But when the cap voltage is already high because the encoder
line has been high a while, and bounces low, it returns high - to the cap
voltage - almost instantly.

We could use lower pullups, but when I designed it this way, I was expecting
contact bounce, and wanted a timeconstant of around 1 msec, with reasonable
size caps. Power drain is also somewhat an issue. These encoders leave
both lines held low on alternate detents, so the pullups draw current. I
could afford 10 k, ie 1 ma drain total, but not 1 k.

Power supply and long line bounce are not an issue here. In fact the whole
power supply, encoder lines and processor are within about 1 inch of each
other. All the problems stem from within the encoder.

Interestingly, when you rotate the encoder (say) clockwise, you only get
bounce on the A line when the B line transitions, and only when you rotate
a/c do you get bounce on the B line from the A transition. This definitely
makes me think the problem is within the encoder mechanism itself.
I just tried another encoder of the same type - probably the same batch -
since the supplier only had 6 in stock - and it does exactly the same,
although perhaps not as often.

I am still playing with Frank's suggestion of fast polling the lines with a
timer, and doing no debounce, but still have to get the software right for
this.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
"Frank Bemelman" <f.bemelmanx@planet.invalid.nl> wrote in message
news:40baf98f$0$325$c3e8da3@news.astraweb.com...
"Adrian Jansen" <qqv@noqqwhere.com> schreef in bericht
news:40ba9482@duster.adelaide.on.net...
Here is jpg of a scope shot of the encoder bounce, showing bounce on the
A
line co-incident with the B line transitions.

The strange thing is that when contact A opens in a normal way,
the voltage rises from 0V to 2.5V and then rises slowly furhter,
but when it opens due to bouncing, it rises from 0V to 4V ????

How do you do that? Can we see a piece of schematic showing
the encoder, filter and uC inputs?

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)
 

Welcome to EDABoard.com

Sponsor

Back
Top