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 .
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)
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]
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.
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.
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.
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.
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
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
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.
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.