Pages: [1]   Go Down
Author Topic: D-Flip Flop issue  (Read 4505 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 38
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there!
I just got myself the 4013 flip flop and am trying to understand how exactly it works.
I've hooked it up to the +5V of my arduino, but somehow nothing's happening..
Here's what I'd expect should happen:



1) D is attached to +5V and Gnd, D = HIGH
2) Clk is attached to +5V and Gnd, Clk = HIGH
3) S is attached to Gnd, S = LOW
4) R is attached to Gnd, R = LOW

Since both - D and Clk - are HIGH, I'd expect the LED to turn on (also to measure an output voltage of around 4-5V, which I don't). The LED is connected to Q.
I'd also expect the LED to stay on when I remove the Clk wire.
Additionally, if I connect R to +5V and Gnd, I'd expect the LED to turn off and stay off.

None of that is actually happening. Upon powering the circuit, the LED stays off, no matter what wires I connect/disconnect. If I connect the LED to NQ, it turns on, as expected.

Is there anything I'm missing here?

Greets,
Philipp
Logged


Brisbane, Australia
Offline Offline
Newbie
*
Karma: 6
Posts: 36
B.E.E. / B.Inf.Tech.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have an O-scope or a miltimeter it would help you debug circuits like this much quicker (a cheap multimeter can be bought for ~20$).

Now about the flip-flop. I believe most flip flops are positive EDGE triggered so the CLK line must be clocked in such a way so the flip-flop will detect the positive edge. Connecting the CLK constantly HIGH may not be triggering the FF. So, try pulling out the CLK pin and then putting it back in to very crudely simulate a clock. Alternatively, configure an arduino PWM and connect it to this pin to clock it properly.

in 1) you say D is connected to +5v and GND. How is it connected to both?
Basically, looking at 4013 flip flop datasheet, you want:
D -> HIGH
S -> LOW
R -> LOW
CLK -> POSITIVE EDGE TRIGGERED (confirmed from datasheet) so you MUST have a rising edge to trigger it!

Also, since there are two FFs on that IC, make sure you got your pins connected correctly.
HTH
-Igor
Logged

Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 38
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Igor!
Thanks for the quick reply smiley-wink
I do own a (cheap) multimeter.. I also thought about debugging it that way, but all I can get out of it is what I wrote above. NQ shows a voltage of +4-5V and Q is around 0.2V

About 1):
There's a line running from +5V over a 1k resistor to Gnd. Before that resistor I added the wire going to D.
So, using the multimeter, I can confirm that D is HIGH, S is LOW and R is LOW too.
The only thing that bothers me now is the edge triggering. I already tried pulling the Clk line out before powering the circuit and then plugging it in. The thing is, I need to control the flip flops (both, D and Clk) from a simple pushbutton, while the reset afterwards comes from the arduino. The arduino will globally reset all flip flops on the circuit (there's around 6 of them, so 12 flip flops overall)

Pins are definitely connected correctly. Only thing that could be wrong is the wiring of Vdd and Vss. Vdd runs from +5V and Vss runs to Gnd.

Greets,
Philipp

[Edit]
What's also interesting is that if I completely remove the LED and the resistor leading to it from Q, I get 0V on Q and +4-5V on NQ. The LED lights up on NQ.
However, if I add the LED and resistor to Q, I get 0V on NQ and +4-5V on Q, however, the LED doesn't turn on.. that somehow seems illogical..
I'm testing with the multimeter from the wire leading to Vdd and the Q/NQ pins.

Also, another observation:
Setting the third pin (Clk1) HIGH gives me +5V on Q and 0V on NQ, while D is either floating or connected to Gnd. Afterwards, setting it to LOW leaves +5V on Q and 0V on NQ, which obviously shouldn't happen since D is always LOW. This way, when Clk1 becomes LOW, Q should also become LOW and not stay HIGH. Like I said, it can't be wired wrong, it's the third pin, which is Clk1.

Also, setting R to HIGH should give me 0V on Q and +5V on NQ, which it doesn't. Even when Clk1 and D are LOW.
« Last Edit: January 26, 2011, 06:39:31 am by Christoph680 » Logged


Germany
Offline Offline
Newbie
*
Karma: 1
Posts: 38
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, wiring all cables up to arduino ports that are obviously pulled down fixes the issues and the IC works fine.. now the question would be how I can wire the flip flop up so that D and Clk are simultaneously controlled by one pushbutton and only R is controlled by the arduino..

I noticed that S sets D immediately to HIGH, but keeps it on HIGH as long as R isn't HIGH. That might be the simplest solution. Could I simply wire S up to my pushbutton and wire R to the arduino? I don't think that's essentially what S is supposed to do (override D and Clk for the period it is on HIGH), but at least it works smiley-grin
Logged


Worcester, MA
Offline Offline
God Member
*****
Karma: 3
Posts: 623
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you just trying to get the output to toggle each time you push the pushbutton?  If so just connect !Q to D and connect the pushbutton to the clock input.  Every time you push the button Q will toggle.
Logged

I2C GPS Shield

Checkout my Open Source GPS Tracker on Kickstarter

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 514
Posts: 26260
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd say you had two options.
One is to use  Set and Reset inputs as you just described:

May need transistor to get decent current thru the LED to make it turn on.
The other would be to pull down the clock line with a resistor and use the switch connecting to +5VC to clock in the D input (high or low), and use arduino to Set, or Reset,to the opposite state.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Could I simply wire S up to my pushbutton and wire R to the arduino?
If you just want the PB to set and Ard to reset then yes. In this case there's no obvious reason to have a FF in the first place, just run the button into the Arduino (unless you don't have the extra pin).

Or do you want to toggle the FF?

______
Rob

Logged

Rob Gray aka the GRAYnomad www.robgray.com

Calgary, AB
Offline Offline
Newbie
*
Karma: 2
Posts: 46
Arduino Newbie
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Christoph680

Check out this link for a cheap logic probe.  http://www.electronics-tutorials.com/test-equip/led-test-lamp.htm Sometimes easier then using a multimeter for quick checks of logic levels.

It may be better to post a drawing of your connections.  From you last description, you tied a resistor between +V and Gnd, taking a connection from the +V side for a high.  From your descritpion, you could never take that pin low, as it would short the +V connection.  That is not he way to create a high.  You want to connect the reistor between +V and the pin.  That way you can pull the pin low.

Also, what size resistor are you using with your LED?  Make sure you are not exceeding the current capabilty of the outputs.

A very simple way to set the Q output to H (1), set D, CLK and R low,  pulse the S (set) to high then low.  The Q should go H.

Logged

Don't you just hate ONE D 10 T problems?

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 514
Posts: 26260
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The other thing  you can do for a test tool is download Visual Analyzer
http://www.sillanumsoft.org/
Its a soundcard based PC oscilloscope that you can use to look at signals with, often times a picture is worth way more than what a digital multimeter can tell you.

Or get a proper hardware based scope like this one, www.dpscope.com $89, have to do a little assembly yourself, is what I use whenn debugging.

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11639
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or the natty little DSO nano: http://www.seeedstudio.com/depot/dso-nano-pocket-size-digital-storage-oscilloscope-p-512.html?cPath=174 which doesn't need a PC attached (but can be)
Logged

[ I won't respond to messages, use the forum please ]

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6633
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or a little "buffered" LED "logic analyzer" that will show you states of several pins without loading the circuit.
This can be as simple as a logic chip from the same family set up to drive LEDs.  pretty much any simple gate can be made into an LED buffer.
Logged

Pages: [1]   Go Up
Jump to: