Self built JK Flip-Flop

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
Hi guys, bear with me as I'm completely new to logic gates (and the inner workings of electronics, in general.)

I'm attempting to build a fairly simple binary clock. I feel jumping in a (somewhat) simple project like this is a good starting point.

I have a 555 timer outputting (approximately) one high per second. I haven't gotten it tweaked exactly right just yet, but close enough I should be able to use it for proof of concept.

My 555 timer out is feeding a JK built from 2 AND gates and 2 OR gates. My understanding is that if I output high to both "J" and "K" I should get the desired toggle. Unfortunately, I'm not getting anything but 1V from both Q and Q`.

As I understand, perhaps I have to set the flip-flop before it can be toggled? Maybe just a simple relay or some such?

Excuse my lack of knowledge, before starting this project I had never even heard of a logic gate. I'm a computer programmer, so I'm learning fairly quickly. (At least I like to think I am!)

Thanks in advance for any help. :)
 

Attachments

Wendy

Joined Mar 24, 2008
23,421
Welcome to AAC!

You will get better response if you post in a graphic standard, such as gif or png formats. I can not look at your schematic as is, and I'm one of the major graphic poster types here.

I also have a pretty good set of 555 tutorials here, and am interested in your design.

Fluffy Ninja? I mean no disrespect, but would you be of the feminine persuasion? :D
 

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
Thanks for the welcome!

I think I've narrowed down my trouble. I just need to figure out a way to send a pulse to J (A4, I believe) to "set" the flip-flop initially. Unfortunately, I'm not sure or the best way to do that. Perhaps an XOR gate running back to itself? I'll keep working on it while I wait for a response.

As suggested I have attached the bit I'm having trouble with (in PNG this time). The finished design will be more JKs with some ANDs to control the conversion from minutes to seconds, etc etc.

The final design should be much more interesting, I'm even considering building the whole thing out of relays or some similarly large component. That way I can hang it up over my mantle with all the inner workings exposed. Should make for an awesome conversation starter, especially when people ask how to read it. ;)

Finally, the bit you actually wanted to know...
I'm sitting here in a white bathrobe I stole from a hotel as I type one-handed, the other holding a ninjato. I'm currently using the ninjato to shave my neck. Also, I'm a man.
 

Attachments

Last edited:

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
Alright, I'll give it a shot!

I understand it would be easier to just buy completed components, but I'd rather start off with an understanding of what makes them tick. I chose this project specifically to learn how things work.

I'll design it the hard way, and then I may later switch to pre-built components depending on how difficult I think the physical manifestation will be to build.

Thanks again for your help, I'll update this if/when I make more progress. In the meantime, I welcome more suggestions!

P.S. If anyone else has any interest in this project, I will be more than happy to supply my finished drafts.
 

Wendy

Joined Mar 24, 2008
23,421
Interesting, the had a guy join my Kung Fu class who was a black belt in Ninjutsu, and he mentioned women in his old class. The style is based on the art of bone breaking in the hand to hand part.

I've done bistable flip flops, and have thought hard how to toggle one electrically. The one I have uses a simple button.

555 Bistable Multivibrator

I'll look through the other designs (haven't done that yet).
 

Georacer

Joined Nov 25, 2009
5,182
Ok, it's not a rule, but the iconic figure of the ninja is strictly masculine. Women weren't very high esteemed in feudal Japan.

It's like talking about a female knight. Who would take you seriously? The burned the last one for heresy on the stake.
 

Wendy

Joined Mar 24, 2008
23,421
Japan isn't feudal any more, and true martial arts can be learned by anyone. I love grade D martial arts movies more than most, it is a hallmark of people who are actually into martial arts (that and critiquing how bad they are).

Woman are not great in stand up fights tis true, which is why they are taught to fight dirtier than most. But this is off topic.

I did a lot of experiments with gates to make various flip flops way back when.
 

SgtWookie

Joined Jul 17, 2007
22,230
I see that you are using LTSpice, and you are using the built-in functions that are provided for INV, BUF, AND, OR, XOR, SCHMITT, SCHMTBUF, SCHMTINV, DFLOP, etc.

By default, these have a logic high output of 1v, and a logic low output of 0v, and have a threshold of 0.5v. They are more-or-less documented in the Help file under:
A. Special Functions.

However, rather than using those (they are idealized, and it will be difficult to get them to act more or less like real-world parts) I suggest that you join the Yahoo! LTSpice group, and download the CD4000.zip and 74hc.zip from the file section.

The LTSpice group has loads of LTSpice-adapted Spice models and symbols that you can load right into LTSpice; the first time is the hardest - it becomes very easy after the first couple of times you do it.
[eta]
Have a look at my entries in this thread: http://forum.allaboutcircuits.com/showthread.php?t=46892

There is also freely available help for LTSpice. However, I encourage you to read through the Help file a couple of times, and try out a number of the examples that were provided with LTSpice; you will learn a lot very quickly that way.

I'd upload them here, but I'm not on my usual computers; I'm in transit, and my computers & backups are in storage.

Also, the NE555 timer model supplied with LTSpice is idealized; it's optimized for speed of execution rather than accuracy. It's sort of like a super-duper version of a CMOS 555; you can't buy one like it. I have uploaded a component model of the LM555 and symbol to the board; you can find it using the Search function; look for LM555.zip

Tip:
For 555 timers, use larger values of resistors and smaller values of capacitors. Try starting with a 1uF or 10uF cap, and adjust the resistors to suit. Caps get much larger with increased values; resistors stay about the same size.

74xx series logic ICs should be operated using 5v.
4000 series CMOS logic ICs can use 3v to 15v for Vdd.
Remember that when you start building the real circuit, you should use one 0.1uF capacitor across the Vdd/GND pins of each logic IC for transient suppression; "bypass capacitors" - without these, you can wind up with very odd and hard-to-troubleshoot problems.
 
Last edited:

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
This is where I got my information on building the JK flip-flop from:
http://mryantho.wordpress.com/2008/02/13/jk-t-flip-flops/
http://wearcam.org/ece385/lectureflipflops/flipflops/
http://en.wikipedia.org/wiki/JK_flip_flop#JK_flip-flop

Granted, my original design didn't have J and K connected directly to 6V+, as I later found out I should be doing. I'm currently checking out the link Georacer posted. Perhaps your google-fu is better than mine...

Speaking of martial arts, I can tell you that in my combatives training we weren't usually allowed to practice with a female partner. I'm sure there are women who could handily kick my butt, though.

Quick edit:
Wookie (AKA Spice God) responded while I was typing up my response. I'll begin loading in the files, now. Is there any "better" software for a beginner than LTspice? I've noticed some of these websites allow you to click a button and watch the signal flow. That would be really cool for a noob like me.

Another edit:
Georacer, your design works flawlessly. Looks like I have all of the basics I need to get this project rolling!
 
Last edited:

Georacer

Joined Nov 25, 2009
5,182
Glad I could help. Much more on logic circuit implementation can be found on Weste and Harris' "CMOS VLSI". It's a good read but rather expensive. If you 're a college student, maybe your library will have it.
 

SgtWookie

Joined Jul 17, 2007
22,230
I don't claim to be a "Spice God"; I'd started using it many years ago, then forgot it, and am re-learning it; this time with a GUI interface.

I'll reiterate; I strongly advise creating a free Yahoo! account if you don't have one already, and then join the LTSpice group. As supplied, LTSpice is/was primarily designed to support Linear Technology's products, but it's also a very good (and very free) general purpose Spice implementation.

Well, there is Falstad:
http://www.falstad.com/circuit/
that uses Java to simulate/display circuit response in pseudo-real time, but it's actually rather limited. It's helpful for you to visualize current flow and polarity, however.

If you look around a bit, you can find Circuitmaker Student hosted online somewhere. It has quite a few 74 and 4000 series ICs already in it, but it is "dead-end" software as the software company was bought by another about 11 years ago, and support for Circuitmaker was promptly discontinued. You can't add components to Circuitmaker Student, and you are limited to 50 components per simulation; this latter limitation can prove to be a real annoyance for even moderately-sized simulations.

PSPICE Student is available for download if you do a Google search; I don't recall if there are time/size limitations - and I don't recall what all the library contains. I fiddled around with it some, but that was many moons ago. I don't know who's using it on this board.

Texas Instruments has Tina-TI available, some folks really like it. It's all what you got used to first. I don't know who's currently using it on here, nor do I know what all the provided libraries contain.

LTSpice isn't perfect, and there are some quirky things about the interface that can be somewhat annoying; particularly when you are drawing wires on a schematic or on a symbol, or dragging items. These oddities can be largely avoided/compensated for if you zoom out before or during the odd events.

As far as getting a "really accurate" output from a real-world 555 timer - forget it. With real-world components, you'll be doing really good to be within 1% of the desired frequency - and that's woefully inadequate for timekeeping purposes. A crystal oscillator will be much more suitable, but without compensation of some sort, even that will drift a couple of minutes (or more) per week.
 

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
I don't claim to be a "Spice God"; I'd started using it many years ago, then forgot it, and am re-learning it; this time with a GUI interface.

As far as getting a "really accurate" output from a real-world 555 timer - forget it. With real-world components, you'll be doing really good to be within 1% of the desired frequency - and that's woefully inadequate for timekeeping purposes. A crystal oscillator will be much more suitable, but without compensation of some sort, even that will drift a couple of minutes (or more) per week.
You misunderstand. I've done a lot of forum searching, and every useful bit of information I've found seems to have your name attached somewhere. You haven't claimed to be the Spice God, I have simply assigned you a fitting nickname. Don't ask how I became Fluffy Ninja

I considered using a rheostat so I could adjust for fluctuations, would the variances still be too large?

How about something along the lines of those "atomic watches" which receive a WWVB radio signal from (I think) the NIST?
 

SgtWookie

Joined Jul 17, 2007
22,230
Re:using a rheostat to adjust for fluctuations...
Yes, the variances would still be too large. The values of capacitance and the threshold/trigger levels of the 555 will change slightly over time and temperature; not a lot if you need an approximate time, but the errors will be cumulative - and the more time goes by, the less acceptable it will be.

An uncompensated crystal oscillator circuit will be at least 100x more stable.
A temperature compensated xtal oscillator will be very significantly more stable.
An oven controlled xtal oscillator will be even more stable.
If you need better accuracy than that, the solutions get rather pricey. Google "rhodium time standard". Sometimes you can find rhodium oscillators on auction sites for under $50 or so.

If you need even more accuracy, you could use the WWVB time signal:
http://www.nist.gov/pml/div688/grp40/wwvb.cfm
The time signal is broadcast on a number of different frequencies. Unfortunately, the gov't reduced the signal strength in a power-saving move awhile back, which limits the usefulness of the signal; also, switching supplies generate broadband noise that tends to interfere with the signal.

You could also simply use the 60Hz mains frequency as a clock. It's pretty accurate in the States, as if power generating stations go off-frequency, power dissipation in the grid skyrockets. Outside the US and Canada, the mains frequency stability will vary widely depending on location.
 

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
Alright, I'm making (surprisingly) good progress with my design, now.

I'm running into a limitation in LTspice where I can't get the simulation window to show me more than 10 seconds. I realize most people will be happy with that limitation, but it doesn't do me much good now that I'm working on my 5th and 6th bits, which will represent 10s of seconds. :(

Also, can anyone name a decent supplier of ICs? I'd like to build this small before jumping up to my giant relay-driven monster clock. Hopefully pointing me in the right direction won't violate any forum rules.
 
Last edited:

Georacer

Joined Nov 25, 2009
5,182
It doesn't violate any rules, but first you have to give us an idea of your general area.

Modern digital electronics behave more or less the same, when you operate them in the seconds, milliseconds or even microseconds realm, so you can just scale up your base clock. The results will be the same, without much doubt.

A relay clock will have larger frequency limitations, though, but it won't matter once you have made a proof of concept design.
 

SgtWookie

Joined Jul 17, 2007
22,230
Alright, I'm making (surprisingly) good progress with my design, now.
Good - did you download the 74hc and cd4000 libraries?
I'm running into a limitation in LTspice where I can't get the simulation window to show me more than 10 seconds. I realize most people will be happy with that limitation, but it doesn't do me much good now that I'm working on my 5th and 6th bits, which will represent 10s of seconds. :(
OK, keep in mind that under the "Edit Simulation Command", the "Stop Time" is what determines how long that the simulation runs; the default unit of time is seconds - so, 60 seconds is 1 minute; 3600 seconds is 1 hour, etc.

It can take a LONG time for a simulation to run if you're using a 555 timer instead of a voltage source set up to generate a pulse. (hint,hint!) If you really want to use the 555 timer, you can speed it up by using the Control Panel, and decreasing the precision of the variables saved on the SPICE menu, and under compression, increase the vol tol and current tol.

Also, can anyone name a decent supplier of ICs? I'd like to build this small before jumping up to my giant relay-driven monster clock. Hopefully pointing me in the right direction won't violate any forum rules.
http://www.Mouser.com, http://www.Digikey.com, http://www.avnetexpress.com are authorized distributors for a number of electronic component manufacturers, and have very good to excellent track records. You should stick to authorized distributors at least until you get fairly well experienced; there are lots of counterfeit components out there nowadays.

You might consider using http://www.findchips.com to discover who has components available and what the prices were at the time the inventory was checked. It's not 100% accurate, but it can help you find stuff quickly.
 

Thread Starter

fluffyninja

Joined Mar 2, 2012
9
Awesome!

Can I just say this forum is fantastic? Hopefully one day I can go around answering the simple questions and flexing my muscly brain.

I'd like to get a big old bag of logic ICs to start, from what I've seen they aren't too terribly expensive. I may even cheat and use some JKs without NANDing them together myself, as that'll make troubleshooting much easier on my poor brain.

Here's a list of stuff I need as I understand it currently:

Breadboard
20x JK flip-flops
20x LEDs
5V power supply
12x AND gates (probably less, but I understand they're fairly cheap).
Timing source (555 would work fine for proof of concept, and they're super cheap.)

Here's what I already have:
2x Butane soldering irons
Acid-core solder
Flux
Limited soldering experience. I've made a clock before, but it was a kit with diagrams.
 

SgtWookie

Joined Jul 17, 2007
22,230
Something very handy for digital simulations;

Find Dview.zip on the yahoo LTSpice files section. There is DVIEW5 and DVIEW10 available; see dview.asc for instructions on how to use it.

Also, get used to giving nodes (nets) useful names (labels); it makes comparing output plots to schematics SO much easier. The "label net" icon on the menu bar allows you to label nodes; it looks like an "A" on a signboard.
 
Top