4026 decade counter: switch bounce, ungated C output

A

Adam Funk

Guest
I've been playing with some 4026 decade counters (the ones with output
suitable for direct connection to 7-segment LEDs) based on some
material in the _Make: Electronics_ book.


The book mentions switch bounce when using a push-button switch, &
says "The simplest option [to debounce the switch] is to put a small
capacitor in parallel with the switch, to absorb the fluctuations; but
this is less than ideal." I tried it anyway, & found that a 100 nF
capacitor does the job quite well, but 33 nF and 1 nF capacitors
don't. What is bad about using a capacitor for this?

I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.


--
I used to be better at logic problems, before I just dumped
them all into TeX and let Knuth pick out the survivors.
-- plorkwort
 
On Mon, 06 Aug 2012 13:01:34 +0100, Adam Funk <a24061@ducksburg.com> wrote:

I've been playing with some 4026 decade counters (the ones with output
suitable for direct connection to 7-segment LEDs) based on some
material in the _Make: Electronics_ book.


The book mentions switch bounce when using a push-button switch, &
says "The simplest option [to debounce the switch] is to put a small
capacitor in parallel with the switch, to absorb the fluctuations; but
this is less than ideal." I tried it anyway, & found that a 100 nF
capacitor does the job quite well, but 33 nF and 1 nF capacitors
don't. What is bad about using a capacitor for this?
As you found out, it's not reliable. The value of this capacitor is dependent
on the timing of the switch bounce. If that changes the circuit can become
flaky. It can be done but you have to be careful and it's often a source of
headaches. The perfect debounce is a couple of cross-coupled gates (RS flip
flop) and a SPDT switch but it's usually impractical so some version of a
filter is used.

I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.
Apparently it's needed for divide by 60 and divide by 12. The 'c' segment is
unique in that it's lit with every code except '2'. I don't see their
circuits and I haven't thought about it for more than thirty seconds but I
imagine they're feeding the '2' back to the reset for a divide by 12. This
logic should be valid whether or not the display is gated.
 
On Mon, 06 Aug 2012 13:01:34 +0100, Adam Funk <a24061@ducksburg.com>
wrote:

I've been playing with some 4026 decade counters (the ones with output
suitable for direct connection to 7-segment LEDs) based on some
material in the _Make: Electronics_ book.


The book mentions switch bounce when using a push-button switch, &
says "The simplest option [to debounce the switch] is to put a small
capacitor in parallel with the switch, to absorb the fluctuations; but
this is less than ideal." I tried it anyway, & found that a 100 nF
capacitor does the job quite well, but 33 nF and 1 nF capacitors
don't. What is bad about using a capacitor for this?

I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.
Surf on "debounce". There are a lot of better ways than just a
capacitor. (And the size of the capacitor, alone, is likely to be
"user" dependent :)

...Jim Thompson
--
| James E.Thompson, CTO | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
 
On Mon, 6 Aug 2012, Adam Funk wrote:

I've been playing with some 4026 decade counters (the ones with output
suitable for direct connection to 7-segment LEDs) based on some
material in the _Make: Electronics_ book.


The book mentions switch bounce when using a push-button switch, &
says "The simplest option [to debounce the switch] is to put a small
capacitor in parallel with the switch, to absorb the fluctuations; but
this is less than ideal." I tried it anyway, & found that a 100 nF
capacitor does the job quite well, but 33 nF and 1 nF capacitors
don't. What is bad about using a capacitor for this?

Switch bounce isn't the problem of the counter. The switch goes from one
state to the other, and for a lot of things, it does. But for digital
logic that can respond really fast, it sees the "bounce" from the switch,
where the switch alternates between the two states at a very fast rate,
before settling on the other one. Since the counter can count fast, it
sees those pulses, and counts them.

One problem with a capacitor is that if you start using too large a value,
you end up slowing down real switch output. I suspect with the 100uF you
won't be able to advance the count by the switch at a very fast rate, the
capacitor slowing things down.

The traditional way is a couple of cross connected nand gates, the output
of one goes to the input of the other, and the same with the second gate,
the switch is a single pole double throw, and its common point goes to
ground, the output terminals go to the so far unused inputs of the nand
gates. It is a latch, it triggers on the first pulse from the switch,
doesn't reset until the switch is released.


I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.

Pine 14, according to Don Lancaster's CMOS Cookbook, is an output. He
labels it "2 out" and says it only goes low on count 2.

Since it's an output, it would never be grounded. Most logic families
will be damaged if you short an output to ground.

Clock Enable, pin 2, if that's not high the pulses on the clock input, pin
1, will be ignored.

Display Enable, pin 3, only controls the output to the readout. A low on
that pin turns off the display, so you can sleep at night, or as Don
Lancaster suggests, it's a way of controlling the brightness of the
display by clocking the Display Enable at a fast rate, changing the duty
cycle controls the brightness.

Michael
 
On 2012-08-06, krw@att.bizzzzzzzzzzzz wrote:

On Mon, 06 Aug 2012 13:01:34 +0100, Adam Funk <a24061@ducksburg.com> wrote:

I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.

Apparently it's needed for divide by 60 and divide by 12. The 'c' segment is
unique in that it's lit with every code except '2'. I don't see their
circuits and I haven't thought about it for more than thirty seconds but I
imagine they're feeding the '2' back to the reset for a divide by 12. This
logic should be valid whether or not the display is gated.
Well duh. I think it was the capital C that threw me off, whereas the
rest of the data sheet uses lower-case letters for the display
segments. Thanks.


--
Classical Greek lent itself to the promulgation of a rich culture,
indeed, to Western civilization. Computer languages bring us
doorbells that chime with thirty-two tunes, alt.sex.bestiality, and
Tetris clones. (Stoll 1995)
 
On 2012-08-06, Michael Black wrote:

On Mon, 6 Aug 2012, Adam Funk wrote:

I've been playing with some 4026 decade counters (the ones with output
suitable for direct connection to 7-segment LEDs) based on some
material in the _Make: Electronics_ book.


The book mentions switch bounce when using a push-button switch, &
says "The simplest option [to debounce the switch] is to put a small
capacitor in parallel with the switch, to absorb the fluctuations; but
this is less than ideal." I tried it anyway, & found that a 100 nF
capacitor does the job quite well, but 33 nF and 1 nF capacitors
don't. What is bad about using a capacitor for this?

Switch bounce isn't the problem of the counter. The switch goes from one
state to the other, and for a lot of things, it does. But for digital
logic that can respond really fast, it sees the "bounce" from the switch,
where the switch alternates between the two states at a very fast rate,
before settling on the other one. Since the counter can count fast, it
sees those pulses, and counts them.

One problem with a capacitor is that if you start using too large a value,
you end up slowing down real switch output. I suspect with the 100uF you
won't be able to advance the count by the switch at a very fast rate, the
capacitor slowing things down.

The traditional way is a couple of cross connected nand gates, the output
of one goes to the input of the other, and the same with the second gate,
the switch is a single pole double throw, and its common point goes to
ground, the output terminals go to the so far unused inputs of the nand
gates. It is a latch, it triggers on the first pulse from the switch,
doesn't reset until the switch is released.
Interesting, thanks.


I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.

Pine 14, according to Don Lancaster's CMOS Cookbook, is an output. He
labels it "2 out" and says it only goes low on count 2.

Since it's an output, it would never be grounded. Most logic families
will be damaged if you short an output to ground.
Oops. I double-checked the book and it definitely shows it grounded.
By connecting it to an LED & series resistor, however, I've seen what
it does --- exactly what you say.


Clock Enable, pin 2, if that's not high the pulses on the clock input, pin
1, will be ignored.

Display Enable, pin 3, only controls the output to the readout. A low on
that pin turns off the display, so you can sleep at night, or as Don
Lancaster suggests, it's a way of controlling the brightness of the
display by clocking the Display Enable at a fast rate, changing the duty
cycle controls the brightness.
Thanks. I understood those but failed to get "C-SEGMENT".


--
The three-martini lunch is the epitome of American efficiency.
Where else can you get an earful, a bellyful and a snootful at
the same time? [Gerald Ford, 1978]
 
On 2012-08-07, Adam Funk wrote:

On 2012-08-06, Michael Black wrote:

On Mon, 6 Aug 2012, Adam Funk wrote:

I'm also wondering what pin 14 is for. The data sheet calls it
UNGATED "C-SEGMENT" and says it's not gated by DISPLAY ENABLE, a
feature required for certain divider functions. The Make book labels
it "Not-2 output" & the example circuits show it grounded, but doesn't
(unless I've missed something) explain what it's for.

Pine 14, according to Don Lancaster's CMOS Cookbook, is an output. He
labels it "2 out" and says it only goes low on count 2.

Since it's an output, it would never be grounded. Most logic families
will be damaged if you short an output to ground.

Oops. I double-checked the book and it definitely shows it grounded.
By connecting it to an LED & series resistor, however, I've seen what
it does --- exactly what you say.

The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?



--
The kid's a hot prospect. He's got a good head for merchandising, an
agent who can take you downtown and one of the best urine samples I've
seen in a long time. [Dead Kennedys t-shirt]
 
Adam Funk wrote:
The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Let it float.
 
On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com>
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?
Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

CMOS inputs usually have no pull-up or pull-down - an unconnected
input will float to whatever level it wishes, causing mysterious bugs,
and possibly excess current in the input stages, if it goes to a
"maybe" level.


--
Peter Bennett, VE7CEI
peterbb (at) telus.net
GPS and NMEA info: http://vancouver-webpages.com/peter
Vancouver Power Squadron: http://vancouver.powersquadron.ca
 
On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett <peterbb@somewhere.invalid>
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

CMOS inputs usually have no pull-up or pull-down - an unconnected
input will float to whatever level it wishes, causing mysterious bugs,
and possibly excess current in the input stages, if it goes to a
"maybe" level.
Unused inputs may not do any functional problems if left floating. Data pins,
for example, won't cause any problems if floating because no matter what the
data, nothing unexpected will happen. However, CMOS inputs are high impedance
and as such are a perfect target for ESD. They should be tied to a rail just
to bleed off charge. Outputs will usually be driven to one state or the other
via a low impedance driver so ESD isn't as much of a problem. Tristate
outputs probably should have a resistor tieing them to one state or the other.
 
On 2012-08-08, krw@att.bizzzzzzzzzzzz wrote:

On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett <peterbb@somewhere.invalid
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)
I guess it doesn't do any harm to use my latest approach: stick an LED
& a series resistor on every otherwise unused output, just to see when
it blinks. :) And it makes the breadboard look more impressive.


CMOS inputs usually have no pull-up or pull-down - an unconnected
input will float to whatever level it wishes, causing mysterious bugs,
and possibly excess current in the input stages, if it goes to a
"maybe" level.

Unused inputs may not do any functional problems if left floating. Data pins,
for example, won't cause any problems if floating because no matter what the
data, nothing unexpected will happen. However, CMOS inputs are high impedance
and as such are a perfect target for ESD. They should be tied to a rail just
to bleed off charge. Outputs will usually be driven to one state or the other
via a low impedance driver so ESD isn't as much of a problem. Tristate
outputs probably should have a resistor tieing them to one state or the other.
That makes sense.


Thanks to everyone who answered.


--
A recent study conducted by Harvard University found that the average
American walks about 900 miles a year. Another study by the AMA found
that Americans drink, on average, 22 gallons of alcohol a year. This
means, on average, Americans get about 41 miles to the gallon.
http://www.cartalk.com/content/average-americans-mpg
 
On Wed, 08 Aug 2012 11:38:29 +1000, krw@att.bizzzzzzzzzzzz
<krw@att.bizzzzzzzzzzzz> wrote:

On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett
peterbb@somewhere.invalid
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

CMOS inputs usually have no pull-up or pull-down - an unconnected
input will float to whatever level it wishes, causing mysterious bugs,
and possibly excess current in the input stages, if it goes to a
"maybe" level.

Unused inputs may not do any functional problems if left floating. Data
pins,
for example, won't cause any problems if floating because no matter what
the
data, nothing unexpected will happen. However, CMOS inputs are high
impedance
and as such are a perfect target for ESD. They should be tied to a rail
just
to bleed off charge. Outputs will usually be driven to one state or the
other
via a low impedance driver so ESD isn't as much of a problem. Tristate
outputs probably should have a resistor tieing them to one state or the
other.
Also the input may not be high or low causing both N and P transistors
further down the chain to turn partly on - which screws up CMOS power
consumption.


--
Using Opera's revolutionary email client: http://www.opera.com/mail/
 
On Wed, 08 Aug 2012 10:32:59 +0100, Adam Funk <a24061@ducksburg.com> wrote:

On 2012-08-08, krw@att.bizzzzzzzzzzzz wrote:

On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett <peterbb@somewhere.invalid
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

I guess it doesn't do any harm to use my latest approach: stick an LED
& a series resistor on every otherwise unused output, just to see when
it blinks. :) And it makes the breadboard look more impressive.
It just eats a lot of power. Make sure the outputs can handle the current -
all of them together (you don't exceed the current in the power or ground
pins).
 
On Wed, 08 Aug 2012 21:15:06 +1000, "David Eather" <eather@tpg.com.au> wrote:

On Wed, 08 Aug 2012 11:38:29 +1000, krw@att.bizzzzzzzzzzzz
krw@att.bizzzzzzzzzzzz> wrote:

On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett
peterbb@somewhere.invalid
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

CMOS inputs usually have no pull-up or pull-down - an unconnected
input will float to whatever level it wishes, causing mysterious bugs,
and possibly excess current in the input stages, if it goes to a
"maybe" level.

Unused inputs may not do any functional problems if left floating. Data
pins,
for example, won't cause any problems if floating because no matter what
the
data, nothing unexpected will happen. However, CMOS inputs are high
impedance
and as such are a perfect target for ESD. They should be tied to a rail
just
to bleed off charge. Outputs will usually be driven to one state or the
other
via a low impedance driver so ESD isn't as much of a problem. Tristate
outputs probably should have a resistor tieing them to one state or the
other.


Also the input may not be high or low causing both N and P transistors
further down the chain to turn partly on - which screws up CMOS power
consumption.
That's a good point, depending on the logic. High-speed gates tend to have a
lot of shoot-thru, which will show up if the gates are allowed to hang in the
threshold region.
 
On 2012-08-08, krw@att.bizzzzzzzzzzzz wrote:

On Wed, 08 Aug 2012 10:32:59 +0100, Adam Funk <a24061@ducksburg.com> wrote:

On 2012-08-08, krw@att.bizzzzzzzzzzzz wrote:

On Tue, 07 Aug 2012 16:02:54 -0700, Peter Bennett <peterbb@somewhere.invalid
wrote:

On Tue, 07 Aug 2012 21:22:23 +0100, Adam Funk <a24061@ducksburg.com
wrote:


The book has a "no floating pins" sidebar & warns that all the input
pins on a CMOS need to be connected to something (either ground or
Vcc, if nothing else). But what is the right thing to do with an
unneeded *output* pin?

Leave unused output pins unconnected - the chip will drive them to
whatever state it wants. (if the chip wants to drive it high, you
don't want to tie the pin low, or vice versa, otherwise excessive
current will flow in the output driver.)

I guess it doesn't do any harm to use my latest approach: stick an LED
& a series resistor on every otherwise unused output, just to see when
it blinks. :) And it makes the breadboard look more impressive.

It just eats a lot of power. Make sure the outputs can handle the current -
all of them together (you don't exceed the current in the power or ground
pins).

Thanks. I'll check. (No magic smoke has escaped yet.)


--
Some say the world will end in fire; some say in segfaults.
[XKCD 312]
 

Welcome to EDABoard.com

Sponsor

Back
Top