Grounding the data input of a flip-flop by default

Status
Not open for further replies.

Squishie

New Member
Hi all, a barely experienced mechatronics student here who's decided it's high time to actually start building things that do fun stuff!

(BTW just in case, apologies if this is in the wrong forum or has been asked many times before)

For one particular project (I think) I need to use a flip flop IC, which needs to change its output based on two micro-switch inputs. Ie, any time you click one microswitch, it will make the IC output 0, and clicking the other will change it to 1.

The one that causes the output to be 1 seems simple enough - just send a pulse through the D and clock inputs at the same time when the "1" microswitch is clicked, but I don't know for certain how to ground the D input by default to make it 0 when the "0" microswitch is clicked (which would just pulse the clock input alone).

I have a feeling it's something simple like connecting the D pin to ground through a resistor, but I don't have the parts yet so I can't experiment, and after hours of searching don't have a clue of the terminology so I can't find any theory behind it.

Thanks in advance for any help! Wish I'd found this site a loooong time ago.
 
You could use a JK flip-flip instead of a D. That has separate inputs for changing the flip-flop high and low. But remember, the clock has to occur slightly after the control inputs, so you will need to add a delay to the clock. This can be done with a RC delay circuit into a Schmitt-trigger gate, such as the 4093, that then drives the clock.
 
Last edited:
To create a TOGGLE flip-flop out of a D-FlipFlop, just wire the D input to Q-bar
 
If you want to use two switches and a D flip flop you should be able to configure it like the attached. As each switch is pressed the outputs will toggle. Was that what you had in mind using 2 switches? Depending on what you do be careful of switch bounce issues.

Ron
 

Attachments

  • 7474..gif
    4.9 KB · Views: 217
Last edited:
To modify Reloadron's suggestion, if you can ground the switch inputs, then just run them to the set and reset inputs of the FF (since the set and reset FF inputs are usually active low). You don't need a clock or worry about switch bounce. Just use a pull-up resistor (say 10k) from each switch output to the +5V supply. Connect the D and Clock inputs to ground.
 
Last edited:
Slight bump - thanks fellas!
I finally got the components and tried out the various configurations on a JK flip flop. I had a lot of trouble with predictability using the microswitches as whether they toggled or not seemed to depend entirely on how the switches were clicked, though this was probably because of the delay issue crutschow mentioned (didn't have a delay chip).

However, more by chance than anything I stumbled upon the fact that for whatever reason putting the microswitches between ground and set and reset pins worked perfectly. I guess when the switches are open the pins are considered high or something, because otherwise it makes no sense at all to me!

Thanks again.
 
What is the part number of the FlipFlop?
Did you have the pullup resistors?
 
That's the circuit I mentioned in my previous post.

TTL inputs will appear high when open. But for best operation and maximum noise immunity, you should add 10k pull-up resistors from each input to +5V.
 
Don't like RC circuits into logic because of long time when input voltage is somewhere between high and low. I would rather go for two logic inverters in series. It's faster anyway. A 4009 could work (but it probably takes more space than a rc delay circuit).
 
Added the pullup resistors (now that I know what they are), and yeah it seems to be working better now. Now that I also know what switch bounce is, I'm much more glad I don't need to worry about it in this case.

So, the next challenge in this project is to convert the 5V logic signal into something strong enough to trigger a 12V relay. Apparently this in some way involves a transistor, so that's the next port of call for the brain strain known as "learning stuff". Any pointers on where to start with transistor usage would be much appreciated!

BTW, another thing I'm still majorly ignorant of is power supplies. Thus far I've basically had it easy using an adjustable DC power supply I built as a kit for a uni subject. It is very handy but it means I still don't really have a clue how I might take say, a 24V supply and get for example 5 and 15V circuits out of it?
 
What is the relay coil resistance (coil current) and what is the FF logic circuit family you are using? That will determine the transistor(s) you need to use.

To make more than one voltage from a single supply you typically use regulator. For small currents you can use a linear regulator such as the 317. For larger currents you may need to use a switching regulator to minimize power dissipation.
 

I think your next logical step is to select your relay(s) based on the load(s) you plan to have them switching. Once the current the relay contacts will need to switch is known then a relay can be selected and the needed coil current known.

However, there is a caveat here. Back to the beginning the object was to toggle the output of a flip flop using a pair of micro switches. I think that has pretty much been nailed down. You have your switches and the flip flop is ... well flip flopping. Now that flip flop action will be used to toggle a relay or relays on and off.

Now this gets me to wondering. If I want to use a momentary switch to latch a relay on and another momentary switch to turn a relay off I generally use a simple circuit like the attached. The relay used in this example is one of these using an 8 pin configuration. They also come in 11 pin configurations depending on how many contacts you want. The idea here is pressing the NO push button (or NO contacts of a micro switch) will energize the relay closing the NO contacts of pins 1 & 3. That action will Latch the relay on. The relay will remain latched on until power is removed by pressing the NC push button (or NC contacts of a micro switch).

Depending on the relay that could leave another full pair of SPDT contacts for loads or other applications. Nice is that my relay coils can be AC or DC in a variety of voltages. I don't need extra parts to regulate voltages or transistor drivers for relay coils.

I am not trying to disuade learning logic and driving relays but wanted to point out another approach to latching a relay.

Ron
 

Attachments

  • Relay Latch..gif
    7.5 KB · Views: 147
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…