D-Flip Flop issue

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

Well, it's a bit hard to know for sure what you've got going, there. Your description is a bit odd ["attached to +5 and Gnd"*]. So, it would be great if you would read the How to use this Forum post [near the top of every Forum Category], and then re-do your post, in compliance with it's guidelines.

But, the piece you are probably missing is the concept of "Clocking". A regular gate, for instance, a NAND gate, relies merely on static levels. Take a 2 input NAND gate, as an example: When both inputs are HIGH, the output is LOW. If either of the inputs go low, the output goes high.

A D Flip-Flop is a little different. If the clock input is at a static level [i.e. a steady HIGH or steady LOW], you can change the D input all you want, and it won't change the Q output [or the ~Q output, but I will speak only of the Q output, because the ~Q output always follows the inverse of the Q output (when only the D and Clk inputs are involved)].

BUT, if, say the D input is LOW, and the Clock transitions from LOW to HIGH, that "Clocks the D input, to the Q output", thus making the Q output LOW. So, for the Q output to change, the Clock must Transition from LOW to HIGH. This is know as a "Rising-Edge" Clock. If the D input is HIGH, and the Clock transitions from LOW to HIGH, the HIGH on the D input will be "Clocked" to the output, thus making the Q output HIGH. If Q was already HIGH, nothing changes, because the condition is already satisfied.

That is the only situation where the output of a D Flip-Flop changes [when using only the D and Clk inputs]. When the Clock input falls from HIGH to LOW, nothing changes. It's only when the Clock input rises from LOW to HIGH. It's on that edge that the magic happens. Another way of saying this is, the D Flip-Flop is edge triggered--the edge being that transition from LOW to HIGH. And the absolute most detailed way to language it is: The 4013 D-Type Flip-Flop is positive edge triggered.

There are Clock inputs that are negative edge triggered--which means a transition from HIGH to LOW. But the 4013 is positive edge triggered.

If that didn't resolve your issue, then I will need to see a schematic, and even, perhaps, a photo of your setup.

*Did you mean: the inputs range from +5 to Gnd?

Reading the datasheet, which contains a state transition diagram, explains what happens...

Allan

  1. D is attached to +5V and Gnd, D = HIGH
  2. Clk is attached to +5V and Gnd, Clk = HIGH

If you connect anything to +5V and GND, you will cause a short circuit which could damage components including the Arduino, or at least cause it to shut down.

DQ flipflops fire up in a random state. You have to give them a clock edge to copy input (D) to outputs (Q, #Q),
until the first clock edge or reset pulse the output is undefined state.

Or use set or reset... don't leave these floating.

The datasheet makes all clear

Allan

Indeed, never leave any CMOS logic chip input floating...

allanhurst:
Or use set or reset... don't leave these floating.

MarkT:
Indeed, never leave any CMOS logic chip input floating...

What are you guys talking about? The OP stated that the R and S inputs are tied to "Gnd".