SlideShare a Scribd company logo
1 of 127
Analog Sensor Interfacing
• Digital Computer use binary values, but in the
physical world everything is analog(Continuous).
• Temperature, Pressure(wind or liquid),humidity
and velocity are a few examples of physical
quantities.
• A physical quantity is converted to electrical
(voltage, current) signals using a device called a
transducer.
• Therefore, we need an analog to digital converter
to translate the analog signals to digital numbers
so microcontroller can read and process them.
Characteristics of the ADC
Resolution:
• The ADC has n-bit resolution, where n can be
8,10,12,16, or 24 bits.
• Higher Resolution ADCs provide a smaller step
size
– where step size is the smallest change that can be
sense by an ADC.
• Examples
Conversion Time:
• Conversion time is defined as the time it
takes the ADC to convert the analog
input to a digital number. It will depend
upon clock source, method for data
conversion and technology.
Vref (V Reference):
• The voltage connected to this pin, along with
the resolution of the ADC chip, dictate the
step size.
• Step Size=Vref/Resolution
1
• Find out the step size if vref = 5V and
resolution is 8 bit .
Example
• Digital Data as Output:
D=Vin/step size(mV)
2
• For an 8-bit ADC, we have Vref=2.56V. Calculate
the D0-D7 output if the analog input is 1.7V
3
• For an 8-bit ADC, we have Vref=2.56V. Calculate
the D0-D7 output if the analog input is 2.1V
Solution of 2 and 3 -
• For an 8-bit ADC, we have Vref=2.56V. Calculate the
D0-D7 output if the analog input is (a) 1.7V and (b)
2.1V
1. Step Size= 2.56/256= 10mv
2. Dout=1.7v/10mv=170 in decimal which gives us
10101010 in binary for D7-D0.
3. Dout=2.1V/10mV=210 in decimal, which give us
11010010 in binary for D7-D0.
Parallel Vs Serial ADC
SOC and EOC Signals:
• When SOC is activated the ADC starts
converting the analog input value of digital.
• When the data conversion is complete, the
EOC signals notifies the CPU that the
converted data is ready to be picked up.
4
MAX1112 is a _________ type of ADC
converter?
a) parallel
b) 12 bit
c) serial
d) all of the mentioned
ATmega32 ADC Features
1. It is a 10-bit ADC
2. It has 8 analog input channels.
3. The converted data is held by two SFRs :
ADCL(A/D result lower byte) and ADCH(A/D
Result Higher byte)
4. ADCH and ADCL gives us 16 bits and the ADC
data out is only 10 bits wide,6 bits of the 16 are
unused.
5. We have three options for Vref. Vref can be
connected to AVCC, internal 2.56V reference or
external AREF pin.
ADC Recommended Connection
5
• Which of the following factors can affect the
step size calculation?
a) number of bits
b) input current
c) output current
d) all of the mentioned
In the AVR microcontroller five major registers
are associated with the ADC.
– ADCH(A/D result higher byte)
– ADCL(A/D result lower byte)
– ADCSRA(ADC Control and Status Register)
– ADMUX(ADC multiplexer selection register)
– SPIOR(Special Function I/O Register)
ADMUX
Vref Source Selection
Channel Selection
ADLAR bit Operation
ADCSRA Register
• For the AVR the ADC requires an input clock
frequency less than 200kHz for the maximum
accuracy.
Programming Steps for A/D Converter
Using Polling
1. Make the pin for the selected ADC channel an input
pin.(DDRA register)
2. Turn on the ADC module of the AVR because it is
disabled upon power-on rest to save power. (ADEN--
ADCSRA)
3. Select the Conversion speed. We use bits ADPS2:0 to
select the conversion speed.(ADCSRA)
4. Select voltage reference and ADC input channels.
1. Use REFS0 and REFS1 bits in the ADMUX to select voltage
reference(ADMUX)
2. Use MUX 4:0 bits in ADMUX to select the ADC input
Channel. (ADMUX)
5. Activate the start conversion bit by writing a one to
the ADSC bit of ADCSRA.
6. Wait for the conversion to be completed by polling
the ADIF bit in the ADCSRA register.
7. After the ADIF bit has gone HIGH, read the ADCL
and ADCH registers to get digital data output.
8. If you want to read again, go back to step 5.
9. If you want to select another Vref source or input
channel, go back to step 4.
• Assume a analog sensor potentiometer is
connected with ADC0 channel. Write a
program to send converted data to
PORTD.[Select CLk/128,2.56V Vref and right –
justified data]
• ADCSRA =0x87
• ADMUX =0xC0
#include<avr/io.h>
int main(void)
{
DDRB=0xFF;
DDRD=0xFF;
DDRA=0x00;
ADCSRA=0x87;
ADMUX=0xC0;
while(1)
{
ADCSRA |=(1<<ADSC);
while((ADCSRA&(1<<ADIF)==0);
PORTD=ADCL;
PORTB=ADCH;
}
return 0;
}
Temperature Sensor Interfacing
• Thermistor converted temperature to
electrical signals.
• A thermistor responds to temperature change
by changing resistance but its response is not
linear.
• The Sensors LM34 series are precision
integrated-circuit temperature whose output
voltage is linearly proportional to the
Fahrenheit temperature.
• The LM34 requires no external calibration
because it is internally calibrated.
• It outputs 10mV for each degree of Fahrenheit
temperature.
• The Sensors LM35 series are precision
integrated-circuit temperature whose output
voltage is linearly proportional to the Celsius
temperature.
• The LM35 requires no external calibration
because it is internally calibrated.
• It outputs 10mV for each degree of Celsius
temperature.
• The A/D has 10-bit resolution with a
maximum of 1024 steps
• The LM34 or LM35 produces 10mV for every
degree of temperature change.
• Now Step Size of 10mV will give
• Vout =10240mV(10.24V)
• Maximum Sense 300 degree Fahrenheit
• Vout= 3000mv (3V)
• Now if we use the internal 2.56 V reference
Voltage the step size would be
2.56V/1024=2.5mV.
• Four times of real temperature because the
sensor produces 10mV.
• We can Scale it by dividing it by 4 to get the
real number for temperature.
Reading and Displaying Temperature
#include<avr/io.h>
int main(void)
{
DDRB=0xFF;
DDRD=0xFF;
DDRA=0x00;
ADCSRA=0x87;
ADMUX=0xE0;
while (1)
{
ADCSRA |=(1<<ADSC);
while (ADCSRA &(1<<ADIF)==0);
PORTB=ADCH;
}
return 0;
}
Seven Segment Interfacing
Seven Segment Interfacing
Common Anode Seven Segment Value
#include<avr/io.h>
#include<util/delay.h>
Char Seg_values[] =
{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
int main(void)
{
DDRB=0xFF;
while(1)
{
for( char z=0;z<=9;z++)
{
PORTB=Seg_values[z];
delay_us(10000);
}
}
}
LCD Interfacing
• LCD replacing LED’s (Seven Segment LEDs or
other multi-segment LEDs).This is due to
following reasons:
• The declining prices of LCDs
• The ability to display numbers, characters and
graphics.
• Ease of Programming for characters and
graphics.
LCD Pin Desciptions
Sending Commands and data to LCDs
• Initializing the LCD-
• Initialize the LCD for 5 * 7 matrix and 8-bit
operation, the following sequence of
commands should be sent to the LCD.
– 0x38
– 0x0E
– 0x01
• Sending Commands to the LCD-
• To send any of the commands from table to the
LCD
– Make RS pin=0
– And R/W=0
– Send a high to low pulse to the E pin to enable the
internal latch of the LCD.
– Each Command wait about 100microseconds to let
the LCD module run the command.
• Sending Data to the LCD
• To send any of the data to the LCD
– Make RS pin=1
– And R/W=0
– Send a high to low pulse to the E pin to enable the
internal latch of the LCD.
– Each data wait about 100microseconds to let the
LCD module write the data on the screen.
LCD Connection for 8-bit Data
LCD Program for 8-bit Data
#include <avr/io.h>
#include<util/delay.h>
#define LCD PORTA
#define EN 2
#define RW 1
#define RS 0
void lcdcmd(unsigned char cm)
{
PORTB &=~(1<<RS);
PORTB &=~(1<<RW);
PORTB|=(1<<EN);
LCD=cm;
_delay_ms(1);
PORTB &=~(1<<EN);}
void lcddata(unsigned char dat)
{PORTB |=(1<<RS);
PORTB&=~(1<<RW);
PORTB|=(1<<EN);
LCD=dat;
_delay_ms(1);
PORTB &=~(1<<EN);
}
void init(){
DDRA=0XFF;
DDRB=0XFF;
lcdcmd(0X38); //8BIT 2 LINES
lcdcmd(0X0E); //DISPLAY ON CURSORON
lcdcmd(0X01); //CLEAR
lcdcmd(0X80); //ROW 0 COLUMN0
_delay_ms(1);}
int main(void)
{
unsigned char a[]="ABCD";
while (1){
init();
unsigned char i;
for(i=0;i<4;i++)
{
lcddata(a[i]);
_delay_ms(1000);}}}
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
int main(void)
{
lcd_init(LCD_DISP_ON_CURSOR); /* initialize lcd, display on, cursor on */
/* for more options for
/* lcd_init(), view lcd.h file
while(1) /* run continuously */
{
lcd_clrscr(); /* clear screen of lcd */
lcd_home(); /* bring cursor to 0,0 */
lcd_puts("HELLO"); /* type something random */
lcd_gotoxy(0,1); /* go to 2nd row 1st col */
lcd_puts(“EVERYONE"); /* type something random */
_delay_ms(50); /* wait 50ms */
}
}
Electromechanical Relays
• A relay is an electrically controllable switch
widely used in Industrial controls, automobiles
and appliances.
• It allows the isolation of two separate sections
of a system with two different voltage sources.
• For Example: A 5V system can be isolated from
a 120V system by placing a relay between
them.
• The EMRs have three components:
– The Coil
– Spring
– Contacts
• When Current Flows----Magnetic Field is
created around coil ----which causes the
contact to be attracted to the coil
• When the coil is not energized, a spring pulls
the armature to its normal state of open or
closed.
Choosing A Relay
• The Contact can be normally open(NO) or
normally closed(NC).
• There can be one or more contacts.
– SPST (single pole, single throw)
– SPDT(single pole,double throw)
– DPDT(double pole,double throw)
• The Voltage and current needed to energize the coil.
The voltage can vary from a few volts to 50 volts, while
the current can be from a few mA to 20mA.
• The relay has minimum voltage, below which the coil
will not be energized called as PULL-IN voltage.
– In datasheet only Voltage and Coil resistance is provided. By
Ohms law we can find PULL-IN current.
• The Maximum DC/AC voltage and current that can be
handled by the contacts.
ULN2803 is a High voltage, high current
Transistor Array IC used especially with
Microcontrollers where we need to drive high
power loads. Thic IC consists of a eight NPN
Darlington connected transistors with common
Clamp diodes for switching the loads connected
to the output.
DC MOTOR
• A Direct Current motor is a widely used devices
that translates electrical pulses into mechanical
movement.
• In DC motor we have only + and – leads.
• Connecting them a DC voltage source moves the
motor in one direction.
• By reversing he polarity the DC motor will move
in the opposite direction.
• While a steeper motor moves in steps of 1 to 15
degrees, the DC motor moves continuously.
• The maximum speed of a DC motor is indicated in
rpm and is given in the data sheet.
• The DC motor has two rpms: no load and loaded.
• The manufacturer’s datasheet gives the no load
rpm.
• The rpm is reduced when moving a load and it
decreases as the load is increased.
• The DC motors also have voltage and current
ratings. As voltage increase the rpm goes up.
Unidirectional Control
A switch is connected to pin PA7. Write a C
program to monitor the status of SW and
perform the following:
A) If SW=0, the DC motor moves clockwise.
B) If SW=1, the DC motor moves
counterclockwise.
How we can change the direction of the DC motor
with AVR ?
· by interchanging the + and - terminal
· by changing the program
· both 1 and 2
· none of the above
Which driver IC is required to interface DC motor
with AVR ?
· NE555
· L293D
· L295
· L290D
An optoisolator (also known as an optical
coupler, photocoupler, optocoupler) is a
semiconductor device that transfers an
electrical signal between isolated circuits
using light.
An optoisolator couples high voltages
from one side of the circuit to the other
without any direct electrical contact.
Opto-isolator
Servo Motor
What are Servo Motors?
• A servo motor is a linear or rotary actuator that
provides fast precision position control for closed-loop
position control applications.
• Unlike large industrial motors, a servo motor is not
used for continuous energy conversion.
• Servo motors have a high speed response due to low
inertia and are designed with small diameter and long
rotor length.
Working Principle of DC Servo
Motor
• A DC servo motor is an assembly of four major components,
 DC motor
 position sensing device
 gear assembly
 control circuit.
• A DC reference voltage is set to the value corresponding to the
desired output.
• This voltage can be applied by using another potentiometer,
control pulse width to voltage converter, or through timers
depending on the control circuitry.
which is not the component of Servo motor ?
· DC motor
· Gear assembly
· Control Circuit
· none of these
Circuit Diagram
Program
#define F_CPU 8000000UL // 8 MHz clock
speed
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRC = 0x01; //Makes RC0 output pin
PORTC = 0x00;
while(1)
{
//Rotate Motor to 0 degree
PORTC = 0x01;
_delay_us(1000);
PORTC = 0x00;
_delay_ms(2000); //Rotate Motor to 90
degree
PORTC = 0x01;
_delay_us(1500);
PORTC = 0x00;
_delay_ms(2000);
//Rotate Motor to 180 degree
PORTC = 0x01;
_delay_us(2000);
PORTC = 0x00;
_delay_ms(2000);
}
}
Program
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRC = 0x01; //Makes RC0 output
pin
PORTC = 0x00;
while(1)
{
//Rotate Motor to 0 degree
PORTC = 0x01;
_delay_us(1000);
Program
PORTC = 0x00;
_delay_ms(2000); //Rotate Motor to 90 degree
PORTC = 0x01;
_delay_us(1500);
PORTC = 0x00;
_delay_ms(2000);
//Rotate Motor to 180 degree
PORTC = 0x01;
_delay_us(2000);
PORTC = 0x00;
_delay_ms(2000);
}
}
Stepper Motor Interfacing
• A stepper motor is a widely used device that
translates electrical pulses into mechanical
movement.
• In applications such as disk drives, dot matrix
printers and robotics, the stepper motor is
used for position control.
• Stepper motor have a permanent magnet
rotor(also called the shaft) surrounded by a
stator.
Normal Four-Step Sequence
Step Angle
• The step angle is the minimum degree of rotation
associated with a single step.
• This depends on the internal construction of the motor, in
particular the number of teeth on the stator and rotor.
AVR Connection to Stepper Motor
8-step mode
• Write a program to rotate stepper motor clock
wise direction using 4 step sequence.
#include <avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0xFF;
while(1)
{
PORTB=0x66;
_delay_ms(100);
PORTB=0xCC;
_delay_ms(100);
PORTB=0x99;
_delay_ms(100);
PORTB=0x33;
_delay_ms(100);
}
}
• A switch is connected to pin PA7. Write a C
program to monitor the status of SW and
perform the following:
– SW=0, Rotate stepper motor to clockwise
direction
– SW=1, Rotate stepper motor to anti clockwise
direction.
#define F_CPU 16000000UL
#include <avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0xFF;
DDRA=0x00;
while(1)
{
if((PINA&0x80)==0)
{
PORTB=0x66;
_delay_ms(100);
PORTB=0xCC;
_delay_ms(100);
PORTB=0x99;
_delay_ms(100);
PORTB=0x33;
_delay_ms(100);
}
else
{
PORTB=0x33;
_delay_ms(100);
PORTB=0x99;
_delay_ms(100);
PORTB=0xCC;
_delay_ms(100);
PORTB=0x66;
_delay_ms(100);
}
}
}
UNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptx

More Related Content

Similar to UNIT 4 & 5 - I nterfacing_Lecture7.pptx

Fundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptFundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptBEVARAVASUDEVAAP1813
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog worldIslam Samir
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded systemram avtar
 
ANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORAnil Yadav
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers finalSARITHA REDDY
 
project - Copy
project - Copyproject - Copy
project - Copypiedaholic
 
03 analog control_sp17
03 analog control_sp1703 analog control_sp17
03 analog control_sp17John Todora
 
digital anlage c converter for digital .ppt
digital anlage c converter for digital .pptdigital anlage c converter for digital .ppt
digital anlage c converter for digital .pptAbdullahOmar64
 
adc dac converter
adc dac converteradc dac converter
adc dac converterGaurav Rai
 
ELECTRICAL ENGINEERING PROJECT
ELECTRICAL ENGINEERING PROJECTELECTRICAL ENGINEERING PROJECT
ELECTRICAL ENGINEERING PROJECTvasav2204
 
electrical engineering project
electrical engineering projectelectrical engineering project
electrical engineering projectvasav2204
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversionEngr Ahmad Khan
 
Chap 3. signal processing elemnt part three
Chap 3. signal processing elemnt part threeChap 3. signal processing elemnt part three
Chap 3. signal processing elemnt part threeYemaneBayray
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.pptDreamers6
 
ADC Interfacing with pic Microcontrollert
ADC Interfacing with pic MicrocontrollertADC Interfacing with pic Microcontrollert
ADC Interfacing with pic Microcontrollertleapshare007
 
Cockpit White Box
Cockpit White BoxCockpit White Box
Cockpit White Boxncct
 

Similar to UNIT 4 & 5 - I nterfacing_Lecture7.pptx (20)

Fundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.pptFundamental of MSD Module-III Part-a.ppt
Fundamental of MSD Module-III Part-a.ppt
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded system
 
ANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTOR
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers final
 
project - Copy
project - Copyproject - Copy
project - Copy
 
Adc and dac
Adc and dacAdc and dac
Adc and dac
 
03 analog control_sp17
03 analog control_sp1703 analog control_sp17
03 analog control_sp17
 
digital anlage c converter for digital .ppt
digital anlage c converter for digital .pptdigital anlage c converter for digital .ppt
digital anlage c converter for digital .ppt
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
adc dac converter
adc dac converteradc dac converter
adc dac converter
 
ELECTRICAL ENGINEERING PROJECT
ELECTRICAL ENGINEERING PROJECTELECTRICAL ENGINEERING PROJECT
ELECTRICAL ENGINEERING PROJECT
 
electrical engineering project
electrical engineering projectelectrical engineering project
electrical engineering project
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversion
 
ADC and DAC Best Ever Pers
ADC and DAC Best Ever PersADC and DAC Best Ever Pers
ADC and DAC Best Ever Pers
 
Chap 3. signal processing elemnt part three
Chap 3. signal processing elemnt part threeChap 3. signal processing elemnt part three
Chap 3. signal processing elemnt part three
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.ppt
 
ADC Interfacing with pic Microcontrollert
ADC Interfacing with pic MicrocontrollertADC Interfacing with pic Microcontrollert
ADC Interfacing with pic Microcontrollert
 
Cockpit White Box
Cockpit White BoxCockpit White Box
Cockpit White Box
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 

UNIT 4 & 5 - I nterfacing_Lecture7.pptx

  • 2. • Digital Computer use binary values, but in the physical world everything is analog(Continuous). • Temperature, Pressure(wind or liquid),humidity and velocity are a few examples of physical quantities. • A physical quantity is converted to electrical (voltage, current) signals using a device called a transducer. • Therefore, we need an analog to digital converter to translate the analog signals to digital numbers so microcontroller can read and process them.
  • 3.
  • 4. Characteristics of the ADC Resolution: • The ADC has n-bit resolution, where n can be 8,10,12,16, or 24 bits. • Higher Resolution ADCs provide a smaller step size – where step size is the smallest change that can be sense by an ADC.
  • 6. Conversion Time: • Conversion time is defined as the time it takes the ADC to convert the analog input to a digital number. It will depend upon clock source, method for data conversion and technology.
  • 7. Vref (V Reference): • The voltage connected to this pin, along with the resolution of the ADC chip, dictate the step size. • Step Size=Vref/Resolution
  • 8. 1 • Find out the step size if vref = 5V and resolution is 8 bit .
  • 10.
  • 11. • Digital Data as Output: D=Vin/step size(mV)
  • 12. 2 • For an 8-bit ADC, we have Vref=2.56V. Calculate the D0-D7 output if the analog input is 1.7V
  • 13. 3 • For an 8-bit ADC, we have Vref=2.56V. Calculate the D0-D7 output if the analog input is 2.1V
  • 14. Solution of 2 and 3 - • For an 8-bit ADC, we have Vref=2.56V. Calculate the D0-D7 output if the analog input is (a) 1.7V and (b) 2.1V 1. Step Size= 2.56/256= 10mv 2. Dout=1.7v/10mv=170 in decimal which gives us 10101010 in binary for D7-D0. 3. Dout=2.1V/10mV=210 in decimal, which give us 11010010 in binary for D7-D0.
  • 16. SOC and EOC Signals: • When SOC is activated the ADC starts converting the analog input value of digital. • When the data conversion is complete, the EOC signals notifies the CPU that the converted data is ready to be picked up.
  • 17.
  • 18.
  • 19. 4 MAX1112 is a _________ type of ADC converter? a) parallel b) 12 bit c) serial d) all of the mentioned
  • 20. ATmega32 ADC Features 1. It is a 10-bit ADC 2. It has 8 analog input channels. 3. The converted data is held by two SFRs : ADCL(A/D result lower byte) and ADCH(A/D Result Higher byte) 4. ADCH and ADCL gives us 16 bits and the ADC data out is only 10 bits wide,6 bits of the 16 are unused. 5. We have three options for Vref. Vref can be connected to AVCC, internal 2.56V reference or external AREF pin.
  • 22. 5 • Which of the following factors can affect the step size calculation? a) number of bits b) input current c) output current d) all of the mentioned
  • 23. In the AVR microcontroller five major registers are associated with the ADC. – ADCH(A/D result higher byte) – ADCL(A/D result lower byte) – ADCSRA(ADC Control and Status Register) – ADMUX(ADC multiplexer selection register) – SPIOR(Special Function I/O Register)
  • 24. ADMUX
  • 29. • For the AVR the ADC requires an input clock frequency less than 200kHz for the maximum accuracy.
  • 30.
  • 31.
  • 32. Programming Steps for A/D Converter Using Polling 1. Make the pin for the selected ADC channel an input pin.(DDRA register) 2. Turn on the ADC module of the AVR because it is disabled upon power-on rest to save power. (ADEN-- ADCSRA) 3. Select the Conversion speed. We use bits ADPS2:0 to select the conversion speed.(ADCSRA) 4. Select voltage reference and ADC input channels. 1. Use REFS0 and REFS1 bits in the ADMUX to select voltage reference(ADMUX) 2. Use MUX 4:0 bits in ADMUX to select the ADC input Channel. (ADMUX)
  • 33. 5. Activate the start conversion bit by writing a one to the ADSC bit of ADCSRA. 6. Wait for the conversion to be completed by polling the ADIF bit in the ADCSRA register. 7. After the ADIF bit has gone HIGH, read the ADCL and ADCH registers to get digital data output. 8. If you want to read again, go back to step 5. 9. If you want to select another Vref source or input channel, go back to step 4.
  • 34.
  • 35.
  • 36. • Assume a analog sensor potentiometer is connected with ADC0 channel. Write a program to send converted data to PORTD.[Select CLk/128,2.56V Vref and right – justified data]
  • 37. • ADCSRA =0x87 • ADMUX =0xC0
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46. Temperature Sensor Interfacing • Thermistor converted temperature to electrical signals. • A thermistor responds to temperature change by changing resistance but its response is not linear.
  • 47. • The Sensors LM34 series are precision integrated-circuit temperature whose output voltage is linearly proportional to the Fahrenheit temperature. • The LM34 requires no external calibration because it is internally calibrated. • It outputs 10mV for each degree of Fahrenheit temperature.
  • 48.
  • 49. • The Sensors LM35 series are precision integrated-circuit temperature whose output voltage is linearly proportional to the Celsius temperature. • The LM35 requires no external calibration because it is internally calibrated. • It outputs 10mV for each degree of Celsius temperature.
  • 50.
  • 51. • The A/D has 10-bit resolution with a maximum of 1024 steps • The LM34 or LM35 produces 10mV for every degree of temperature change. • Now Step Size of 10mV will give • Vout =10240mV(10.24V) • Maximum Sense 300 degree Fahrenheit • Vout= 3000mv (3V)
  • 52. • Now if we use the internal 2.56 V reference Voltage the step size would be 2.56V/1024=2.5mV. • Four times of real temperature because the sensor produces 10mV. • We can Scale it by dividing it by 4 to get the real number for temperature.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57. Reading and Displaying Temperature
  • 58.
  • 59.
  • 63.
  • 64. Common Anode Seven Segment Value
  • 65.
  • 67. int main(void) { DDRB=0xFF; while(1) { for( char z=0;z<=9;z++) { PORTB=Seg_values[z]; delay_us(10000); } } }
  • 69. • LCD replacing LED’s (Seven Segment LEDs or other multi-segment LEDs).This is due to following reasons: • The declining prices of LCDs • The ability to display numbers, characters and graphics. • Ease of Programming for characters and graphics.
  • 71.
  • 72.
  • 73.
  • 74. Sending Commands and data to LCDs • Initializing the LCD- • Initialize the LCD for 5 * 7 matrix and 8-bit operation, the following sequence of commands should be sent to the LCD. – 0x38 – 0x0E – 0x01
  • 75. • Sending Commands to the LCD- • To send any of the commands from table to the LCD – Make RS pin=0 – And R/W=0 – Send a high to low pulse to the E pin to enable the internal latch of the LCD. – Each Command wait about 100microseconds to let the LCD module run the command.
  • 76. • Sending Data to the LCD • To send any of the data to the LCD – Make RS pin=1 – And R/W=0 – Send a high to low pulse to the E pin to enable the internal latch of the LCD. – Each data wait about 100microseconds to let the LCD module write the data on the screen.
  • 77. LCD Connection for 8-bit Data
  • 78. LCD Program for 8-bit Data #include <avr/io.h> #include<util/delay.h> #define LCD PORTA #define EN 2 #define RW 1 #define RS 0 void lcdcmd(unsigned char cm) { PORTB &=~(1<<RS); PORTB &=~(1<<RW); PORTB|=(1<<EN); LCD=cm; _delay_ms(1); PORTB &=~(1<<EN);}
  • 79. void lcddata(unsigned char dat) {PORTB |=(1<<RS); PORTB&=~(1<<RW); PORTB|=(1<<EN); LCD=dat; _delay_ms(1); PORTB &=~(1<<EN); } void init(){ DDRA=0XFF; DDRB=0XFF; lcdcmd(0X38); //8BIT 2 LINES lcdcmd(0X0E); //DISPLAY ON CURSORON lcdcmd(0X01); //CLEAR lcdcmd(0X80); //ROW 0 COLUMN0 _delay_ms(1);}
  • 80. int main(void) { unsigned char a[]="ABCD"; while (1){ init(); unsigned char i; for(i=0;i<4;i++) { lcddata(a[i]); _delay_ms(1000);}}}
  • 81. #include <avr/io.h> #include <util/delay.h> #include "lcd.h" int main(void) { lcd_init(LCD_DISP_ON_CURSOR); /* initialize lcd, display on, cursor on */ /* for more options for /* lcd_init(), view lcd.h file while(1) /* run continuously */ { lcd_clrscr(); /* clear screen of lcd */ lcd_home(); /* bring cursor to 0,0 */ lcd_puts("HELLO"); /* type something random */ lcd_gotoxy(0,1); /* go to 2nd row 1st col */ lcd_puts(“EVERYONE"); /* type something random */ _delay_ms(50); /* wait 50ms */ } }
  • 82. Electromechanical Relays • A relay is an electrically controllable switch widely used in Industrial controls, automobiles and appliances. • It allows the isolation of two separate sections of a system with two different voltage sources. • For Example: A 5V system can be isolated from a 120V system by placing a relay between them.
  • 83.
  • 84. • The EMRs have three components: – The Coil – Spring – Contacts
  • 85. • When Current Flows----Magnetic Field is created around coil ----which causes the contact to be attracted to the coil • When the coil is not energized, a spring pulls the armature to its normal state of open or closed.
  • 86. Choosing A Relay • The Contact can be normally open(NO) or normally closed(NC). • There can be one or more contacts. – SPST (single pole, single throw) – SPDT(single pole,double throw) – DPDT(double pole,double throw)
  • 87.
  • 88. • The Voltage and current needed to energize the coil. The voltage can vary from a few volts to 50 volts, while the current can be from a few mA to 20mA. • The relay has minimum voltage, below which the coil will not be energized called as PULL-IN voltage. – In datasheet only Voltage and Coil resistance is provided. By Ohms law we can find PULL-IN current. • The Maximum DC/AC voltage and current that can be handled by the contacts.
  • 89.
  • 90.
  • 91.
  • 92. ULN2803 is a High voltage, high current Transistor Array IC used especially with Microcontrollers where we need to drive high power loads. Thic IC consists of a eight NPN Darlington connected transistors with common Clamp diodes for switching the loads connected to the output.
  • 93. DC MOTOR • A Direct Current motor is a widely used devices that translates electrical pulses into mechanical movement. • In DC motor we have only + and – leads. • Connecting them a DC voltage source moves the motor in one direction. • By reversing he polarity the DC motor will move in the opposite direction. • While a steeper motor moves in steps of 1 to 15 degrees, the DC motor moves continuously.
  • 94. • The maximum speed of a DC motor is indicated in rpm and is given in the data sheet. • The DC motor has two rpms: no load and loaded. • The manufacturer’s datasheet gives the no load rpm. • The rpm is reduced when moving a load and it decreases as the load is increased. • The DC motors also have voltage and current ratings. As voltage increase the rpm goes up.
  • 96.
  • 97.
  • 98. A switch is connected to pin PA7. Write a C program to monitor the status of SW and perform the following: A) If SW=0, the DC motor moves clockwise. B) If SW=1, the DC motor moves counterclockwise.
  • 99. How we can change the direction of the DC motor with AVR ? · by interchanging the + and - terminal · by changing the program · both 1 and 2 · none of the above
  • 100. Which driver IC is required to interface DC motor with AVR ? · NE555 · L293D · L295 · L290D
  • 101. An optoisolator (also known as an optical coupler, photocoupler, optocoupler) is a semiconductor device that transfers an electrical signal between isolated circuits using light. An optoisolator couples high voltages from one side of the circuit to the other without any direct electrical contact. Opto-isolator
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 108. What are Servo Motors? • A servo motor is a linear or rotary actuator that provides fast precision position control for closed-loop position control applications. • Unlike large industrial motors, a servo motor is not used for continuous energy conversion. • Servo motors have a high speed response due to low inertia and are designed with small diameter and long rotor length.
  • 109. Working Principle of DC Servo Motor • A DC servo motor is an assembly of four major components,  DC motor  position sensing device  gear assembly  control circuit. • A DC reference voltage is set to the value corresponding to the desired output. • This voltage can be applied by using another potentiometer, control pulse width to voltage converter, or through timers depending on the control circuitry.
  • 110. which is not the component of Servo motor ? · DC motor · Gear assembly · Control Circuit · none of these
  • 111.
  • 113. Program #define F_CPU 8000000UL // 8 MHz clock speed #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0x01; //Makes RC0 output pin PORTC = 0x00; while(1) { //Rotate Motor to 0 degree PORTC = 0x01; _delay_us(1000); PORTC = 0x00; _delay_ms(2000); //Rotate Motor to 90 degree PORTC = 0x01; _delay_us(1500); PORTC = 0x00; _delay_ms(2000); //Rotate Motor to 180 degree PORTC = 0x01; _delay_us(2000); PORTC = 0x00; _delay_ms(2000); } }
  • 114. Program #define F_CPU 16000000UL #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0x01; //Makes RC0 output pin PORTC = 0x00; while(1) { //Rotate Motor to 0 degree PORTC = 0x01; _delay_us(1000);
  • 115. Program PORTC = 0x00; _delay_ms(2000); //Rotate Motor to 90 degree PORTC = 0x01; _delay_us(1500); PORTC = 0x00; _delay_ms(2000); //Rotate Motor to 180 degree PORTC = 0x01; _delay_us(2000); PORTC = 0x00; _delay_ms(2000); } }
  • 116. Stepper Motor Interfacing • A stepper motor is a widely used device that translates electrical pulses into mechanical movement. • In applications such as disk drives, dot matrix printers and robotics, the stepper motor is used for position control.
  • 117. • Stepper motor have a permanent magnet rotor(also called the shaft) surrounded by a stator.
  • 119. Step Angle • The step angle is the minimum degree of rotation associated with a single step. • This depends on the internal construction of the motor, in particular the number of teeth on the stator and rotor.
  • 120. AVR Connection to Stepper Motor
  • 122. • Write a program to rotate stepper motor clock wise direction using 4 step sequence.
  • 124. • A switch is connected to pin PA7. Write a C program to monitor the status of SW and perform the following: – SW=0, Rotate stepper motor to clockwise direction – SW=1, Rotate stepper motor to anti clockwise direction.
  • 125. #define F_CPU 16000000UL #include <avr/io.h> #include<util/delay.h> void main() { DDRB=0xFF; DDRA=0x00; while(1) { if((PINA&0x80)==0) { PORTB=0x66; _delay_ms(100); PORTB=0xCC; _delay_ms(100); PORTB=0x99; _delay_ms(100); PORTB=0x33; _delay_ms(100); } else { PORTB=0x33; _delay_ms(100); PORTB=0x99; _delay_ms(100); PORTB=0xCC; _delay_ms(100); PORTB=0x66; _delay_ms(100); } } }