4040 and 2716 EPROM; is this the way to set it up?

MrChips

Joined Oct 2, 2009
35,331
Here is another switch debounce circuit for SPST pushbuttons.

In this example, the charge time-constant is about 40ms. The discharge time-constant is reduced through the diode.

Switch-Debounce with NAND gate.jpg
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
Here is another switch debounce circuit for SPST pushbuttons.

In this example, the charge time-constant is about 40ms. The discharge time-constant is reduced through the diode.

View attachment 163261
And that is because it bypasses R2? I think those 40ms are based on R1, R2 and C1, (10K+10K)*2.2uF = 44ms.

I think my biggest knowledge gap,is how the current flows in both situations... I'll try to explain how I think it works, hope you can help me.

When S1 is NOT pressed, current flows form the source, through R1, is blocked by D1, through R2, through C1 to ground, till C1 is charged. I'm not sure about the lower input of the NAND... I'd say it is high at that moment, as current flows through R2 to it. The upper input of the NAND is always high. When C1 is charged, after 44ms, I'd say that current still flows to the lower input of the NAND, making/keeping it high.

When S1 is pressed, current flows through R1 to the upper input of the NAND, making it high, and current flows through S1 to ground. I guess when this happens, C1 discharges? Current does not flow through R2, because current has an faster /easier way to ground. C1 discharges, but in what direction.I guess when C1 is fully discharged, it pulls the lower input of the NAND low, hence making the output of the NAND high. I do understand the logic (I guess), but I need to learn what happens with the current.

I think when I understand this, I made quite some progress... I tried to simulate things with EveryCircuit, but it was not completely clear to me...
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
By the way, based on the info in this thread, I got things working. I actually did not use the ULN2803 and 8 LEDs, but I once got a few HP 8250-7340 hex displays. That was easy, after each push on the counter button, the 8 bit value is display in hex. Nice! Still, this is only to learn things.

What I'm a bit puzzeled about, again this has to do with how current flows, see my previous post in this thread, is if I want to reset MR on the 4040 when a certain output gets high, let's say Q11. When power is applied the 10uF C charges through the 8.2K R, current flows till it is fully charged, which keeps MR (active high) high. When S2 is pressed, the 10uF C discharges, actually nothing happens, but when S2 is released, the C charges again, which makes MR temporarily high (till the C is fully charged).

My idea is to make MR high, when Q11 becomes high, hence resetting the 4040. I added the diode to avoid when C charges, Q11, which is only an output, is connected to +5V either.But it doesn't work as planned, when I add the diode, the counter starts at 1 rather than 0. In logical terms, I don't know the impact of the potential difference decrease as the voltage drops approx. 0.6V because of the diode... And, does current flow from Q11,through the diode,only to MR, or does it prefer to flow to ground through the 8.2K resistor? And when Q11 gets high, I'm not sure what will happen with the C... Or do I need to add another diode between the junction of the cathode and the MR-line, and the junction between the C and the R to avoid current takes that route?

The problem here is that you need to know what happens, you can't see it. Another things is that sometimes my experiments work 999 out of 1,000 times or that it is not clear at first that I'm on my way destroying a port (for example by pulling to much current(, which can sometimes only be seen after quite some time and not instantly.

Hope you can help me with this as well. I know these are all very basis schematics, but the flow of current is the big puzzle for me...
 

Attachments

MrChips

Joined Oct 2, 2009
35,331
And that is because it bypasses R2? I think those 40ms are based on R1, R2 and C1, (10K+10K)*2.2uF = 44ms.

I think my biggest knowledge gap,is how the current flows in both situations... I'll try to explain how I think it works, hope you can help me.

When S1 is NOT pressed, current flows form the source, through R1, is blocked by D1, through R2, through C1 to ground, till C1 is charged. I'm not sure about the lower input of the NAND... I'd say it is high at that moment, as current flows through R2 to it. The upper input of the NAND is always high. When C1 is charged, after 44ms, I'd say that current still flows to the lower input of the NAND, making/keeping it high.

When S1 is pressed, current flows through R1 to the upper input of the NAND, making it high, and current flows through S1 to ground. I guess when this happens, C1 discharges? Current does not flow through R2, because current has an faster /easier way to ground. C1 discharges, but in what direction.I guess when C1 is fully discharged, it pulls the lower input of the NAND low, hence making the output of the NAND high. I do understand the logic (I guess), but I need to learn what happens with the current.

I think when I understand this, I made quite some progress... I tried to simulate things with EveryCircuit, but it was not completely clear to me...
The purpose of a switch debounce circuit is to remove any transients on both rising and falling switch transitions.
The NAND circuit was taken from a scenario where there is a positive going pulse in a noisy environment. It should work in this switch debounce application.

When the switch is idle (normally open), both inputs to the NAND gate are HIGH (the capacitor is fully charged), giving a logic-LOW output.

When the switch is pressed, both inputs go LOW. (The capacitor is discharged almost instantly through the diode.) The NAND gate output is HIGH. Any transients on the switch does not affect the outcome of the NAND gate because the input with the capacitor is held LOW.

When the switch is released, the upper input is pulled HIGH through R1 but may have transients.
The lower input is held LOW by the slowly charging capacitor. The NAND output goes LOW only after BOTH inputs are at logic-HIGH.
 

MrChips

Joined Oct 2, 2009
35,331
By the way, based on the info in this thread, I got things working. I actually did not use the ULN2803 and 8 LEDs, but I once got a few HP 8250-7340 hex displays. That was easy, after each push on the counter button, the 8 bit value is display in hex. Nice! Still, this is only to learn things.

What I'm a bit puzzeled about, again this has to do with how current flows, see my previous post in this thread, is if I want to reset MR on the 4040 when a certain output gets high, let's say Q11. When power is applied the 10uF C charges through the 8.2K R, current flows till it is fully charged, which keeps MR (active high) high. When S2 is pressed, the 10uF C discharges, actually nothing happens, but when S2 is released, the C charges again, which makes MR temporarily high (till the C is fully charged).

My idea is to make MR high, when Q11 becomes high, hence resetting the 4040. I added the diode to avoid when C charges, Q11, which is only an output, is connected to +5V either.But it doesn't work as planned, when I add the diode, the counter starts at 1 rather than 0. In logical terms, I don't know the impact of the potential difference decrease as the voltage drops approx. 0.6V because of the diode... And, does current flow from Q11,through the diode,only to MR, or does it prefer to flow to ground through the 8.2K resistor? And when Q11 gets high, I'm not sure what will happen with the C... Or do I need to add another diode between the junction of the cathode and the MR-line, and the junction between the C and the R to avoid current takes that route?

The problem here is that you need to know what happens, you can't see it. Another things is that sometimes my experiments work 999 out of 1,000 times or that it is not clear at first that I'm on my way destroying a port (for example by pulling to much current(, which can sometimes only be seen after quite some time and not instantly.

Hope you can help me with this as well. I know these are all very basis schematics, but the flow of current is the big puzzle for me...
You cannot pull too much current from an input port if you stay within the acceptable range of voltages for an input.

As for the functional description of the above circuit, you need to post the circuit with the description.
RESET should not affect the counting functionality of a counter circuit. Active RESET ought to set the counter to the reset state.
Note that CLOCK inputs may cause counter transition on the rising edge of the CLOCK or on the falling edge of the CLOCK. You can alter which edge is present by using a NOT gate or XOR gate (if you want to select the option).

Erratic counter performance can occur for many reasons:

1) poor power supply decoupling. Use 0.1μF capacitors across the power rails.
2) poor power supply regulation
3) poor power supply voltage
4) noisy CLOCK signal
5) improper CLOCK timing
6) improper timing on other control signals
7) overloading the counter outputs
8) non-CMOS 555 timer chips. Use LMC555 or TLC555 CMOS 555-timer chips
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
You cannot pull too much current from an input port if you stay within the acceptable range of voltages for an input.
My remark was actually in general. Due to the lack of knowledge, I might over time destroy something, what I'm not aware of now, I might end up in timing races, etc...
As for the functional description of the above circuit, you need to post the circuit with the description.
Maybe I misinterpreted you, but I added the latest schematic to the post or the post just above the one you replied on... Or do you mean I need to add it to every post where I refer to my schematic, but that would mean a lot of redundant schematics added to this thread.
RESET should not affect the counting functionality of a counter circuit. Active RESET ought to set the counter to the reset state.
Note that CLOCK inputs may cause counter transition on the rising edge of the CLOCK or on the falling edge of the CLOCK. You can alter which edge is present by using a NOT gate or XOR gate (if you want to select the option).
Maybe it was they way I set things up. In general, what I'm trying to understand and I would like to learn, is what exactly happens (and,I guess, that will be in terms of current flow); can you please comment on my logic in trying to understand what happens?
Erratic counter performance can occur for many reasons:
...
I think I'm safe here, this is just a CMOS 4040 counter, where I am the clock pressing a button ;-)
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
The purpose of a switch debounce circuit is to remove any transients on both rising and falling switch transitions.
The NAND circuit was taken from a scenario where there is a positive going pulse in a noisy environment. It should work in this switch debounce application.

When the switch is idle (normally open), both inputs to the NAND gate are HIGH (the capacitor is fully charged), giving a logic-LOW output.

When the switch is pressed, both inputs go LOW. (The capacitor is discharged almost instantly through the diode.) The NAND gate output is HIGH. Any transients on the switch does not affect the outcome of the NAND gate because the input with the capacitor is held LOW.

When the switch is released, the upper input is pulled HIGH through R1 but may have transients.
The lower input is held LOW by the slowly charging capacitor. The NAND output goes LOW only after BOTH inputs are at logic-HIGH.
Your remarks are about the logic, I think that part is clear. What I would like to know, to learn and to be able to design things myself, is what exactly happens in terms of current flow. Without that knowledge, I'm not able to understand what exactly happens. Can you please help me with that as well?
 

MrChips

Joined Oct 2, 2009
35,331
With regards multiple postings of schematics, that is not a problem.
It is difficult to describe a circuit when the circuit is on a different post or page. In this particular case, I wasn't sure what circuit you were describing.
 

MrChips

Joined Oct 2, 2009
35,331


In the circuit above, when the switch S1 is idle (in the open state) a small current about 1μA flows through R1 to the upper input of the NAND gate (assuming CMOS type 74HC132 or CD4093). The input will be close to Vcc (+5V).

At the same time, capacitor C1 will be charging up via current through R1 + R2 until C1 stops charging after reaching a voltage close to Vcc. At this point, the current through R2 will be about 1μA also, the input current of a CMOS input.

When the switch is closed, the upper input will be at 0V. The current through R1 = 5V/10kΩ = 50μA. This is inconsequential.

Current will also flow through D1 from the capacitor to GND, thus discharging the capacitor. Very quickly, the voltage of the lower input will fall below Vcc/2 (the CMOS switching threshold) and will continue to fall to about 0.6V (the diode voltage drop). The capacitor at a voltage below Vcc/2 will hold the output of the NAND gate in a HIGH state until the capacitor charges up to a voltage above Vcc/2 when the switch is released.
 

Thread Starter

georgedb

Joined Jul 29, 2017
49


In the circuit above, when the switch S1 is idle (in the open state) a small current about 1μA flows through R1 to the upper input of the NAND gate (assuming CMOS type 74HC132 or CD4093). The input will be close to Vcc (+5V).

At the same time, capacitor C1 will be charging up via current through R1 + R2 until C1 stops charging after reaching a voltage close to Vcc. At this point, the current through R2 will be about 1μA also, the input current of a CMOS input.

When the switch is closed, the upper input will be at 0V. The current through R1 = 5V/10kΩ = 50μA. This is inconsequential.

Current will also flow through D1 from the capacitor to GND, thus discharging the capacitor. Very quickly, the voltage of the lower input will fall below Vcc/2 (the CMOS switching threshold) and will continue to fall to about 0.6V (the diode voltage drop). The capacitor at a voltage below Vcc/2 will hold the output of the NAND gate in a HIGH state until the capacitor charges up to a voltage above Vcc/2 when the switch is released.
Very interesting, very helpful. It raises a million new questions, but I sort of got the hang from it. I guess the inputs of the NAND gate have a VERY high resistance (I think then it is called impedance)?
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
BTW: this calculation was correct?

"And that is because it bypasses R2? I think those 40ms are based on R1, R2 and C1, (10K+10K)*2.2uF = 44ms."
(quoting myself ;-) )
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
By the way, based on the info in this thread, I got things working. I actually did not use the ULN2803 and 8 LEDs, but I once got a few HP 8250-7340 hex displays. That was easy, after each push on the counter button, the 8 bit value is display in hex. Nice! Still, this is only to learn things.

What I'm a bit puzzeled about, again this has to do with how current flows, see my previous post in this thread, is if I want to reset MR on the 4040 when a certain output gets high, let's say Q11. When power is applied the 10uF C charges through the 8.2K R, current flows till it is fully charged, which keeps MR (active high) high. When S2 is pressed, the 10uF C discharges, actually nothing happens, but when S2 is released, the C charges again, which makes MR temporarily high (till the C is fully charged).

My idea is to make MR high, when Q11 becomes high, hence resetting the 4040. I added the diode to avoid when C charges, Q11, which is only an output, is connected to +5V either.But it doesn't work as planned, when I add the diode, the counter starts at 1 rather than 0. In logical terms, I don't know the impact of the potential difference decrease as the voltage drops approx. 0.6V because of the diode... And, does current flow from Q11,through the diode,only to MR, or does it prefer to flow to ground through the 8.2K resistor? And when Q11 gets high, I'm not sure what will happen with the C... Or do I need to add another diode between the junction of the cathode and the MR-line, and the junction between the C and the R to avoid current takes that route?

The problem here is that you need to know what happens, you can't see it. Another things is that sometimes my experiments work 999 out of 1,000 times or that it is not clear at first that I'm on my way destroying a port (for example by pulling to much current(, which can sometimes only be seen after quite some time and not instantly.

Hope you can help me with this as well. I know these are all very basis schematics, but the flow of current is the big puzzle for me...
I was wondering if my above logic is correct, and if the diode I added, see the schematic to that post, to prevent current flowing to Q11, which is an output, is a good solution, or that this third way of resetting (upon power-up, when pressing the button and when Q11 gets high) needs to be solved in a different way?
 

MrChips

Joined Oct 2, 2009
35,331


I now see the circuit to which you refer that contains Q11 (circuit above).

Q11 is an output pin from the 4040 binary counter. The purpose of the diode is to reset the counter when Q11 output goes HIGH.
This is unnecessary since only outputs Q0 to Q10 are to be used as address bits. When the 4040 count exceeds 11 bits (2047), the address will wrap around to 0. Q11 state can be ignored. There is no need to reset the counter.
 

Thread Starter

georgedb

Joined Jul 29, 2017
49


I now see the circuit to which you refer that contains Q11 (circuit above).

Q11 is an output pin from the 4040 binary counter. The purpose of the diode is to reset the counter when Q11 output goes HIGH.
This is unnecessary since only outputs Q0 to Q10 are to be used as address bits. When the 4040 count exceeds 11 bits (2047), the address will wrap around to 0. Q11 state can be ignored. There is no need to reset the counter.
Yeah, you got a point there... Just for my knowledge, so hypothetically in this case, if I would want to reset based on an output of the CMOS 4040 getting high, let's say Q11, would what I had in mind with the diode be an adequate solution?

PS: thanks again for your help, I'm really learning things here that I have not found in books... I wish there was something like an electronics class here in Amsterdam that I could go to every week.
 

MrChips

Joined Oct 2, 2009
35,331
It is a good idea to draw the truth table of what you are trying to do.

In this case, you want MR to go HIGH when either Q11 or RESET goes HIGH.

Q11 RESET MR
0 - - - 0 - - - 0
0 - - - 1 - - - 1
1 - - - 0 - - - 1
1 - - - 1 - - - 1

That looks like an OR gate.
You can use diodes and resistors to create a logic function if you have valid reasons for doing so.
 

Thread Starter

georgedb

Joined Jul 29, 2017
49
It is a good idea to draw the truth table of what you are trying to do.

In this case, you want MR to go HIGH when either Q11 or RESET goes HIGH.

Q11 RESET MR
0 - - - 0 - - - 0
0 - - - 1 - - - 1
1 - - - 0 - - - 1
1 - - - 1 - - - 1

That looks like an OR gate.
You can use diodes and resistors to create a logic function if you have valid reasons for doing so.
Wow, of course, never looked at it that way. The only downside of taking a readily available OR gate (IC) would be that my breadboard would become quite crowded, so I'll look for a diode/R-based OR-gate (I know about the diode-based AND gate), and I saw an OR-gate with diodes the other day...
 
Top