0% found this document useful (0 votes)
37 views42 pages

EEE 6a

The document discusses several sensors and their interfacing with Arduinos, including: 1. An accelerometer that can measure acceleration on one, two, or three axes using analog, digital, or PWM interfaces. Common types include capacitive, piezoelectric, and piezoresistive. 2. A strain gauge whose resistance varies with applied force, allowing it to measure tension, pressure, etc. It is often used in a bridge circuit for measurement. 3. An LVDT that converts linear motion to electrical signals using a primary coil and two secondary coils, with the output being the difference between secondary voltages.

Uploaded by

Aisha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views42 pages

EEE 6a

The document discusses several sensors and their interfacing with Arduinos, including: 1. An accelerometer that can measure acceleration on one, two, or three axes using analog, digital, or PWM interfaces. Common types include capacitive, piezoelectric, and piezoresistive. 2. A strain gauge whose resistance varies with applied force, allowing it to measure tension, pressure, etc. It is often used in a bridge circuit for measurement. 3. An LVDT that converts linear motion to electrical signals using a primary coil and two secondary coils, with the output being the difference between secondary voltages.

Uploaded by

Aisha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Peripheral interface-2

Analog to Digital Converter


ADC parameters
• Step Size and Resolution:
• The entire input voltage range (0VtoVREF) is divided
into a number of sub-ranges called Step.
• Each step is assigned a single output digital code.
• No. of steps of ADC is given by Vref/2^n.
• This n is called as resolution of ADC and it represents
the size of digital output.
ADC in Arduino
• Atmega 328p based arduino board has inbuilt
ADC.
• ADC has 6 channels with 10 bit resolution.
• So, it maps input voltage between 0-5V into
integer value between 0 and 1023.
• Analog pins read analog sensor input.
• Smallest measurable voltage change is
4.8mV.(5V/1024 means Vref/no.ofstates)
Analog pins in Atmega328p
Interfacing of temperature sensor LM35

Output voltage is linearly


proportional to the
temperature.
LM 35 interfacing to arduino
Accelerometer
• Accelerometer are devices that measures accelerations, which is
the rate of the change of the velocity of the object.
• They measures meter/second ^2.
• They are useful for sensing vibrations in system or for
orientation operation.
• Accelerometer are electromechanical devices that senses either
static or dynamic forces of acceleration.
• Static forces includes gravity and dynamic forces includes
vibrations and movement.
• Accelerometer can measure acceleration on one ,two or three
axes.3-axes units are becoming more common as the cost of
development for them decreases.
Types of Accelerometer
• Capacitive Accelerometer:
• It contains capacitive plates internally. Some of these are fixed,while
others are attached to the spring that moves internally as forces at upon
sensor.
• As these plates move in relation to each other, the capacitance
between them changes.
• From these changes in capacitance acceleration can be determined.
• A capacitive accelerometer is also known as a vibration sensor.
• Piezoelectric Accelerometer
• A piezoelectric accelerometer is an accelerometer that
employs the piezoelectric effect of certain materials to measure
dynamic changes in mechanical variables (e.g., acceleration,
vibration, and mechanical shock).
• Piezoresistive Accelrometer:
• They work by measuring the electric resistance of a material
when mechanical stress is applied.
• They are preferred in high shock applications and can measure
acceleration down to 0 Hz.
• Hall Effect Accelerometer:
• Hall effect accelerometers work by measuring the voltage
variations caused by the change in magnetic field around them.
• Heat transfer accelerometers:
• They consist in a single heat source centered in a
substrate and suspended across cavity.
• They include equally spaced thermoresistors on the
four side of the heat source.
• They measure the internal changes in heat due to an
acceleration. When there is zero acceleration, the heat
gradient will be symmetrical. Otherwise, under
acceleration, the heat gradient will become
asymmetrical due to convection heat transfer
Applications of Accelerometer
• Cost sensitive, low power, motion-and tilt sensing
applications
• Mobile devices
• Gaming systems
• Disk drive protection
• Image stabilization
• Sports and health devices
Interfacing
• Accelerometer will communicate over Analog, Digital or
PWM connection interface.
• Accelerometer with an analog interface show acceleration
through varying voltage level.
• These values generally fluctuates between ground and the
supply voltage level.
• An ADC on microcontroller can be then used to read these
values.
• Accelerometers with a digital interface can either communicate
over SPI or I2C communication protocols.
• These tend to have more functionality and be less susceptible to
noise than analog accelerometers.
• Accelerometers that output data over pulse-width
modulation (PWM) output square waves with a known
period, but a duty cycle that varies with changes in
acceleration.
• Read Analog devices ADXL3xx series(ADXL320,
ADXL321,ADXL322 ADXL330)accelerometer and
communicate the acceleration to the personal computer
through the serial monitor of Arduino IDE.
• The ADXL3xx outputs the acceleration on each axis as
an analog voltage between 0 and 5 volts.To read this,
the analogRead() function is used.
• Here are the pin connections for the configuration :

Breakout Self-Test Z-Axis Y-Axis X-Axis Ground VDD


Board Pin

Arduino 0 1 2 3 4 5
Analog
Input Pin
Sketch(Program)
• The accelerometer connections are defined as
constants at the beginning of the sketch, using the two
Analog pins 4 and 5 as source of power.
• This is accomplished using them as Digital I/O pins 18
and 19.
• const int groundpin = 18;
• const int powerpin = 19;
• Setting pin 19 (A5) as HIGH and pin 18 (A4) as LOW
provides the 5V with few milliamps needed by the
accelerometer to work.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
Program
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
• void setup() {
Serial.begin(9600); // initialize the serial communication
// provide ground and power by using the analog inputs as
//normal digital pins
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop() {
// print the sensor values:
Serial.print(analogRead(xpin));
// print a tab between values:
Serial.print("\t");
Serial.print(analogRead(ypin));
// print a tab between values:
Serial.print("\t");
Serial.print(analogRead(zpin));
// delay before next reading:
delay(100);
}
LVDT
• Linear variable differential transformer.
• It converts linear motion into electrical signals.
• Output across secondary of transformer is differential, so the
name is differential transformer.
• The LVDT is highly reliable sensor because the magnetic core
can move without friction and do not touch the inside of tube.
• Applications:
-Flight control feedback system
-Automated measurements in machine tools
-Position feedback in servo motors
-Many industrial and scientific eletromechanical
applications
LVDT
LVDT operation
• LVDT transformer consists of primary winding P and
two secondary winding S1 and S2 wound on a
cylindrical former.
• Both secondary winding have equal number of turns
and are identically placed on the either side of primary
winding.
• Primary winding is connected to AC source which
produced flux in air gap so voltages are produced in the
secondary of LVDT.
• The resultant output i9s the difference between the
voltages of two winding.
Block diagram of LVDT interface
Strain Gauge
• A strain gauge is a sensor whose resistance varies with the
applied force.
• It converts force, pressure, tension, weight, etc., into a change
in electrical resistance which can then be measured.
Description
• When an external force is applied on an object, due to which
there is a deformation occur in the shape of the object.
• The deformation in the shape is either compressive or tensile is
called as strain, and it is measured by strain gauge.
• Because of the deformation in the shape of the object there is a
change in the resistance end to end.
• The strain gauge is sensitive to the small changes occurs in the
geometry of the object.
• By measuring the resistance of the object, the amount of
induced stress can be measured.
• Strain gauge has a long thin metallic strips arranged in a zig-zag
pattern on a non conducting material called as carrier.
Strain gauge bridge circuit
• R1 and R3 are the ratio arms equals to each other and R2 is the
rheostat arm has value equal to strain gauge resistor.
• When gauge is unstrained, the bridge is balanced and voltmeter
shows zero voltage.
• As there is a change in a resistance of gauge, bridge is unbalanced
and voltmeter shows reading.
• The output voltage of the bridge is amplified with differential
amplifier.
• The output of the amplifier can read through the analog input
of the Arduino board and output is displayed on the serial monitor
or LCD display.
Concept of PWM
• Pulse width modulation(PWM) is technique for getting analog
results with digital means.
• Pulse Width Modulation or PWM is a common technique used to
vary the width of the pulses in a pulse-train. PWM has many
applications such as controlling servos and speed controllers,
limiting the effective power of motors and LEDs.
• Pulse width modulation is basically, a square wave with a varying
high and low time. A basic PWM signal is shown in the following
figure.
There are various terms associated with PWM −
On-Time − Duration of time signal is high.
Off-Time − Duration of time signal is low.
Period − It is represented as the sum of on-time and off-time of
PWM signal.
Duty Cycle − It is represented as the percentage of time signal that
remains on during the period of the PWM signal.
Period
As shown in the figure, Ton denotes the on-time and Toff denotes the
off-time of signal. Period is the sum of both on and off times and is
calculated as shown in the following equation −
Ttotal=Ton+Toff
Duty Cycle
Duty cycle is calculated as the on-time of the period of time. duty
cycle is calculated as −
D=Ton/(Ton+Toff)=Ton/Ttotal
Arduino’s PWM
• analogWrite() function generates a square wave that can be
varied in the function.
• The two things the function needs to run are a pin/variable and a
value to set the duty cycle.
• The value that gets input for this function has to be between 0
and 255.
• A duty cycle of 100% occurs if the value is set at 255 and a
value of 0 gives a duty cycle of 0%.
• To get a specific duty cycle a value for analogWrite() needs to be
calculated. This is shown below.
• Duty cycle x 255=analogWrite value
• For example, a duty cycle of 20% would need to be set at a value
of 51.
Generating PWM signals on Arduino board
Timers/Counters

• Atmega 328p has three timers


• Timer0: 8 bit timer
• Timer1: 16 bit timer
• Timer2: 8 bit timer
• 8-bit timer means it can count 256 values
• 16-bit timer means it can count 65536 values
:TC0:8 bit:Timer/Counter0

• Timer/Counter0 (TC0) is a general purpose 8-bit


Timer/Counter module, with two independent Output Compare
Units, and PWM support.
• It allows accurate program execution timing (event
management) and wave generation.
• Features
 Two independent Output Compare Units
 Double Buffered Output Compare Registers
 Clear Timer on Compare Match (Auto Reload)
 Glitch free, phase correct Pulse Width Modulator (PWM)
 Variable PWM period
 Frequency genera
 Three independent interrupt sources (TOV0, OCF0A, and
OCF0B)
Registers
The Timer behavior can change with timer registers
TCCRx:Timer/Counter control Register: The prescaler
can be configured here.
TCNTx:TCCRx: Timer/Counter Register: The actual
timer value is stored here.
OCRx:Output compare register
ICRx:Input compare register(only for 16 bit timer)
TIMSKx: Timer/Counter Interrupt mask register: Used
to enable or disable the interrupt
TIFRx: Timer/Counter Interrupt flag register: Indicates
a pending timer interrupt
Counter Unit:

• Depending of the mode of operation used, the counter is cleared,


incremented, or decremented at each timer clock (clkT0).
• clkT0 can be generated from an external or internal clock source.
• The Timer/Counter Overflow Flag (TOV0) is set according to the mode of
operation
• TOV0 can be used for generating a CPU interrupt.
Output Compare Unit:
• The 8-bit comparator continuously compares TCNT0 with the
Output Compare Registers (OCR0A and OCR0B).
• Whenever TCNT0 equals OCR0A or OCR0B, the comparator
signals a match. A match will set the Output Compare Flag
(OCF0A or OCF0B) at the next timer clock cycle.
• If the corresponding interrupt is enabled, the Output Compare
Flag generates an Output Compare interrupt.
• The Output Compare Flag is automatically cleared when the
interrupt is executed.
TC1 - 16-bit Timer/Counter1 with PWM
Features
• True 16-bit Design (i.e., allows 16-bit PWM)
• Two independent Output Compare Units
• Double Buffered Output Compare Registers
• One Input Capture Unit
• Input Capture Noise Canceler
• Clear Timer on Compare Match (Auto Reload)
• Glitch-free, Phase Correct Pulse Width Modulator (PWM)
• Variable PWM Period
• Frequency Generator
• External Event Counter
• Independent interrupt Sources (TOV, OCFA, OCFB, and ICF)
Registers
• The Timer/Counter (TCNT1), Output Compare Registers
(OCRA/B), and Input Capture Register (ICR1) are all 16-bit
registers.
• The Timer/Counter Control Registers (TCCR1A/B/C) are 8-bit
registers.
• Interrupt requests signals are all visible in the Timer Interrupt
Flag Register (TIFR1). All interrupts are individually masked
with the Timer Interrupt Mask Register (TIMSK1).
• The double buffered Output Compare Registers (OCR1A/B) are
compared with the Timer/Counter value at all time. The result of
the compare can be used by the Waveform Generator to generate
a PWM or variable frequency output on the Output Compare pin
(OC1A/B).
TC2 - 8-bit Timer/Counter2 with PWM and Asynchronous Operation

Features
• Channel Counter
• Clear Timer on Compare Match (Auto Reload)
• Glitch-free, Phase Correct Pulse Width Modulator (PWM)
• Frequency Generator
• 10-bit Clock Prescaler
• Overflow and Compare Match Interrupt Sources (TOV2, OCF2A,
and OCF2B)
• Allows Clocking from External 32kHz.
Registers
• The Timer/Counter (TCNT2) and Output Compare Register
(OCR2A and OCR2B) are 8-bit registers.
• Interrupt request signals are all visible in the Timer Interrupt
Flag Register (TIFR2). All interrupts are individually masked
with the Timer Interrupt Mask Register (TIMSK2).
• The Timer/Counter can be clocked internally, via the prescaler,
or asynchronously clocked from the TOSC1/2 pins.The
asynchronous operation is controlled by the Asynchronous
Status Register (ASSR).
• The double buffered Output Compare Register (OCR2A and
OCR2B) are compared with the Timer/ Counter value at all
times. The result of the compare can be used by the Waveform
Generator to generate a PWM or variable frequency output on
the Output Compare pins (OC2A and OC2B).

You might also like