MOV AX, BLOG

Electronics, Photography, Gadgets

Tag: circuit simulator

Building Logic Gates Using Transistors

Moving on from the NOT gate we built using a single transistor and described in a previous post, I decided to show my son how to build more complex logic gates and ultimately much more complex combinational logic circuits using transistors; which is the basis of all modern computers including the one you are using right now to read this blog. The video attached below from Make is a great overview to the transistor, but I would also suggest performing some simple experiments with NPN transistors before moving onto combinational logic.

[youtube=http://www.youtube.com/watch?v=-td7YT-Pums&feature=related]

The circuits below for the gates NAND, NOR, AND, OR and NOT have been designed using NPN transistors and these circuits will be the basis of the Full Adder which we intend to build using them; please note that these circuits may not be the most efficient as I designed them just for fun. In the screen shot you will also see the symbol for each of these gates and if you are unfamiliar with them and their truth tables, I suggest taking a look at the wikipedia article for each.

NAND, NOR, AND, OR and NOT Gates Using NPN Transistors

In order to get a feeling for how they work, I would recommend getting a copy of the excellent and free Java Circuit simulator and importing the following code into the program.

$ 1 5.0E-6 10.20027730826997 50 5.0 50
t 304 176 352 176 0 1 0.5607262480623159 0.6439221594808273 100.0
t 304 224 352 224 0 1 0.5610808902467164 0.6446279101012331 100.0
w 352 192 352 208 0
g 352 240 352 272 0
r 304 224 240 224 0 10000.0
r 304 176 240 176 0 10000.0
R 176 176 128 176 0 0 40.0 5.0 0.0 0.0 0.5
s 176 176 240 176 0 0 false
s 176 224 240 224 0 0 false
w 176 224 176 176 0
w 176 176 176 128 0
w 176 112 352 112 0
162 352 160 400 160 1 2.1024259 1.0 0.0 0.0
w 400 160 400 240 0
r 352 160 352 112 0 330.0
w 176 112 176 128 0
x 242 86 313 92 0 24 NAND
t 560 720 592 720 0 1 -1.7015314369328909 0.0985395491791375 100.0
R 416 720 368 720 0 0 40.0 5.0 0.0 0.0 0.5
s 416 720 480 720 0 1 false
r 480 720 544 720 0 10000.0
w 544 720 560 720 0
r 592 704 592 656 0 330.0
w 592 656 416 656 0
162 592 704 640 704 1 2.1024259 1.0 0.0 0.0
g 592 736 592 768 0
x 489 626 541 632 0 24 NOT
w 416 656 416 720 0
w 640 704 640 736 0
w 176 416 176 432 0
r 352 464 352 416 0 330.0
w 176 416 352 416 0
w 176 480 176 432 0
w 176 528 176 480 0
s 176 528 240 528 0 0 false
s 176 480 240 480 0 0 false
R 176 480 128 480 0 0 40.0 5.0 0.0 0.0 0.5
r 304 480 240 480 0 10000.0
r 304 528 240 528 0 10000.0
g 352 544 352 576 0
w 352 496 352 512 0
t 304 528 352 528 0 1 0.5610808902472575 0.6446279101002914 100.0
t 304 480 352 480 0 1 0.5607262480628803 0.6439221594798585 100.0
w 448 448 448 480 0
162 400 448 448 448 1 2.1024259 1.0 0.0 0.0
t 352 464 384 464 0 1 -1.6333280543612416 0.1667429312700123 100.0
w 592 736 640 736 0
w 352 240 400 240 0
w 400 480 448 480 0
r 352 416 400 416 0 330.0
w 400 416 400 448 0
w 384 448 400 448 0
w 384 480 400 480 0
x 255 369 308 375 0 24 AND
w 832 240 880 240 0
x 685 85 737 91 0 24 NOR
w 608 112 608 128 0
r 784 160 784 112 0 330.0
w 880 160 880 240 0
162 832 160 880 160 1 2.1024259 1.0 0.0 0.0
w 608 112 784 112 0
w 608 176 608 128 0
w 608 224 608 176 0
s 608 224 672 224 0 0 false
s 608 176 672 176 0 1 false
R 608 176 560 176 0 0 40.0 5.0 0.0 0.0 0.5
r 736 176 672 176 0 10000.0
r 736 224 672 224 0 10000.0
g 784 240 784 272 0
t 736 224 784 224 0 1 0.561235418839239 0.6443539216856129 100.0
t 736 176 784 176 0 1 -0.01047151862990496 0.07264698421646892 100.0
w 784 208 800 208 0
w 784 192 832 192 0
w 784 160 800 160 0
w 800 160 800 208 0
w 832 192 832 240 0
w 832 240 784 240 0
w 800 160 832 160 0
w 384 480 384 544 0
w 384 544 352 544 0
w 800 464 832 464 0
w 832 544 784 544 0
w 832 496 832 544 0
w 800 464 800 512 0
w 784 464 800 464 0
w 784 496 832 496 0
w 784 512 800 512 0
t 736 480 784 480 0 1 -0.010470026008861447 0.07264847683763566 100.0
t 736 528 784 528 0 1 0.561235418839193 0.6443539216856902 100.0
g 784 544 784 576 0
r 736 528 672 528 0 10000.0
r 736 480 672 480 0 10000.0
R 608 480 560 480 0 0 40.0 5.0 0.0 0.0 0.5
s 608 480 672 480 0 1 false
s 608 528 672 528 0 0 false
w 608 528 608 480 0
w 608 480 608 432 0
w 608 416 784 416 0
r 784 464 784 416 0 330.0
w 608 416 608 432 0
x 696 372 730 378 0 24 OR
w 864 544 832 544 0
w 864 480 864 544 0
w 864 480 880 480 0
w 864 448 880 448 0
w 880 416 880 448 0
r 832 416 880 416 0 330.0
w 880 480 928 480 0
t 832 464 864 464 0 1 -1.7169524832810044 0.0831185028464971 100.0
162 880 448 928 448 1 2.1024259 1.0 0.0 0.0
w 928 448 928 480 0
w 784 416 832 416 0
151 336 64 432 64 0 2 5.0
153 768 64 864 64 0 2 5.0
150 336 352 432 352 0 2 0.0
152 768 352 864 352 0 2 0.0
I 560 608 656 608 0 0.5

Building a 4bit Counter Using JK Flip-Flops

This weekend’s electronics project with my son was to build a 4bit counter using JK flip-flops. Before implementing the circuit in hardware, I first explained the binary system and we then designed the counter using the free Circuit Simulator which I described in a previous post. Interestingly, he was amazed by the fact that adding just one more bit doubles the size of the counter – exponential growth is not intuitive ;-). The counter circuit, which chains together the flip-flops can be seen below: 

4bit Counter Using JK Flip-Flops

One important feature of the design is that we tie both J and K to +5v which turns the JK flip-flop into a T or Toggle flip-flop. Below is the code for the circuit. Copy and import the code into Circuit Simulator to get a better feeling of how the counter works – just press the switch to activate the next “tick” of the counter. 

$ 1 5.0E-6 10.20027730826997 50 5.0 50
162 496 272 496 208 1 2.1024259 1.0 0.0 0.0
g 320 208 320 176 0
w 320 208 496 208 0
r 496 272 496 352 0 330.0
r 544 272 544 352 0 330.0
162 544 272 544 208 1 2.1024259 1.0 0.0 0.0
r 592 272 592 352 0 330.0
162 592 272 592 208 1 2.1024259 1.0 0.0 0.0
r 640 272 640 352 0 330.0
162 640 272 640 208 1 2.1024259 1.0 0.0 0.0
w 496 208 544 208 0
w 544 208 592 208 0
w 592 208 640 208 0
156 368 464 432 464 0 5.0
R 288 432 256 432 0 0 40.0 5.0 0.0 0.0 0.5
w 288 432 288 464 0
w 288 464 368 464 0
w 288 464 288 528 0
w 288 528 368 528 0
s 288 432 352 432 0 1 true
w 368 496 352 496 0
w 352 496 352 432 0
156 528 464 560 464 0 0.0
w 528 464 512 464 0
w 512 464 512 528 0
w 512 528 528 528 0
w 512 528 512 576 0
w 512 576 288 576 0
w 288 576 288 528 0
w 464 464 480 464 0
w 480 496 528 496 0
w 640 352 640 416 0
w 640 416 464 416 0
w 624 464 624 384 0
w 624 384 624 352 0
w 624 352 592 352 0
156 704 464 736 464 0 5.0
w 512 576 672 576 0
w 688 528 688 576 0
w 672 576 688 576 0
w 688 528 704 528 0
w 704 464 688 464 0
w 688 464 688 528 0
w 624 464 640 464 0
w 640 464 640 496 0
w 640 496 704 496 0
w 800 464 800 368 0
w 800 368 544 368 0
w 544 368 544 352 0
156 864 464 896 464 0 5.0
w 688 576 864 576 0
w 864 576 864 528 0
w 864 528 848 528 0
w 848 528 848 480 0
w 848 480 848 464 0
w 848 464 864 464 0
w 800 464 816 464 0
w 816 464 816 496 0
w 816 496 864 496 0
w 496 352 496 384 0
w 496 384 960 384 0
w 960 464 960 384 0
w 464 416 464 464 0
w 480 464 480 496 0

The next step was to build the circuit using real JK flip-flops. We used dual HEF 4027BP JK flip-flops from NXP Semiconductors, 4 LEDs, 4 330 ohm resistors, a 10k resistor and a push button. Please note that these flip-flops are triggered on the rising edge and therefore, we chained them together via NOT Q and used Q to power the LEDs. As we used a push button to activate the clock on the first flip-flop, we pulled the clock pin down to 0v using a 10k resistor connected to ground. One last detail is that the Set and Reset pins for each flip-flop are connected to 0v. Below is the finished result built by Luke. 

4bit Counter

Amazing Java Circuit Simulation

Circuit Simulator is an amazing piece of free software. If you are in any way interested in electronics, download it from here and play around with it for an hour or so. I’m going to be using this application to publish the layouts for the cicuits we are working on in my future electronics related posts.

Circuit Simulator

If you want to see how the blinking LED circuit shown in the previous post works, paste the following into program using the import feature.

$ 1 5.0E-6 382.76258214399064 99 5.0 43
v 352 672 352 400 0 0 40.0 5.0 0.0 0.0 0.5
w 352 400 352 288 0
w 352 288 608 288 0
w 608 288 880 288 0
162 880 288 1008 288 1 2.1024259 1.0 0.0 0.0
r 1008 288 1008 320 0 500.0
w 1008 320 1008 336 0
w 1008 336 1120 336 0
w 1120 336 1120 832 0
w 1120 832 1104 832 0
r 1104 832 992 832 0 10000.0
w 992 832 816 832 0
t 528 400 608 400 0 1 -0.12632236495348304 0.5010407108474094 100.0
w 528 400 528 832 0
w 528 832 736 832 0
w 528 400 528 352 0
t 944 400 1008 400 0 1 0.5847909946260287 0.6273630758008925 100.0
w 1008 336 1008 352 0
w 1008 352 1008 384 0
w 1008 416 1008 672 0
w 800 352 800 400 0
w 800 400 944 400 0
w 1008 672 672 672 0
w 672 672 352 672 0
w 608 416 608 560 0
w 608 560 656 560 0
w 656 560 656 608 0
w 656 608 672 608 0
w 672 608 672 624 0
w 672 624 672 672 0
r 608 288 608 352 0 5000.0
w 608 352 608 384 0
r 608 352 528 352 0 5000.0
w 800 352 608 352 0
c 736 832 816 832 0 1.0E-5 0.21083170251411693

© 2017 MOV AX, BLOG

Theme by Anders NorenUp ↑