If an embedded system is to make anything happen in the world, it will have to deploy energy to effect this. Moreover an essential part of the specificiation of an embedded system is that it should cause events to happen at the right time. So the energy required to effect the change will have to be deployed sufficiently fast, that is the embedded system will have to have the appropriate amount of power available. Now operating at low power is a key ingredient of modern processors, so typically there will not be enough power available at the output terminals of a processor to cause the required effects of the system on the world. Thus an embedded system will typically need to make use of power-amplifiers. Likewise, the inputs of most processors are designed to accept digital signals. Many of the devices that an embedded system can use to sense the state of the world do not directly produce digital signals compatible with a processor. So an embedded system may need to embody signal-processing devices to convert the raw output from sensors to a suitable form for input to a processor.
Since a processor is electronic in its nature, we will need to have a firm understanding of electricity. But first we must begin by refreshing our knowledge of some basic concepts of physics.
The scientific unit of time is the second. For many years scientists measured time in terms of the earth's rotation relative to the "fixed" stars. However the earth's rotation is actually slowing down, and astronomers' clocks have now become good enough to notice. Consequently the time-standard is now atomically based.
In our electronic systems things happen rather fast, so it's desirable to subdivide the second.
Time can be measured with great precision, a fact that can be very useful in electronics. The best clocks in use by astronomers today have a precision better than one part in 1012. To put it another way, such a clock would lose or gain a few seconds in a million years. While we will not need such precision, it's worth remembering that the most precise electronic component we can buy for a modest couple of dollars is a crystal oscillator that provides an excellent time-reference.
A mnemonic for getting a feel of the newton as a unit is that one newton is the weight of an apple - think of it as the force exerted on the palm of your hand by an apply lying on it.
The standard physical unit of energy is the joule. It is the energy released when a force of one newton acts through a distance of one metre. Being a mechanical unit, it is quite convenient when we come to think about how electricity can cause mechanical effects, such as turning an electric motor.
However it is also basic to understanding the electrical unit the volt, as we shall see.
A homely way of thinking about a joule is that it is roughly the energy released when an apple falls one metre.
Heat energy is usually measured in terms of the calorie, or the big calorie (Cal) which is the amount of energy required to raise the temperature of one kilogram of water by one degree centigrade.
Power is the rate of transfer of energy. The standard physical unit of power is the watt which is a rate of energy transfer of one joule per second.
Energy is conserved. That is to say the total amount of energy in a closed system remains constant (unless we're doing high-energy physics experiments). This means that energy is a very useful unifying concept for thinking about systems, such as embedded systems, which have both electrical and mechanical components.
Just as money is the universal currency in economic systems, energy is the universal currency of physical systems - electrical, mechanical, hydraulic etc.. Unless you grace the tables of very fancy establishments, you will always have a good idea how much your lunch ought to cost, and be outraged if you are presented with a bill for 50$ when you expected something around 5$. Likewise you should get in the habit of estimating the energy cost of performing a given action (for example switching the track-switches for the train).
Analysing engineered systems in terms of the flow of energy provides a unifying principle. Generally any electronic system can be improved by careful attention to energy-flow. A system that wastes energy is likely to be larger and more expensive than one which conserves it. Nowhere is this more apparent than in computation, where the amount of energy required to represent a bit of information in any form has plummeted over the last 40 years.
Thus the early vacuum-tube computers consumed several watts of energy to represent the state of one bit of information in a CPU. Modern processor-chips operate at levels of a microwatt per bit. In achieving such high performance, power density, that is the power consumed per unit of volume, is a crucial factor - a modern chip would be instantly vaporised if individual bits-of-memory operated at 1 watt each!
If energy is conserved, why is energy supply an issue? The answer to this question is that energy, while it is conserved, is inexorably converted from a more useful form to the less useful form of heat. Generally, if a circuit is producing a lot of heat this is an indication that it might be improved by redesign, or that it has been wrongly designed or built. Beware! components that have been wrongly inserted in a circuit often get hot enough to burn you, so feel your components with circumspection.
It is sometimes helpful to think of the flow of electricity as being like the flow of a fluid, say water. While it is important not to take this analogy too far, it can often help us visualise the rather intangible phenomena associated with electricity in more tangible terms.
Electrons are the "atoms" of electricity. In fundamental physics the electron carries -1 units of electric charge, just as the hydrogen atom is one unit of mass for chemists
However, one electron is a rather small amount of charge to be working with. The macroscopic unit of charge is the coulomb. 1 coulomb is minus the charge carried by 0.624142x1019 electrons. [Why a negative charge on the electron?]
Thus the coulomb is the basic measure of quantity of electricity, as the litre or gallon is a measure of quantity of water.
Electric charge is conserved - the total charge in a closed region of space remains constant. Indeed, in any work we shall be doing, the total number of electrons in a closed region of space remains constant [exceptions?].
Of course, positively charged particles exist. The protons that are a major constituent of the atomic nucleus are positively charged. However, the solid state is characterised by the immobility of atomic nuclei. Most of the devices we shall encounter use matter in the solid state.
In anything we do in this class, positive and negative charges will always be very nearly in balance. This arises from the fact that like charges repel each other, while opposite charges attract. This can be understood (in terms of classical physics) as the existence of a force between any two electrons which acts along the line joining them and which is inversely proportional to the square of the distance between them.
So, getting together a large number of like charges costs a lot of energy. This also accounts for the fact that the analogy between the flow of electricity and the flow of water breaks down. Water molecules attract each other moderately (moderately that is compared with the attraction between the atoms that make up the water molecule). So it doesn't take a lot of energy to collect a lot of water molecules together - in normal conditions water vapour will condense to form liquid water. On the other hand it would take an enormous amount of energy to bring a coulomb of electrons together into (say) a litre space that was devoid of positive charge.
Current is the rate of flow of electric charge. One ampere(A), or amp, is a flow of charge of one coulomb per second.
One milliamp is a thousanth of an amp 1mA = 10-3A. One microamp is a millionth of an amp 1µ A = 10-6A. We also speak of nanoamps 10-9A. and pico 10-12A. amps.
Ordinary matter consists of electrons (negatively charged) and atomic nuclei (positively charged). We can safely regard nuclei in a solid as remaining fixed in position and unchanged in nature. Almost all of the mass of matter is attributable to its nuclei. By contrast, some electrons in some solid forms of matter can move over long distances; in doing so, they constitute an electric current. Whether or not some electrons in a given solid material can move over long distances is a fundamental property of the material.
A metal is a material in which every atom has some electrons that are so loosely bound to the nucleus that they are free to move. Such electrons are called conduction electrons.
An insulator is a material in which all electrons are tightly bound to one specific atomic nucleus, so electric current cannot flow.
In a semiconductor electrons can be made to flow in particular circumstances, which property allows engineers to construct all manner of clever devices. Modern electronics depends greatly on the properties of semiconductors.
Since electrons repel each other, if a piece of material has excess electrons, energy is required to add even more electrons. Likewise, if a piece of material has a deficit of electrons, energy is required to take electrons away from it. We say that two pieces of metal A and B have a potential difference of one volt (1V) between them if it would require one joule to move a charge of one coulomb from A to B, or more precisely the energy cost of moving a small amount of charge from A to B would scale up to requiring one joule to move a charge of one coulomb.
Returning to our water analogy, we can think of a piece of metal as being like a trough of water. If we have two troughs A and B, with B being at a higher level, it costs energy to move a quantity of water from A to B.
It follows that when a current of I amps flows through a potential difference of V volts, the power required is given by:
This power may appear in the form of heat, light, or mechanical power. Or it may be stored to be released in electrical form later.
In a piece of metal free of outside influences the conduction electrons adjust themselves so that the potential difference across any two points is zero.
We can think of this in our hydraulic analogy by observing that if we have a trough of water free of outside influence, the water in the trough will be level - that is the energy cost of moving an infinitesimal quantity of water from one place in the trough to another is zero.
In the case of an insulator or semiconductor, we still have the concept of electric potential. But for a given piece of insulating material, the potential can vary widely across the surface, so we must always think of the potential at a point in the surface. For example, standard photocopying technology involves creating a pattern of charge on a drum coated with semiconductor material which exactly matches the pattern of black-and-white on the page being copied.
We have millivolts(mV), microvolts (µ V) in common use, and kilovolts (kV) too (but not exposed in our lab!).
Current goes through a wire or component Voltage exists between two points in a circuit, We also say voltage across two points. Voltage at a point means voltage between that point and "ground" "Ground" can be chosen arbitrarily; it is not necessarily related to the actual earth.
In electronics, information is carried in a signal, which is a time-varying value of some physical variable, usually voltage, sometimes luminous flux (in optoelectronics). It always requires energy to establish a signal at a point or transmit it to a remote point, because energy is always required to cause a change in any physical variable.
Power is the rate of transfer of energy. Generally, if we are processing information we want signals to have the lowest power consistent with their reliable transmission and processing. However, if we want a signal to make things happen in the big outside world, we will usually need to raise its power level by some kind of amplifier.
Among the factors putting a lower limit on usable power is noise, which can be thought of as an unwanted signal arising from sources internal to the circuit (e.g. thermal noise arises from that vibration of atoms which is thermal energy) or external (e.g. signals picked up from radio transmitters or the mains wiring).
Electronic circuits are classified as:
Kirchoff's Current Law states that in any electrical circuit, the sum of the currents flowing into a node is zero. This is really a statement of the conservation of electrical charge - the number of electrons flowing into a junction must be the same as the number flowing out, so, if we are careful about using the right sign when referring to our currents, the law can be related to basic physics.
Kirchoff's Voltage law states that the sum of the voltages taken round any cycle in a circuit-graph is zero. Or, equivalently, suppose A and B are two conductors in a circuit. Then the potential difference between A and B is the sum of the potential differences across device terminals along any path linking A to B.
It should be noted that Kirchoff's Laws, while they form the basis for analysis of circuits, are not perfectly exact, since they assume that the devices of which a circuit is made up are connected by perfect conductors which offer no resistance to the passage of electricity and have no capacity to store electrons. For most purposes this is an adequate assumption, though for very high speed circuits we need a more complete model.
One approach to dealing with this is to treat conductors themselves as being components in a more complicated circuit.
In particular, the voltage law will fail to be true if the circuit as a whole is exposed to intense and rapidly changing magnetic fields.
We build an electronic circuit out of conductors and devices. The simplest devices have two terminals. Two-terminal devices are characterised by the relationship between voltage V across the device and current I flowing through it. Resistors have the current proportional to the voltage Capacitors have the current proportional to rate of change of voltage. Diodes allow current to flow in only one direction. Inductors have the voltage proportional to rate of change of current. Photoresistors are light-dependent resistors.
A resistor is a device in which the voltage across the device is proportional to the current through it. This is usually written:
V = IR
Here, R is the resistance in ohms. The equation is known as Ohm's Law. It is also at times to think of a a resistor as a device in which the current through the device is proportional to the voltage across it. This can be written:
I = VC = V(1/R)
From the equations:
we get two more convenient forms by eliminating V and I respectively:
Resistors are the cheapest electronic component. Of all components, they are readily available in the widest range of values, from 1 ohm up to ten megohms, (10million ohms), in a range of preferred values which are chosen to divide each decade into values in each successive value is near to being a fixed multiple of the previous one.
The most commonly used resistor is a carbon film resistor capable of dissipating a maximum of 0.25W, with a value accurate to 5%. (Horowitz and Hill have a discussion on the extent to which you can believe in this accuracy). We have available in the lab a range of resistors with standard values from 10 ohms to 1 megohm, together with a supply of 10 megohm resistors. The nominal value of a carbon film resistor (in ohms) is indicated by coloured bands on the body of the resistor. Digits are colour-coded as follows:
Black 0 Brown 1 Red 2 Orange 3 Yellow 4 Green 5 Blue 6 Violet 7 Grey 8 White 9You can make a model in your head to remember this if you see that the middle digits (2-7) are the colours of the rainbow and then try to hang the whole thing on the idea of a body heating up (when it's cold it's black, when it's very hot it's white). The explanation isn't systematic, but it serves quite well as a mnemonic. The colour code is sometimes used for other devices. It's also worth remembering if you are making decisions about wiring where there is an obvious number associated with some conductors. For example, the 4-bit parallel interface used in the model-train system periphals makes use of 6-wire cable intended to interface modular-telephone style plugs and sockets. The conductor colours are thus pre-determined, but the convention I have adopted is
Black ground Red Digit 0 Yellow Digit 1 Green Digit 2 Blue Digit 3 White + 5 V powerIt's easy to remember this convention if you think of the colour-coding convention. The value of the resistor is encoded as D1 D2 E where D1 and D2 are the first two digits of the value of the resistor, and E is the number of zeros which follow. For example a resistor of 4700 ohms is encoded as yellow, violet, red. In addition resistors have a band which indicates its precision. These days this is almost certainly a gold band indicating 5% precision.
From suppliers, a range of 0.125W resistors is also available - it is primarily of interest for those who are building circuits with a high density of components - to exploit such resistors we would need to be designing professionally made printed circuit boards.
It is also possible to purchase a full range of 0.5W resistors. Generally, if you find that a circuit design calls for such a resistor, it's worth taking a look to see if it can be redesigned to use a lower value, or possibly to use another kind of component entirely. You can also obtain a very limited range of 1W and 10W resistors. Generally, if your circuit requires a low power resistor you can reckon to find just the right value of resistor to meet your requirements, whereas if you need a high power resistor you may have to adjust your circuit to fit the available values.
The stability of a resistor is also an important consideration. Resistance varies with temperature (increasing with temperature in the case of metal and carbon resistors). Soldering a resistor in a circuit can cause a permanent change in its value.
High precision resistors are available at a price from specialist suppliers. However if you need a resistance whose value can be specified to better than 5%, the combination of a fixed resistor with a "trimmer" potentiometer (q.v.) is often the best option. The time that you will really need to use a precision resistor is when you need a resistor whose value changes very little with temperature or ageing. For example, if you are wanting a precision voltmeter, you will typically be able to buy a 200mv meter quite cheaply, which can be adjusted to register in the range you require by using precision resistors.
Let's now consider what happens when we form simple combinations of resistors.
Firstly, suppose R1 and R2 are two resistors connected in series, as shown in the diagram.
In this configuration the current I through each resistor is the same, while if V1 and V2 are the potential differences across R1 and R2 respectively, from Kirchoff's Voltage Law, the potential difference across the two resistors in series is given by
V = V1 + V2
From the application of Ohm's Law, we have V1 = IR1 and V2 = IR2 . Hence
Now let's consider the case in which the two resistors are connected in parallel. In this case, the voltage V across each resistor is the same, but by Kirchoff's current law, the current I into the network of 2 resistors is equal to the sum of the currents through each resistor.
From Ohms law, we have V = I1R1, V = I2R2 so that
R1R2 R = ------- R1 + R2One can sum up these results by saying that for resistors in series the total resistance is the sum of the individual resistances, while for resistors in parallel the total conductance is the sum of the conductances.
Assuming we draw no current from the output, the current through the divider is given by
Thus the potential divider acts as a circuit which scales down a signal by the above factor. By itself it is of limited use as a signal processor, since it only works as calculated if an insignificant current is taken from the output, which means in effect that it has can only drive a load with insignificant power.
What does "insignificant" mean here? It can best be related to the accuracy with which the circuit works. It's fairly clear, for example, that if we want 1% accuracy from the circuit we'd better draw from the output less than 1% of the current flowing through the two resistors.
When we come to consider power amplifying devices such as transistors, we'll see how we can buffer a circuit like this one so that its output-voltage is almost independent of load.
For example, suppose you want a resistance of 1K ohms with a 1 percent accuracy. An economical way to do this is to put a 1.2K ohm resistor in parallel with a 10K potentiometer. To set the circuit up, the potentiometer can be adjusted until the resistance of the two in parallel is equal to 1K.
Why not use just the potentiometer? Well, the above arrangement requires you to set the potentometer with an accuracy of 10%, which is a great deal easier than setting it to 1%. And it's hard to be sure that a cheap potentiometer will hold its setting to 1%, while you can be reasonably sure of 10%.
In general, the idea of combining a fixed but inaccurate component with a "trimming" device is of considerable utility in electronics, though of course it's important to have only those adjustments that are strictly necessary in a circuit.
Another variation on this theme is the use of potentiometers as position transducers. For this application it is possible to purchase high-accuracy potentiometers.
A perfect voltage source is a 2 terminal "black box" that maintains a fixed voltage drop across its terminals, regardless of how much current is drawn out of it. Real voltage sources have a limit on maximum current, and behave like a at best like perfect voltage source with a small resistor in series.
Any combination of voltage sources and resistors can be reduced to a single voltage source in series with a single resistor. This resulting simple circuit is called "Thevenin's equivalent circuit".
Examples:
D-size flashlight cell - 1.5volts, 1/4 ohm resistance 10,000 joules (watt-seconds). At end of life, 1.0volt, resistance = several ohms.
dV/dI
So we can regard resistors as devices which have a fixed small signal resistance.
A diode lets current flow in one direction only. There is a small forward voltage drop, usually around half a volt for general purpose silicon diodes.
Usually a diode is realised as a cylindrical body with a lead emerging at each end. The direction in which current flows through such a diode is indicated by a band around the body which is nearest to the negative end of the diode when current is flowing through it. You can remember this as "the bar on the package is the bar in the diode-figure".
Small signal diodes can typically capable of passing 100mA in the forward direction. One Amp diodes are quite cheap, and about the size of a 1/4 watt resistor. Power diodes can handle thousands of amps, for example to rectify AC current for full-size trains.
In the non-conducting direction, diodes are limited by their peak reverse voltage abbreviated PRV. A PRV of 80V is common for run-of-the-mill diode, but hundreds of volts of PRV are possible. Exceed the PRV and you knacker your diode. Notice that the PRV is the PEAK reverse voltage, which is higher than the Root Mean Square voltage that is usually quoted for alternating current supplies.
A diode may allow current to flow in the reverse direction. This current is typically very small. Any diode that passes a reverse current you can measure with an ordinary instrument is knackered.
Diodes also have a (variable) capacitance when biased in the reverse direction.
These are clever diodes that let current go through backwards while maintaining a near-constant voltage across them. So, if you want to build an electronic voltage-source, a zener diode is likely to be the component which provides a reference voltage. You could think of a Zeer diode as being like a weir with water.
They also vary with temperature. The most temperature-stable zener diodes are those around 5-6 volts. Given the limitations of zener diodes, they are seldom used directly as voltage sources, but are incorporated in circuits where they are fed with a reasonably constant current. Amplification of what is in effect a signal from the zener is used to provide as much current as needed from the output of the electronic power source. It's also possible design a circuit which uses a 5-6 volt zener independent of the required output voltage. We'll see how to do this when we learn about the magic of transistors.
Electrically these are diodes with a rather high forward voltage drop (say 2V). If you pass current through them (in the forward direction), by magic, they emit light! The rule for the forward drop is is that the bluer the light the higher the forward voltage - blue LED's may take as much as 5V to drive them.
There are various versions - arrays of LED's are used to form displays, but usually with limited resolution. Another configuration that is seen is to have two LED's back-to-back in a single package - pass the current through in one direction and you get red light, in the other direction you get green light. You can get any colour between red and green by alternating the direction at a speed the eye can't follow (say 100hz).
You should then try to orient your components so that the most positive terminal is highest, with the least positive terminal being lowest.
This can be done for the "DC analysis" of the circuit, that is an estimation of the average voltage levels. Of course, when a circuit is doing something, typically levels will be changing as signals pass through it.
It would be a mistake to follow this "highest = most positive" rule slavishly, because it may result in circuit drawings which are unnecessarily large. But it's a good rule to follow in general, and certainly at first, until you are used to reading circuit drawings.
Only a limited range of metals can be soldered. You can't solder stainless steel or aluminium with standard soldering techniques, because these metals have a thin coating of oxide which gives them their bright appearance. You can solder copper, tinned copper, brass, iron, most steels.
It is vital when soldering to heat up both surfaces to be joined to the melting point of solder, and then feed fresh solder from the reel into the joint. Do not attempt merely to transfer solder to the joint using the iron. The solder we use appears to be a thin solid wire. Actually it has a core of flux which helps to clean the metal to be joined.
However, if you're soldering a component such as a transistor or resistor directly into the circuit, you should beware of overheating it. We do have available little heat-sinks that can be clamped on the leads of a component to protect it during soldering. Typically only a few seconds of heat need to be applied.
While most electronic components and all printed circuit boards have small amounts of metal to be joined, if you are trying to solder heavy conductors or other objects, you will need to feed much more heat in the joint to make it "take".
In a properly soldered joint, the solder wets the metal being joined. You can tell that the metal is wetted by the shape of the meniscus - if the solder looks like a little spherical blob on the metal, the joint is a bad "dry" joint. If the surface of the solder is concave as it joins the metal, then you have a good joint. Bad joints are a source of intermittent circuit failures which are hard to find.
Some magnifying lenses are available in the lab to allow you to examine soldered joints carefully.
Both solid and flexible wire can be soldered. Solid wire is probably easier to work with when making connections in a circuit board. It should not be used for any connection that is subject to flexing, so should not be used for connecting between circuit boards (unless these are rigidly mounted in some kind of card-cage). For solid wire subject to flexing will eventually fail by metal fatigue, giving rise to an intermittent connection that causes malfunctions that are hard to locate.
Flexible wire can be used for wiring up a circuit board. A thin gauge is most suitable. The most satisfactory way to make a joint is to tin the end of the wire (which may need to be twisted to make it suitably compact) with solder before attempting to make the joint. If there's a fat blob of solder left at the very end, just snip it off.
When you solder flexible wire, the end of the wire in effect becomes rigid. Where the remaining flexible part joins this rigid part the wire is likely to fail, so it must be supported in some way to ensure that most flexing takes place well away from the soldered joint. A short length of heat shrink tubing over the end of the wire is usually enough to prevent this happening. It also serves as insulation if needed.
Metal to be soldered should be clean. It can be worth it to burnish up a printed circuit board with a fine-grade abrasive paper before soldering. Old flexible (multi-strand) wire may not take solder easily, even if it was originally tinned. Typically you will have to get it hotter than you might expect for the solder to "take".
Care is needed when soldering, because the solder is hot enough to burn you.
The most useful instrument for checking your work is the Digital Volt Meter (DVM). Ours are bright yellow. Set the dial to the continuity/diode check position.
You should also do a basic check before you apply power to a circuit. Most semiconductor devices will die instantly if you connect the power the wrong way round. One former student in this course destroyed 80$ worth of components by making a wrong connection. Note also that the larger kind of capacitors (above 1 microfarad) are polarised - they also will die if you connect them wrongly. Watch out for excessive current consumption by the circuit. This is usually indicative of a component wrongly wired. Such components can get quite hot enough to burn you, so be careful...
It's difficult to remove devices that have many legs, for example most integrated circuits. For this reason, you should always put integrated circuits in sockets when making an experimental board. And you should regard all boards built in this course as experimental. Sockets also make it easier to debug a board, because you can check that you have provided the right "living conditions" for an integrated circuit before you put it in the board, and if necessary you can pull it out and check again, or perhaps replace it if you have knackered it.
Occasionally you may need to increase the temperature of the iron to melt enough solder to modify a board as required.
Don't forget that desoldering may heat components up enough to knacker them.
Using desoldering wick is generally less satisfactory than using a pump. It's difficult to get it hot enough to work, and it's liable to leave odd bits of wire around to cause shorts, or to solder itself to the circuit.
When making a board it's desirable to require each connector to be different from the others on the board, so that the board cannot be accidentally connected wrongly, possibly resulting in the total destruction of the components on the board, or even of the board itself. This is something like a hardware equivalent of type-declarations when writing software, with the difference that if you get a type error your program doesn't have its functions shrivel up and die.
Unfortunately when we are making prototypes it's difficult to find many different connectors that can be used on a board without drilling a distinctive pattern of holes. Our general purpose boards from Radio Shack are drilled with a pattern of holes on 0.1" centres: most connectors won't fit this pattern. So typically we use male and female headers to connect to boards. Probably the easiest system to work with is to put female headers on the board, and use male headers as plugs to fit into them. You can wire up these male headers as described in the Handyboard manual. Sometimes, particularly with double-row male headers which you'll need for the SSI interface, it's worth putting a blob of epoxy to hold all the pins in position once the basic wiring is done, since the pins of a male header are likely to slip through the plastic.
We can try to make these connectors distinctive by using ones that have spare pins and sockets. If one of these spare pins is snipped off and put in the corresponding socket, you've created a connector that will only go in the right way round. With a bit of care we can create conventions which make it difficult to plug a system up wrongly.
In some assignments the connections with the circuit board will be specified precisely. You must follow this specification, since this should ensure that boards built by different groups are interchangeable. Specifying "pin-out" is as much a part of specifying hardware as specifying a ".h" file is in specifying C, or specifying an interface is in Java.