IC 4017 output modification

AnalogKid

Joined Aug 1, 2013
12,143
Also, a value of 1uF seems more appropriate for C1.
Because 0.33 uF is too small, or because 47 uF is too large? Did you see the update changing C1 to 47 uF.

R1-C1 work to debounce the switch contacts, so one button press is not seen by the 4017 as a dozen or more clock edges. R1 discharges C1 over time, and the component values set how long it takes for the 4017 EN- input to see a logical 1.

Turns out that because the chip still is powered (its GND connection does not go through the switch), the current from a high output, through an LED, and through R2 also discharges C1. R2 is is kinda in parallel with R1, and is the dominant resistance in the discharge path. R2 is chosen to set the LED current, and then C1 is chosen to set the debounce period.

ak
 
Last edited:

ThePanMan

Joined Mar 13, 2020
921
Well, if you read this carefully:
No, AK's circuit advances on the push of the button.
eetech00's circuit advances on the lift of the button.
I certainly don't want to start an argument with anyone. Here's my take on what the TS has stated, just worded a different way:

When the button is pressed - and while it's still held down - [edit] the counter advances one step [end edit] LED 1 lights up. As soon as the switch is released the counter does not change states but the LED goes out.
Upon the next pressing and holding of the button the counter advances one step AND LED 2 lights up. As soon as the switch is released the counter does not change states but LED 2 goes out.
Upon the next pressing and holding of the button the counter advances yet again and LED 3 lights up. As soon as the switch is released the counter does not change states but LED 3 goes out.

In short, one of three LED's are lit according to the count AND during - and ONLY during - the button being held down. MY offering does that. Since at the initial startup of the circuit output 0 will be actively on, but with no LED's connected, upon pressing the button the counter advances to output 1. While the button is STILL pressed down LED 1 lights, but goes out as soon as the button is released. Then the same thing with the next step and LED 2. Then again with LED 3. Output 4 is used to reset the circuit to output 0, which has no LED's connected.

IF the TS wants to use outputs 0, 1 & 2 and use 3 for the reset then there is no OFF period in the chain of events. You go from 1 to 2 to 3 to 1 to 2 to 3. MY circuit goes from OFF (output 0) to 1 to 2 to 3 to RESET (back to 0) and during this last "Reset" event NO LED's are lit.

Your opinion or take on the ask may vary, but this is the way I'm understanding the request.
 
Last edited:

ThePanMan

Joined Mar 13, 2020
921
when press button in first time LED1 on LED2 and LED3 off
To achieve this the counter MUST be at Q0. When press button in first time LED1 on, LED2 and LED3 off". This would suggest using Q1 for LED1, Q2 for LED2 and Q3 for LED3. Q4 would then have to be the Reset command to change back to output Q0.
 

ThePanMan

Joined Mar 13, 2020
921
Because 0.33 uF is too small, or because 47 uF is too large? Did you saw the update changing C1 to 47 uF.

R1-C1 work to debounce the switch contacts, so one button press is not seen by the 4017 as a dozen or more clock edges. R1 discharges C1 over time, and the component values set how long it takes for the 4017 EN- input to see a logical 1.

Turns out that because the chip still is powered (its GND connection does not go through the switch), the current from a high output, through an LED, and through R2 also discharges C1. R2 is is kinda in parallel with R1, and is the dominant resistance in the discharge path. R2 is chosen to set the LED current, and then C1 is chosen to set the debounce period.

ak
Good cover. I wondered about switch debounce but didn't chase that rabbit thinking someone would OR the TS has already solved that issue.
 

eetech00

Joined Jun 8, 2013
4,705
When the button is pressed - and while it's still held down - [edit] the counter advances one step [end edit] LED 1 lights up.
Agreed.

As soon as the switch is released the counter does not change states but the LED goes out.
Disagree.

This is the way it is described in the second description paragraph:
Edit: changed "first" to "second"

But In the "desired" description:
"when the button is released all LEDS off "
 

ThePanMan

Joined Mar 13, 2020
921
As soon as the switch is released the counter does not change states but the LED goes out.
Disagree.

This is the way it is described in the second description paragraph:
Edit: changed "first" to "second"

But In the "desired" description:
"when the button is released all LEDS off "
I'm seeing essentially nine steps:
Step
  1. 1) Power up. No LED's lit.
  2. 2) Press Button (PB), Counter advances to next output. LED1 lit WHILE PB is held down.
  3. 3) Release PB, LED1 off
  4. 4) PB. Counter advances to next output. LED2 lit while PB is held down.
  5. 5) Release PB, LED2 off
  6. 6) PB. Counter advances to next output. LED3 lit while PB is held down.
  7. 7) Release PB, LED3 off
  8. 8) PB. Counter advances to next output and resets to output 0.
  9. 9) Release PB. Nothing happens. No change of state, no LED's lit at all.

@eetech00 you say you agree with me. Help me understand how and why you see it differently.

Also noticed the TS has not rejoined the conversation.
 

ThePanMan

Joined Mar 13, 2020
921
Re reading the posts to try and get a clearer picture of what everyone is saying.
there should be an "all off" time between "on" times.
That would seem to be the case. But then with the push of the PB, LED 1 would be lit regardless of the state of the PB. To turn LED 1 OFF would require a second push of the PB. Another PB for LED 2 ON and another PB for LED 2 OFF. Same for the third. I didn't get that sense. I sensed that the TS only wants any of the three LED's to be lit while he holds the PB down. So regardless of the state of the circuit, when the PB is not pushed down there is nothing going on. No LED's, nearly no current being drawn by the counter.

I'm TRYing to understand how you're seeing it.
 

ThePanMan

Joined Mar 13, 2020
921
Normally working with 3 output LED,
when press button in first time LED1 on LED2 and LED3 off
,then released button in first time LED1 still on LED2 and LED3 still off.
When press button in secend time LED1 off LED2 on LED3 off
,then released button in secend time LED1 still off LED2 still on LED3 still off.
When press button in third time LED1 off LED2 off LED3 on
,then released button in third time LED1 still off LED2 still offLED3 still on.
This is the working circuit. Pushing the PB steps from one LED to the next. Each LED remains lit until the circuit clocks to the next LED. Simple stepping LED circuit.
But i want to modification output to this function.
when press button in first time LED1 on LED2 and LED3 off
,then released button in first time all LED off
When press button in secend time LED1 off LED2 on LED3 off
,then released button in secend time all LED off
When press button in third time LED1 off LED2 off LED3 on
,then released button in third time all LED off
Here's the key:
"when press button in first time LED1 on LED2 and LED3 off
,then released button in first time all LED off"

This is where I'm stuck believing the desired function is to have any one of the LED's lit ONLY when the button is held down.
"then released button in secend time all LED off"
"then released button in third time all LED off"

Unless there's a way to clock the chip on the positive going edge then clock again on the negative going edge - having the extra outputs flying open (no LED's connected) is the only other way I can see it working. In THIS case the circuit in post #9 WOULD (or should) achieve the same function. But with a higher parts count. Like Engineer Montgomery Scott said of the Excelsior "The fancier the plumbing the easier it is to stop up the drain."

In the circuit I drew, the PB clocks the counter AND saturates the transistor which provides a pathway to ground for all LED's so that the active LED is only lit when the transistor provides ground for the LED's. When the PB opens the ground goes away and the LED goes out.

OK, I'm done. Unless someone can point out something I missed.
 
Last edited:

k1ng 1337

Joined Sep 11, 2020
1,038
Because 0.33 uF is too small, or because 47 uF is too large? Did you saw the update changing C1 to 47 uF.

R1-C1 work to debounce the switch contacts, so one button press is not seen by the 4017 as a dozen or more clock edges. R1 discharges C1 over time, and the component values set how long it takes for the 4017 EN- input to see a logical 1.

Turns out that because the chip still is powered (its GND connection does not go through the switch), the current from a high output, through an LED, and through R2 also discharges C1. R2 is is kinda in parallel with R1, and is the dominant resistance in the discharge path. R2 is chosen to set the LED current, and then C1 is chosen to set the debounce period.

ak
I have to breadboard the circuit to confirm I'm not seeing a simulation artifact. What is Vcc?
 

eetech00

Joined Jun 8, 2013
4,705
I'm seeing essentially nine steps:
Step
  1. 1) Power up. No LED's lit.
  2. 2) Press Button (PB), Counter advances to next output. LED1 lit WHILE PB is held down.
  3. 3) Release PB, LED1 off
  4. 4) PB. Counter advances to next output. LED2 lit while PB is held down.
  5. 5) Release PB, LED2 off
  6. 6) PB. Counter advances to next output. LED3 lit while PB is held down.
  7. 7) Release PB, LED3 off
  8. 8) PB. Counter advances to next output and resets to output 0.
  9. 9) Release PB. Nothing happens. No change of state, no LED's lit at all.

@eetech00 you say you agree with me. Help me understand how and why you see it differently.

Also noticed the TS has not rejoined the conversation.
Ageed.
What you have described above is what I've been writing and what I understand the TS wants.
The only thing not stated is that the TS explicitly states that "all LEDS off" between button presses.
What the counter does to achieve this is up to the designer.
 

eetech00

Joined Jun 8, 2013
4,705
I have to breadboard the circuit to confirm I'm not seeing a simulation artifact. What is Vcc?
The OP doesn't state the required supply voltage, but any RC constant used will be will be affected by it.
I chose 9v as a convenience for the user (could be a 9v battery).
 

AnalogKid

Joined Aug 1, 2013
12,143
What is Vcc?
Vcc stands for Voltage Common Collector, a term that evolved in the early days of solid state circuit design as the designation for the non-ground rail in a circuit. In a typical NPN circuit this is the positive rail. There is a sister term, Vee, for the negative rail. You see these a lot on opamp datasheets and app notes. Analog Devices publications are big on this. I suppose it actually should be Vce, for Voltage Common Emitter, but that term already was in use as Voltage Collector to Emitter. Technically, for a CMOS circuit it should be Vdd. The d stands for drain. It follows the same double letter pattern even though that works correctly for Vcc. Many CMOS logic datasheets show what we call the chip's ground pin labeled Vss.

I skimmed through the thread, and there is no mention of a Vcc value. In fact, the TS has not posted anything after #1.

Note that the time window in a normal debounce circuit is independent of the value of Vcc. The time is based on a percentage, which is determined by the values of a resistor and a capacitor; neither of which is voltage-variable. However, in this circuit there is an LED in series with the cap-discharging resistor, and the voltage across an LED is essentially constant. It is a smaller percentage of 12 V than of 5 V, so the debounce period now has a component that is Vcc related. Not the end of the world, and in fact a nice little R-C circuit problem.

ak
 

k1ng 1337

Joined Sep 11, 2020
1,038
Vcc stands for Voltage Common Collector, a term that evolved in the early days of solid state circuit design as the designation for the non-ground rail in a circuit. In a typical NPN circuit this is the positive rail. There is a sister term, Vee, for the negative rail. You see these a lot on opamp datasheets and app notes. Analog Devices publications are big on this. I suppose it actually should be Vce, for Voltage Common Emitter, but that term already was in use as Voltage Collector to Emitter. Technically, for a CMOS circuit it should be Vdd. The d stands for drain. It follows the same double letter pattern even though that works correctly for Vcc. Many CMOS logic datasheets show what we call the chip's ground pin labeled Vss.

I skimmed through the thread, and there is no mention of a Vcc value. In fact, the TS has not posted anything after #1.

Note that the time window in a normal debounce circuit is independent of the value of Vcc. The time is based on a percentage, which is determined by the values of a resistor and a capacitor; neither of which is voltage-variable. However, in this circuit there is an LED in series with the cap-discharging resistor, and the voltage across an LED is essentially constant. It is a smaller percentage of 12 V than of 5 V, so the debounce period now has a component that is Vcc related. Not the end of the world, and in fact a nice little R-C circuit problem.

ak
I should have asked how many volts for Vcc but it doesn't seem to matter anymore. I was getting odd behaviour from the CD4017 model.

I wanted to look at the voltage change across C1 so I added series resistance to V2 to simulate current limiting on the supply otherwise the node sits at 9V.

The odd part is a series resistance of > 10mΩ for V2 causes the chip to increment backwards. I fixed this apparent artifact by using a diode current limit model instead.

Not only that, there are current spikes while the LEDs should be off. The duration is around 100ns so I suspect these are also artifacts. The short duration suggest parasitic elements in the circuit will prevent the voltage from climbing high enough to turn on the LEDs.

Have you tested the circuit on the breadboard? It will be interesting to see what checks out.

akz0.png

akz1.png
 

ThePanMan

Joined Mar 13, 2020
921
What you have described above is what I've been writing and what I understand the TS wants.
The only thing not stated is that the TS explicitly states that "all LEDS off" between button presses.
What the counter does to achieve this is up to the designer.
This is where we are seeing things differently. The TS (hasn't been here in four days, nor have they posted a second post) wants the LED's to be lit ONLY when the button is pressed and held down. As soon as the button is let go NO LED's are lit. Your circuit required a push of the button to light LED1 then another push of the button to turn it off. So the TS wants three presses of the button to clock from LED 1 to 2 to 3. And each LED is only lit while the TS holds the button down.

Anyway, I don't think the TS is going to be back.
 

eetech00

Joined Jun 8, 2013
4,705
Your circuit required a push of the button to light LED1 then another push of the button to turn it off.
No. A press and hold clocks the circuit once and lights the LED. A button release clocks the circuit again and turns it off.
I guess you don't quite understand how the circuit works.
 

ThePanMan

Joined Mar 13, 2020
921
No. A press and hold clocks the circuit once and lights the LED. A button release clocks the circuit again and turns it off.
I guess you don't quite understand how the circuit works.
Didn't look close enough at your circuit. OK, I see your point now. You're clocking with the rising edge then again with the falling edge. OK, I got you now. ")

Just that the one I drew lights the LED when the button is pressed. Each press of the button clocks the counter. And it's done with just an extra transistor. No need for inverting pulses with all that extra stuff.

Anyway - I get it now.
 
Using an AND gate and a BJT is superfluous. You won't need the AND gate. A NAND or an Inverter Buffer can do the same job as an AND gate and BJT. Better still, just a BJT to provide ground pathway (see below) will do even better. Just bias the transistor properly and you are good to go.

View attachment 319444
Could have drawn this better. And outputs 0, and 5 through 9 can be left open.
Hi
Is this the best way to stop initial output on power on cycle to the 4017

when I power up just for the first cycle the 4017 give random output
I’ve stopped both the 555 and 4017 by semi grounding the input signals with 10k resistor but still it fires an output on initial power on

the circuit I’ve made works perfectly there after just not on initial start up

cheers
 

Attachments

Top