D-Type flip flop for toggle. Slap-a-duck

Thread Starter

sirchuck

Joined Feb 14, 2016
150
I have a vibration sensor switch and a LED circuit shoved inside a rubber duck. I want to slap the rubber duck and toggle it on, then slap it again to turn it off. This seems like it should be pretty simple, but when I started researching how to toggle I found D/T/JK flip flops.

The T flip-flop seemed perfect, you send it a signal from the vibration sensor and it would toggle the led on or off. Unfortunately, I couldn't find any for sale on E-bay, so I bought a bunch of D-Type flip flips.

Now I'm wondering how to wire up my D-Type flip-flop to turn my duck on and off based on jiggling my vibration sensor.

The D Flip Flop has 5 connections.
Vcc ( For incoming voltage ) check
CLK ( For my vibration sensor ) check
GND ( For ground ) check
Q ( Output toggle to LED ) check
D ( Data input ? ) --- What do i attach here so that Q will toggle? Do I wire directly to VCC ?

Do I need to throw my D-Type's away and hunt harder for a T-type flip flop ic?

Thanks !
 

crutschow

Joined Mar 14, 2008
34,912
No, the D-FF will readily work as a T FF..
But you need to deal with multiple triggers from vibration sensor, which will cause it to rapidly switch back and forth, so you need a way for the FF to only trigger once when it receives a bunch of pulses.

Here's an LTspice simulation of such a circuit.

The Q output follows the D input whenever a CLK pulse is detected so if you connect the /Q output to the D input, it will alternate states for every clock pulse.
R1C1 delsys this change at the D input so it only changes state once for a series of clock inputs until the D input reaches the logic level change value (about 1/2 the supply voltage.
So you can see below that the output only changes state for the first in a series of clock pulses (green trace).
If the series of pulses from the vibration sensor is too long and it triggers more than once, then just increase the value of C1 until it only changes state once.

I used 4.5V for the supply (as from 3 AAA alkalines) and drove the LED directly from the FF output.
If you want more than a couple mA through the LED to make it brighter, then you can add a transistor driver on the FF output, but a high brightness type LED may be bright enough with that current.

The signal from the vibration sensor must be at least 4V.

Power and ground for the CD4013 are not shown but must be connected, and all unused inputs for the other FF in the package must be grounded.

upload_2017-7-3_16-48-37.png
 

Thread Starter

sirchuck

Joined Feb 14, 2016
150
crutschow,

Ok, yes that's a good catch about needed to trap consecutive vibrations from the sensor, and I think I get what you did with the resistor and capacitor, but I do not understand what to connect to D in my situation from your 4013 chip. I don't have a |Q only a Q.

Do I need to invert Q and then attach that to D? What do I use to invert Q if so?
 

crutschow

Joined Mar 14, 2008
34,912
That FF does not have a /Q output so can't be use as a toggle FF without added logic.
You should have posted here before ordering parts. :rolleyes:
 

crutschow

Joined Mar 14, 2008
34,912
crutschow, would this one work for me? If not, could you point me to one that would? I can't find anyone selling T-Type flip flops anywhere. I guess real electricians just alter D-types in the wild.

Thinking about this one:
http://www.fairchildsemi.com/datasheets/NC/NC7SZ175.pdf
That should work.
But it's designed for glue-logic in microprocessor applications and comes in a tiny, surface-mount package.
Those are somewhat tricky to solder if you don't have some experience with that.
I recommended going with a CD4013 in a DIP package as it's a lot easier to work with.

I don't think they build T-FFs since they are easy to make by connecting D to /Q.
Printed circuit traces are cheap. :)
 

MrChips

Joined Oct 2, 2009
31,199
If you insist on using a single D-type flip-flop with no /Q output, you can create an inverter using a single transistor and a couple of resistors.
 
Top