4017 counter signal to toggle between two PWM signals

crutschow

Joined Mar 14, 2008
38,674
Below is the LTspice simulation of my take on the 555 and CD4017 circuit to do what you want.

The first 555, U3 generates the slow CLK pulse to the CD4017 counter to alternate between the two PWM signals.

U1 generates pulses with a nominal 20ms period (Out, blue trace) that goes to the servo.

U2 causes the pulse width to alternate between a nominal 1ms and 2ms, as it sequences through its 5 pulse sequence (yellow trace) and alternately applys 6V (for1ms) and 0V (for 2ms) to R5.

When Q9 goes high at the last pulse, that Stop signal (brown trace) at the input to NAND gate U4 pulls the 555 Reset input low and stops it from outputting pulses.

To start the sequence, the NAND gate Start input (from an IR sensor input if desired) goes momentarily from 6V to 0V (green trace).
(You can use a spare NAND gate as in inverter if you want the Start signal to go from 0V to 6V instead.)

1574732052159.png
 

crutschow

Joined Mar 14, 2008
38,674
Here's the circuit using two 2N3904 transistors as a simple NAND gate.
You can use just about any small NPN BJT in place of the 2N3904's.

1574806956314.png
 
Last edited:

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Okay its weekend and I'm finally in the work shop.

I am using my "own" circuit from where we left at comment #15

I would like to use crutschow solution to start and stop the circuit wit two transistors as a NAND gate. And I have put it in the circuit. for now I have replaced the IR sensor though with a switch button connected to vcc.

I does not work, but I am not sure I have connected the 4017 timer correct to the simple NAND gate. Is it correct of me to connect the diode array to the base of Q2 through a 100K resistor?
and will two bc547b work as nand gate?
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
I've put in 3904 transistors as you labeled in the diagram.
The circuit starts up instantly when power is supplied. But that is okay. It's not that important.
But it does not stop after one sequence.

I've been checking what I have put together and can't seem to find out if I may have connected it wrong.
Are you able to spot something in this picture?
 

Attachments

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
In the picture is a yellow jumper wire. Thats the one you are looking for. I connected it shortly to vcc and ground to make it switch but nothing happens.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
I've put in 3904 transistors as you labeled in the diagram.
The circuit starts up instantly when power is supplied. But that is okay. It's not that important.
But it does not stop after one sequence.

I've been checking what I have put together and can't seem to find out if I may have connected it wrong.
Are you able to spot something in this picture?
I was pulsing it. It is the yellow jumper wire in the top of the picture.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
I'm confused.
In post #32 you say
So what do you mean "nothing happens"?

To stop after one sequence the input to Q1 needs to stay high.
Putting it momentarily to ground should restart the sequence.
Im sorry if I mislead you. I meant that the circuit doesn't react on the NAND gate but now I know it was because it has to stay high. I mixed it up with the function of a mosfet. Im sorry about that.

So it actually works, only the IR only outputs when it detects movement so the circuit will run continuously.
I think I have to switch the IC's around because the second 555 timer runs all the time. I should make sure they dont use up the battery when its not necessary. I guess your circuit takes that into account right?:)
 

danadak

Joined Mar 10, 2018
4,057
I am trying another way around in my project concerning a "Santa Jumping Jack" where I want a servo motor to simulate 5 pulls in the string of the santa jumping jack.

I have found a 555-circuit that provides the two PWM signals I need for the servo motor to toggle between to positions 0 and 180 degrees when pushing the two buttons.
View attachment 192514

I need help to replace the two buttons (forward and reverse) with something automated that simulates a push on the two buttons combined with this 4017 circuit:
View attachment 192603
I want a 4017 counter to control when "Forward" and when "Reverse".
When 4017 outputs a signal the position of the servo motor shall be "forward" and when there is no output signal from 4017 the servo motor position shall be "reverse".

Can anyone help me with a solution to this?

For future work here is a single chip approach. The buttons are debounced and control
a mux to select the appropriate PWM output. This is all onchip, and a bunch of other
capabilities. When a button is pressed the SR FF is either set or reset to select the correct
PWM output. I did this async, can be done sync so that no jitter in the servo occurs when
switched from one PWM to the other. The design will start up in a known state with no
output glicthing.

Right hand window shows a lot of other resources remain that youc an use, analog as well
as digital. This requires two lines of code be written

Code:
TCPWM_1_Start( );
TCPWM_2_Start( );

A small board for debug, realization IS $ 10.


1575203803120.png

Note I missed the point where you want to eliminate the buttons. Thats trivial
to do, which also gets rid of the debouncers. And just place in design either
a simple pulser to the mux. Something like this -

1575204147136.png

Regards, Dana.
 

Attachments

Last edited:
Top