Author |
Message |
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Sun Sep 02, 2018 11:52 am Post subject:
basic guidelines for digital circuit design |
|
|
Here are some basic guidelines that might be useful if you want to design your own digital circuits. This is not an introduction into
electronics and you should already know a bit (or byte) about digital logic. There is an excellent post by Rykhaard with some basic
info about electronics which you can find here and there is of course a lot more in depth information available online.
feel free to add, correct, ask or comment in any other way.
Connecting outputs and inputs together
When you want to connect a single output of a logic chip directly to an input you generally don't need any extra components.
So no pulldown/pullup resistors or diodes. (there are some exceptions but I will get into that later)
Never leave input pins unconnected (floating)
If you leave an input unconnected its state is undetermined (at least for CMOS) which can cause all kinds of odd behaviour in the
circuit. This also goes for unused gates so if you have a circuit that uses a NAND chip like a 4093 but only uses 3 of the available
gates you should not leave the input pins of the unsused gates floating. Eventhough the output is not connected to anything it could
still cause problems internally. Generally unused pins are direclty connected to GND or V+ depending on their purpose, so without
any pulldown/pullup resistors. It doesn't alway have to be GND or V+ though, for example the inputs of an unused logic gate could
be connected to any digital signal which in some case might be easier when designing a PCB.
there are cases in which you might want to leave a pin unconnected. Because of the high impedance of CMOS inputs they can act
like an antenna and if you add a wire to it it can pick up all kinds of electromagnetic 'noise' so you could use this to create some
unpredictable signals. Be careful though, inputs are sensitive to static electricity so they could get damaged.
Never connect outputs directly together*
If for example you would combine 2 signals, one being high the other low it'll create a dead short which has the potential to release
some magic smoke and as you might know chips don't work without this magic smoke. Logic gates are the key for combining signals
and simple gates like OR and AND gates can be achieved with some diodes and a resistor. (more about that later). There are some
exceptions: Some chips have what is called a tri-state output. This means that besides being high or low they can also be very high
impedance which basically makes them float. You can connect these pins directly together but you have to be very careful in the
design of the circuit so that they can never be in a state where they would create any shorts. Another somewhat similar exception is
when using analog muxes or switches. Output pins of these (or actually they are bi-directional so pins can be used both as output
and input) can also be high impedance so as with tri-state outputs they could be connected together directly if you design the circuit
properly. *Never connect outputs directly to GND/Vcc either for the same reasons as mentioned above.
When to use pulldown/pullup resistors
pulldown/pullup resistors are used whenever an input pin is connected to a signal but can stil end up in a floating state. An example
of this would be when you want to control an input with a switch. Let's say you have a switch between an input and V+. When this
switch is closed the input wil be high but when the switch is open the input would be floating. By also connecting a resistor to GND
to this input (= pulldown resistor) the input will be held low when the switch is open. You could also have a switch between the
input and GND in which case you would need to add a resistor connected to V+ (= pullup resistor). pullupdown/pullup resistors can
also be needed when using analog muxes/switches or chips with tri-state outputs as these can also cause a floating state. The choice
between a pullup or puldown resistor depends on the circuit.
note: the value for these resistors is usually not very critical and values between 10K~1M are most common
Diode OR/AND (mickey mouse logic)
Allthough diodes can serve several purposes they are often used in digital circuits to create simple logic gates to combine signals. You
could use actual OR/AND gates but using some diodes and a resistor can be much more convenient, especially when you need a gate
with a lot of inputs. To make an OR gate with diodes connect all the cathodes together, this will be the output. The anodes will be the
inputs. Whenever one or more of the inputs are high the output wil be high (like a standard OR gate) but if all the inputs are low the
output would be floating (the diodes block the current flow) so usually it also needs a pulldown resistor. To make an AND gate you
connect the anodes together, which will be the output and the cathodes will be the inputs. It's a bit less obvious than an OR gate but
when one of the signals is low (in other words they're not all high) the output will be low. However when all inputs are high the output
would be floating so in this case it needs a pullup resistor on the output. Because the outputs aren't buffererd this method can't always
be used. For example it gets a bit tricky when you would want to use a diode OR to control a diode AND or drive an LED. For this reason
it is also better to avoid using them as an output stage of a circuit, at least without an extra buffer for which a transistor/opamp/
comparator or even another logic gate could be used.
Note that you only need to use diodes for signals that can be both high and low. If for example you want to combine (OR) an output
of a logic gate with a switch connected to V+ you don't need a diode for the switch as it can never be low
Transistor inverter
As with the diode OR/AND gates you could use an actual inverting logic gate but sometimes a single transistor can be a lot more convenient.
Most commonly used is a standard NPN transistor (BC547, 2N3904 etc) with the Emitter connected to GND. The Collector will be the output
but since it can only provide a low signal in this configuration it also needs a pullup resistor. The base should have a current limiting resistor
in series and be treated as other inputs so not left floating. You could also use a PNP transistor connected to V+ and a pulldown resistor but
this is not used as often. One big advantage of a transistor over an actual logic gate is that it can be used to convert voltages. For example
controllling a logic circuit powered by 12V with 5V signals will usuallly not work but a transistor only needs about 0.7V on the base so 5V is
plenty and with a pullup resistor connected to 12V the output can now switch between GND and 12V with a much lower control voltage.
Protection
Although you could just use outputs of CMOS chips as they are it's wise to add a current limiting resistor in series to protect the ouputs
from accidental shorts. Personally I also add diodes in series which makes it possible to connect multiple outputs to one input as they
will form a diode OR together with the pulldown resistors I use on inputs. Downside of this method is that the outputs can only be high
because low signals are blocked by the diodes, so sometimes I have to add an extra pulldown resistor for example when I want to
listen to an output.
Decoupling
I won't go into the details but it is generally good practise to connect a small capacitor (10nF~100nF) between the supply pins of every
chip as close to the V+ pin as possible. Often these lunetta circuits might work fine without them but it can make the difference between
it properly working or not. There are cases where you don't want to use them, for example the Cacophonator which actually creates an
unstable supply voltage on purpose.
* (I might add some images later) *
edit: added some examples
Description: |
|
Filesize: |
42.6 KB |
Viewed: |
847 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
_________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube Last edited by PHOBoS on Thu Aug 19, 2021 4:53 am; edited 4 times in total |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
|
Back to top
|
|
|
jondent
Joined: Oct 04, 2013 Posts: 8 Location: Australia
|
Posted: Sat Jan 26, 2019 12:58 am Post subject:
|
|
|
great advice |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
jondent
Joined: Oct 04, 2013 Posts: 8 Location: Australia
|
Posted: Sat Jan 26, 2019 7:42 am Post subject:
|
|
|
many thanks |
|
Back to top
|
|
|
CHRISKELLY
Joined: Apr 08, 2018 Posts: 103 Location: England
Audio files: 3
|
Posted: Fri Feb 08, 2019 1:13 am Post subject:
|
|
|
Phobos - is there an easy way to explain how the mickey mouse logic AND works? Can't seem to get my head round that one |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Fri Feb 08, 2019 3:33 am Post subject:
|
|
|
That one can be a bit confusing as it requires you to look at it in a slightly different way. You're used to thinking that for an AND gate when all inputs are high
the output will be high. For this mickey mouse logic AND it's easier to understand if you write that as when none of the inputs are low the output will be
high. Or you could also say when (at least) one of the inputs is low the output will be low. Also the high output state is provided by the pullup resistor
and the low states through the diodes.
last but not least a truth table might help too (A/B are inputs, X is the output):
Code: | B | A | X
-----------
0 | 0 | 0
0 | 1 | 0
1 | 0 | 0
1 | 1 | 1 |
_________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube Last edited by PHOBoS on Fri Feb 08, 2019 2:51 pm; edited 1 time in total |
|
Back to top
|
|
|
CHRISKELLY
Joined: Apr 08, 2018 Posts: 103 Location: England
Audio files: 3
|
Posted: Fri Feb 08, 2019 6:21 am Post subject:
|
|
|
Ah OK thanks Makes sense now |
|
Back to top
|
|
|
|