# Johnson counter

Discussion in 'Homework Help' started by wijendra14, Apr 13, 2008.

1. ### wijendra14 Thread Starter New Member

Apr 13, 2008
9
0
I know how what a Johnson counter is but how exactly does it work? I need to write up code in a programming language and I need help to write this.

2. ### Papabravo Expert

Feb 24, 2006
10,178
1,799
A Johnson counter (aka a twisted ring counter) is a variant of the rotate left or rotate right instruction available on many processors. Instead of taking the MSB and inserting it in the LSB you take the COMPLEMENT of the MSB and insert it in the LSB. Since there is generally no concept of a carry flag in higher level languages like C, you have to test the value of the MSB, then shift, then copy the complement of the MSB back to the LSB. If you want to do it in reverse with a right shift then you test the LSB, then shift right, then copy the complement of the LSB into the MSB.

What good is it you ask? Well for an n-bit counter it has a period of 2n, and it is self initializing. For a 3-bit counter with an initial value of zero the sequence of states is {000,001,011,111,110,100}*. Many designers prefer counters like this because only one bit changes for each clock pulse. If you decode the outputs, there are no hazards that occur when multiple bits change at different times as in a ripple counter, where the ouput depends on the speed of carry propagation.

Now if the initial condition is either 010 or 101 then the counter will alternate between those two states so if you want the six state sequence you need to do a proper RESET.

Got it?

3. ### wijendra14 Thread Starter New Member

Apr 13, 2008
9
0
Thank you. That was great help!

4. ### palak New Member

Jul 3, 2008
2
0
but basically isn't it a counter so how am i to get its basic functionality of counting 00,01,10,11 so on and i am refering malvino-leach in that circuit the shifts the bits frm left to right and there are three flip-flops viz. A, B, C cascaded but they have given two output tables they are as follows:
C|B|A|State
0|0|1|1
0|1|1|2
1|1|1|3
1|1|0|4
1|0|0|5
0|0|0|6

C|B|A|Binary
0|0|0|0
0|0|1|1
0|1|0|2
0|1|1|3
1|0|0|4
1|0|1|5
1|1|0|6
1|1|1|7

5. ### RiJoRI Well-Known Member

Aug 15, 2007
536
26
Consider a "non-sequential" counter. If this counter gave the counts in the pattern 1-3-7-6-4-0 repeatedly, you could take and decode them. If you had a 7, you would know that you were at the third count. If you need more than 6 counts, you would need some way to trap the 0-to-1 transition.

--Rich

6. ### palak New Member

Jul 3, 2008
2
0
thanks a lot!

7. ### idknox New Member

Nov 4, 2008
2
0
Not to dig up an old thread but I had a related question.

I'm taking a Logic Design class and am trying to figure out how to build a Johnson counter with J-K Flipflops. I'm not sure whether the imput for K is supposed to be the same as J, or if the imput for K comes from the non-inverted output, as opposed to the inverted output which is the imput for J.

Any help would be greatly appreciated.

8. ### Papabravo Expert

Feb 24, 2006
10,178
1,799
You make a johnson counter by starting with a shift register. To make a shift register you connect Q to J and Q' to K. For the the last stage you "twist" Q and Q' back to the first stage by connecting Qn to K1 and Qn' to J1. Viola you have the twisted ring counter. You also need to confirm that J=1,K=0 sets Q=1 and J=0,K=1 sets Q'=0. There are such things as JK-Bar Flip Flops so you need to be careful. If you have one of those then you just swap the connections on all stages except the last one and make that one a straight connection.

In the world of logic design there D-designers and there are JK-designers. Congratulations you seem to be on the road to being the latter.

Last edited: Nov 4, 2008
9. ### idknox New Member

Nov 4, 2008
2
0
So far I much prefer using D's than J-K's, just had to do this for an assignment.

Thanks a lot for your help.