Uploaded by Spike Os

Chapter 1

advertisement
Chapter 1
Physical Computing
Week 1: Representation
The Physical Computing workshops are a chance for you to develop
understanding and skills in the building blocks of computers, and also to
experiment with some of the fundamental ideas behind computation. It
is important that you realise why we are doing this – it is not because
we expect most of you to have careers designing and buildings
computers, but because the confidence you gain from understanding how
things work at this low level with help you work at higher levels.
The first technical task we are setting is to work out the basics behind
the hardware and software we are using, how components work and how
to connect them all together! There are lots of simple details you will
need to learn quickly – none of them are difficult, but you will need to
do the exercises to ensure you have got them right. Remember that we
are not trying to teach you electronics here but getting you ready to
experiment with the building blocks of computation. The fact that you
will pick up a few very basic electronic ideas on the way simply helps
you in a competitive job market!
Fig 1. Your first circuit: Eight switches operating eight LEDs
CHAPTER 1 | Michael Heeney & David Dorvekinger
The first task is simply getting some switches to control some LEDs
(Light Emitting Diodes). Essentially this Is just wiring up a simple
circuit to connect a power source to lights. This is a good start to
understand representation; using SPDTs (switches or Single Pole Double
Throw) to turn on LEDs. The LEDs represent binary numbers, being
“on” to represent a 1 or being “off” to represent a 0. It is important on
the figure below to look at the numbering of the components, we always
start with 0 e.g. LED 0. This is because of how we work with the
number systems that have been familiar with you in the Binary
Handout:
1) Binary (Base 2) – Numbers go between 0 and 1
2) Octal (Base 8) – Numbers go between 0 and 7
3) Hexadecimal (Base 16) – Numbers go between 0 – F (15)
The same as when you’re counting binary numbers, the switches are
LEDs are labelled in a way to count from the right-hand side!
It is important before starting these exercises, you have read and
understood the National Instruments MultiSim guide and the 4-bit
binary adder exercise; so, you know how to import basic components
onto your canvas and are familiar with navigating around the GUI. For
this exercise you will need the following components:
1) 8 – LEDs (Known as probes on MultiSim)
a) Go to Master Group >> All groups and search “Probe”
2) 8 – Switches (SPDT – Single Pole Double Throw)
a) Go to Master Group >> Basic >> Switch
3) 1 – 5V VCC (Power!)
a) Go to Master Group >> Sources >> Power Sources
4) 1 – GND (Ground (0V) – Opposite of Power!)
a) Go to Master Group >> Sources >> Power Sources
CHAPTER 1 | Michael Heeney & David Dorvekinger
Ground in electronics is a reference voltage with respect to which the
voltages in the other part of the circuit is measured. In other words, it is
the point where the black wire of the multimeter (more of this in later
weeks!) is fixed in measuring potential difference between any two points
of the circuit. You will notice once we start looking at Integrated
Circuits a lot, that all chips require a GND to and 5V to operate; with
real hardware, if these are the wrong way, the chip will blow!
Once your circuit is completed, press the play and make sure you can
turn the LEDs on and off. When you can try the following exercises:
1) Convert the following numbers from decimal to binary and display
them on the LEDs.
a) 5
b) 17
c) 21
d) 257
2) Convert the following octal numbers to binary and display them on
the LEDs.
a) 17
b) 25
c) 234
3) Convert the following hexadecimal numbers to binary and display
them on the LEDs.
a) 17
b) A5
c) 6B
4) Look at simple binary to ASCII charts and convert the first letter of
your name to binary. Tell us the answer in #physical on Slack.
Save this circuit! It will save you a lot of time for the future and allow
you not to waste time re-labelling, re-importing all the basic components
which will be needed for almost all circuits!
CHAPTER 1 | Michael Heeney & David Dorvekinger
Now thinking of binary to decimal conversions, we will introduce 7segment displays. A 7-segment display is 7 different “lines” that are lit up
(or sometimes displayed by rotating things mechanically) to make
conventional representations of our usual numbers 0…9. The signals are
we use to “drive” this display are binary numbers, using up to the binary
representation of 9 (1001), the 7-segment will deploy some
encoding/decoding to show us a 9.
Fig 2. Four of our switches connected to the 7-seg display (called “DCD HEX” on
MultiSim!). Binary to Decimal conversion.
CHAPTER 1 | Michael Heeney & David Dorvekinger
MultiSim has lots of displays, from Hexadecimal to ASCII displays. We
will use some different ones in the year to represent different things, but
make sure you understand how this is working and save it, it’s very
useful for lots of things e.g. understanding outputs from an integrated
circuit, reading a carry-in or display memory addresses, for example.
5) Make sure you’re able to understand the basic conversions and show
us in your work. Display the following numbers:
a) 6
b) 9
c) 1
6) Implement a 7-segment display to show the answer of the 4-bit binary
adder from last week!
CHAPTER 1 | Michael Heeney & David Dorvekinger
Week 1: Transistors
Transistors are found almost all electrical device. To read this document
on your device or print it onto paper, it is made possible by millions of
transistors working together, with hundreds of thousands of conversions
happening simultaneously. For an understanding on the relevancy of
this, the first production use of transistors was transistor radio (the
Regency TR-1 by Texas Instruments) – it used only four transistors! But
in other systems we could think of the first microcontroller (Intel 4004,
built in 1971) which contained 4,528 transistors. More recently, we can
look at high-spec gaming CPUs – the AMD Ryzen Threadripper 3990x
has approximately 39,500,000,000 MOS transistors!
This section will discuss what transistors are and how they built simple
logic gates; which will later use as integrated circuits.
Transistors can control the flow of electricity. They can be used as
switches or amplifiers. In the following exercises, we will use transistors
as switches. Using them in this style, we can control what path the
electrons should take to complete the circuit.
There are two types of transistors, bipolar junction and field effect
transistors. Both of them can be used as switches for this exercise. The
most common transistor is the MOSFET (Metal Oxide Semiconductor
Field Effect Transistor). More than 90% of transistors are MOSFETs
because they can be miniaturised and are easier to manufacture.
We will use the NPN transistor as switches. To turn on the transistor,
we need to apply a small amount of current to the base to enable the
current to flow from the collector and emitter. The reason for this is
because the three legs have a negative, positive and negative charge (this
is why NPN transistors are called this). As soon as we apply a small
current to the base, we introduce extra electrons so the depletion region
disappears, and the electrons can freely flow from the collector to the
emitter. In the next section you will see how we can use the transistors
to create logic gates.
CHAPTER 1 | Michael Heeney & David Dorvekinger
Fig 3. The NPN transistors consists of three legs. The Collector, Base and Emitter.
We will now create a digital buffer using a transistor. A digital buffer is
an electronic circuit that is used to isolate the input from the output,
providing either no voltage or a voltage that is same as the input voltage
(in our case, 5V).
On the diagrams below, there is a very simple circuit, demonstrating a
buffer. The electricity flows from the 5.0V toward the ground. On the
left the LED is off, even though it’s connected to 5V and the wires are
going to ground. Exactly for the reason we discussed above, about the
depletion region. To be able to turn the LED on, we need to turn on the
transistor first. We need to have a small amount of current running to
the base, to enable the flow from the collector to the emitter. As the
picture on the right shows, the switch is closed; this way the transistor
can turn on and it enables the current to flow through the LED, so it
turns on.
CHAPTER 1 | Michael Heeney & David Dorvekinger
For these exercises you will need the following components:
1) – LED
a) Go to Master Group >> All groups and search
“LED_RED_RATED”
2) Up to 2 Switches
a) Go to Master Group >> All groups and search “DIPSW1”
3) Up to 2 NPN Transistors
a) Go to Master Group >> All groups and search “2N2925”
4) Resistors
a) Go to Master Group >> All groups and search
“RESISTOR_RATED”
5) POWER (VSS) and GROUND as previously
Fig 4. A simple buffer showing two states. Switching the switch on provides an on or
off LED.
7) Create the circuit for a digital buffer and test it. How different do you
think an NOT gate (or inverting buffer) will look in circuit? Note:
Remember to save!
The next two diagrams below show an inverter. An inverter has one
input and one output, same as the buffer. The input can be 0 or 1 (0
representing the absence of electricity and 1 is the presence of electricity
in the given input) and the NOT gate will invert these states, giving the
output of 1 if the input is 0 and visa-versa.
The circuit looks similar to the previous one. The only difference is an
extra wire on the right side of the transistor and the position of the
LED.
CHAPTER 1 | Michael Heeney & David Dorvekinger
On the left diagram the LED is on and the switch is off. By seeing this
we can confirm, this circuit is creating an inverter. The input is 0 (the
switch if OFF) and the output is 1 (the LED is ON). As we look closer
to see how it happens, we can see the wire is coming from the 5V, it
forks and connects to two different resistors. The resistors have the same
amount of resistance. Following the wire on the top, it forks again and
connects to the LED and the transistor. Looking at the wire connected
to the LED, we can see it goes straight to the ground. This way the
circuit is closed, and the LED is turned on.
The diagram on the right shows, what happens when the switch is ON.
Our input is 1, and the output will be 0. Previously we followed the wire
on the top, in this instance we will take a closer look what happens to
the other path. As soon as the switch is ON (the switch will close, and it
connects the wires) it allows the electricity flow into the base and it will
turn the transistor on. The resistance is the same in both wires (220
ohm). By knowing, electricity takes the path of least resistance and the
LED has a higher resistance than the transistor, we can understand why
the LED is OFF.
Fig 5. An inverter, or NOT gate.
So, thinking of this, an inverter (or NOT gate) has the following truth
table and diagram as a component in a schematic:
INPUT
0
1
OUTPUT
1
0
Fig 6. The NOT gate (also seen as ¬), as drawn in logic and it’s truth table of
inputs/outputs.
CHAPTER 1 | Michael Heeney & David Dorvekinger
8) Build and test the circuit above in MultiSim:
a) We are now building gates, can you find a NOT gate (as an
integrated circuit) on MultiSim and get it working? We are here to
help, ask if stuck! In the library it will be called 74LS04.
b) On paper or on your whiteboard, draw a NOT gate as above, what
happens if you invert a NOT gate?
To implement an AND gate we need two transistors. The positioning of
the components is similar to the buffer, because the electricity needs to
flow through the transistor in order to turn the LED on. An AND gate
works with two inputs. On the diagram there are A and B the two
inputs to control the state of the LED. The AND relation means, both of
the inputs need to be 1 (true) to get an output of 1 (in other words, we
need to close both switches to turn the LED on). If we take a closer look,
we can see it very clearly that if we only close either of the switches, the
electricity will not flow to the ground, since the two transistors are
dependent on each other.
Fig 7. An AND Gate.
CHAPTER 1 | Michael Heeney & David Dorvekinger
With the truth table, you can see an AND gate like multiplication – it
needs two positive inputs to have a positive output. Again, an AND has
the following truth table and diagram as a component in a schematic:
INPUT 1 INPUT 2 OUTPUT
0
0
0
0
1
0
1
0
0
1
1
1
Fig 8. The AND gate (also seen as ∧), as drawn in logic and it’s truth table of
inputs/outputs.
9) Build and test the circuit above in MultiSim:
a) In the same library as the NOT gate, look for a 74LS08 – this is an
AND gate. Can you import 3 of these to create a simple
combinatorial circuit? That should mean you will have 4 total
inputs (switches) and still 1 LED.
b) You now have created an AND and a NOT gate in transistors, can
you use the premade components in MultiSim to try and create an
NAND gate? Hint: This means NOT AND.
i) Once you have, can you think how this gate would look as a
symbol and can you show the truth table for it?
To create an OR gate we need two transistors. The OR gate circuit has
two inputs. There are three different ways to turn on the LED in this
circuit. To confirm this behaviour first we need to understand how does
an OR gate work. Using the two inputs, there can be four different
outcomes. When both of the switches are closed, either of switches are
turned on (this gives two iterations) and the scenario when both of the
switches are on. To implement this logic, we need to have a circuit that
is parallel in terms of the wiring of the transistors, so neither of the
transistor is dependent on the state of the other transistor.
CHAPTER 1 | Michael Heeney & David Dorvekinger
Fig 9. An OR Gate.
With the truth table, you can see an OR gate like addition – only with
two negative inputs, is the output ever 0. Again, an OR has the following
truth table and diagram as a component in a schematic:
INPUT 1 INPUT 2 OUTPUT
0
0
0
0
1
1
1
0
1
1
1
1
Fig 10. The OR gate (also seen as ∨), as drawn in logic and it’s truth table of
inputs/outputs.
CHAPTER 1 | Michael Heeney & David Dorvekinger
10) Build and test the circuit above in MultiSim:
a) In the same library as the NOT and AND gate, look for a
74LS32N – this is an OR gate. Can you build a NOR gate? NOR
Gates are used to build almost any integrated circuit and they help
use soon understand concepts like memory and flip flops soon.
b) There are two famous laws in logic that we use extensively in
designing circuits: De Morgan’s Laws. Can you draw the truth
tables for the truth tables and convince yourself that these laws
hold? Then build the circuits in simulation to check.
Fig 11. De Morgan’s Laws.
CHAPTER 1 | Michael Heeney & David Dorvekinger
Download