The Outside World

advertisement
The Outside World
The computer in an embedded system interacts with the other parts of the
system, receiving and sending various types of electrical signals.
The input signals typically represent some aspect of the outside world, such
as position, speed, temperature, force, communications input, user input,
or whatever.
The output signals may control some mechanical device, varying the speed
or direction of motion of a motor, turn on or off power to a heater,
communicate with other devices, and so on, and will often display
status/results to the user.
Setting up these signals and connecting them to the embedded computer is
the job of the hardware folk (poor devils), but it is very desirable that
software developers have an understanding of the basic issues.
So here is a quick summary of some of the main ideas involved :
Review of basic electricity/electronics
Safety
Inputs
Outputs
Real Time & Embedded Systems
1.1
CA480  Dublin City University 2007
The Electric Review (1)
Electric charge comes in two types, ‘plus’ and ‘minus’. The basic unit is the
charge on a fundamental particle, the electron, which happens to have a
minus charge. This is too small for everyday use, so the ‘Coulomb’, which
is the positive equivalent of about 6,000,000,000,000,000,000 electron
charges, is used instead.
When charges move there is an electric current. This could simply be
measured in Coulombs per second, but for some reason a new unit is
used, the Ampere, shortened to Amp, or just A (he was a notoriously
Absent-minded French scientist). One A is just shorthand for ‘one
Coulomb per second’ – very helpful.
It’s just like water in a river – Coulombs instead of litres, Amps instead of
litres per second.
Note current is not the speed of flow, but rather the quantity that goes past
per second. The Amazon is not flowing very quickly as it enters the sea,
but the number of litres per second is huge. The number of movable
electrons in a metre of e.g. household wire is enormous, like a vast river,
and a current of 1 A corresponds to the electrons moving along at a
speed of only a few metres per month.
Real Time & Embedded Systems
1.2
CA480  Dublin City University 2007
The Electric Review (2)
If the electrons in a wire drift along very slowly, how can electrical devices
react so quickly?
The electrons in the wire repel each other so savagely, and are so light, that
they behave like a very rigid rod – start one end moving with a push, and
the other end moves almost immediately.
Push one end of a solid rod so as to start it moving slowly. The push travels
down to the other end at roughly the speed of sound in the rod, maybe
about 1 mile per second, and the other end starts also to move slowly
almost at once. The push travels fast, even though the rod travels slow.
Push the electrons at one end of a wire, and the push travels to the other
end at about two thirds the speed of light, about 120,000 miles per sec
(the actual speed depends on many things, but can’t exceed that of light).
A billion (i.e. 1,000,000,000) seconds is roughly 31 years. So a nanosecond,
I.e. a billionth of a second, is to a second as a second is to 31 years. A
computer with a 1 GHz clock does something new every nanosecond. In
that time an electric push can only travel about 20 cms.
So if a signal is to be sent from A to B and an answer received back in one
nanosecond, A and B need to be closer than 10cms. This is one reason
why it can be desirable for computers to be small.
Real Time & Embedded Systems
1.3
CA480  Dublin City University 2007
The Electric Review (3)
If a solid rod is moving, it can be difficult to stop it, or to make it go faster,
because of its inertia, which we measure by its mass.
Electrons are so light compared to electric forces that they can be stopped
moving very quickly – very high frequencies are possible.
There is a catch though
Moving electrons cause a magnetic field, and when the current changes the
magnetic field changes. And a changing magnetic field causes an electric
force, which will try to resist the change in the current – a bit like inertia.
By arranging a wire as much as possible in the magnetic field of its own
current, e.g. by shaping it into a coil, this effect can be made quite large.
Don’t try to stop the current in a coil quickly – give it a chance to die off.
This property is known as inductance, and if signals are to change quickly
inductance needs to be kept low.
Interacting electric and magnetic effects are also involved in transformers,
and are the basis for electromagnetic waves, I.e. radio, light, X-rays and
so on.
Real Time & Embedded Systems
1.4
CA480  Dublin City University 2007
The Electric Review (4)
So what gets electric charges to move – what causes a current to flow?
In the case of the river, which only flows downhill, gravity is the explanation.
Electric charges feel gravity, but also an enormously stronger force, the
electric force (we can forget about gravity by comparison). This force is
the source of the atomic bomb’s energy, for example, and should be
treated with respect at all times.
All electrically charged objects exert an electric force on each other – the
force gets stronger as the charges get nearer, and weaker as they get
further apart, but never dies out entirely. The force can either push or pull
- like charges repel each other, unlike charges attract. Luckily most
objects, including ourselves, have equal amounts of positive charge (at
the centres of atoms) and negative charges (the electrons on the
outsides of atoms) and the repel and attract forces exactly cancel out.
This is just as well.
Electric charges also feel a force if they move in an area where there is a
magnetic force, or if the magnetic force changes. Note that for
magnetism to cause an electric force, there must be a change, either in
position or in the size of the magnetic force. It turns out that electric and
magnetic forces are really just different aspects of the same thing, the
electromagnetic field, but that’s another story.
Real Time & Embedded Systems
1.5
CA480  Dublin City University 2007
The Electric Review (5)
So how to measure the size of the electric ‘push’ that is trying to get the
current to flow?
Standard way is to look at the energy involved in the charge going from A to
B, the so called ‘potential difference’ – the ‘potential’ refers to ‘potential
energy’. This will depend on the amount of charge involved, so let’s talk
in terms of unit charge being moved. If one Coulomb gets one Joule of
energy in getting from A to B, we say the potential difference is one Volt,
or one V (after Volta, an Italian scientist), and we talk about voltage.
Looking at energy difference is fine for the overall push, but what about the
actual force, the electric force strength - how big is it. Energy change is
got by multiplying force x distance, so we can measure the electric force
in units of Volts per metre. For a given voltage difference, if the distance
between A and B is large, the electric force will be small, and if the
distance is small, the electric force will be large.
In objects that are very small, voltage differences must be kept small, to
keep down the maximum electric force. Circuits on chips are now so tiny
that voltages are often kept below 2V.
Notice also that voltage refers to energy per coulomb – if the voltage is very
high but the charge very small, so that the energy involved is tiny,
objects like humans may be little affected, although objects with small
features, such as chips, may be badly damaged.
Real Time & Embedded Systems
1.6
CA480  Dublin City University 2007
The Electric Review (6)
So how hard is it, for a given ‘push’, to get charge to go onto B?
As we get charge onto B, it repels the next lot of charge coming on, and
does so very strongly. The bigger B is however, the more the existing
charge can spread out, and the easier it will be to get more charge on. So
the ‘capacitance’ of B will depend on its size, and it turns out it also
depends on its shape. We can measure the capacitance of B in terms of
the amount of charge we can get onto it per Volt of push, in units of
Coulombs per Volt. To help ensure the writers of glossaries of technical
terms have enough to do, this is named the Farad, or F (after Michael
Faraday, a great scientist and admirable man).
Most objects have capacitances so small they can be regarded as zero.
Some devices, known as capacitors, allow both positive and negative
charges to be stored close to each other, and are shaped in such a way
that the repulsive forces are mostly cancelled by attractive ones. These
can store useful amounts of charge even at low voltages. They are widely
used in electronics, often as a kind of reservoir to damp out fluctuations
in the supply voltage (decoupling capacitors).
Because the capacitance of most things is so small, if charge does get
transferred onto them, say by rubbing them against something else, a
very high voltage results, sometimes big enough to cause a spark, as the
charge jumps through the air to somewhere it can spread out more.
Real Time & Embedded Systems
1.7
CA480  Dublin City University 2007
The Electric Review (7)
So how hard is it, how much ‘push’ is needed, to get charge to travel
through the connection between A and B?
We might expect that some energy will be used up just in getting charge to
travel through a connection, and that there will be a voltage difference
between the two ends of the connection as long as a current is flowing.
This is generally true, although special ‘superconductors’ are an
exception.
We might expect that this voltage difference will be greater for bigger
currents. This also is generally true, though again there are exceptions.
What few expected was that for many materials, the voltage difference is
just proportional to the current. Double one, you double the other, and so
on. Poor Ohm, a German academic who suggested this in the early
1800s, was sacked for suggesting something so ridiculously simple, and
only re-instated more than ten years later.
Ohm’s famous law, Voltage = Current x Resistance, or V = IR, where the
voltage V is in Volts, the Current I is in Amps, and the ‘Resistance’ R is in
Ohms, is probably the most widely used formula in electronics today.
The resistance of a connection depends on the ‘resistivity’ of the material
from which it is made, the thickness of the connection (wide pipes have
less resistance to flow), and its length (long pipes have more resistance).
Real Time & Embedded Systems
1.8
CA480  Dublin City University 2007
The Electric Review (8)
Few (if any) physical properties have as wide a range of values as the
resistivity of materials.
Metals generally have low resistivity (silver and copper in particular). They
are good conductors.
Some substances have middle resistivity – ordinary water with the usual
amount of impurities, the fluids of which biological organisms are mostly
made, semiconductors like silicon with small amounts of special
impurities added, and so on.
Some substances have very high resistivity – they are good insulators.
Rubber, most plastics, glass, dry paper, dry air, the vacuum are all
examples. Even a high voltage will only manage to force a tiny current
through them.
It is worth noting that there are no perfect insulators. A big enough electric
force (Volts per metre) will ‘break down’ any insulation, and let a
catastrophically large current flow if enough charge is available.
Very good insulators can cause problems, any charges rubbed onto them
cannot leak away easily, and high voltages can result – static electricity.
In humid environments condensation can cause problems due to leakage
currents. On the other hand very dry environments encourage static due
to lack of leakage currents. So humidity control is a good idea.
Real Time & Embedded Systems
1.9
CA480  Dublin City University 2007
The Electric Review (9)
Getting a charge to go from A to B is all very well, but the capacitance of B
is typically so small that only a very small charge will be involved.
It’s more interesting to get the charge to move around in a circuit.
This current may be driven by a chemical reaction in part of the circuit (a
battery), where one compound in the battery wants to give out electrons,
and another wants to take them in. Or it may be driven by a changing
magnetic field, as in a generator or a transformer. Or it may be generated
by light falling on special materials, and so on.
The total voltage ‘pushing’ the current around will be equal to the sum of the
voltages across the different parts of the circuit, including the voltage
needed to push current through the voltage source itself (the internal
resistance of the source).
The most basic circuit in electronics, and in many ways the most common,
is arguably the ‘potential divider’, where the same current goes through
two components connected ‘in series’. The voltage across each
component is then the same fraction of the total voltage as its resistance
is of the total resistance. By varying the resistance of one component the
voltage across it can be made to change.
All the electronic devices we deal with involve circuits. You should know the
basic rules for parallel and series connections and power – consult ‘The
Art of Electronics’ or the WWW if you’ve forgotten
Real Time & Embedded Systems
1.10
CA480  Dublin City University 2007
Safety, Safety, Safety (1)
Electric current heats the substance it passes through. Too big a current
can cause fire. Wires must be thick enough (low resistance) to carry the
maximum current without overheating. To ensure this, circuits include
fuses, thin wires which melt first and breaks the current if it exceeds a
safe limit. Never bypass a fuse.
Human nerves use electrical impulses to tell the muscles to contract. An
electrical current passing through the body can have the same effect,
and cause muscles to contract very strongly and lock up out of control.
This ‘electric shock’ can be very painful. Worse, since the heart is a
muscle, and breathing depends on muscles also, it can be fatal.
Even a small torchlight battery of 1.5 V will pass a current through the
human body. The body’s resistance is high enough to ensure this current
is too small to be noticed. Voltages less than 20V or so are unlikely to
cause a big enough current through human tissues for any electric shock
to be felt. But the mains voltage of 230V can push enough current
through the human body to stop the heart and stop breathing, and cause
some burning, and is lethal.
Many low voltage supplies in computers (also e.g. car batteries) can put out
big currents, in excess of 100A. They won’t give an electric shock, but If
a finger ring or metal watch strap shorts out such a supply, the resulting
high current can make the ring or strap red hot, or even melt it, resulting
in the loss of a finger, or badly damaged wrist and paralysed hand.
Real Time & Embedded Systems
1.11
CA480  Dublin City University 2007
Safety, Safety, Safety (2)
The main danger of electric shock is from the mains 230V. One side of the
this supply is connected to earth by the power company, so unless you
are floating in mid-air, you personally are connected to the mains supply.
The connection is really good (low resistance) if you are standing on wet
ground. If you now touch the ‘live’ side of the mains, the one trying to
send a current to the side connected to earth, it will see you as an
attractive alternative path, and send a current through you. This is best
avoided (understatement). This current can be cut off quickly by an ‘earth
leakage trip’ or ‘residual current detect RCD’ device if this is installed.
So :
Ensure that the mains supply to any device you are working on
has an RCD – if not, or if uncertain, buy one of the plug-in types.
Ensure a fuse or circuit breaker is protecting wiring from
excessive currents, which can cause fires.
Ensure the metal case is earthed, so that it cannot become live if
accidentally put in contact with the mains.
Wear nothing metal on hands or wrists – a molten ring will
remove a finger in a second. Wrists are worse.
Most important, take care - RCDs fail, earth links work loose, …
And if you see someone getting a shock, get the supply turned off
before helping the victim, or you may become a victim yourself.
Real Time & Embedded Systems
1.12
CA480  Dublin City University 2007
Safety - Handling Components
If removing or installing circuit boards or components, care needs to be
taken to avoid causing damage. The two main dangers are mechanical
abuse and static electricity.
It is surprisingly easy to misalign pins and sockets, causing bent or broken
pins or perhaps even electrical damage due to incorrect connections.
In very dry environments, charges can build up on the human body as it
rubs against other materials and against the air, and be unable to leak
away because everything around is such a good insulator. These
charges will spread out to any uncharged object brought near, perhaps
jumping as a spark since the voltage can be very high. This may give the
human a slight jolt, but is not serious, as the total energy involved is tiny.
On the other hand, it can totally destroy electronic components.
So
done
Take care to check alignment of pins and sockets. Do not force
things – check and see what’s going wrong. Usually you can feel
that things have located properly – there’s a kind of ‘clunk’. If this
is missing, be suspicious.
Earth yourself before touching any components. This can be
by touching any earthed metal, or by wearing an earth strap
which is connected to earth. If the components comes in a
protective wrapper, earth yourself while holding this, before
touching the component.
Real Time & Embedded Systems
1.13
CA480  Dublin City University 2007
Download