Discussion in 'Electronic Basics' started by gimp, Apr 24, 2004.

1. ### gimpGuest

Hi, I am trying to learn some of the basics of logic chips. How can I
count pulses to a register? How can I add the contents of two
registers? Are there any simple calculation/calculator schematics out
there? Is it possible to multiply the contents of a register by 10?

I'd like to use discrete logic chips, or relays. Anyone with an idea
of how I could start would be a great help to hear from. Thanks.

Nathanial Hendler
Tucson, AZ USA
http://retards.org/

2. ### John PopelishGuest

If you want to count successive cycles of logic state changes, you
need a toggle flip flop chain. Each flip flop has two stable states
and it toggles between these during one of the two transitions in a
logic cycle (Either the zero to one transition or the one to zero
transition. Both types are made.) The first flip flop will cycle
through its two logic stated for every two cycles of the input. If
the output of the first flip flop is connected to the toggle input of
a second flip flop, that one will cycle through its two states for
every 4 input cycles, etc.

one side of this string of flip flops (one output on each one) hold a
binary number that counts the number of input cycles.

See:
http://www.play-hookey.com/digital/ripple_counter.html
The simplest logic family to experiment with is the 4000 series CMOS
logic family. They operate off 3 to 18 volts, use little power and
are cheap and available lots of places.
Here is a page that lists some of the available functions with access
ot their data sheets:
http://www.onsemi.com/site/products/parts/0,4454,395,00.html
The toggle flip flops are 4027 (dual JK flip flop) that has gating to
enable or disable the toggling in either direction for more
complicated counters.

Adding binary values is pretty simple.

Multiplication and division are much more complicated. The exception
is multiplication or division by a power of two. These can be
accomplished by shifting bits left or right, since each binary bit
position represents twice as big a value as the next smaller bit. So
multiplication of a constant like 10 (decimal) involves breaking 10
into a bunch of values that add up to 10 and shifting the bit pattern
the right number of positions to represent each of those simple
multiplications. Then you add all those different products together
(or add them up in sequence as they are produced.

For example, if you have the binary number for 12 (decimal) 1100
(binary representing 1*2^3 + 1*2^2 + 1*2^1 + 0*2^0 or 1*8 + 1*4 + 0*2
+ 0*1 ), most significant digit on left) and want to multiply it by 10
(decimal) 1010 (binary) you break 10 down into the powers of 2 that
make up 10 and shift the 12 by those power positions and add them up.
Since 10 is the sum of 8 and 2, the addition uses copies of the 12
pattern only shifted left 1 and 3 times. For the 0 and 2 shift
positions the 12 pattern is not added.

1100000 (12 shifted left 3 bits, so 3 zeros are appended on its
right)
000000
+ 11000 (12 shifted one bit left, so one zero is appended to its
right)
0000
_________
1111000 (total of all required shifted 12's)

1*2^6 + 1*2^5 + 1*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 0*2^0
0r 64 + 32 + 16 + 8 + 0 + 0 + 0 = 120 = 10*12

In most microprocessors this shifting and adding process is done by
hardware, but the sequence of these operations is done by program
control. Some processors have hardware to automate the whole process,
but it takes a lot of gates compared to adding.

3. ### R. Steve WalzGuest  