Sei sulla pagina 1di 93

Advance Security System With Intruder Image Capture And

Forward Through Email

Title of the project : Advance Security System With Intruder Image Capture

And Forward Through Email

Domain : Embedded Systems Design


Software : Python Programming, Linux Arch
Microcontroller : BCM2837

Power Supply : +5V, 1A Regulated Power Supply

Sensor : PIR sensor


ABSTARCT:

Security is primary concern everywhere and for every one. Every person wants his home,
industry etc to be secured. This project describes a security system that can monitor an
industry and home. This is a simple and useful security system and easy to install.

Here our application uses Raspberry Pi as its controller and PIR sensor which detects
presence of a person where ever we place this module either at a door near home or at
offices, factories or any other place where we need monitoring every minute for the
purpose of security. Through the camera image of the person is captured when ever PIR
senses presence of a person and our controller sends those image to the pre-stored e-mail
address through LAN. So that one can have the knowledge of the person appeared at that
instant.

Passive Infrared sensor (PIR sensor) is an electronic device that is being used to
measure the infrared (IR) light radiating from objects in its field of view. PIR sensors are
often used in the construction of PIR-based motion detectors. Apparent motion is
detected when an infrared source with one temperature, such as a wall. All objects above
absolute zero emit energy in the form of radiation. Usually infrared radiation is invisible
to the Human eye but can be detected by electronic gadgets designed for such a purpose.
The term passive in this instance means that the PIR device does not emit an infrared
beam but merely passively accepts incoming infrared radiation. Infra means below our
ability to detect it visually and Red is because of its Color representation which shows
the lowest energy level of the color RED and applies to many sources of invisible energy.

The Raspberry Pi is a credit-card-sized single-board computer developed in


the UK by the Raspberry Pi Foundation . The Raspberry Pi has a Broadcom system on a
chip . It does not include a built-in hard disk or solid-state drive, but Uses an SD card for
booting and long-term storage.
This project uses regulated 3.3V, 1A power supply. 7805 three terminal voltage
regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify
the ac out put of secondary of 230/12V step down transformer.
Block Diagram

Power Supply

Camera for
Image
capturing LAN

Raspberry
pi
PIR
SENSOR
Email
throug
h
Interne
t

Step Bridge Filter


down Rectifier Circuit Regulator
T/F
LAN

A local area network (LAN) is a computer network that interconnects computers within a
limited area such as a home, school, computer laboratory, or office building, using
network media. The defining characteristics of LANs, in contrast to wide area
networks (WANs), include their smaller geographic area, and non-inclusion of leased
telecommunication lines.

ARCNET, Token Ring and other technology standards have been used in the past,
but Ethernet over twisted pair cabling, and Wi-Fiare the two most common technologies
currently used to build LANs.

History

A conceptual diagram of a local area network using 10BASE5Ethernet

The increasing demand and use of computers in universities and research labs in the late
1960s generated the need to provide high-speed interconnections between computer
systems. A 1970 report from the Lawrence Radiation Laboratory detailing the growth of
their "Octopus" network gave a good indication of the situation.

Cambridge Ring (computer network) was developed at Cambridge University in 1974 but
was never developed into a successful commercial product.

Ethernet was developed at Xerox PARC in 19731975, and filed as U.S. Patent
4,063,220. In 1976, after the system was deployed at
PARC, Metcalfe and Boggs published a seminal paper, "Ethernet: Distributed Packet-
Switching for Local Computer Networks."

ARCNET was developed by Datapoint Corporation in 1976 and announced in 1977. It


had the first commercial installation in December 1977 at Chase Manhattan Bank in New
York.

Standards evolution

The development and proliferation of personal computers using the CP/M operating
system in the late 1970s, and later DOS-based systems starting in 1981, meant that many
sites grew to dozens or even hundreds of computers. The initial driving force for
networking was generally to share storage and printers, which were both expensive at the
time. There was much enthusiasm for the concept and for several years, from about 1983
onward, computer industry pundits would regularly declare the coming year to be the
year of the LAN.

In practice, the concept was marred by proliferation of incompatible physical layer and
network protocol implementations, and a plethora of methods of sharing resources.
Typically, each vendor would have its own type of network card, cabling, protocol,
and network operating system. A solution appeared with the advent of Novell
NetWare which provided even-handed support for dozens of competing card/cable types,
and a much more sophisticated operating system than most of its competitors. Netware
dominated the personal computer LAN business from early after its introduction in 1983
until the mid-1990s when Microsoft introduced Windows NT Advanced Server
and Windows for Workgroups.

Of the competitors to NetWare, only Banyan Vines had comparable technical strengths,
but Banyan never gained a secure base. Microsoft and 3Com worked together to create a
simple network operating system which formed the base of 3Com's 3+Share,
Microsoft's LAN Manager and IBM's LAN Server - but none of these was particularly
successful.

During the same period, Unix computer workstations from vendors such as Sun
Microsystems, Hewlett-Packard, Silicon Graphics, Intergraph, NeXT and Apollo were
using TCP/IPbased networking. Although this market segment is now much reduced, the
technologies developed in this area continue to be influential on the Internet and in
both Linux and Apple Mac OS X networkingand the TCP/IP protocol has now almost
completely replaced IPX, AppleTalk, NBF, and other protocols used by the early PC
LANs.

Cabling

Early LAN cabling had generally been based on various grades of coaxial cable.
Shielded twisted pair was used in IBM's Token Ring LAN implementation, but in
1984, StarLANshowed the potential of simple unshielded twisted pair by
using Cat3 cablethe same simple cable used for telephone systems. This led to the
development of 10Base-T (and its successors) and structured cabling which is still the
basis of most commercial LANs today.

Fiber-optic cabling is common for links between switches, but fiber to the desktop is
uncommon.

Wireless

As well as traditional cabling, many LANs are now based partly or wholly on wireless
technologies. Almost all of today's smartphoness, tablets and laptops have wireless
support built-in so a wireless local area network, or WLAN, gives users the ability to
move around within a local coverage area and still be connected to the network. Wireless
networks have become popular in domestic homes due to ease of installation, and in
commercial complexes to offer easy network access to their staff. Visiting guest are often
offeredinternet access via a hotspot service.

Technical aspects

Network topology describes the layout of interconnections between devices and network
segments. At the Data Link Layer and Physical Layer, a wide variety of LAN topologies
have been used, including ring, bus, mesh and star, but the most common LAN topology
in use today is switched Ethernet. At the higher layers, the Internet Protocol (TCP/IP) has
become the standard, replacing NetBEUI, IPX/SPX, AppleTalk and others.
Simple LANs generally consist of one or more switches. A switch can be connected to
a router, cable modem, or ADSL modem for Internet access. Complex LANs are
characterized by their use of redundant links with switches using the spanning tree
protocol to prevent loops, their ability to manage differing traffic types via quality of
service(QoS), and to segregate traffic with VLANs. A LAN can include a wide variety of
network devices such as switches, firewalls, routers, load balancers, and sensors.

LANs can maintain connections with other LANs via leased lines, leased services, or
the Internet using virtual private network technologies. Depending on how the
connections are established and secured in a LAN, and the distance involved, a LAN may
also be classified as a metropolitan area network (MAN) or a wide area network (WAN).
Hardware Explanation

RESISTOR:

Resistors "Resist" the flow of electrical current. The higher the value of resistance
(measured in ohms) the lower the current will be. Resistance is the property of a
component which restricts the flow of electric current. Energy is used up as the voltage
across the component drives the current through it and this energy appears as heat in the
component.

Color Code:
CAPACITOR:

Capacitors store electric charge. They are used with resistors


in timing circuits because it takes time for a capacitor to fill with charge. They are used
to smooth varying DC supplies by acting as a reservoir of charge. They are also used in
filter circuits because capacitors easily pass AC (changing) signals but they block DC
(constant) signals.

Circuit symbol:

Electrolytic capacitors are polarized and they must be connected the correct way
round, at least one of their leads will be marked + or -.

Examples:

DIODES:

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol
shows the direction in which the current can flow. Diodes are the electrical version of a
valve and early diodes were actually called valves.

Circuit symbol:

Diodes must be connected the correct way round, the diagram may be
labeled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The
cathode is marked by a line painted on the body. Diodes are labeled with their code in
small print; you may need a magnifying glass to read this on
small signal diodes.
Example:

LIGHT-EMITTING DIODE (LED):


The longer lead is the anode (+) and the shorter lead is the cathode (&minus). In the
schematic symbol for an LED (bottom), the anode is on the left and the cathode is on the
right. Light emitting diodes are elements for light signalization in electronics.

They are manufactured in different shapes, colors and sizes. For their low price,
low consumption and simple use, they have almost completely pushed aside other light
sources- bulbs at first place.
It is important to know that each diode will be immediately destroyed unless its current is
limited. This means that a conductor must be connected in parallel to a diode. In order to
correctly determine value of this conductor, it is necessary to know diodes voltage drop
in forward direction, which depends on what material a diode is made of and what colors
it is. Values typical for the most frequently used diodes are shown in table below: As
seen, there are three main types of LEDs. Standard ones get full brightness at current of
20mA. Low Current diodes get full brightness at ten times lower current while Super
Bright diodes produce more intensive light than Standard ones.

Since the 8051 microcontrollers can provide only low input current and since their
pins are configured as outputs when voltage level on them is equal to 0, direct
confectioning to LEDs is carried out as it is shown on figure (Low current LED, cathode
is connected to output pin).

Switches and Pushbuttons:

A push button switch is used to either close or open an electrical circuit depending
on the application. Push button switches are used in various applications such as
industrial equipment control handles, outdoor controls, mobile communication terminals,
and medical equipment, and etc. Push button switches generally include a push button
disposed within a housing. The push button may be depressed to cause movement of the
push button relative to the housing for directly or indirectly changing the state of an
electrical contact to open or close the contact. Also included in a pushbutton switch may
be an actuator, driver, or plunger of some type that is situated within a switch housing
having at least two contacts in communication with an electrical circuit within which the
switch is incorporated.
Typical actuators used for contact switches include spring loaded force cap actuators
that reciprocate within a sleeve disposed within the canister. The actuator is typically
coupled to the movement of the cap assembly, such that the actuator translates in a
direction that is parallel with the cap. A push button switch for a data input unit for a
mobile communication device such as a cellular phone, a key board for a personal
computer or the like is generally constructed by mounting a cover member directly on a
circuit board. Printed circuit board (PCB) mounted pushbutton switches are an
inexpensive means of providing an operator interface on industrial control products. In
such push button switches, a substrate which includes a plurality of movable sections is
formed of a rubber elastomeric. The key top is formed on a top surface thereof with a
figure, a character or the like by printing, to thereby provide a cover member. Push button
switches incorporating lighted displays have been used in a variety of applications. Such
switches are typically comprised of a pushbutton, an opaque legend plate, and a back
light to illuminate the legend plate.
Block Diagram For Regulated Power Supply (RPS):

Figure: Power Supply

Description :

Transformer

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductorsthe transformer's coils. A varying current in the
first or primary winding creates a varying magnetic flux in the transformer's core, and
thus a varying magnetic field through the secondary winding. This varying magnetic field
induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This
effect is called mutual induction.

Figure: Transformer Symbol

(or)

Transformer is a device that converts the one form energy to another form of energy like
a transducer.
Figure: Transformer

Basic Principle

A transformer makes use of Faraday's law and the ferromagnetic properties of an iron
core to efficiently raise or lower AC voltages. It of course cannot increase power so that if
the voltage is raised, the current is proportionally lowered and vice versa.
Figure: Basic Principle

Transformer Working

A transformer consists of two coils (often called 'windings') linked by an iron core, as
shown in figure below. There is no electrical connection between the coils; instead they
are linked by a magnetic field created in the core.

Figure: Basic Transformer


Transformers are used to convert electricity from one voltage to another with minimal
loss of power. They only work with AC (alternating current) because they require a
changing magnetic field to be created in their core. Transformers can increase voltage
(step-up) as well as reduce voltage (step-down).

Alternating current flowing in the primary (input) coil creates a continually changing
magnetic field in the iron core. This field also passes through the secondary (output) coil
and the changing strength of the magnetic field induces an alternating voltage in the
secondary coil. If the secondary coil is connected to a load the induced voltage will make
an induced current flow. The correct term for the induced voltage is 'induced
electromotive force' which is usually abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are
currents produced by the alternating magnetic field inducing a small voltage in the core,
just like that induced in the secondary coil. Eddy currents waste power by needlessly
heating up the core but they are reduced to a negligible amount by laminating the iron
because this increases the electrical resistance of the core without affecting its magnetic
properties.

Transformers have two great advantages over other methods of changing voltage:

1. They provide total electrical isolation between the input and output, so they can
be safely used to reduce the high voltage of the mains supply.
2. Almost no power is wasted in a transformer. They have a high efficiency (power
out / power in) of 95% or more.

Classification of Transformer

Step-Up Transformer
Step-Down Transformer

Step-Down Transformer
Step down transformers are designed to reduce electrical voltage. Their primary voltage
is greater than their secondary voltage. This kind of transformer "steps down" the voltage
applied to it. For instance, a step down transformer is needed to use a 110v product in a
country with a 220v supply.

Step down transformers convert electrical voltage from one level or phase configuration
usually down to a lower level. They can include features for electrical isolation, power
distribution, and control and instrumentation applications. Step down transformers
typically rely on the principle of magnetic induction between coils to convert voltage
and/or current levels.

Step down transformers are made from two or more coils of insulated wire wound around
a core made of iron. When voltage is applied to one coil (frequently called the primary or
input) it magnetizes the iron core, which induces a voltage in the other coil, (frequently
called the secondary or output). The turns ratio of the two sets of windings determines
the amount of voltage transformation.

Figure: Step-Down Transformer

An example of this would be: 100 turns on the primary and 50 turns on the secondary, a
ratio of 2 to 1.

Step down transformers can be considered nothing more than a voltage ratio device.

With step down transformers the voltage ratio between primary and secondary will mirror
the "turns ratio" (except for single phase smaller than 1 kva which have compensated
secondary). A practical application of this 2 to 1 turns ratio would be a 480 to 240
voltage step down. Note that if the input were 440 volts then the output would be 220
volts. The ratio between input and output voltage will stay constant. Transformers should
not be operated at voltages higher than the nameplate rating, but may be operated at
lower voltages than rated. Because of this it is possible to do some non-standard
applications using standard transformers.

Single phase step down transformers 1 kva and larger may also be reverse connected to
step-down or step-up voltages. (Note: single phase step up or step down transformers
sized less than 1 KVA should not be reverse connected because the secondary windings
have additional turns to overcome a voltage drop when the load is applied. If reverse
connected, the output voltage will be less than desired.)

Step-Up Transformer

A step up transformer has more turns of wire on the secondary coil, which makes a larger
induced voltage in the secondary coil. It is called a step up transformer because the
voltage output is larger than the voltage input.

Step-up transformer 110v 220v design is one whose secondary voltage is greater than its
primary voltage. This kind of transformer "steps up" the voltage applied to it. For
instance, a step up transformer is needed to use a 220v product in a country with a 110v
supply.

A step up transformer 110v 220v converts alternating current (AC) from one voltage to
another voltage. It has no moving parts and works on a magnetic induction principle; it
can be designed to "step-up" or "step-down" voltage. So a step up transformer increases
the voltage and a step down transformer decreases the voltage.

The primary components for voltage transformation are the step up transformer core and
coil. The insulation is placed between the turns of wire to prevent shorting to one another
or to ground. This is typically comprised of Mylar, nomex, Kraft paper, varnish, or other
materials. As a transformer has no moving parts, it will typically have a life expectancy
between 20 and 25 years.
Figure: Step-Up Transformer

Applications :

Generally these Step-Up Transformers are used in industries applications only.

Types of Transformer

Mains Transformers

Mains transformers are the most common type. They are designed to reduce the AC
mains supply voltage (230-240V in the UK or 115-120V in some countries) to a safer
low voltage. The standard mains supply voltages are officially 115V and 230V, but
120V and 240V are the values usually quoted and the difference is of no significance in
most cases.

Figure: Main Transformer

To allow for the two supply voltages mains transformers usually have two separate
primary coils (windings) labeled 0-120V and 0-120V. The two coils are connected in
series for 240V (figure 2a) and in parallel for 120V (figure 2b). They must be wired the
correct way round as shown in the diagrams because the coils must be connected in the
correct sense (direction):

Most mains transformers have two separate secondary coils (e.g. labeled 0-9V, 0-9V)
which may be used separately to give two independent supplies, or connected in series to
create a centre-tapped coil (see below) or one coil with double the voltage.

Some mains transformers have a centre-tap halfway through the secondary coil and they
are labeled 9-0-9V for example. They can be used to produce full-wave rectified DC with
just two diodes, unlike a standard secondary coil which requires four diodes to produce
full-wave rectified DC.

A mains transformer is specified by:

1. Its secondary (output) voltages Vs.


2. Its maximum power, Pmax, which the transformer can pass, quoted in VA (volt-
amp). This determines the maximum output (secondary) current, Imax...
...where Vs is the secondary voltage. If there are two secondary coils the
maximum power should be halved to give the maximum for each coil.

3. Its construction - it may be PCB-mounting, chassis mounting (with solder tag


connections) or toroidal (a high quality design).

Audio Transformers

Audio transformers are used to convert the moderate voltage, low current output of an
audio amplifier to the low voltage, high current required by a loudspeaker. This use is
called 'impedance matching' because it is matching the high impedance output of the
amplifier to the low impedance of the loudspeaker.

Figure: Audio transformer

Radio Transformers

Radio transformers are used in tuning circuits. They are smaller than mains and audio
transformers and they have adjustable ferrite cores made of iron dust. The ferrite cores
can be adjusted with a non-magnetic plastic tool like a small screwdriver. The whole
transformer is enclosed in an aluminum can which acts as a shield, preventing the
transformer radiating too much electrical noise to other parts of the circuit.

Figure: Radio Transformer


Turns Ratio and Voltage

The ratio of the number of turns on the primary and secondary coils determines the ratio
of the voltages...

...where Vp is the primary (input) voltage, Vs is the secondary (output) voltage, Np is the
number of turns on the primary coil, and Ns is the number of turns on the secondary coil.

Diodes

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol
shows the direction in which the current can flow. Diodes are the electrical version of a
valve and early diodes were actually called valves.

Figure: Diode Symbol

A diode is a device which only allows current to flow through it in one direction. In this
direction, the diode is said to be 'forward-biased' and the only effect on the signal is that
there will be a voltage loss of around 0.7V. In the opposite direction, the diode is said to
be 'reverse-biased' and no current will flow through it.

Rectifier

The purpose of a rectifier is to convert an AC waveform into a DC waveform (OR)


Rectifier converts AC current or voltages into DC current or voltage. There are two
different rectification circuits, known as 'half-wave' and 'full-wave' rectifiers. Both use
components called diodes to convert AC into DC.

The Half-wave Rectifier

The half-wave rectifier is the simplest type of rectifier since it only uses one diode, as
shown in figure.

Figure: Half Wave Rectifier

Figure 2 shows the AC input waveform to this circuit and the resulting output. As you
can see, when the AC input is positive, the diode is forward-biased and lets the current
through. When the AC input is negative, the diode is reverse-biased and the diode does
not let any current through, meaning the output is 0V. Because there is a 0.7V voltage
loss across the diode, the peak output voltage will be 0.7V less than Vs.
Figure: Half-Wave Rectification

While the output of the half-wave rectifier is DC (it is all positive), it would not be
suitable as a power supply for a circuit. Firstly, the output voltage continually varies
between 0V and Vs-0.7V, and secondly, for half the time there is no output at all.

The Full-wave Rectifier

The circuit in figure 3 addresses the second of these problems since at no time is the
output voltage 0V. This time four diodes are arranged so that both the positive and
negative parts of the AC waveform are converted to DC. The resulting waveform is
shown in figure 4.
Figure: Full-Wave Rectifier

Figure: Full-Wave Rectification

When the AC input is positive, diodes A and B are forward-biased, while diodes C and D
are reverse-biased. When the AC input is negative, the opposite is true - diodes C and D
are forward-biased, while diodes A and B are reverse-biased.

While the full-wave rectifier is an improvement on the half-wave rectifier, its output still
isn't suitable as a power supply for most circuits since the output voltage still varies
between 0V and Vs-1.4V. So, if you put 12V AC in, you will 10.6V DC out.

Capacitor Filter
The capacitor-input filter, also called "Pi" filter due to its shape that looks like the
Greek letter pi, is a type of electronic filter. Filter circuits are used to remove unwanted or
undesired frequencies from a signal.

Figure: Capacitor Filter

A typical capacitor input filter consists of a filter capacitor C1, connected across the
rectifier output, an inductor L, in series and another filter capacitor connected across the
load.

1. The capacitor C1 offers low reactance to the AC component of the rectifier output
while it offers infinite reactance to the DC component. As a result the capacitor
shunts an appreciable amount of the AC component while the DC component
continues its journey to the inductor L
2. The inductor L offers high reactance to the AC component but it offers almost
zero reactance to the DC component. As a result the DC component flows through
the inductor while the AC component is blocked.
3. The capacitor C2 bypasses the AC component which the inductor had failed to
block. As a result only the DC component appears across the load RL.
Figure: Centered Tapped Full-Wave Rectifier with a Capacitor Filter

Voltage Regulator

A voltage regulator is an electrical regulator designed to automatically maintain a


constant voltage level. It may use an electromechanical mechanism, or passive or active
electronic components. Depending on the design, it may be used to regulate one or more
AC or DC voltages. There are two types of regulator are they.

Positive Voltage Series (78xx) and


Negative Voltage Series (79xx)

78xx:

78 indicate the positive series and xxindicates the voltage rating. Suppose 7805
produces the maximum 5V.05indicates the regulator output is 5V.

79xx:

78 indicate the negative series and xxindicates the voltage rating. Suppose 7905
produces the maximum -5V.05indicates the regulator output is -5V.

These regulators consists the three pins there are

Pin1: It is used for input pin.


Pin2: This is ground pin for regulator

Pin3: It is used for output pin. Through this pin we get the output.

Figure: Regulator
EXPLANATION OF EACH BLOCK
Sensor
Definition:
A sensor is a device that measures a physical quantity and converts it into a signal which
can be read by an observer or by an instrument. For example, a mercury-in-glass
thermometer converts the measured temperature into expansion and contraction of a
liquid which can be read on a calibrated glass tube. A thermocouple converts temperature
to an output voltage which can be read by a voltmeter. For accuracy, all sensors need to
be calibrated against known standards
(OR)
Sensor is the device which converts any physical quantity to its equivalent
electrical signal. There are different types of sensor are available there are: Temperature
sensor, Light sensor, Voltage sensor, Smoke Sensor, Gas sensor, Fire sensor, Magnetic
Sensors, etc.

Classification of measurement errors

A good sensor obeys the following rules:

Is sensitive to the measured property


Is insensitive to any other property likely to be encountered in its application
Does not influence the measured property

Ideal sensors are designed to be linear or linear to some simple mathematical function of
the measurement, typically logarithmic. The output signal of such a sensor is linearly
proportional to the value or simple function of the measured property. The sensitivity is
then defined as the ratio between output signal and measured property. For example, if a
sensor measures temperature and has a voltage output, the sensitivity is a constant with
the unit [V/K]; this sensor is linear because the ratio is constant at all points of
measurement

Sensor deviations

If the sensor is not ideal, several types of deviations can be observed:


The sensitivity may in practice differ from the value specified. This is called a
sensitivity error, but the sensor is still linear.
Since the range of the output signal is always limited, the output signal will
eventually reach a minimum or maximum when the measured property exceeds
the limits. The full scale range defines the maximum and minimum values of the
measured property.
If the output signal is not zero when the measured property is zero, the sensor has
an offset or bias. This is defined as the output of the sensor at zero input.
If the sensitivity is not constant over the range of the sensor, this is called
nonlinearity. Usually this is defined by the amount the output differs from ideal
behavior over the full range of the sensor, often noted as a percentage of the full
range.
If the deviation is caused by a rapid change of the measured property over time,
there is a dynamic error. Often, this behavior is described with a bode plot
showing sensitivity error and phase shift as function of the frequency of a periodic
input signal.
If the output signal slowly changes independent of the measured property, this is
defined as drift (telecommunication).
Long term drift usually indicates a slow degradation of sensor properties over a
long period of time.
Noise is a random deviation of the signal that varies in time.
Hysteresis is an error caused by when the measured property reverses direction,
but there is some finite lag in time for the sensor to respond, creating a different
offset error in one direction than in the other.
If the sensor has a digital output, the output is essentially an approximation of the
measured property. The approximation error is also called digitization error.
If the signal is monitored digitally, limitation of the sampling frequency also can
cause a dynamic error, or if the variable or added noise noise changes periodically
at a frequency near a multiple of the sampling rate may induce aliasing errors.
The sensor may to some extent be sensitive to properties other than the property
being measured. For example, most sensors are influenced by the temperature of
their environment.

All these deviations can be classified as systematic errors or random errors. Systematic
errors can sometimes be compensated for by means of some kind of calibration strategy.
Noise is a random error that can be reduced by signal processing, such as filtering,
usually at the expense of the dynamic behavior of the sensor.

Resolution

The resolution of a sensor is the smallest change it can detect in the quantity that it is
measuring. Often in a digital display, the least significant digit will fluctuate, indicating
that changes of that magnitude are only just resolved. The resolution is related to the
precision with which the measurement is made. For example, a scanning tunneling probe
(a fine tip near a surface collects an electron tunneling current) can resolve atoms and
molecules.

Different Types Sensor:

1] Acoustic, sound, vibration

Geophone
Hydrophone
Lace Sensor a guitar pickup
Microphone
Seismometer
Accelerometer

2] Automotive, transportation

Air-fuel ratio meter


Crank sensor
Curb feeler, used to warn driver of curbs
Defect detector, used on railroads to detect axle and signal problems in passing
trains
Engine coolant temperature sensor, or ECT sensor, used to measure the engine
temperature
Hall effect sensor, used to time the speed of wheels and shafts
MAP sensor, Manifold Absolute Pressure, used in regulating fuel metering.
Mass flow sensor, or mass airflow (MAF) sensor, used to tell the ECU the mass of
air entering the engine
Oxygen sensor, used to monitor the amount of oxygen in the exhaust
Parking sensors, used to alert the driver of unseen obstacles during parking
manoeuvres
Radar gun, used to detect the speed of other objects
Speedometer, used measure the instantaneous speed of a land vehicle
Speed sensor, used to detect the speed of an object
Throttle position sensor, used to monitor the position of the throttle in an internal
combustion engine
Tire-pressure monitoring sensor, used to monitor the air pressure inside the tires
Transmission fluid temperature sensor, used to measure the temperature of the
transmission fluid
Turbine speed sensor (TSS), or input speed sensor (ISS), used to measure the
rotational speed of the input shaft or torque converter
Variable reluctance sensor, used to measure position and speed of moving metal
components
Vehicle speed sensor (VSS), used to measure the speed of the vehicle
Water sensor or water-in-fuel sensor, used to indicate the presence of water in fuel
Wheel speed sensor, used for reading the speed of a vehicle's wheel rotation

3] Chemical

Breathalyzer and Alcohol Sensor


Carbon dioxide sensor
Carbon monoxide detector
Catalytic bead sensor
Chemical field-effect transistor
Electrochemical gas sensor
Electronic nose
Electrolyteinsulatorsemiconductor sensor
Hydrogen sensor
Hydrogen sulfide sensor
Infrared point sensor
Ion-selective electrode
Nondispersive infrared sensor
Microwave chemistry sensor
Nitrogen oxide sensor
Olfactometer
Optode
Oxygen sensor
Pellistor
pH glass electrode
Potentiometric sensor
Redox electrode
Smoke detector
Zinc oxide nanorod sensor

4] Electric current, electric potential, magnetic, radio

Ammeter
Current sensor
Galvanometer
Hall effect sensor
Hall probe
Leaf electroscope
Magnetic anomaly detector
Magnetometer
Metal detector
Multi-meter
Ohmmeter
Radio direction finder
Telescope
Voltmeter
Voltage detector
Watt-hour meter

5] Environment, weather, moisture, humidity

Bedwetting alarm
Dew warning
Fish counter
Gas detector
Hook gauge evaporimeter
Hygrometer
Leaf sensor
Pyranometer
Pyrgeometer
Psychrometer
Rain gauge
Rain sensor
Seismometers
Snow gauge
Soil moisture sensor
Stream gauge
Tide gauge
6] Flow, fluid velocity

Air flow meter


Anemometer
Flow sensor
Gas meter
Mass flow sensor
Water meter

7] Ionizing radiation, subatomic particles

Bubble chamber
Cloud chamber
Geiger counter
Neutron detection
Particle detector
Scintillation counter
Scintillator
Wire chamber

8] Navigation instruments

Air speed indicator

Altimeter

Attitude indicator

Depth gauge

Fluxgate compass

Gyroscope

Inertial reference unit

Magnetic compass
MHD sensor

Ring laser gyroscope

Turn coordinator

Variometer

Vibrating structure gyroscope

Yaw rate sensor

9] Position, angle, displacement, distance, speed, acceleration

Accelerometer
Capacitive displacement sensor
Free fall sensor
Gravimeter
Inclinometer
Laser rangefinder
Linear encoder
Linear variable differential transformer (LVDT)
Liquid capacitive inclinometers
Odometer
Piezoelectric accelerometer
Position sensor
Rotary encoder
Rotary variable differential transformer
Selsyn
Sudden Motion Sensor
Tilt sensor
Tachometer
Ultrasonic thickness gauge
10] Optical, light, imaging

Charge-coupled device
Colorimeter
Contact image sensor
Electro-optical sensor
Flame detector
Infra-red sensor
LED as light sensor
Nichols radiometer
Fiber optic sensors
Photodetector
Photodiode
Photomultiplier tubes
Phototransistor
Photoelectric sensor
Photoionization detector
Photomultiplier
Photoresistor
Photoswitch
Phototube
Proximity sensor
Scintillometer
Shack-Hartmann
Wavefront sensor

11] Pressure

Barograph
Barometer
Boost gauge
Bourdon gauge
Hot filament ionization gauge
Ionization gauge
McLeod gauge
Oscillating U-tube
Permanent Downhole Gauge
Pirani gauge
Pressure sensor
Pressure gauge
Tactile sensor
Time pressure gauge

12] Force, density, level

Bhangmeter
Hydrometer
Force gauge
Level sensor
Load cell
Magnetic level gauge
Nuclear density gauge
Piezoelectric sensor
Strain gauge
Torque sensor
Viscometer

13] Thermal, heat, temperature

Bolometer
Calorimeter
Exhaust gas temperature gauge
Gardon gauge
Heat flux sensor
Infrared thermometer
Microbolometer
Microwave radiometer
Net radiometer
Resistance temperature detector
Resistance thermometer
Silicon bandgap temperature sensor
Temperature gauge
Thermistor
Thermocouple
Thermometer

14] Proximity, presence

Alarm sensor
Motion detector
Occupancy sensor
Passive infrared sensor
Reed switch
Stud finder
Triangulation sensor
Touch switch
Wired glove
Doppler radar
Introduction to PIR
Passive infrared sensor

A Passive Infra Red sensor (PIR sensor) is an electronic device that measures infrared
(IR) light radiating from objects in its field of view. PIR sensors are often used in the
construction of PIR-based motion detectors (see below). Apparent motion is detected
when an infrared source with one temperature, such as a human, passes in front of an
infrared source with another temperature, such as a wall.

All objects emit what is known as black body radiation. It is usually infrared radiation
that is invisible to the human eye but can be detected by electronic devices designed for
such a purpose. The term passive in this instance means that the PIR device does not emit
an infrared beam but merely passively accepts incoming infrared radiation. Infra
meaning below our ability to detect it visually, and Red because this color represents
the lowest energy level that our eyes can sense before it becomes invisible. Thus, infrared
means below the energy level of the color red, and applies to many sources of invisible
energy.

Design

Infrared radiation enters through the front of the sensor, known as the sensor face. At the
core of a PIR sensor is a solid state sensor or set of sensors, made from an approximately
1/4 inch square of natural or artificial pyroelectric materials, usually in the form of a thin
film, out of gallium nitride (GaN), caesium nitrate (CsNO 3), polyvinyl fluorides,
derivatives of phenylpyrazine, and cobalt phthalocyanine. (See pyroelectric crystals.)
Lithium tantalate (LiTaO3) is a crystal exhibiting both piezoelectric and pyroelectric
properties.

The sensor is often manufactured as part of an integrated circuit and may consist of one
(1), two (2) or four (4) 'pixels' of equal areas of the pyroelectric material. Pairs of the
sensor pixels may be wired as opposite inputs to a differential amplifier. In such a
configuration, the PIR measurements cancel each other so that the average temperature of
the field of view is removed from the electrical signal; an increase of IR energy across the
entire sensor is self-cancelling and will not trigger the device. This allows the device to
resist false indications of change in the event of being exposed to flashes of light or field-
wide illumination. (Continuous bright light could still saturate the sensor materials and
render the sensor unable to register further information.) At the same time, this
differential arrangement minimizes common-mode interference, allowing the device to
resist triggering due to nearby electric fields. However, a differential pair of sensors
cannot measure temperature in that configuration and therefore this configuration is
specialized for motion detectors, see below.

PIR-based motion detector

In a PIR-based motion detector (usually called a PID, for Passive Infrared Detector), the
PIR sensor is typically mounted on a printed circuit board containing the necessary
electronics required to interpret the signals from the pyroelectric sensor chip. The
complete assembly is contained within a housing mounted in a location where the sensor
can view the area to be monitored. Infrared energy is able to reach the pyroelectric sensor
through the window because the plastic used is transparent to infrared radiation (but only
translucent to visible light). This plastic sheet also prevents the intrusion of dust and/or
insects from obscuring the sensor's field of view, and in the case of insects, from
generating false alarms.

A few mechanisms have been used to focus the distant infrared energy onto the sensor
surface. The window may have multiple Fresnel lenses molded into it.

The PID can be thought of as a kind of infrared camera that remembers the amount of
infrared energy focused on its surface. Once power is applied to the PID, the electronics
in the PID shortly settle into a quiescent state and energize a small relay. This relay
controls a set of electrical contacts that are usually connected to the detection input of a
burglar alarm control panel. If the amount of infrared energy focused on the pyroelectric
sensor changes within a configured time period, the device will switch the state of the
alarm relay. The alarm relay is typically a "normally closed (NC)" relay, also known as a
"Form B" relay.

A person entering a monitored area is detected when the infrared energy emitted from the
intruder's body is focused by a Fresnel lens or a mirror segment and overlaps a section on
the chip that had previously been looking at some much cooler part of the protected area.
That portion of the chip is now much warmer than when the intruder wasn't there. As the
intruder moves, so does the hot spot on the surface of the chip. This moving hot spot
causes the electronics connected to the chip to de-energize the relay, operating its
contacts, thereby activating the detection input on the alarm control panel. Conversely, if
an intruder were to try to defeat a PID, perhaps by holding some sort of thermal shield
between himself and the PID, a corresponding 'cold' spot moving across the face of the
chip will also cause the relay to de-energize unless the thermal shield has the same
temperature as the objects behind it.

Manufacturers recommend careful placement of their products to prevent false (non-


intruder caused) alarms. They suggest mounting the PIDs in such a way that the PID
cannot 'see' out of a window. Although the wavelength of infrared radiation to which the
chips are sensitive does not penetrate glass very well, a strong infrared source such as
from a vehicle headlight or sunlight reflecting from a vehicle window can overload the
chip with enough infrared energy to fool the electronics and cause a false alarm. A person
moving on the other side of the glass however would not be 'seen' by the PID.

They also recommended that the PID not be placed in such a position that an HVAC vent
would blow hot or cold air onto the surface of the plastic which covers the housing's
window. Although air has very low emissivity (emits very small amounts of infrared
energy), the air blowing on the plastic window cover could change the plastic's
temperature enough to, once again, fool the electronics.

PIDs come in many configurations for a wide variety of applications. The most common,
used in home security systems, have numerous Fresnel lenses or mirror segments and an
effective range of about thirty feet. Some larger PIDs are made with single segment
mirrors and can sense changes in infrared energy over one hundred feet away from the
PID. There are also PIDs designed with reversible orientation mirrors which allow either
broad coverage (110 wide) or very narrow 'curtain' coverage.

PIDs can have more than one internal sensing element so that, with the appropriate
electronics and Fresnel lens, it can detect direction. Left to right, right to left, up or down
and provide an appropriate output signal.
Raspberry Pi

Built on the latest Broadcom 2837 ARMv8 64bit processor, the new generation
Raspberry Pi 3 Model B is faster and more powerful than its predecessors. With built-in
wireless and Bluetooth connectivity, it becomes the ideal IoT ready solution.

Description

Model

Brand: Raspberry Pi

Model: 3 Model B

Bundle

CPU: Broadcom BCM2837 64bit ARMv8 QUAD Core 64bit Processor

powered Single Board Computer running at 1.2GHz

Memory: 1GB RAM


Onboard LAN

Wireless LAN: BCM43438 Wi-Fi on board

Bluetooth: Bluetooth Low Energy (BLE) on board

Rear Panel Ports

HDMI: Full size HDMI

USB 1.1/2.0: 4 x USB 2.0

Audio Ports: 4 pole Stereo output and Composite video port

A 1.2GHz 64-bit quad-core ARMv8 CPU

802.11n Wireless LAN

Bluetooth 4.1

Bluetooth Low Energy (BLE)


That makes the new BCM2837 more than 50% faster than the Raspberry Pi 2, and almost
ten times faster than the original Model B. Although that performance does come at a
cost, the new Raspberry Pi 3 draws half-again more power than the old Raspberry Pi 2.
Pin diagram

ARM Cortex-A53
The ARM Cortex-A53 is a microarchitecture implementing the ARMv8-A 64-
bit instruction set designed by ARM Holdings. The Cortex-A53 is a superscalar
processor capable of dual-issuing some instructions. It is available as SIP core to
licensees, and is marketed by ARM as either a stand-alone, more energy-efficient
alternative to the more powerful Cortex-A57 microarchitecture, or to be used alongside a
more powerful microarchitecture in a big.LITTLE configuration.

Overview

8-stage pipelined processor with 2-way superscalar execution pipeline


DSP and NEON SIMD extensions are mandatory per core
VFPv4 Floating Point Unit onboard (per core)
Hardware virtualization support
TrustZone security extensions
64-byte cache lines
10-entry L1 TLB, and 512-entry L2 TLB
4 Kb conditional branch predictor, 256-entry indirect branch predictor

BCM43438 Wi-Fi chip


Single-Chip IEEE 802.11 b/g/n MAC/Baseband/ Radio with Bluetooth 4.1 and an
FM Receiver

GENERAL DESCRIPTION

The Broadcom BCM43438 is a highly integrated single-chip solution and offers the
lowest RBOM in the industry for smartphones, tablets, and a wide range of other portable
devices. The chip includes a 2.4 GHz WLAN IEEE 802.11 b/g/n MAC/baseband/ radio,
Bluetooth 4.1 support, and an FM receiver. In addition, it integrates a power amplifier
(PA) that meets the output power requirements of most handheld systems, a low-noise
amplifier (LNA) for best-in-class receiver sensitivity, and an internal transmit/receive
(iTR) RF switch, further reducing the overall solution cost and printed circuit board area.
The WLAN host interface supports gSPI and SDIO v2.0 modes, providing a raw data
transfer rate up to 200 Mbps when operating in 4-bit mode at a 50 MHz bus frequency.
An independent, high-speed UART is provided for the Bluetooth/FM host interface Using
advanced design techniques and process technology to reduce active and idle power, the
BCM43438 is designed to address the needs of highly mobile devices that require
minimal power consumption and compact size. It includes a power management unit that
simplifies the system power topology and allows for operation directly from a
rechargeable mobile platform battery while maximizing battery life. The BCM43438
implements the worlds most advanced Enhanced Collaborative Coexistence algorithms
and hardware mechanisms, allowing for an extremely collaborative WLAN and
Bluetooth coexistence.
IEEE 802.11x Key Features

Single-band 2.4 GHz IEEE 802.11b/g/n.

Support for 2.4 GHz Broadcom TurboQAM data rates (256-QAM) and 20 MHz
channel bandwidth.

Integrated iTR switch supports a single 2.4 GHz antenna shared between WLAN and
Bluetooth.

Supports explicit IEEE 802.11n transmit beam forming.

Tx and Rx Low-density Parity Check (LDPC) support for improved range and power
efficiency.

Supports standard SDIO v2.0 and gSPI host interfaces.

Supports Space-Time Block Coding (STBC) in the receiver.


Integrated ARM Cortex-M3 processor and onchip memory for complete WLAN
subsystem functionality, minimizing the need to wake up the applications processor for
standard WLAN functions. This allows for further minimization of power consumption,
while maintaining the ability to field-upgrade with future features. On-chip memory
includes 512 KB SRAM and 640 KB ROM.

OneDriver software architecture for easy migration from existing embedded WLAN
and Bluetooth devices as well as to future devices. Bluetooth and FM Key Features

Complies with Bluetooth Core Specification Version 4.1 with provisions for supporting
future specifications. Bluetooth Class 1 or Class 2 transmitter operation.

Supports extended Synchronous Connections (eSCO), for enhanced voice quality by


allowing for retransmission of dropped packets.

Adaptive Frequency Hopping (AFH) for reducing radio frequency interference.

Interface support Host Controller Interface (HCI) using a high-speed UART interface
and PCM for audio data.

Bluetooth and FM Key Features (Continued)

FM receiver unit supports HCI for communication.

Low-power consumption improves battery life of handheld devices.

FM receiver: 65 MHz to 108 MHz FM bands; supports the European Radio Data
Systems (RDS) and the North American Radio Broadcast Data System (RBDS)
standards.

Supports multiple simultaneous Advanced Audio Distribution Profiles (A2DP) for


stereo sound.

Automatic frequency detection for standard crystal and TCXO values. General Features
Supports a battery voltage range from 3.0V to 4.8V with an internal switching regulator.
Programmable dynamic power management.

4 Kbit One-Time Programmable (OTP) memory for storing board parameters.

Can be routed on low-cost 1 x 1 PCB stack-ups.

63-ball WLBGA package (4.87 mm 2.87 mm, 0.4 mm pitch).

Security: WPA and WPA2 (Personal) support for powerful encryption and
authentication. AES in WLAN hardware for faster data encryption and IEEE 802.11i
compatibility. Reference WLAN subsystem provides Cisco Compatible Extensions
(CCX, CCX 2.0, CCX 3.0, CCX 4.0, CCX 5.0). Reference WLAN subsystem provides
WiFi Protected Setup (WPS).

Worldwide regulatory support: Global products supported with worldwide homologated


design.

Features

The BCM43438 supports the following WLAN, Bluetooth, and FM features:

IEEE 802.11b/g/n single-band radio with an internal power amplifier, LNA, and T/R
switch

Bluetooth v4.1 with integrated Class 1 PA

Concurrent Bluetooth, FM (RX) RDS/RBDS, and WLAN operation

On-chip WLAN driver execution capable of supporting IEEE 802.11 functionality

Simultaneous BT/WLAN reception with a single antenna

WLAN host interface options: SDIO v2.0, including default and high-speed timing.
gSPIup to a 50 MHz clock rate
BT UART (up to 4 Mbps) host digital interface that can be used concurrently with the
above WLAN host interfaces.

ECIenhanced coexistence support, which coordinates BT SCO transmissions around


WLAN receptions.

PCM for FM/BT audio, HCI for FM block control

HCI high-speed UART (H4 and H5) transport support

Wideband speech support (16 bits, 16 kHz sampling PCM, through PCM interfaces)

Bluetooth SmartAudio technology improves voice and music quality to headsets.

Bluetooth low power inquiry and page scan Bluetooth Low Energy (BLE) support

Bluetooth Packet Loss Concealment (PLC) FM advanced internal antenna support

FM auto searching/tuning functions FM multiple audio routing options: PCM, eSCO,


and A2DP

FM mono-stereo blending and switching, and soft mute support

FM audio pause detection support

Multiple simultaneous A2DP audio streams

FM over Bluetooth operation and on-chip stereo headset emulation


PYTHON PROGRAMMING LANGUAGE
Introduction of python language
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Pythons elegant syntax and dynamic typing, together with its interpreted nature, make it
an ideal language for scripting and rapid application development in many areas on most
platforms.
The Python interpreter and the extensive standard library are freely available in
source or binary form for all major platforms from the Python Web site and may be
freely distributed. The same site also contains distributions of and pointers to many free
third party Python modules, programs and tools, and additional documentation.
The Python interpreter is easily extended with new functions and data types
implemented in C or C++ (or other languages callable from C). Python is also suitable as
an extension language for customizable applications.
This tutorial introduces the reader informally to the basic concepts and features of the
Python language and system. It helps to have a Python interpreter handy for hands-on
experience, but all examples are self-contained, so the tutorial can be read off-line as
well.
For a description of standard objects and modules, see The Python Standard
Library. The Python Language Reference gives a more formal definition of the language.
To write extensions in C or C++, read Extending and Embedding the Python
Interpreter and Python/C API Reference Manual. There are also several books covering
Python in depth.
This tutorial does not attempt to be comprehensive and cover every single feature, or
even every commonly used feature. Instead, it introduces many of Pythons most
noteworthy features, and will give you a good idea of the languages flavor and style.
After reading it, you will be able to read and write Python modules and programs, and
you will be ready to learn more about the various Python library modules described
in The Python Standard Library.
While I am trying to be as precise as possible, I chose to use English rather than
formal specifications for everything except syntax and lexical analysis. This should make
the document more understandable to the average reader, but will leave room for
ambiguities. Consequently, if you were coming from Mars and tried to re-implement
Python from this document alone, you might have to guess things and in fact you would
probably end up implementing quite a different language. On the other hand, if you are
using Python and wonder what the precise rules about a particular area of the language
are, you should definitely be able to find them here. If you would like to see a more
formal definition of the language, maybe you could volunteer your time or invent a
cloning machine.
It is dangerous to add too many implementation details to a language reference
document the implementation may change, and other implementations of the same
language may work differently. On the other hand, there is currently only one Python
implementation in widespread use (although alternate implementations exist), and its
particular quirks are sometimes worth being mentioned, especially where the
implementation imposes additional limitations. Therefore, youll find short
implementation notes sprinkled throughout the text.
Every Python implementation comes with a number of built-in and standard modules.
These are documented in The Python Standard Library. A few built-in modules are
mentioned when they interact in a significant way with the language definition.

Whetting and Appetite

If you do much work on computers, eventually you find that theres some task youd like
to automate. For example, you may wish to perform a search-and-replace over a large
number of text files, or rename and rearrange a bunch of photo files in a complicated
way. Perhaps youd like to write a small custom database, or a specialized GUI
application, or a simple game.

If youre a professional software developer, you may have to work with several C/C+
+/Java libraries but find the usual write/compile/test/re-compile cycle is too slow. Perhaps
youre writing a test suite for such a library and find writing the testing code a tedious
task. Or maybe youve written a program that could use an extension language, and you
dont want to design and implement a whole new language for your application.

Python is just the language for you.

You could write a Unix shell script or Windows batch files for some of these
tasks, but shell scripts are best at moving around files and changing text data, not well-
suited for GUI applications or games. You could write a C/C++/Java program, but it can
take a lot of development time to get even a first-draft program. Python is simpler to use,
available on Windows, Mac OS X, and Unix operating systems, and will help you get the
job done more quickly.
Python is simple to use, but it is a real programming language, offering much
more structure and support for large programs than shell scripts or batch files can offer.
On the other hand, Python also offers much more error checking than C, and, being
a very-high-level language, it has high-level data types built in, such as flexible arrays
and dictionaries. Because of its more general data types Python is applicable to a much
larger problem domain than Awk or even Perl, yet many things are at least as easy in
Python as in those languages.
Python allows you to split your program into modules that can be reused in other
Python programs. It comes with a large collection of standard modules that you can use
as the basis of your programs or as examples to start learning to program in Python.
Some of these modules provide things like file I/O, system calls, sockets, and even
interfaces to graphical user interface toolkits like Tk.
Python is an interpreted language, which can save you considerable time during
program development because no compilation and linking is necessary. The interpreter
can be used interactively, which makes it easy to experiment with features of the
language, to write throw-away programs, or to test functions during bottom-up program
development. It is also a handy desk calculator.
Python enables programs to be written compactly and readably. Programs written
in Python are typically much shorter than equivalent C, C++, or Java programs, for
several reasons:

the high-level data types allow you to express complex operations in a single
statement;
statement grouping is done by indentation instead of beginning and ending
brackets;
no variable or argument declarations are necessary.

Python is extensible: if you know how to program in C it is easy to add a new built-in
function or module to the interpreter, either to perform critical operations at maximum
speed, or to link Python programs to libraries that may only be available in binary form
(such as a vendor-specific graphics library). Once you are really hooked, you can link the
Python interpreter into an application written in C and use it as an extension or command
language for that application.
By the way, the language is named after the BBC show Monty Pythons Flying
Circus and has nothing to do with reptiles. Making references to Monty Python skits in
documentation is not only allowed, it is encouraged!
Now that you are all excited about Python, youll want to examine it in some more
detail. Since the best way to learn a language is to use it, the tutorial invites you to play
with the Python interpreter as you read.
In the next chapter, the mechanics of using the interpreter are explained. This is rather
mundane information, but essential for trying out the examples shown later.
The rest of the tutorial introduces various features of the Python language and system
through examples, beginning with simple expressions, statements and data types, through
functions and modules, and finally touching upon advanced concepts like exceptions and
user-defined classes.

Using the python interpreter

The Python interpreter is usually installed as /usr/local/bin/python on those


machines where it is available; putting /usr/local/bin in your Unix shells search path
makes it possible to start it by typing the command

python

to the shell. Since the choice of the directory where the interpreter lives is an installation
option, other places are possible; check with your local Python guru or system
administrator. (E.g., /usr/local/python is a popular alternative location.)
On Windows machines, the Python installation is usually placed in C:\Python27,
though you can change this when youre running the installer. To add this directory to
your path, you can type the following command into the command prompt in a DOS box:

set path=%path%;C:\python27
Typing an end-of-file character (Control-D on Unix, Control-Z on Windows) at
the primary prompt causes the interpreter to exit with a zero exit status. If that doesnt
work, you can exit the interpreter by typing the following command: quit().
The interpreters line-editing features usually arent very sophisticated. On Unix,
whoever installed the interpreter may have enabled support for the GNU read line library,
which adds more elaborate interactive editing and history features. Perhaps the quickest
check to see whether command line editing is supported is typing Control-P to the first
Python prompt you get. If it beeps, you have command line editing; see
Appendix Interactive Input Editing and History Substitution for an introduction to the
keys. If nothing appears to happen, or if ^P is echoed, command line editing isnt
available; youll only be able to use backspace to remove characters from the current line.
The interpreter operates somewhat like the Unix shell: when called with standard
input connected to a tty device, it reads and executes commands interactively; when
called with a file name argument or with a file as standard input, it reads and executes
a script from that file.
A second way of starting the interpreter is python -c command [arg] ..., which
executes the statement(s) in command, analogous to the shells -c option. Since Python
statements often contain spaces or other characters that are special to the shell, it is
usually advised to quote command in its entirety with single quotes.
Some Python modules are also useful as scripts. These can be invoked
using python -m module [arg] ..., which executes the source file for module as if you had
spelled out its full name on the command line.
When a script file is used, it is sometimes useful to be able to run the script and
enter interactive mode afterwards. This can be done by passing before the script.
All command-line options are described in Command line and environment
When known to the interpreter, the script name and additional arguments
thereafter are turned into a list of strings and assigned to the argv variable in
the sys module. You can access this list by executing import sys. The length of the list is
at least one; when no script and no arguments are given, sys.argv is an empty string.
When the script name is given as '-'(meaning standard input), sys.argv is set to '-'. When -
c command is used, sys.argv is set to '-c'. When -m module is used, sys.argv[0] is set to
the full name of the located module. Options found after -c command or -m module are
not consumed by the Python interpreters option processing but left in sys.argv for the
command or module to handle.
When commands are read from a tty, the interpreter is said to be in interactive
mode. In this mode it prompts for the next command with the primary prompt, usually
three greater-than signs (>>>); for continuation lines it prompts with the secondary
prompt, by default three dots (...). The interpreter prints a welcome message stating its
version number and a copyright notice before printing the first prompt:

python
Python 2.7 (#1, Feb 28 2010, 00:02:06)
Type "help", "copyright", "credits" or "license" for more information.
>>>

Continuation lines are needed when entering a multi-line construct. As an


example, take a look at this if statement:
>>>

>>> the_world_is_flat = 1
>>> if the_world_is_flat:
... print "Be careful not to fall off!"
...
Be careful not to fall off!

For more on interactive mode, see Interactive Mode

Source Code Encoding

It is possible to use encodings different than ASCII in Python source files. The
best way to do it is to put one more special comment line right after the #! line to define
the source file encoding:

# -*- coding: encoding -*-


With that declaration, all characters in the source file will be treated as having the
encoding encoding, and it will be possible to directly write Unicode string literals in the
selected encoding. The list of possible encodings can be found in the Python Library
Reference, in the section on codecs.
For example, to write Unicode literals including the Euro currency symbol, the
ISO-8859-15 encoding can be used, with the Euro symbol having the ordinal value 164.
This script, when saved in the ISO-8859-15 encoding, will print the value 8364 (the
Unicode code point corresponding to the Euro symbol) and then exit:

# -*- coding: iso-8859-15 -*-

currency = u""
print ord(currency)

If your editor supports saving files as UTF-8 with a UTF-8 byte order mark (aka
BOM), you can use that instead of an encoding declaration. IDLE supports this capability
ifOptions/General/Default Source Encoding/UTF-8 is set. Notice that this signature is not
understood in older Python releases (2.2 and earlier), and also not understood by the
operating system for script files with #! lines (only used on Unix systems).
By using UTF-8 (either through the signature or an encoding declaration),
characters of most languages in the world can be used simultaneously in string literals
and comments. Using non-ASCII characters in identifiers is not supported. To display all
these characters properly, your editor must recognize that the file is UTF-8, and it must
use a font that supports all the characters in the file. In the following examples, input and
output are distinguished by the presence or absence of prompts (>>> and ...): to repeat
the example, you must type everything after the prompt, when the prompt appears; lines
that do not begin with a prompt are output from the interpreter. Note that a secondary
prompt on a line by itself in an example means you must type a blank line; this is used to
end a multi-line command.
Many of the examples in this manual, even those entered at the interactive prompt,
include comments. Comments in Python start with the hash character, #, and extend to
the end of the physical line. A comment may appear at the start of a line or following
whitespace or code, but not within a string literal. A hash character within a string literal
is just a hash character. Since comments are to clarify code and are not interpreted by
Python, they may be omitted when typing in examples.
Some examples:

# this is the first comment


spam = 1 # and this is the second comment
# ... and now a third!
text = "# This is not a comment because it's inside quotes."

Modules
If you quit from the Python interpreter and enter it again, the definitions you have
made (functions and variables) are lost. Therefore, if you want to write a somewhat
longer program, you are better off using a text editor to prepare the input for the
interpreter and running it with that file as input instead. This is known as creating
a script. As your program gets longer, you may want to split it into several files for easier
maintenance. You may also want to use a handy function that youve written in several
programs without copying its definition into each program.
To support this, Python has a way to put definitions in a file and use them in a
script or in an interactive instance of the interpreter. Such a file is called a module;
definitions from a module can be imported into other modules or into the main module
(the collection of variables that you have access to in a script executed at the top level
and in calculator mode).
A module is a file containing Python definitions and statements. The file name is
the module name with the suffix .py appended. Within a module, the modules name (as a
string) is available as the value of the global variable __name__. For instance, use your
favorite text editor to create a file called fibo.py in the current directory with the
following contents Known implementations include:
CPython
This is the original and most-maintained implementation of Python, written in C.
New language features generally appear here first.
Jython
Python implemented in Java. This implementation can be used as a scripting
language for Java applications, or can be used to create applications using the Java class
libraries. It is also often used to create tests for Java libraries. More information can be
found at the Jython website.

Python for .NET


This implementation actually uses the CPython implementation, but is a
managed .NET application and makes .NET libraries available. It was created by Brian
Lloyd. For more information, see the Python for .NET home page.
IronPython
An alternate Python for .NET. Unlike Python.NET, this is a complete Python
implementation that generates IL, and compiles Python code directly to .NET assemblies.
It was created by Jim Hugunin, the original creator of Jython. For more information,
see the IronPython website.
PyPy
An implementation of Python written completely in Python. It supports several
advanced features not found in other implementations like stack less support and a Just in
Time compiler. One of the goals of the project is to encourage experimentation with the
language itself by making it easier to modify the interpreter (since it is written in Python).
Additional information is available on the PyPy projects home page.
Each of these implementations varies in some way from the language as
documented in this manual, or introduces specific information beyond whats covered in
the standard Python documentation. Please refer to the implementation-specific
documentation to determine what else you need to know about the specific
implementation youre using.

Notation:
The descriptions of lexical analysis and syntax use a modified BNF grammar
notation. This uses the following style of definition:

name ::= lc_letter (lc_letter | "_")*


lc_letter ::= "a"..."z"

The first line says that a name is an lc_letter followed by a sequence of zero or
more lc_letters and underscores. An lc_letter in turn is any of the single
characters 'a' through 'z'. (This rule is actually adhered to for the names defined in lexical
and grammar rules in this document.)
Each rule begins with a name (which is the name defined by the rule) and ::=. A vertical
bar (|) is used to separate alternatives; it is the least binding operator in this notation. A
star (*) means zero or more repetitions of the preceding item; likewise, a plus (+) means
one or more repetitions, and a phrase enclosed in square brackets ([ ]) means zero or one
occurrences (in other words, the enclosed phrase is optional). The * and + operators bind
as tightly as possible; parentheses are used for grouping. Literal strings are enclosed in
quotes. White space is only meaningful to separate tokens. Rules are normally contained
on a single line; rules with many alternatives may be formatted alternatively with each
line after the first beginning with a vertical bar.

C Programming in Raspberry pi
This is a short and quick introduction to programming in C. This section is aimed at
anybody who is interested new to programming and may wish to exploring the libRPii
source files. The examples and exercise are designed to provide enough references and
experience such that even complete beginners can still make the most out of the exploring
libRPii tools. All of the source code examples (with prefix ExS.) can be found in the
libRPii example source packages. See section GS.2 about how to get these resources.

The Compiler

To produce a program in C, there are two things that must be done. The programmer must
write their program, but then they must also convert the code that they have written in C,
into a language that the computer's hardware can understand. This language is called
machine code and consists of purely 1's and 0's. If humans had to write all of their
programs in machine code, then writing any complex program would take too long, and
reading it would be even harder! To overcome having to program in machine code a
language called assembly was conceived. The assembly language is a language of core
instructions like 'move memory,' 'read memory,' 'goto memory location,' 'Add' and
'subtract', and each instruction has an associated representation in machine code call an
opcode; when we want to run the program we have written we use an application call an
assembler to turn the simple instructions into binary machine code which can be directly
read by the computer. Every computer processor or microcontroller is designed to be able
to execute these simple instructions, and most have a set of roughly 30 unique
instructions (although there may be many more variations on these). The Raspberry Pi's
ARM chip has 28. Because of its simplicity, Assembly is known as a low level language.
Being constrained to only 30 different commands is still limiting, and is still too time
consuming to code complex applications. Each line of code in assembly is (nearly
always) stored as 4 bytes of information. Early computer games often used assembly
code to give programmers maximum control over the available hardware, and games
could easily run to hundreds of thousands of lines long! Once again, to make life easier
for programmers, applications call compilers were written to transform commands that
are easier for us humans to understand into many more lines of assembly code which can
then easily be turned into machine code. A compiler is written in such a way that it
understands a file that we give it so long as the file is written in a particular way; i.e in a
particular language, following a particular grammar. Moreover, when a programmer does
make mistakes (and we all do!), compilers are able to point out where in the code the
errors occurred from, and the cause of the error. Therefore, to make a program using the
C language, we must pass the files that we want to turn into a program, to the C compiler.
The C compiler then turns our C code into assembly code, and the assembler turns this
resulting assembly code into a binary file. With a binary file we can run our programs by
calling them from the command line.

Functions, Libraries and Headers

In C, every line of code we write essentially performs a function of some type. Functions
can include inputs, and can produce an output when they finish. For every function that
we want a program to perform, we must define (in machine code eventually) how the
computer must manipulate the electronic signals in order to produce an output, and how
to interpret the output. Take a calculator as an example, when we press '1+2=' the
calculator must be programmed to know how to represent the numbers 1 & 2 in such a
way so that it can manipulate both of them to find out what the answer is. It must then
convert this answer into a form that we understand - the image '3'. Somewhere in the
calculator there will be a series of instructions saved in machine code which tell the
calculator exactly how to do this. We call the inputs to a function the arguments, and the
outputs the outputs; in this case for the 'add' function, if the arguments are 1 and 2, then
the output is 3.
Say the calculator already 'knows' how to add. Let's explore how we could instruct it to
multiply two numbers together. Noting that that '3 x 2' is the same as '2 + 2 + 2,' then as
we know how to add, when the calculator has inputs '3x2' we can instruct it to add 2 and
2, and then to add 2 to the answer.

Notice how by doing this, we don't have to tell the calculator how to add again; the work
that was done previously to tell the calculator how to add does not need to be redone
ever (unless we wanted to improve its computational efficiency and make it faster). This
is an important concept in programming; once we have written a function to do
something, we can use that function as many times as we want. In order to organise the
functions which have already been written, we save collections of function definitions
into documents called libraries and save them in a known location on our computer. On
the Raspberry Pi, such libraries are saved in /usr/lib.

Now consider compiling a source file which calls a function we have written previously.
For the compiler to turn our source file into a binary file, the compiler requires that:

1. The functions called in the source file exist and have been defined elsewhere on
the computer.
2. The functions defined on our computer have the same types of arguments (i.e
numbers rather than words) and outputs as the function of the same name we have
called in our source files.
3. We tell it where to find the binary instructions which describe how the function is
implemented; the address of the library that contains the function we want to use.
We give this information to the compiler in the following ways:

To satisfy requirements 1 and 2 we produce what we call a 'header file.' Each


header file contains, among other things, lists of many function names and defines
each of their inputs and outputs. We call these function prototypes. If we use a
function from another library in our code we must tell the compiler to look in a
particular header file in order for it to confirm that the functions that we want to use
match what exists in the computer's libraries. If a function we want to use is not
found in any of the header files that we told the compiler to look in, then the
compilation will fail.
Should the compiler be happy that all of the functions used in a program exist, it
then continues to look for where the functions are defined. The compiler first looks
in a number of default directories. If however we want to use libraries which are
installed in different directories to the default, then when we run the compiler, along
we must also give the location of the libraries which we want to include.
Summary

A computer has many saved libraries of pre-written code. When we write a program, in
our source code we tell the compiler to check in header files for the existence of the
functions we want to use, and when we run the compiler we tell it where to look for
libraries. If the compiler can find the definitions of the functions we want to use, then it
can successfully compile our program. In section C.1.3 we look into how we structure a
C source file so that the compiler knows which header files to look for, and can interpret
the rest of the code we have written.

The structure of a C source file: hellopi.c

In order to have a program successfully compile (that is be successfully converted


without errors into machine code) particular features must be included in the source files
to help the compiler find everything it needs. Example Source ExS.1 is for a simple
program which prints "Hello Pi" to the terminal. The line by line breakdown which
follows explains the role of each line in the program.
ExS.1 Example Source Code: hellopi.c

// Comment: This is the Hello Pi Program.


1. #include <stdio.h>
2.
3. int main(){
4. printf("Hello Pi");
5. return 0; //This is also a comment and is
6. ignored.
7. }
A line by line breakdown of ExS.1 hellopi.c

Line
No. Comment
1. In C the compiler doesn't read any code after '//'. This lets us write comments
about the code. It is important that we leave comments about each section of our
code, so that it is easier to understand which sections of code do what.
Furthermore, if we would like other contributers to edit our code, then
commenting is especially important as code without any comments is very time
consuming to understand.
2. At the top of each file, as discussed in section C.1.2, we tell the compiler to look
in the header file stdio.h.
#include tells the compiler to include the file which follows. In this case
the file stdio header file.
The chevrons, < and >, tell the compiler to look for stdio.h in the default
'include directory', where most of the standard header files are saved.
stdio.h is the 'standard input and output' header file. It contains
prototypes for functions which let us print out or read in words and
numbers to or from the terminal. We need to include this header to use the
function 'printf' on line 5.
Line
No. Comment

3. An empty line does nothing (as we may expect). We do not need them in our
code, but they make reading it easier and help separate different sections of
code. Here it separates the 'include' command from the 'main' function.
4. The compiler always looks for the main function and expects our programs to
start there. The parentheses, '()' always follow any function name, and are used
to contain any inputs to the function. This main function has no inputs and so
they are empty. The curly bracket '{', indicates the start of the main function
definition, and the function definition is ended by placing a closing curly bracket
'}' at the end of the function (line 7). The word 'int' is specific to the output of the
function, we will discuss this more later.
5. Note the indent (using the 'tab' key) at the start of this line. Similarly to an empty
line, in C this does nothing (together, spaces, tabs and returns are known as
white space, and all are ignored by the compiler).Once again however, it helps to
clearly show that line 5 is part of the function 'main', and makes reading the code
much easier. 'printf' is a function in the stdio library. The sole purpose of this
program is to call this line of code - the rest of the writing in this file is just to
keep the compiler happy. The input to the function is placed between
parentheses, and using double quotes, "", signifies to the function that the input
is a string of characters which we want to appear in the terminal. Finally, the line
ends with a semi-colon, ';'. Every line in a function must end with a semicolon
as it signifies to a compiler the end of a statement.
6. We exit any function, including the main loop, by using a line with return in
like this one. It is used here to signify the end of the main function, and
describes the output of the function. Note that this line still needs a semicolon at
the end of it, and that the comments (following the //) are ignored by the
compiler.
7. The curly bracket signifies the end of the definition of the function 'main'.
Compiling and Makefiles

In this section we briefly discuss how to compile a program into a binary executable. The
compiler is essentially just another program which runs on a computer - like the teaching
resources, we can call it from the command line. For compiling C programs, we use a
compiler called gcc because it comes installed on the Raspberry Pi. It has many
complicated options which allow us to tailor its output to our needs, however to compile
a simple program like the Hello Pi above, it is nicely simple. Just like the functions
discussed in C.1.2 & C.1.3, the program takes in arguments which are passed to the
program by the command when gcc is called.

Try typing gcc --help into the command line. In this case, --help is the only argument
needed and in response to this input, the gcc program prints out all of its functionalities
and how to use them. You do not need to read everything it outputs, this was purely a
demonstration on how to pass arguments into a function.
To compile a simple source file into an executable, we must give the compiler 2
arguments - the source files which make up the program, and the name of the executable.
By convention source files written in c have a '.c' suffix at the end of their filename to
indicate that the file is written in C. Files written in another language have different
suffixes; e.g C plus plus has the suffix '.cpp'. We signify the name of the executable
output file by preceeding it with a '-o' argument (Explore the --help option again if you
are interested in what the '-o' represents). The executable output file can be named
anything we want, but it makes sense to name it after the source file. It does not matter
which order these two inputs are passed, however we must give the location of the source
file with respect to the working directory of the terminal, and the executable will be saved
in the working directory. Furthermore, as the only library we wish to compile with, the
stdio library, is a default library, we have no need to link the compiler to it, which keeps
compiling the hellopi.c source file nicely simple.
In order to use the gcc compiler to turn our hellopi.c source file into a binary executable,
first we need to navigate to the directory which includes our hellopi.c source file. Once
we are in the same directory, (as order of inputs does not matter) to compile our short
program we can type into the command line either of:

gcc hellopi.c -o hellopi


or

gcc -o hellopi hellopi.c

The executable hellopi can be run by typing


./hellopi
We see that the line 'Hello Pi' has been printed to the terminal!

Typing 'gcc -o ' into the command line every time we want to re-compile a program
may not seem too bad considering the example above, however once we want to compile
many files together and link with libraries which are not default, our gcc calls become
more and more complicated - to the extent that we want an easier way to call these lines.

make is another program which comes installed on the Raspberry Pi. The program
searches the working directory for a file calledmakefile or Makefile, and uses this file to
execute the necessary gcc commands. Using make can save time in the long run, as by
writing a makefile once, the command gcc hellopic.c -o hellopi can be reduced to
just make. A makefile for the hellopi program is shown and explained below.
ExS.1.m Example make Code for hellopi.c

#in makefiles, a hash indicates a comment


1. instead
2. all: hellopi
3. hellopi: hellopi.c
4. gcc -o hellopi hellopi.c
A line by line breakdown of ExS.1.m

Line
No. Comment
1. To make a comment in a makefile, instead of using // as in C, we use #. The
make program ignors any text which follows a #.
2. A makefile uses what are known as targets to decide what needs to be compiled.
The target is followed by a colon, and following the colon is a list of the files (or
other targets) upon which the target depends. This line states that the 'all:' target
depends on hellopi.
3. Make then looks at the hellopi: target to see what that depends on; in this case it
depends on hellopi.c. If the file hellopi.c has been changed since the target was
compiled, then make runs the line of code below the target.
4. Unlike in C source files, in a makefile the TAB key is not completely
ignored. The line following a target MUST begin with (and only with) a tab.
(If a space is mixed up in there then make will return a '***missing separator'
error). This line gives make the command to run when the target is to be re-
made. Note that this line is the same as those used to run gcc directly from
the command line.
Exercise 2: hellopi

1. Using the documentation in section 'GS.2 Navigating the terminal' find your way
to the examplesources/RPii_C-1/ExampleSources directory. Use the ls command
to find out which documents exist in this directory.
2. Open the GUI file manager and also navigate into the hellopi folder. Move the
windows so that you can see both the GUI file manager and the terminal at the
same time. The two documents you see should match the names of the documents
which were returned when using ls from the terminal in 1.
3. You can choose to open the files in either of 2 ways:
If you want to use the gedit text editor, type into the command line:
gedit hellopi.c &
If you are using another editor, type editorname hellopi.c
If you wanted to create a new file, you can type
gedit newfile.c &
and gedit will create a new file with the name 'newfile.c' in the current working
directory.
Alternatively, you can double click on a file in the file manager, or right
click and choose another editor of choice via the 'open with' option.
Try both; learning the first method can help speed up your work in the future.
4. Using the explanation in section C.1.3, spend some time thinking about what each
line does. Write a comment after each line (use '//') about why each line is included
in the source file and save this new file as 'myhellopi.c'.
5. The original hellopi.c file needs compiling. Use the command:
gcc -o hellopi hellopi.c
in the terminal to compile the program. When this is finished use the ls command
again and note that a new file has been created in the directory. Alternatively, you
may choose to use make; the makefile discussed in C.1.4 is in the directory already,
so running make straight away will also compile the program. It will not however,
compile myhellopi.c (unless we edit it).
6. By typing ./hellopi into the command line and pressing enter, we can run the
program. Our new terminal should read:
pi@raspberry ~/examplesources/hellopi $ ./hellopi
Hello Pi pi@raspberrypi ~/examplesources/hellopi $
7. We are going to introduce the new line character. Including '\n' in
a printf function has the same effect as pressing return/enter on the keyboard - it
causes a new line. If we add this character to the end of "Hello Pi" in hellopi.c, re-
compile the program and run it again, then this time our terminal should read:
pi@raspberry ~/examplesources/hellopi $ ./hellopi
Hello Pi
pi@raspberry ~/examplesources/hellopi $
8. Finally, we will add our second file, myhellopi.c to the makefile. This means that
if we change either of hellopi.c or myhellopi.c, then running make will re-compile
either of the programs if they have had their source files altered. First, we want to
make sure that we can tell if the code has re-compiled, so in myhellopi.c, change
Hello Pi, to Hello Pi version 1. So that make will compile both source files, we
need to add another target to the makefile. We must add myhellopi as a
dependency to 'all:', and then write some lines which tell the makefile how to
make the new target. By copying the format of the hellopi target, add a few more
lines to the makefile so that runningmake will re-compile both myhellopi.c and
hellopi.c should they be changed.
RELAYS
Relays

A relay is used to isolate one electrical circuit from another. It allows a low current
control circuit to make or break an electrically isolated high current circuit path. The
basic relay consists of a coil and a set of contacts. The most common relay coil is a length
of magnet wire wrapped around a metal core. When voltage is applied to the coil, current
passes through the wire and creates a magnetic field. This magnetic field pulls the
contacts together and holds them there until the current flow in the coil has stopped. The
diagram below shows the parts of a simple relay.

Figure: Relay
Operation:
When a current flows through the coil, the resulting magnetic field attracts an armature
that is mechanically linked to a moving contact. The movement either makes or breaks a
connection with a fixed contact. When the current is switched off, the armature is usually
returned by a spring to its resting position shown in figure 6.6(b). Latching relays exist
that require operation of a second coil to reset the contact position.
By analogy with the functions of the original electromagnetic device, a solid-state relay
operates a thyristor or other solid-state switching device with a transformer or light-
emitting diode to trigger it.
Pole and throw

SPST

SPST relay stands for Single Pole Single Throw relay. Current will only flow through the
contacts when the relay coil is energized.

Figure: SPST Relay


SPDT Relay
SPDT Relay stands for Single Pole Double Throw relay. Current will flow between the
movable contact and one fixed contact when the coil is De-energized and between the
movable contact and the alternate fixed contact when the relay coil is energized. The
most commonly used relay in car audio, the Bosch relay, is a SPDT relay.

Figure: SPDT Relay


DPST Relay
DPST relay stands for Double Pole Single Throw relay. When the relay coil is energized,
two separate and electrically isolated sets of contacts are pulled down to make contact
with their stationary counterparts. There is no complete circuit path when the relay is De-
energized.
Figure: DPST Relay
DPDT Relay
DPDT relay stands for Double Pole Double Throw relay. It operates like the SPDT relay
but has twice as many contacts. There are two completely isolated sets of contacts.

Figure: DPDT Relay


This is a 4 Pole Double Throw relay. It operates like the SPDT relay but it has 4 sets of
isolated contacts.
Figure: 4 Pole Double Throw relay

Types of relay:

1. Latching Relay
2. Reed Relay
3. Mercury Wetted Relay
4. Machine Tool Relay
5. Solid State Relay (SSR)

Latching relay
Latching relay, dust cover removed, showing pawl and ratchet mechanism. The ratchet
operates a cam, which raises and lowers the moving contact arm, seen edge-on just below
it. The moving and fixed contacts are visible at the left side of the image.
A latching relay has two relaxed states (bi-stable). These are also called "impulse",
"keep", or "stay" relays. When the current is switched off, the relay remains in its last
state. This is achieved with a solenoid operating a ratchet and cam mechanism, or by
having two opposing coils with an over-center spring or permanent magnet to hold the
armature and contacts in position while the coil is relaxed, or with a remanent core. In the
ratchet and cam example, the first pulse to the coil turns the relay on and the second pulse
turns it off. In the two coil example, a pulse to one coil turns the relay on and a pulse to
the opposite coil turns the relay off. This type of relay has the advantage that it consumes
power only for an instant, while it is being switched, and it retains its last setting across a
power outage. A remnant core latching relay requires a current pulse of opposite polarity
to make it change state.

Figure: Latching relay

Reed relay

A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube, which
protects the contacts against atmospheric corrosion. The contacts are closed by a
magnetic field generated when current passes through a coil around the glass tube. Reed
relays are capable of faster switching speeds than larger types of relays, but have low
switch current and voltage ratings.

Mercury-wetted Relay

A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted
with mercury. Such relays are used to switch low-voltage signals (one volt or less)
because of their low contact resistance, or for high-speed counting and timing
applications where the mercury eliminates contact bounce. Mercury wetted relays are
position-sensitive and must be mounted vertically to work properly. Because of the
toxicity and expense of liquid mercury, these relays are rarely specified for new
equipment. See also mercury switch.
Machine tool relay

A machine tool relay is a type standardized for industrial control of machine tools,
transfer machines, and other sequential control. They are characterized by a large number
of contacts (sometimes extendable in the field) which are easily converted from
normally-open to normally-closed status, easily replaceable coils, and a form factor that
allows compactly installing many relays in a control panel. Although such relays once
were the backbone of automation in such industries as automobile assembly, the
programmable logic controller (PLC) mostly displaced the machine tool relay from
sequential control applications.

Solid-state relay
A solid state relay (SSR) is a solid state electronic component that provides a similar
function to an electromechanical relay but does not have any moving components,
increasing long-term reliability. With early SSR's, the tradeoff came from the fact that
every transistor has a small voltage drop across it. This voltage drop limited the amount
of current a given SSR could handle. As transistors improved, higher current SSR's, able
to handle 100 to 1,200 Amperes, have become commercially available. Compared to
electromagnetic relays, they may be falsely triggered by transients.

Figure: Solid relay, which has no moving parts


Specification
Number and type of contacts normally open, normally closed, (double-throw)
Contact sequence "Make before Break" or "Break before Make". For example,
the old style telephone exchanges required Make-before-break so that the
connection didn't get dropped while dialing the number.
Rating of contacts small relays switch a few amperes, large contactors are rated
for up to 3000 amperes, alternating or direct current
Voltage rating of contacts typical control relays rated 300 VAC or 600 VAC,
automotive types to 50 VDC, special high-voltage relays to about 15 000 V
Coil voltage machine-tool relays usually 24 VAC, 120 or 250 VAC, relays for
switchgear may have 125 V or 250 VDC coils, "sensitive" relays operate on a few
milli-amperes

Applications:

Relays are used:


To control a high-voltage circuit with a low-voltage signal, as in some types of
modems,
To control a high-current circuit with a low-current signal, as in the starter
solenoid of an automobile,
To detect and isolate faults on transmission and distribution lines by opening and
closing circuit breakers (protection relays),
To isolate the controlling circuit from the controlled circuit when the two are at
different potentials, for example when controlling a mains-powered device from a
low-voltage switch. The latter is often applied to control office lighting as the low
voltage wires are easily installed in partitions, which may be often moved as
needs change. They may also be controlled by room occupancy detectors in an
effort to conserve energy,
To perform logic functions. For example, the boolean AND function is realized by
connecting relay contacts in series, the OR function by connecting contacts in
parallel. Due to the failure modes of a relay compared with a semiconductor, they
are widely used in safety critical logic, such as the control panels of radioactive
waste handling machinery.
As oscillators, also called vibrators. The coil is wired in series with the normally
closed contacts. When a current is passed through the relay coil, the relay operates
and opens the contacts that carry the supply current. This stops the current and
causes the contacts to close again. The cycle repeats continuously, causing the
relay to open and close rapidly. Vibrators are used to generate pulsed current.
To generate sound. A vibrator, described above, creates a buzzing sound because
of the rapid oscillation of the armature. This is the basis of the electric bell, which
consists of a vibrator with a hammer attached to the armature so it can repeatedly
strike a bell.
To perform time delay functions. Relays can be used to act as an mechanical time
delay device by controlling the release time by using the effect of residual
magnetism by means of a inserting copper disk between the armature and moving
blade assembly.

Transistor Switching Circuit

The circuit resembles that of the Common Emitter circuit we looked at in the previous
tutorials. The difference this time is that to operate the transistor as a switch the transistor
needs to be turned either fully "OFF" (Cut-off) or fully "ON" (Saturated). An ideal
transistor switch would have an infinite resistance when turned "OFF" resulting in zero
current flow and zero resistance when turned "ON", resulting in maximum current flow.
In practice when turned "OFF", small leakage currents flow through the transistor and
when fully "ON" the device has a low resistance value causing a small saturation voltage
(Vce) across it. In both the Cut-off and Saturation regions the power dissipated by the
transistor is at its minimum.

To make the Base current flow, the Base input terminal must be made more positive than
the Emitter by increasing it above the 0.7 volts needed for a silicon device. By varying
the Base-Emitter voltage Vbe, the Base current is altered and which in turn controls the
amount of Collector current flowing through the transistor as previously discussed. When
maximum Collector current flows the transistor is said to beSaturated. The value of the
Base resistor determines how much input voltage is required and corresponding Base
current to switch the transistor fully "ON".

Then to summarize when using a Transistor as a Switch.S

Transistor switches can be used to switch and control lamps, relays or even
motors.

When using bipolar transistors as switches they must be fully "OFF" or fully
"ON".

Transistors that are fully "ON" are said to be in their Saturation region.

Transistors that are fully "OFF" are said to be in their Cut-off region.

In a transistor switch a small Base current controls a much larger Collector


current.

When using transistors to switch inductive relay loads a "Flywheel Diode" is


required.

When large currents or voltages need to be controlled, Darlington


Transistors are used.
LED (Light emitting diode):

A light-emitting diode (LED) is a semiconductor light source. LEDs are used


as indicator lamps in many devices and are increasingly used for other lighting.
Introduced as a practical electronic component in 1962, early LEDs emitted low-intensity
red light, but modern versions are available across the visible, ultraviolet,
and infrared wavelengths, with very high brightness.

When a light-emitting diode is forward-biased (switched on), electrons are able


to recombine with electron holes within the device, releasing energy in the form
of photons. This effect is called electroluminescence and the color of the light
(corresponding to the energy of the photon) is determined by the energy gap of the
semiconductor. LEDs are often small in area (less than 1 mm2), and integrated optical
components may be used to shape its radiation pattern. LEDs present
many advantages over incandescent light sources including lower energy consumption,
longer lifetime, improved robustness, smaller size, and faster switching. LEDs powerful
enough for room lighting are relatively expensive and require more precise current
and management than compact fluorescent lamp sources of comparable output.

Light-emitting diodes are used in applications as diverse as aviation lighting, automotive


lighting, advertising, general lighting, and traffic signals. LEDs have allowed new text,
video displays, and sensors to be developed, while their high switching rates are also
useful in advanced communications technology. Infrared LEDs are also used in
the remote control units of many commercial products including televisions, DVD
players, and other domestic appliances.
ADVANTAGES
&
APPLICATIONS
Advantages:

Highly sensitive
Fit and Forget system
Low cost and reliable circuit

Applications:
Museums
Home / Office security
Jeweler shops
Banks
Future scope

A vibration sensor can also be interfaced to the door to know about the breakage of the
door and a siren can be fixed to alert the neighbors about the thief.
CONCLUSION

The project Advance Security System With Intruder Image Capture And Forward
Through Email is successfully tested and implemented. This can be used for many
applications in security purpose for Houses, Banks, Jeweler shops.
REFERENCE

Text Books:
Basics of Secuirty Engineering By David Louis
Sensors Engineering Applications By Morris Hamington

Potrebbero piacerti anche