Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problems with a binary counter

Status
Not open for further replies.

krytie

New Member
Hello all,

just to start, i am quite a Novice with Electronics so please excuse me if my thought process is completely wrong.

I am making a TOSlink switch to accept 4 incoming audio streams and has one output. to switch between them all, instead of using a 4-way mechanical switch, i wanted to use one button to cycle between the 4 inputs..

I realised early that a 2-bit binary number should do the job nicely, after doing a bit of research and checking the inventory at the local electronics store, i went for a Dual J-K Flip-Flop i got a MC74HC76 Click here for datasheet.

I decided to test the idea on a breadboard, I wired up 2 LED's so i could see the binary cycle (off-off,off-on,on-off,on-on) as i pressed the button. i plugged everything into a breadboard as shown in the image below

**broken link removed**

now everytime i press the button, i get a random set of leds. sometimes it doesn't change, sometimes it picks a random sequence, and every so often i get the next light in the sequence, i pressed the button 20 times writing down the result and did not see any kind of pattern forming. so i am at a total loss.

I added a resistor and a capacitor between the not gate and clock 1 just in case there was some kind of interference on the push button hoping to maybe smooth out the button press, but there was no difference.

I appreciate any ideas on how to get this to work
 
Without looking deeply into your circuit I notice you are trying to clock a FF with a switch. You can't do this as a switch is mechanical and it will bounce, ie. make lots of on off connections after first depress. This in turn may toggle your FF and give you random results. You must debounce your switch. Have a look at this article. http://www.ganssle.com/debouncing.pdf

Another alternative which requires no logic may be something like this.
**broken link removed**
 
Last edited:
To overcome your problems which are almost certainly due to contact bounce in the switch, I suggest that you modify your circuit as I have shown below.

Also, add a decoupling capacitor between the +5v line and gnd.
A 0.1uf in parallel with a 100uf would be good to have.

JimB
 

Attachments

  • Counter.JPG
    Counter.JPG
    14.4 KB · Views: 323
Hey Guys,

bouncing does sound like the source of my problem.

i used the caps and resistors you suggested Jimb and removed the not gate. however i am still getting the same problem. is there anything else you guys can suggest or different values for the cap and resistor?

Thanks all
 
Mikebit's Link said:
I pressed each switch 300 times, logging the min and max amount of bouncing for both
closing and opening of the contacts.

What some people will do for science!
 
Since you want to switch audio signals why don't you use an analog multiplexer like a 4051?
 
Last edited:
Hey Guys,

bouncing does sound like the source of my problem.

i used the caps and resistors you suggested Jimb and removed the not gate. however i am still getting the same problem. is there anything else you guys can suggest or different values for the cap and resistor?

Thanks all

hi,
Look at this modified circuit.
If required increase the 100nF upto say, 1uF.
 

Attachments

  • binary_counter.jpg
    binary_counter.jpg
    13.6 KB · Views: 223
Hi ericgibbs,

I followed your circuit to the letter and it now works perfectly, Thank you so much. Thanks to all for your input
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top