Tuesday, 10 January 2023

The JK Flip Flop (Quickstart Tutorial)

The JK Flip Flop is a type of flip flop that can be set, reset, and toggled. It can be used for making counters, event detectors, frequency dividers, and much more.

In this tutorial, you will learn how it works, its truth table, and how to build one with logic gates.

JK Flip Flop symbol
JK Flip Flop symbol

What is a JK Flip Flop?

Flip flops are components that can store a digital value on their output. They have a Clock input (Clk) which determines when they can change the state of their output.

Contrary to what you’d think, the two inputs of the JK Flip Flop, “J” and “K”, are not abbreviations for what the pins do (which is the case for the S-R latch). They were chosen by its inventor Jack Kilby (JK) to distinguish his flip flop design from other types.

You can see a basic implementation of the circuit below. It’s based on the S-R latch and built with NAND gates:

Jk Flip Flop basic NAND cirucuit
JK Flip Flop basic circuit

The J and K inputs of the JK flip flop can be used to set, reset, or toggle the output, like this:

  • J=1 and K=0 sets the output to 1
  • J=0 and K=1 resets the output to 0
  • J=1 and K=1 toggles the output

But for the flip flop to make any change, its Clock input must be 1. Check out the truth table below:

Clk J K Q Description
 0 X X Q Clk in 0 no
change in Q
1 0 0 Q Memory
(no change)
1 1 0 1 Set
 1 0 1 0 Reset
 1 1 1 Toggle
JK Flip Flop Truth Table

An alternative way to implement the basic JK flip flop circuit is using two AND gates and two NOR gates as follows (it works exactly like the one built with NAND gates):

JK Circuit with AND and NOR gates

Racing Problem

In principle, the basic implementation above works, but a timing problem arises.  When the clock is “1” and you want to toggle the output, it will toggle really fast between “1” and “0” until the clock goes back to “0”. This issue is called a race condition.

You can solve this by making the the flip flop pulse-triggered or edge-triggered.

Pulse-Triggered JK Flip Flop

Below you have a pulse-triggered JK flip flop based on the Master-Slave principle:

Master-Slave JK Flip Flop
Master-Slave circuit

As you can see, to build this configuration you need a basic JK Flip Flop circuit tied together with an S-R flip flop.

To understand how this version works check out its timing diagram below:

Timing diagram for the master-slave setup

As soon as the clock makes a rising edge ↑, which is a change from 0 to 1 (0→1), it triggers the master section. As a result, the value of the outputs in this section changes. These signals are connected to the slave section, but this doesn’t trigger on the rising edge because the clock has been inverted.

Once the clock signal produces a falling edge ↓, a change from 1 to 0 (1→0), it triggers the slave section, causing the Q output to reflect the master’s output value.

So this circuit requires a complete pulse (0→1 →0) in order to change the output. That’s why this configuration is called pulse-triggered JK Flip Flop.

Clk J K Q Description
 0 or 1 X X Q No pulse
no change
0→1 →0 0 0 Q Memory
(no change)
0→1 →0 1 0 1 Set
0→1 →0 0 1 0 Reset
0→1 →0 1 1 Toogle
Truth Table

Edge-Triggered JK Flip Flop

Unlike the Master-Slave design, you can trigger this edge-triggered JK Flip Flop just with either a rising edge ↑ or a falling edge ↓.

Below you have the timing diagram for one that triggers on the rising edge:

Edge-triggered timing diagram

The above picture shows how this circuit just needs a rising edge on the Clk input to change the state of the output Q. And it will only change on the rising edge.

Clk J K Q Description
 0 or 1 X X Q No rising edge
no change
0→1 (↑) 0 0 Q Memory
(no change)
 0→1 (↑) 1 0 1 Set
 0→1 (↑) 0 1 0 Reset
 0→1 (↑) 1 1 Toogle
Edge-triggered JK Flip Flop Truth Table

To build a JK Flip Flop that triggers only with rising edge signals, you can use a rising edge-triggered D flip flop, a NOT gate, and NAND gates as follows:

Edge-triggered JK Flip Flop circuit
Edge-triggered JK Flip Flop circuit

Questions?

Do you have any questions about how this type of flip flop works? Let me know in the comments below.

Copyright Build Electronic Circuits

No comments:

Post a Comment

Tiny, wireless antennas use light to monitor cellular communication

Researchers developed a biosensing technique that eliminates the need for wires. Instead, tiny, wireless antennas use light to detect minute...