Вы находитесь на странице: 1из 102

Transducers and Instrumentation

EO-102
Fundamentals of Electronics & Instrumentation
Electronics & Instrumentation EO-102 1
Transducers/ Sensors

Variety of Sensors/ Transducers Digital or Analog

For example:
Temperature Sensor
Humidity Sensor
Radiation Sensor
Ultrasonic Sensor
Infrared Sensor
Vibration Sensor
Global Positioning System (GPS)
Global System for Mobile Module (GSM)
Optical/ Hyper spectral Camera etc.

Electronics & Instrumentation EO-102 2


Sensing process

Input Energy Output Energy


Transducer
(or signal) (or signal)

Fig. 1. The Sensing Process

Electronics & Instrumentation EO-102 3


Definition of a transducer

Transducer is any device that converts energy in one form


to another energy. The majority either convert electrical
energy to mechanical displacement or convert some
non-electrical physical quantity, such as temperature,
sound or light to an electrical signal.

Electronics & Instrumentation EO-102 4


Functions of transducer
1. To sense the presence, magnitude, change in, and frequency
of some measurand.

2. To provide an electrical output that, when appropriately


processed and applied to readout device, gives accurate
quantitative data about the measurand

Measurand
Transducer Electrical
output

Excitation

Measurand refers to the quantity, property or condition which the


transducer translates to an electrical signal.

Electronics & Instrumentation EO-102 5


Classification of transducers
Transducer can be classified according to their application,
based primarily on the physical quantity, property, or
condition that is measured.
The transducer can be categories into:
A) Passive transducer:
- requires an external power
- output is a measure of some variation, such resistance and
capacitance. E.g. : condenser microphone

B) Self generating transducer:


- not require an external power, and they produce analog
voltage or current when stimulated by some physical form of
energy. E.g. : Thermocouple
Electronics & Instrumentation EO-102 6
Transducer types
Quantity
Input Device Output Device
being
(Sensor) (Actuator)
Measured
Light Dependant Resistor (LDR), Lights & Lamps, LED's &
Light Level
Photodiode, Phototransistor, Solar Cell Displays, Fiber Optics
Thermocouple, Thermistor,
Heater, Fan, Peltier
Temperature Thermostat, Resistive temperature
Elements
detectors (RTD)
Force/Pressur Strain Gauge, Pressure Switch, Load Lifts & Jacks,
e Cells Electromagnetic, Vibration
Potentiometer, Encoders, Motor, Solenoid, Panel
Position
Reflective/Slotted Opto-switch, LVDT Meters
Tacho-generator, Reflective/Slotted AC and DC Motors, Stepper
Speed
Opto-coupler, Doppler Effect Sensors Motor, Brake
Carbon Microphone, Piezo-electric
Sound Bell, Buzzer, Loudspeaker
Crystal
Electronics & Instrumentation EO-102 7
Selecting a transducers
1. Operating range
2. Sensitivity
3. Frequency response and resonant frequency
4. Environmental compatibility -
5. Minimum sensitivity measurand.
6. Accuracy
7. Usage and ruggedness
8. Electrical parameter

Electronics & Instrumentation EO-102 8


Transducers to be covered
Temperature transducers
Resistive Position Transducer
Capacitive Transducer
Inductive Transducer
Strain Gauge
LVDT
Photoelectric etc.

Electronics & Instrumentation EO-102 9


Temperature Transducers

Temperature transducers can be divided into


four main categories:

1. Resistance Temperature Detectors (RTD)


2. Thermocouples
3. Thermistor

Electronics & Instrumentation EO-102 10


1) Resistance Temperature Detector (RTD)
Detectors of wire resistance temperature common employ platinum,
nickel or resistance wire elements, whose resistance variation with
temperature has high intrinsic accuracy. They are available in many
configurations and size and as shielded or open units for both
immersion and surface applications.
The relationship between temperature and resistance of conductors can
be calculated from the equation:

R R0 (1 T )
where
R = the resistance of the conductor at temperature t (0C)
R0 = the resistance at the reference temperature, usually
200C
= the temperature coefficient of resistance
T = the difference between the operating and the
reference temperature
Electronics & Instrumentation EO-102 11
2) Thermocouple

It consists of two wires of different metals are joined together


at one end, a temperature difference between this end and the
other end of wires produces a voltage between the wires. The
magnitude of this voltage depends on the materials used for the
wires and the amount of temperature difference between the
joined ends and the other ends.

Electronics & Instrumentation EO-102 12


Contd
The emf of the thermocouple :
E = c(T1 T2) + k(T12 T22)

Where
c and k = constant of the thermocouple
materials
T1 = The temperature of the hot
junction
T2 = The temperature of the cold or
reference junction

Electronics & Instrumentation EO-102 13


Thermocouples
Two dissimilar metals induce voltage difference (few mV
per 10K) electro-thermal or Seebeck effect

Use op-amp to process/amplify the voltage


Absolute accuracy of 1K is difficult

Electronics & Instrumentation EO-102 14


Electronics & Instrumentation EO-102 15
3) Thermistor

A thermistor is a semiconductor made by sintering


mixtures of metallic oxide, such as oxides of manganese,
nickel, cobalt, copper and uranium.
Termistors have negative temperature coefficient (NTC).
That is, their resistance decreases as their temperature
rises.

Types of thermistor Resistance


Disc 1 to 1M
Washer 1 to 50k
Rod high resistance

Electronics & Instrumentation EO-102 16


This figure shows
resistance versus
temperature for a
family thermistor.
The resistance value
marked at the bottom
end of each curve is a
value at 250C

Note!
The resistance
decreases as their
temperature rises-NTC

Electronics & Instrumentation EO-102 17


Advantages of thermistor
Small size and low cost

Fast response over narrow temperature range

Good sensitivity in Negative Temperature Coefficient


(NTC) region

Cold junction compensation not required due to dependence


of resistance on absolute temperature.

Contact and lead resistance problems not encountered due


to large resistance

Electronics & Instrumentation EO-102 18


Limitations of thermistor

Non linearity in resistance vs temperature


characteristics
Unsuitable for wide temperature range
Very low excitation current to avoids self heating
Need of shielded power lines, filters, etc due to high
resistance

Electronics & Instrumentation EO-102 19


Temperature Sensors
Bimetallic switch (electro-mechanical) used in
thermostats. Can be creep or snap action.

Creep-action: coil or
spiral that unwinds
or coils with
changing
temperature

Thermistors (thermally sensitive resistors); Platinum


Resistance Thermometer (PRT), very high accuracy.

Electronics & Instrumentation EO-102 20


Resistive Position Transducer

The principle of the resistance transducer is that the physical


variable under measurement causes a resistance change in the
sensing element.
A common requirement in industrial measurement and control
work is to be able to sense the position of an object or distance it
has moved.
L
. R Potentiometer
A

R: resistance change
: density
L: Length
A: area
Electronics & Instrumentation EO-102 21
Contd

FIG 1 (a) FIG 1 (b)

Figure shows the construction of a displacement transducer uses a


resistance element with a sliding contact or wiper linked to the object
being monitored.

The resistance between the slider and one end of the resistance element
depends on the position of the object. The output voltage depends on
the wiper position and therefore is a function of the shaft position

Electronics & Instrumentation EO-102 22


Consider Fig 1 (b), if the circuit is unloaded, the output voltage V 0 is a certain
fraction of VT, depending on the position of the wiper:

V0 R2

VT R1 R2
This equation shows that the output voltage is directly proportional to
the position of the wiper, if the resistance of the transducer is distributed
uniformly along the length of travel of the wiper

EXAMPLE 1

A displacement transducer with a shaft stroke of 4 in. is used in the


circuit of figure 1 (b). R1 +R2 is 1000 and VT = 4 V.
The wiper is 1.5 in from B. Find V0?

Electronics & Instrumentation EO-102 23


Positional Sensors: potentiometer
Can be Linear or Rotational

Processing circuit

Electronics & Instrumentation EO-102 24


Positional Sensors: Rotary Encoders
Incremental and absolute types
Incremental encoder needs a counter, loses absolute
position between power glitches, must be re-homed
Absolute encoders common in CD/DVD drives

Electronics & Instrumentation EO-102 25


Capacitive Transducer
The capacitance of a parallel plate capacitor is given by

kA 0
C ( Farads)
d

where
k = dielectric constant
A = the area of the plate, in m2
o = 8.854 x 10-12 F/m
d = the plate placing in m

Electronics & Instrumentation EO-102 26


Contd
Forms of Capacitance Transducers

Rectilinear Capacitance
Rotary plate capacitor Transducer

Thin diaphragm

Electronics & Instrumentation EO-102 27


Contd

Rotary plate capacitor:

The capacitance of this unit proportional to the


amount of the fixed plate that is covered, that
shaded by moving plate. This type of transducer
will give sign proportional to curvilinear
displacement or angular velocity.

Electronics & Instrumentation EO-102 28


Contd

Rectilinear capacitance
transducer:

It consists of a fixed cylinder and


a moving cylinder. These
pieces are configured so the
moving piece fits inside the
fixed piece but insulated from
it.

Electronics & Instrumentation EO-102 29


Contd

Thin diaphragm:
A transducer that varies the
spacing between surfaces. The
dielectric is either air or vacuum.
Often used as Capacitance
microphones.

Electronics & Instrumentation EO-102 30


Contd
Advantages:
1. Has excellent frequency response
2. Can measure both static and dynamic phenomena.

Disadvantages:
1. Sensitivity to temperature variations
2. the possibility of erratic or distortion signals owing to
long lead length

Applications:
1. As frequency modulator in RF oscillator
2. In capacitance microphone
3. Use the capacitance transducer in an ac bridge circuit

Electronics & Instrumentation EO-102 31


Inductive Transducer
Inductive transducers may be either of the self generating or
passive type. The self generating type utilises the basic
electrical generator principle, i.e, a motion between a
conductor and magnetic field induces a voltage in the
conductor (generator action). This relative motion between
the field and the conductor is supplied by changes in the
measurand.

An inductive electromechanical transducer is a device that


converts physical motion (position change) into a change in
inductance. Transducers of variable inductance type work
upon one of the following principles:
1. Variation of self inductance
2. Variation of mutual inductance
Electronics & Instrumentation EO-102 32
Cont..

Inductive transducers are mainly used for the measurement of


displacement. The displacement to be measured is
arranged to cause variation in any of three variables:

1. Number of turns
2. Geometric configuration
3. Permeability of the magnetic material or magnetic circuits

Electronics & Instrumentation EO-102 33


Positional Sensors: Inductive Proximity Switch
Detects the presence of metallic objects (non-contact) via
changing inductance
Sensor has 4 main parts: field producing Oscillator via a
Coil; Detection Circuit which detects change in the field;
and Output Circuit generating a signal (NO or NC)
Used in traffic lights (inductive loop buried under the road). Sense
objects in dirty environment.
Does not work for non-metallic objects. Omni-directional.

Electronics & Instrumentation EO-102 34


Strain Gauge
The strain gauge is an example of a passive transducer that
uses electric resistance variation in wires to sense the strain
produced by a force on wires. It is a very versatile detector
and transducer for measuring weight, pressure, mechanical
force, or displacement.
The construction of a bonded strain
gauge (see figure) shows a fine wire
element looped back and forth on a
mounting plate, which is usually
cemented to the member undergoing
stress. A tensile stress tends to
elongate the wire and thereby
increase its length and decrease its
cross-sectional area.
Electronics & Instrumentation EO-102 35
The combined effect is an increase in resistance:

L
R
Where,
A
: the specific resistance of the conductor material in ohm meters
L : length of conductor (meters)
A : area of conductor (m2)

As consequence of strain, 2 physical qualities are particular interest:

1) The change in gauge resistance


2) The change in length

The relationship between these two variables called gauge factor,


K, is expressed mathematically as

Electronics & Instrumentation EO-102 36


R / R
K
L / L
Where

K= the gauge factor


R=the initial resistance in ohms (without strain)
R= the change in initial resistance in ohms
L= the initial length in meters (without strain)
L=the change in initial length in meters

L/L same unit with G, therefore

R / R
K
G
Electronics & Instrumentation EO-102 37
From Hooke theory, stress, S, is defined as internal force/area.

F
S
A
Where
S= the stress in kilograms per square meter
F= the force in kilograms
A= area in square meters

Then the modulus of elasticity of material E or called Youngs modulus (Hookes


Law) is written as:

Where,
S
E E= Young modules in kg per square meter
S= the stress in kilograms per square meter
G G= the strain (no units)

Electronics & Instrumentation EO-102 38


Metallic strain gauge formed from thin resistance
wire or etched from thin sheets of metal foil.

Wire gauge (small) to minimum leakage for high T


applications

Semiconductor strain gauge high output transducers


as load cells

Strain gauge is generally used as one arm of bridge

Electronics & Instrumentation EO-102 39


Positional Sensors: LVDT
Linear Variable
Differential
Transformer

Electronics & Instrumentation EO-102 40


LINEAR VARIABLE DIFFERENTIAL
TRANSFORMER (LVDT)

It consists basically of a primary winding and


two secondary windings, wound over a hollow
tube and positioned so the primary winding is
between two secondaries. In figure shows the
construction of the LVDT.

An iron core slides within the tube and therefore affects the magnet
coupling between the primary and the two secondaries. When the core is in
the centre, voltage induced in the two secondaries is equal. When the core
is moved in one direction from centre, the voltage induced in one winding
is increased and that in the other is decreased. Movement in the opposite
direction reverses this effect
Electronics & Instrumentation EO-102 41
Cont..

Electronics & Instrumentation EO-102 42


Cont..

Electronics & Instrumentation EO-102 43


Motion sensors/transducers
Switches, solenoids, relays, motors, etc.
Motors
DC
Brushed/brushless
Stepper motor
Servo
Stepper motors
AC

Brushed motor permanent magnets on armature, rotor acts as electromagnet


Electronics & Instrumentation EO-102 44
Brushless motor permanent magnet on the rotor, electromagnets on armature are switched
Light sensors: photoconductive cells
Light dependent resistor (LDR) cell

Electronics & Instrumentation EO-102 45


Light level sensitive switch

Electronics & Instrumentation EO-102 46


Photo-junction devices
phototransistor
photodiode

Electronics & Instrumentation EO-102 47


Whats Photoelectric Effect?
-is the emission of electrons from matter upon the
absorption of electromagnetic radiation, such as
ultraviolet radiation or x-rays.-refers to the emission,
or ejection, of electrons from the surface of,
generally, a metal in response to incident light.

Electronics & Instrumentation EO-102 48


Photoelectric Transducer
Can be categorized as: photoemissive, photoconductive, or photovoltaic.

No. Types Characteristics

1. Photoemmisive radiation falling into a cathode causes


electrons to be emitted from cathode
surface.

2. Photoconductive the resistance of a material is change


when its illuminated.

3. Photovoltaic Generate an output voltage


proportional to radiation intensity

Electronics & Instrumentation EO-102 49


Examples of Photoelectric Transducer

(i) The Photomultiplier Tube


(ii) Photoconductive Cells OR Photocells
the electrical resistance of the materials
varies with the amount of light striking.
(iii) The Photovoltaic Cell or solar cell
- produce an electrical current when
connected to the load.

Electronics & Instrumentation EO-102 50


Photovoltaic Solar Cells
Can convert about 20% of light power into electricity
Voltage is low (diode drop, ~0.6V)

Solar power is 1.4kW/m^2

Electronics & Instrumentation EO-102 51


Photomultiplier tubes (PMT)
Most sensitive of light sensors (can detect individual
photons)
Acts as a current source

electrons

Electronics & Instrumentation EO-102 52


Piezo transducers
Detect motion (high and low frequency)
Sound (lab this week), pressure, fast motion
Cheap, reliable but has a very limited range of motion

Electronics & Instrumentation EO-102 53


Piezoelectric
transducers are based
on the property of
accumulating charges if
stressed (direct
effect)and to strain in
case of an electric signal
is applied across their
electrodes (inverse
effect)

Piezoelectricity is due to
asymmetries in the
crystallographic structure.

Electronics & Instrumentation EO-102 54


The Curie point is about 130C. Above 130C, a nonpiezoelectric cubic
phase is stable, where the center of positive charge (Ba2+ and Ti4+)
coincides with the center of the negative charge (O2) (Figure a).
When cooled below the Curie point, a tetragonal structure (shown in Figure
b) develops where the center of positive charge is displaced relative to the
O2ions, leading to the formation of electric dipoles.

Electronics & Instrumentation EO-102 55


Naturally occurring Piezoelectric Material
Quartz
Berlinite (AlPO4), a rare phosphate mineral that is
structurally identical to quartz
Sucrose (table sugar)
Rochelle salt
Topaz
Tourmaline-group minerals
Lead Titanate (PbTiO3)

Electronics & Instrumentation EO-102 56


Advantages

High stiffness, to measure force.


High resonant frequency (up to 500 kHz)
Stability, reproducibility and linearity
Large operating temperature range
Low sensitivity to external magnetic field.

Drawbacks

Curie Temperature, Tc
Resonant behaviour
High output impedance
Cannot be used to detect static quantities

Electronics & Instrumentation EO-102 57


Electronics & Instrumentation EO-102 58
Sound transducers
microphone speaker

Note: voice coil can also be used to generate fast motion


Electronics & Instrumentation EO-102 59
Where would you interface these sensors?

Require suitable sensor nodes

For example:

Single Board Microcontrollers


Arduino Uno

Single Board Computers


Raspberry Pi
Beaglebone Black

Electronics & Instrumentation EO-102 60


ATmega328
The ATmega328 is a single chip micro-
controller created by Atmel and
belongs to the megaAVR series.

The Atmel 8-bit AVR RISC-based microcontroller combines 32 KB ISP


flash memory with read-while-write capabilities, 1 KB EEPROM, 2 KB
SRAM, 23 general purpose I/O lines, 32 general purpose working
registers, three flexible timer/ counters with compare modes, internal and
external interrupts, serial programmable USART, a byte-oriented 2-wire
serial interface, SPI serial port, 6-channel 10-bit A/D converter (8-
channels in TQFP and QFN/MLF packages), programmable watchdog
timer with internal oscillator, and five software selectable power saving
modes. The device operates between 1.8-5.5 volts. The device achieves
throughputs approaching 1 MIPS.

Electronics & Instrumentation EO-102 61


Electronics & Instrumentation EO-102 62
Electronics & Instrumentation EO-102 63
Electronics & Instrumentation EO-102 64
Electronics & Instrumentation EO-102 65
Electronics & Instrumentation EO-102 66
Electronics & Instrumentation EO-102 67
Arduino
A free development system based on
Atmega328.

Electronics & Instrumentation EO-102 68


What is Arduino
Open Source Hardware, you can make your own
board, or buy one.
Cheap, easily available.
Open Source Software.
Very widespread, many projects openly available.
Extra HW (shields) available.

Electronics & Instrumentation EO-102 69


Arduino Uno

Electronics & Instrumentation EO-102 70


Arduino IDE

Electronics & Instrumentation EO-102 71


Arduino Language
C like syntax, but simplified
Abstracts the pin naming to numbers
Trades efficience for ease of use
Easy to learn, yet powerful
Lots of example code
Easy to reuse C-code from other projects
Libraries can be written in C++
Lots of libraries available

Electronics & Instrumentation EO-102 72


Simple Arduino Code(Blink LED)
int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts


void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,


// as long as the Arduino has powervoid
loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(500); // wait for half a second
digitalWrite(ledPin, LOW); // set the LED off
delay(500); // wait for half a second
}
Electronics & Instrumentation EO-102 73
Introduction to Raspberry Pi
(RPi)

Electronics & Instrumentation EO-102 74


What is Raspberry Pi
Created by Raspberry Pi Foundation
The Raspberry Pi is a credit-card sized computer that plugs
into your TV and a keyboard.
Available in two revisions (Model-A and Model-B)
It has a powerful processing unit (BCM2835 ARM11 RISC)
Graphic processing capabilities (GPU@250MHz)
Has ported Open source OSs specially developed for ARM11
like Raspbian, Pidora, etc.
Raspberry+debian = Raspbian,Fedora
Remix+Raspberry = Pidora

Electronics & Instrumentation EO-102 75


Why Raspberry pi?
Faster on-Board processing (When spontaneous
response is required).
Includes Audio-Video processing capabilities.
Extended Peripheral devices support
(like Keyboard, Mouse, USB-stick etc.)
Networkable board (via Ethernet Cable)
Camera support (CSI)
Less power consumption (5V adapter)

Electronics & Instrumentation EO-102 76


Model A Model B
Raspberry
Price Pi Model-A and B
Rs.1900 Rs.2400
CPU: 700 MHz ARM1176JZF-S core (ARM11 family)
Broadcom VideoCore IV, OpenGL ES 2.0, MPEG-2 and VC-
GPU:
1, 1080p 30 h.264/MPEG-4 AVC
Memory
256 MB (shared with GPU) 512 MB (shared with GPU)
(SDRAM):
USB 2.0 ports: 1 2
Composite RCA, HDMI, raw LCD Panels via DSI 14 HDMI
Video outputs:
resolutions from 640350 to 19201200
Audio outputs: HDMI, 3.5 mm jack (stereo analog)
Onboard storage: SD / MMC / SDIO card slot
Onboard
None 10/100 Ethernet
network:
Power ratings: 300 mA (1.5 W) 700 mA (3.5 W)
Size and Weight 85.60 mm 53.98 mm, 45 g
Operating Debian GNU/Linux, Raspbian OS, Fedora, Arch Linux ARM,
systems: RISC OS, FreeBSD, Plan 9

Electronics & Instrumentation EO-102 77


Raspberry Pi (Short Map)
Audio
Video USB

GPIO

DSI Ethernet

CSI
SD
HDMI
Power CPU/GPU

Electronics & Instrumentation EO-102 78


Ref: http://pi.gadgetoid.com/pinout/pin6_ground
http://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/
Electronics & Instrumentation EO-102 79
Electronics & Instrumentation EO-102 80
Set up your Raspberry Pi
SD card (Minimum size 4Gb)
HDMI to HDMI / DVI lead
RCA video lead (if you are not using the HDMI output)
Keyboard and mouse (USB 2.0)
Ethernet network cable (optional)
Power adapter (micro USB power 700mA at 5V)
Audio lead (If you are not using HDMI)

HDMI connector HDMI to DVI lead RCA composite video


Electronics & Instrumentation EO-102
connector 81
Set up your Raspberry Pi

Electronics & Instrumentation EO-102 82


Serial between Arduino-RPi
Data Received on RPi using
simple Python programs
accessing USB serial
Data can be immediately
processed and send back to
arduino for further routing
over network

Electronics & Instrumentation EO-102 83


LM335 PRECISION
TEMPERATURE SENSOR

The LM335 are precision temperature sensors which can be easily


calibrated. Wide range, low power temperature sensor outputs an
analog voltage that is proportional to the ambient temperature

1C Initial Accuracy Available

Operates from 400 A to 5 mA

Less than 1 Dynamic


Impedance

200 C overrange

Time stability (Tcase =


+125C)=0.2 C/kh
Electronics & Instrumentation EO-102 84
Interfacing with Arduino

Electronics & Instrumentation EO-102 85


Interfacing with Raspberry Pi

Required parts

Raspberry Pi
MCP3008 8 channel ADC
Light dependent resistor (LDR)
TMP36 temperature sensor
10 Kohm resistor

Electronics & Instrumentation EO-102 86


MCP 3008
The MCP3008 is a 10bit 8-channel Analogue-to-digital converter
(ADC).

The following list shows how the MCP3008 can


be connected. It requires 4 GPIO pins on the Pi
P1 Header.

VDD 3.3V
VREF 3.3V
AGND GROUND
CLK GPIO11 (P1-23)
DOUT GPIO9 (P1-21)
DIN GPIO10 (P1-19)
CS GPIO8 (P1-24)
DGND GROUND

Electronics & Instrumentation EO-102 87


Reading The Data Using a Python
Script
#!/usr/bin/python
import spidev
temp = ((data * 330)/float(1023))-50
import time
temp = round(temp,places)
import os return temp
# Open SPI bus # Define sensor channels
spi = spidev.SpiDev() light_channel = 0
spi.open(0,0) temp_channel = 1
# Define delay between readings
# Function to read SPI data from MCP3008 chip
delay = 5
# Channel must be an integer 0-7 while True:
def ReadChannel(channel): # Read the light sensor data
adc = spi.xfer2([1,(8+channel)<<4,0]) light_level = ReadChannel(light_channel)
data = ((adc[1]&3) << 8) + adc[2] light_volts = ConvertVolts(light_level,2)
# Read the temperature sensor data
return data
temp_level = ReadChannel(temp_channel)
# Function to convert data to voltage level, temp_volts = ConvertVolts(temp_level,2)
# rounded to specified number of decimal places. temp = ConvertTemp(temp_level,2)
def ConvertVolts(data,places): # Print out results
volts = (data * 3.3) / float(1023) print "--------------------------------------------"
print("Light: {} ({}V)".format(light_level,light_volts))
volts = round(volts,places)
print("Temp : {} ({}V) {} deg
return volts C".format(temp_level,temp_volts,temp))
# Function to calculate temperature from # Wait before repeating loop
# TMP36 data, rounded to specified time.sleep(delay)
# number of decimal places.
def ConvertTemp(data,places):
Electronics & Instrumentation EO-102 88
MQ-6 LPG Sensor
They are used in gas leakage detecting equipment in family and industry, are suitable for
detecting of LPG, iso-butane, propane, LNG, avoid the noise of alcohol and cooking fumes and
cigarette smoke.

FEATURES

MQ-6: High sensitive to LPG, Propane,


Butane.
Small sensitivity to alcohol, smoke
Fast response
Stable and long life
Simple drive circuit

Electronics & Instrumentation EO-102 89


Interfacing with Arduino
int sensorValue;

void setup()
{
Serial.begin(9600); // sets the serial
port to 9600
}

void loop()
{
sensorValue = analogRead(0); // read
analog input pin 0
Serial.println(sensorValue, DEC); //
prints the value read
delay(100); // wait 100ms
for next reading
}
Electronics & Instrumentation EO-102 90
MQ-7 Gas sensor
This is a simple-to-use Carbon Monoxide (CO) sensor, suitable for sensing CO
concentrations in the air. The MQ-7 can detect CO-gas concentrations anywhere
from 20 to 2000ppm.This sensor has a high sensitivity and fast response time.
The sensors output is an analog resistance.

FEATURES
High sensitivity to carbon monoxide
Stable and long life
Heating consumption About 350mW

APPLICATION
They are used in gas detecting equipment for
carbon monoxide(CO) in family and industry or car.

Electronics & Instrumentation EO-102 91


Interfacing with Arduino
int sensorValue;

void setup()
{
Serial.begin(9600); // sets the serial
port to 9600
}

void loop()
{
sensorValue = analogRead(0); // read
analog input pin 0
Serial.println(sensorValue, DEC); // prints
the value read
delay(100); // wait 100ms for
next reading
}

Electronics & Instrumentation EO-102 92


Electrat (condensor) microphone
DESCRIPTION
An electret microphone is a type of condenser microphone, which eliminates the need for
a polarizing power supply by using a permanently charged material.

APPLICATIONS

1.Telephones
2.Handheld devices
3.Recording devices
4.2-way
communications
5.Audio/visual
equipment
6.Flow detectors
7.GPS systems

Electronics & Instrumentation EO-102 93


Interfacing with Arduino

void setup()
{ Serial.begin(9600); }
void loop()
{ Serial.println(analogRead(0));
delay(300); }

Electronics & Instrumentation EO-102 94


PIR sensor
PIR sensors allow you to sense motion, almost always
used to detect whether a human has moved in or out of
the sensors range.
PIRs are basically made of a pyroelectric sensor which
can detect levels of infrared radiation.

FEATURES
1. Operating voltage: 4.5V to 20V DC
2. Static power consumption: 65 micro-amps
3. Output Logic level : High-3.3V, Low-0V
4. Delay Time: adjustable (5-200S +-3%)
5. Blocked Time: 2.5 Seconds Default
6. Trigger Jumper: L No Repeat, H Repeated
Trigger(Default)
7. Sensing range: <1400 , 3-7 meters(Adjustable)
8. Operating temperature: -20 -+800 C

Electronics & Instrumentation EO-102 95


Interfacing with Arduino

void setup()

{ Serial.begin(9600);}

Serial.println("Warming up...");
delay(20000); }

void loop()

{ Serial.print("IN2 = ");
Serial.println(digitalRead(2), DEC);
delay(200); }

Electronics & Instrumentation EO-102 96


Infrared transmitter and reciever
Infrared proximity sensor has an analog
output that varies from 2.8V at 15cm to
0.4V at 150cm with a supply voltage
between 4.5 and 5.5VDC.

Features
1. Distance measuring range : 20 to 150
cm
2. Analog output type
3. Package size : 29.51321.6 mm
4. Consumption current : Typ. 33 mA
5. Supply voltage : 4.5 to 5.5 V

Applications
1. Touch-less switch
(Sanitary equipment, Control of
illumination, etc. )
2. Sensor for energy saving
(ATM, Copier, Vending machine, Laptop
computer,
LCD monitor)
Electronics & Instrumentation EO-102 97
Interfacing with Arduino

const int x;

void setup()

{
Serial.begin(9600);}

void loop()
{
x = analogRead(2);
Serial.println(x);
}

Electronics & Instrumentation EO-102 98


DHT11 Humidity sensor
DHT11 digital temperature and humidity sensor is a
composite Sensor contains a calibrated digital signal
output of the temperature and humidity.

2Applications
HVAC, dehumidifier, testing and inspection
equipment, consumer goods, automotive, automatic
control, data loggers, weather stations, home
appliances, humidity regulator, medical and other
humidity
measurement and control.

3Features
Low cost, long-term stability, relative humidity and
temperature measurement, excellent quality, fast
response, strong anti-interference ability, long
distance signal transmission, digital signal output,
and
precise calibration.
Electronics & Instrumentation EO-102 99
Interfacing with Arduino

int potpin=0;
int ledpin=12;
int potval=0;
Void setup()
{
pinMode(ledpin,OUTPUT);
}
Void loop(){
Potval= analogRead(potpin);
digitalWrite(ledpin,HIGH);
Delay(potval);
digitalWrite(ledpin,LOW);
Delay(potval);
}
Electronics & Instrumentation EO-102 100
Accelerometer sensor
The ADXL335 is a small, thin, low power, complete 3-axis accel-erometer with
signal conditioned voltage outputs. The product measures acceleration with a
minimum full-scale range of 3 g

FEATURES
Small and thin
4 mm 4 mm 1.45 mm LFCSP package
Wide supply voltage range: 2.4 V to 5.25 V
Low power: 350 A at VS = 2.4 V (typ)
Good sensitivity accuracy
X-axis and Y-axis aligned to within 0.1 (typ)
Single-supply operation
10,000 g shock survival
APPLICATIONS
Cost-sensitive motion- and tilt-sensing applications
Smart hand-held devices
Sports and health-related devices
PC security and PC peripherals
Electronics & Instrumentation EO-102 101
Interfacing with Arduino
const int groundpin = 18; // analog input pin 4
const int powerpin = 19; // analog input pin 5
const int xpin = A3; // x-axis of the accl.
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis
void setup()
{
Serial.begin(9600);
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
Serial.print(analogRead(xpin));
Serial.print("\t");
Serial.print(analogRead(ypin));
Serial.print("\t");
Serial.print(analogRead(zpin));
Serial.println();
Electronics & Instrumentation EO-102 102
delay(100);

Вам также может понравиться