SlideShare a Scribd company logo
1 of 122
By / Ramadan Ahmed
Digital input/output
 Motor
 Color Sensor
 LDR
Interrupt
 External interrupt
 Peripherals interrupt
Timer
 Overflow
 PWM
ADC
 Infra red sensor
ATmega16 has 32 programmable I/O lines divided into 4
PORTS(groups):
 PORTA (PA0….PA7)
 PORTB (PB0….PB7)
 PORTC(PC0…..PC7)
 PORTD(PD0…..PD7)
Each Port Can be controlled by 3 Register :
 DDRx(Data direction Register)
 PORTx (Output Register)
 PINx (Input Register)
Note : Most Pins of Microcontroller are multi-tasking (more
than one function)(Multiplexed)
First we decide if the pin used as input or output
Then decide the direction of register using DDRx
0 for Input
1 for Output
In case we Read input from pin we use PINx register
In case we Write output on pin we use PORTx register
How to set values in Register :
 DDRA = 0x55;
 DDRA = 0b01010101;
 DDRA = 5;
How to set value on specific pin without changing the
other:
 To set the pin with 1 :
 Make OR operation on the register with The pin no
 Example: We want to set pin number 5 in PORTA with 1
 PORTA=PORTA | (1<<PA5);
 To set the pin with 0:
 Make AND operation on the register with (NOT) The pin no
 Example: We want to set pin number 3 in PORTB with 0
 PORTB=PORTB & ( ~ (1<<PB3) );
 To toggle the pin :
 Make XOR operation on the register with The pin no
 Example: We want to toggle pin number 2 in PORTC
 PORTC=PORTC ^ (1<<PC2);
How to check on specific pin without checking the others:
 To check if input on the pin is 1 :
 Make AND operation on the register with The pin no
 Example: We check if pin number 5 in PORTA is 1
 if (PORTA & (1<<PA5)){}
 To check if input on the pin is 0 :
 Make AND operation on the register with The pin no and check if
equal zero OR Not the condition
 Example: We check if pin number 5 in PORTA is 1
 if ((PORTA & (1<<PA5)) == 0 ){}
 if (!(PORTA & (1<<PA5))){}
Application:
Outputs:
Motors ( DC, Stepper, Servo).
LEDS.
LCD.
7 segment.
Inputs:
Sensors.
Switch.
Keypad.
Output Example:
LED:
We have two way to configure LED :
Negative Logic Positive Logic
R= 220-
330K
Input Example:
Switch:
 We have two way to configure switch :
Pull-up Resistor Pull-down Resistor
R= 10K
Note
Atmega16 provide internal pull up resistor for all port
pins
In case you set any PIN as input you can activate the
internal pull up resistor by setting the corresponding bit
in PORTX register.
Example
To set the pin 2 in PORTB as input pin and use the
internal pull up resistor of this pin.
DDRB = DDRB & (~(1<<PB2));
PORTB= PORTB | (1<<PB2);
Note
Switch has a bouncing problem cause it’s a mechanical
device so it need more time to achieve its state than the
µc check the state of switch.
Due to this problem, we can solve it by software.
We can make a delay of 20-30 ms due to the fact that
de-bounce maximum period takes this time.
The basic idea is to implement a delay after the first
detected edge, during which no scanning for the switch
is done. after the delay period is finished, scanning can
proceed.
Motors:
Dc motor
Stepper motor
Servo motor
Dc Motor
 It comes to speed, weight, size, cost...
DC motors are always preferred over
stepper motors.
Advantage:
Control motion of robot.
Control its speed.
Control direction of its rotation.
Disadvantage:
Hard to control its rotation angle.
How to control Dc-motors using µc ??
Any Motor can be controlled by H-bridge.
H-bridge can be made by 3 ways using:
Switches.
Relays.
Transistors.
IC (L293D).
Working theory of H-bridge?
 The name "H-Bridge" is derived from the actual shape of the
switching circuit which control the motion of the motor. It is also
known as "Full Bridge". Basically there are four switching elements
in the H-Bridge as shown in the figure below.
 Switches
Current flow when
both high side left
and low side right
are switched on
Switches cont.
Using Transistor (BJT & Two pin from µc)
Using Transistor (BJT & Two pin from µc)
Using Transistor (BJT & 4 pin from µc)
Using H-bridge
 Most common chip to control Motor is
L293D
 This chip can control 2 Dc motor
 First DC Motor three µC pins are
needed to control the DC motor (Input1,
Input2, Enable1) and the motor
connected to Output1 & Output2 pins.
 Second DC Motor three µC pins are
needed to control the DC motor (Input3,
Input4, Enable2) and the motor
connected to Output3 & Output4 pins.
 Vss pin is connected to 5v.
 Vs pin is connected to the Motor
voltage 12v .
Types of stepper motor
 Variable Reluctance
 Permanent Magnet & Hybrid
 Unipolar stepper motor (5,6 wires)
 Bipolar stepper motor (4 wires)
 Bifilar (8 wires)
Variable Reluctance
Permanent Magnet & Hybrid
Unipolar (5 or 6 wires) Bipolar (4 wires)
Bifilar (8 wires)
How Stepper motors work ??
Unipolar Stepper Motor
 The unipolar stepper motor has five or six wires and four coils
(actually two coils divided by center connections on each coil).
Unipolar Stepper Motor
 How to differentiate unipolar stepper motor ?
Unipolar Stepper Motor
 How to control unipolar stepper motor using transistors?
Bipolar Stepper Motor
 The bipolar stepper motor usually has four wires coming out of it.
They have two independent sets of coils instead.
Bipolar Stepper Motor
 How to differentiate Bipolar stepper motor ?
Stepper motors drive sequences:
Full Step Sequence
Half Step Sequence
Step Angle
 The angle traversed by the motor in one step.
 To calculate step angle, simply divide 360 by number of steps a
motor takes to complete one revolution.
Example
Full Step Mode:
 In the full step sequence, two coils are energized at the same time
and motor shaft rotates diagonal OR one coil is energized and motor
shaft rotates inline.
Full Steps Sequence
Steps A B A’ B’
1 1 1 0 0
2 0 1 1 0
3 0 0 1 1
4 1 0 0 1
Full Steps Sequence
Steps A B A’ B’
1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1
Full Step Mode:
Half Step Mode :
 In Half mode step sequence, motor step angle reduces to half the
angle in full mode.
Half Mode Sequence
Step A B A B
0 1 1 0 0
1 0 1 0 0
2 0 1 1 0
3 0 0 1 0
4 0 0 1 1
5 0 0 0 1
6 1 0 0 1
7 1 0 0 0
Half Step Mode :
Interfacing Unipolar Stepper Motor
 Interface using L293D - H-Bridge Motor Driver
 Interface using ULN2003/2004 - Darlington Arrays
Unipolar stepper using L293D:
Unipolar using ULN2003/2004
Unipolar Full step Mode (4 wires)
Unipolar Half step Mode (4 wires)
Unipolar Full step Mode (2 wires)
Unipolar Full step Mode (2 wires)
Bipolar Full step Mode (4 wires)
Servo or RC Servo Motors are DC motors equipped with
a servo mechanism for precise control of angular
position.
The RC servo motors usually have a rotation limit from
90° to 180°. Some servos also have rotation limit of 360°
or more.
But servos do not rotate continually. Their rotation is
restricted in between the fixed angles.
Application:
Servo concepts
 The Servo Motors come with three wires or leads.
 Two of these wires are to provide ground and positive supply to the
servo DC motor.
 The third wire is for the control signal.
 The red wire is the DC supply lead and must be connected to a DC
voltage supply in the range of 4.8 V to 6V.
 The black wire is to provide ground.
 The color for the third wire (to provide control signal) varies for
different manufacturers. It can be yellow (in case of Hitec), white (in
case of Futaba), brown etc.
NOTE :
 Unlike DC motors, reversing the ground and positive supply
connections does not change the direction (of rotation) of a servo.
Servo Components
How Servo Works ??
Servo Connection
LDR:
 Sensor used to detect light and create voltage difference
 Most common is photoresistor.
 We use it in line following or detect object nearby.
How it works
It uses the principal that white color reflects lights &
black color absorb light.
How it works
We connect to LDR to both sides and when :
S1 = S2 (in intensity of light) -> motor moves forward
S1= black (less intensity of light) -> Turn Left
S2=black (less intensity of light) ->Turn Right
How it works
How it works
What’s Interrupts ?
Basically events that require immediate attention by the
microcontroller.
An interrupt is a signal to the processor emitted by
hardware or software indicating an event that needs
immediate attention.
When an interrupt event occurs, the microcontroller pause
its current task and attend to the interrupt by executing
its corresponding Interrupt Service Routine (ISR) then
microcontroller returns to the task it had pause and
continue its normal operations.
Such an event may be:
 An peripheral device has finished the last task it was given
and is now ready for another. For example ADC may be
generate interrupt after finishing the conversion from
analog to digital.
 External Interrupt event on I/O Pin.
 An error from a peripheral.
You can think of it as a hardware-generated function
call.
ISR (Interrupt service routine)
 Piece of code that should be execute when an interrupt is triggered
 Should be deterministic and short as possible, as it usually set a flag
to a specific task indicating a certain event is happened, or save
small data in buffer.
AVR Interrupts
The AVR provides several different interrupt sources.
All interrupts are assigned individual enable bits to which
must be written a logic one together with the Global
Interrupt Enable bit in the Status Register in order to
enable the interrupt.
Any Interrupt request is triggered by an event that sets its
corresponding interrupt flag.
REMEMBER
Global interrupt enabled bit MUST be enabled for
interrupts to be activated in the µC.
To Set global interrupt :
 sei(); // AVR microcontroller
 SREG = SREG | (1<<7);
 SREG = SREG | (1<<I);
To clear global interrupt :
 cli();
 SREG = SREG & (~(1<<7));
 SREG = SREG & (~(1<<I));
Interrupt Flags and Enabled bits in AVR µC
 Each interrupt is associated with two (2) bits, an Interrupt
Flag Bit and an Interrupt Enabled Bit. These bits are
located in the I/O registers associated with the specific
interrupt:
The interrupt flag bit is set whenever the interrupt
event occur, whether or not the interrupt is enabled.
And The flag is cleared when the ISR is executed. So it
is also called “Automatic Flag”.
The interrupt enabled bit is used to enable or disable a
specific interrupt. Basically is tells the µC whether or
not it should respond to the interrupt if it is triggered.
Global interrupt
Interrupt flag
Interrupt enabled
Interrupt Request
 The AVR 8-bits microcontroller provide both internal and external
interrupt sources.
 The internal interrupts are associated with the microcontroller's
peripherals like :
 Timer/Counter
 Analog to Digital Converter,
 USART
 The external interrupts are triggered via external pins. for an
AVR 8-bit microcontroller. On this microcontroller there are four
(4) external interrupts:
 RESET interrupt : Triggered from pin 9.
 External Interrupt 0 (INT0) : Triggered from pin 16(PD2).
 External Interrupt 1 (INT1) : Triggered from pin 17(PD3).
 External Interrupt 2 (INT2) : Triggered from pin 3(PB2).
RESET interrupt
 It active low interrupt which means it triggered when low
voltage (0 volt) is applied on reset pin (number 9).
Other 3 hardware interrupt are triggered by event that
can be configured using I/O register.
If any of this interrupt is enabled and triggered , they are
service by an ISR (Code) which is written by programmer.
GICR (General Interrupt Control Register)
 It contains the interrupt enabled bit for all the external
interrupts of the ATmega16. Writing a 1 to the specific
interrupt bit will enable that interrupt.
Don’t forget :Enable Global
interrupt mask is must for
interrupt to be done
MCUCR (MCU Control Register)
INT0 control
INT1 control
GIFR (General Interrupt Flag Register)
 The GIFR register contains the interrupt flags for all the
ATmega16 external interrupts. Each of these bit are set
individually to logic 1 when the interrupt event for the specified
interrupt occurs. Note that the flag bit of an interrupt is set,
whether or not the interrupt is enabled, once the interrupt event
occurs.
 If the interrupt is enabled, it’s corresponding interrupt flag bit will
be cleared after executing it’s ISR code.
Timer is special register that can be 8-16 bit so capable of
holding from 0 to 255-65536
What differ it from any register that it count up / down
automatically at predefined rate and this is Timer Clock
that doesn’t need CPU intervention.
Timer Clock could be internal / external
One of basic condition when Timer overflow( it means
timer counted up to its maximum value and return back to
zero).
In this situation it causes interrupt and if global interrupt
mask is enabled and timer interrupt enable so you have to
write ISR to handle the event of the overflow
In case you want to increase the time needed for specific
operation we use timer prescalar
Prescalar divide the clock frequency and produce timer
clock
Prescalar modes are
 No prescalar (Timer Clock).
 Clock/8.
 Clock/64.
 Clock/256.
 Clock/512.
 Clock/1024.
 NO clock.
Note
CPU Clock doesn’t affected by
reduction using prescalar.
It remain the same
Example for using prescalar :
 If you using 1 MHZ for CPU Clock without using prescalar timer
takes to count up till it overflow 256 µs
 But when you use prescalar 1024 timer takes to count up till it
overflow 0.26 sec
 It’s easy to know the time timer need to overflow if you know
Resolution.
 Resolution is the smallest period taken by timer to take one count
we can calculate it through formula
Resolution = (1/Frequency)
 So if microcontroller is clocked with 1MHz source, then 8 bit timer
without prescaler will run with resolution:
Resolution=1/1MHz=1µs
So if timer take 256 counts to overflow then it takes :
T= Resolution * 256 = 1µs *256 = 256 µs
 And when we use 1024 as prescalar:
Resolution = 1024 / 1 MHZ = 1024µs
T = Resolution * 256 = 1024 * 256 = 0.256
ATmega16/32 have 3 Timer/counter we have three
Timers/Counters each one with Separate Prescaler.
 Timer 0 - 8 bit timer.
 Timer 1 -16 bit timer.
 Timer 2 - 8 bit timer.
Timer also can be operated in 3 modes :
 Normal mode (Overflow).
 Pulse Width Modulation mode(PWM).
 Clear Timer Compare mode(CTC ).
Timer0
 Timer0 is an 8 bit timer/counter which can count from 0 to
0xFF (255).
 In the timer mode this peripheral uses an internal clock
signal.
 In the counter mode an external signal on PIN0 in PORTB.
 The timer can be operated either in the polling mode or in
the interrupt mode.
 Timer/Counter Control Register – TCCR0
 Bit 7 – FOC0: Force Output Compare
 The FOC0 bit is only active when the WGM00 bit specifies a non-
PWM mode.
 Bit 3, 6 – WGM01:0: Waveform Generation Mode
 Bit 5:4 – COM01:00 Compare Match Output Mode
Bit 2:0 – CS02:0: Clock Select
Timer/Counter Register – TCNT0
 This is where the 8-bit counter of the timer resides. The
value of the counter is stored here and it increases
automatically each clock cycle. Data can be both read/written
from this register. The initial value of the counter is set by
writing it.
Output Compare Register – OCR0
 The Output Compare Register contains an 8-bit value that is
continuously compared with the counter value (TCNT0). A match
can be used to generate an output compare interrupt, or to
generate a waveform output on the OC0 pin.
Timer/Counter Interrupt Mask Register –TIMSK
 TOIE0: Timer Overflow Interrupt Enable
 OCIE0: Output Compare Match Interrupt Enable
 Timer/Counter Interrupt Flag Register – TIFR
 TOV0:
 The bit TOV0 is set (one) when an overflow occurs in Timer/Counter0. TOV0 is
cleared by hardware when executing the corresponding interrupt handling
vector. When the SREG I-bit, TOIE0 (Timer/Counter0 Overflow Interrupt
Enable), and TOV0 are set (one), the Timer/Counter0 Overflow interrupt is
executed.
 OCF0
 The OCF0 bit is set (one) when a compare match occurs between the
Timer/Counter0 and the data in OCR0 – Output Compare Register0. OCF0 is
cleared by hardware when executing the corresponding interrupt handling
vector. When the I-bit in SREG, OCIE0 (Timer/Counter0 Compare Match
Interrupt Enable), and OCF0 are set (one), the Timer/Counter0 Compare Match
Interrupt is executed.
Normal Mode (Overflow)
 A timer overflow means that the counter(TCTNx) has counted up
to its maximum value and is reset to zero in the next timer clock
cycle.
 The resolution of the timer determines the maximum value of that
timer.
 The timer overflow event causes the Timer Overflow Flag (TOVx)
to be set in the Timer Interrupt Flag Register (TIFR).
 Timer compare mode :
 In compare mode we load a register called Output Compare
Register OCRx with a value of our choice and the timer will
compare the current value of timer TCTNxwith that of Output
Compare Register continuously and when they match the
following things can be configured to happen:
 In Clear Timer on Compare mode (CTC) timer is configured to
clear its count register TCNTx to “0” when matching occurs
witthe output compare register OCRx.
 A related Output Compare Pin can be made to go high, low or
toggle automatically. This mode is ideal for generating
square waves of different frequency.
 It can be used to generate PWM signals used to implement a DAC
digital to analog converter which can be used to control the
speed of DC motors.
Pulse Width Modulation
 is the technique used to generate analogue signals from a
digital device like a MCU. Almost all modern MCUs have
dedicated hardware for PWM signal generation.
 A digital device, like a microcontroller can only generate two
levels on its output lines, HIGH=5v and LOW=0V.
 But what if we want to generate 2.5v or 3.1v or any voltage
between 0-5 volt output ?
 For these kinds of requirement, instead of generating a
constant DC voltage output we generate a square wave, which
has high = 5V and Low = 0v
 We will use the simplest timer, TIMER0 for PWM generation.
 Pulse Width Modulation
 The period (frequency) depends upon the prescaler settings. Now for PWM
generation from this count sequence we have a OCR0 (Output Compare Register
Zero Register). We can store any value between 0-255 in OCR0, say we store 64 in
OCR0 then it would appear in the graph as follows (the RED line).
 When the TIMER0 is configured for fast PWM mode, while up counting whenever
the value of TIMER0 counter (TCNT0 register) matches OCR0 register an output
PIN (OC0 PIN) is pulled low (0) and when counting sequence begin again from 0
it is SET again (pulled high=VCC).
 Pulse Width Modulation
Note:
to be able to generate
an output from the
PWM in Timer0, the
Output Compare Pin of
Timer0 (OC0) must
be set as output pin.
DDRB |= PB3
 Most data around us is analog like voltage, pressure & temperature.
 So we must process data received, and this operation is inaccurate,
take much time also don’t give accurate results
 So to solve this problem we have to convert analog signal to digital
signal.
 Since MCU is digital device so it can’t understand analog signal so it
converts analog signal to digital and make many processes on it.
 Embedded system use analog to digital module to collect data from
external world (data acquisition system)
Data acquisition system
 Is a system that records information about the world. The data is
stored in digital form on the computer.
 Signal(data) acquisition process
 In general this process take 3 steps :
 In the Real World, a sensor senses any physical parameter and
converts into an equivalent analog electrical signal. Example
temperature sensor.
 For efficient and ease of signal processing, this analog signal is
converted into a digital signal using an Analog to Digital
Converter (ADC).
 This digital signal is then fed to the Microcontroller (MCU) and is
processed accordingly.
 The ADC precision is the number of distinguishable ADC inputs
that ADC can measure (e.g. 1024 alternatives for 10 bits ADC).
 The ADC range is the maximum and minimum ADC input (e.g. 0 to
+5V).
 The ADC resolution is the smallest distinguishable change in input
voltage that can be.
 i.e. The resolution is the change in input that causes the digital
output to change by 1.
 𝑹𝒆𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 =
𝑨𝑫𝑪 𝑹𝒂𝒏𝒈𝒆 (𝒗𝒐𝒍𝒕𝒔)
𝑨𝑫𝑪 𝒑𝒓𝒆𝒄𝒊𝒔𝒊𝒐𝒏
=
𝟓−𝟎
𝟏𝟎𝟐𝟒
= 𝟒. 𝟖𝟖 𝒎𝒗
Don’t forget
Again the goal of an analog to
digital converter is to take an
analog signal (0 to 5 V on our
microcontroller) and convert it to
a digital number (0 to 1024 on
our µC).
 In general, sensors provide with analog output, but a
MCU is a digital one. Hence we need to use ADC. We
can straightaway use the inbuilt ADC of the MCU.
In ATMEGA16/32, PORTA contains the ADC pins.
 8 channel implies that there are 8 ADC pins are
multiplexed together. You can easily see that these
pins are located across PORTA (PA0…PA7).
 10 bit resolution implies that the digital result from
the ADC after converting the analog signal to digital
is 10-bits and there are 2^10 = 1024 steps.
 The type of ADC implemented inside the AVR MCU is of Successive
Approximation type.
 For example: Suppose we use a 5V reference. In this case, any
analog value in between 0 and 5V is converted into its equivalent
ADC value as shown above. The 0-5V range is divided into 2^10 =
1024 steps. Thus, a 0V input will give an ADC output of 0, 5V input
will give an ADC output of 1023, whereas a 2.5V input will give an
ADC output of around 512. This is the basic concept of ADC.
 ADC Prescaler:
 The ADC of the AVR converts analog signal into digital signal at
some regular interval. This interval is determined by the clock
frequency. In general, the ADC operates within a frequency range of
50kHz to 200kHz. But the CPU clock frequency is much higher (in
the order of MHz). So to achieve it, frequency division must take
place. The prescaler acts as this division factor. It produces desired
frequency from the external higher frequency. There are some
predefined division factors –2, 4, 8, 16, 32, 64, and 128.
 For example, a prescaler of 8 implies F_ADC = F_CPU/8. For
F_CPU = 1MHz, F_ADC = 1M/8 = 125kHz.
 ADMUX - ADC Multiplexer Selection Register
 Bits 7:6 – REFS1:0 – Reference Selection Bits
 These bits are used to choose the reference voltage. The following
combinations are used.
 Bit 5 – ADLAR – ADC Left Adjust Result
 The ADLAR bit affects the presentation of the ADC conversion
result in the ADC Data Register. Write one to ADLAR to left adjust
the result. Otherwise, the result is right adjusted.
 Bits 4:0 – MUX4:0 – Analog Channel and Gain Selection Bits
 Used to choose between the 8 channel that can be used to take analog
signal
 These channel are found in PORTA (PA0..PA7)
Need to mention
Since there are 5 bits, it
consists of
2^5 = 32 different conditions
as follows. However, we are
concerned only with the first
8 conditions. Initially, all the
bits are set to zero.
 ADCSRA – ADC Control and Status Register A
 Bit 7 – ADEN – ADC Enable
 As the name says, it enables the ADC feature. Unless this is enabled,
ADC operations cannot take place across PORTA i.e. PORTA will behave
as GPIO pins.
 Bit 6 – ADSC – ADC Start Conversion
 Write this to ’1′ before starting any conversion. This 1 is written as long
as the conversion is in progress, When the conversion is complete, it
returns to zero. Normally it takes 13 ADC clock pulses for this
operation. But when you call it for the first time, it takes 25 as it
performs the initialization together with it.
 Bit 5 – ADATE – ADC Auto Trigger Enable
 When this bit is written to one, Auto Triggering of the ADC is enabled.
The ADC will start a conversion on a positive edge of the selected trigger
signal. The trigger source is selected by setting the ADC Trigger Select
bits, ADTS in SFIOR.
 Bit 4 – ADIF – ADC Interrupt Flag
 This bit is set when an ADC conversion completes and the Data
Registers are updated. The ADC Conversion Complete Interrupt is
executed if the ADIE bit and the I-bit in SREG are set. ADIF is cleared
by hardware when executing the corresponding interrupt handling
vector. Alternatively, ADIF is cleared by writing a logical one to the flag.
 Bit 3 – ADIE – ADC Interrupt Enable
 When this bit is set to ’1′, the ADC interrupt is enabled. This is used in
the case of interrupt-driven ADC.
 Bits 2:0 – ADPS2:0 – ADC Prescaler Select Bits
 The prescaler (division factor between CPU clock frequency and the
ADC clock frequency) is determined by selecting the proper combination
from the following.
 ADCL and ADCH – ADC Data Registers
 The result of the ADC conversion is stored here. Since the ADC has
a resolution of 10 bits, it requires 10 bits to store the result. Hence
one single 8 bit register is not sufficient. We need two registers –
ADCL and ADCH (ADC Low byte and ADC High byte) as follows.
The two can be called together as ADC.
Thanks to
Eng/Mohamed Tarek
Eng/Ahmed Omara
Interfacing with Atmega 16

More Related Content

What's hot

Field effect transistors
Field effect transistorsField effect transistors
Field effect transistorsMuthumanickam
 
Cascaded differential amplifier
Cascaded differential amplifierCascaded differential amplifier
Cascaded differential amplifierHasit Trivedi
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollersMAIYO JOSPHAT
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersMohamed Tarek
 
ANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORAnil Yadav
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )Tarun Khaneja
 
Pulse amplitude modulation
Pulse amplitude modulationPulse amplitude modulation
Pulse amplitude modulationVishal kakade
 
Instrumentation amplifier
Instrumentation amplifierInstrumentation amplifier
Instrumentation amplifiermohdabuzar5
 

What's hot (20)

Field effect transistors
Field effect transistorsField effect transistors
Field effect transistors
 
Cascaded differential amplifier
Cascaded differential amplifierCascaded differential amplifier
Cascaded differential amplifier
 
Voltage regulators
Voltage regulatorsVoltage regulators
Voltage regulators
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollers
 
Ieee 488 by imran
Ieee 488 by imranIeee 488 by imran
Ieee 488 by imran
 
Vlsi design notes
Vlsi design notesVlsi design notes
Vlsi design notes
 
Embedded C - Lecture 2
Embedded C - Lecture 2Embedded C - Lecture 2
Embedded C - Lecture 2
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Twin well process
Twin well processTwin well process
Twin well process
 
MOSFET....complete PPT
MOSFET....complete PPTMOSFET....complete PPT
MOSFET....complete PPT
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr Microcontrollers
 
Lambda design rule
Lambda design ruleLambda design rule
Lambda design rule
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Monolithic ic
Monolithic icMonolithic ic
Monolithic ic
 
ANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTORANALOG TO DIGITAL CONVERTOR
ANALOG TO DIGITAL CONVERTOR
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
 
Microsd card spec
Microsd card specMicrosd card spec
Microsd card spec
 
Pulse amplitude modulation
Pulse amplitude modulationPulse amplitude modulation
Pulse amplitude modulation
 
Instrumentation amplifier
Instrumentation amplifierInstrumentation amplifier
Instrumentation amplifier
 

Viewers also liked

Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CVarun A M
 
Sensorex . . . Your Water Quality Matters!
Sensorex . . . Your Water Quality Matters!Sensorex . . . Your Water Quality Matters!
Sensorex . . . Your Water Quality Matters!Tim Schilz
 
Digital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsDigital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsMitul Lakhani
 
8255:ppi & 8259:pic
8255:ppi & 8259:pic 8255:ppi & 8259:pic
8255:ppi & 8259:pic Adarsh Patel
 
Water Impurity Measurement System using Microwaves
Water Impurity Measurement System using MicrowavesWater Impurity Measurement System using Microwaves
Water Impurity Measurement System using MicrowavesSanket Yavalkar
 
Water environment measuring system using ph sensor
Water environment measuring system using ph sensorWater environment measuring system using ph sensor
Water environment measuring system using ph sensorSuresh Babu
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
electrical conductivity meter
electrical conductivity meterelectrical conductivity meter
electrical conductivity meterJassica Karen
 
Conductivity measurement
Conductivity measurementConductivity measurement
Conductivity measurementPraful Hanmante
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR FundamentalsVinit Vyas
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Mahmoud Sadat
 
Sensors-Interfacing Techniques
Sensors-Interfacing TechniquesSensors-Interfacing Techniques
Sensors-Interfacing TechniquesDr.YNM
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingAnkur Mahajan
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR MicrocontrollerÖzcan Acar
 
pH meter design and working principle
pH meter design and working principlepH meter design and working principle
pH meter design and working principleShreya Ahuja
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
 
Microprocessor based Temperature Controller
Microprocessor based Temperature ControllerMicroprocessor based Temperature Controller
Microprocessor based Temperature ControllerRevanth Reddy
 

Viewers also liked (19)

Programming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded CProgramming ATmega microcontroller using Embedded C
Programming ATmega microcontroller using Embedded C
 
Sensorex . . . Your Water Quality Matters!
Sensorex . . . Your Water Quality Matters!Sensorex . . . Your Water Quality Matters!
Sensorex . . . Your Water Quality Matters!
 
Digital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsDigital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE students
 
8255:ppi & 8259:pic
8255:ppi & 8259:pic 8255:ppi & 8259:pic
8255:ppi & 8259:pic
 
Water Impurity Measurement System using Microwaves
Water Impurity Measurement System using MicrowavesWater Impurity Measurement System using Microwaves
Water Impurity Measurement System using Microwaves
 
Water environment measuring system using ph sensor
Water environment measuring system using ph sensorWater environment measuring system using ph sensor
Water environment measuring system using ph sensor
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
electrical conductivity meter
electrical conductivity meterelectrical conductivity meter
electrical conductivity meter
 
Conductivity measurement
Conductivity measurementConductivity measurement
Conductivity measurement
 
AVR Fundamentals
AVR FundamentalsAVR Fundamentals
AVR Fundamentals
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
Introduction to AVR Microcontroller
Introduction to AVR Microcontroller Introduction to AVR Microcontroller
Introduction to AVR Microcontroller
 
Sensors-Interfacing Techniques
Sensors-Interfacing TechniquesSensors-Interfacing Techniques
Sensors-Interfacing Techniques
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 
P h and ph meter
P h and ph meterP h and ph meter
P h and ph meter
 
AVR Microcontroller
AVR MicrocontrollerAVR Microcontroller
AVR Microcontroller
 
pH meter design and working principle
pH meter design and working principlepH meter design and working principle
pH meter design and working principle
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
Microprocessor based Temperature Controller
Microprocessor based Temperature ControllerMicroprocessor based Temperature Controller
Microprocessor based Temperature Controller
 

Similar to Interfacing with Atmega 16

ACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARHarshit Jain
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]akmalKhan55
 
Rf controlled pick up and drop robot
Rf controlled pick up and drop robotRf controlled pick up and drop robot
Rf controlled pick up and drop robotAdityaBulbule1
 
Design and Development of a prototype of AGV
Design and Development of a prototype of AGVDesign and Development of a prototype of AGV
Design and Development of a prototype of AGVKUNJBIHARISINGH5
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYArduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYVishnu
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded systemram avtar
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsPallavi Bharti
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
DIGITAL HEART BEAT COUNTER
DIGITAL HEART BEAT COUNTERDIGITAL HEART BEAT COUNTER
DIGITAL HEART BEAT COUNTERDeevanshu Swani
 
Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1Nicholas Parisi
 
Multi-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for ArduinoMulti-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for ArduinoWanita Long
 

Similar to Interfacing with Atmega 16 (20)

Adc and dac
Adc and dacAdc and dac
Adc and dac
 
L6283 1.3.pdf
L6283 1.3.pdfL6283 1.3.pdf
L6283 1.3.pdf
 
ACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CAR
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
 
Microcontroller part 3
Microcontroller part 3Microcontroller part 3
Microcontroller part 3
 
Rf controlled pick up and drop robot
Rf controlled pick up and drop robotRf controlled pick up and drop robot
Rf controlled pick up and drop robot
 
Design and Development of a prototype of AGV
Design and Development of a prototype of AGVDesign and Development of a prototype of AGV
Design and Development of a prototype of AGV
 
My minor project
My minor projectMy minor project
My minor project
 
Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYArduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIY
 
Module 4
Module 4Module 4
Module 4
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded system
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and robotics
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
DIGITAL HEART BEAT COUNTER
DIGITAL HEART BEAT COUNTERDIGITAL HEART BEAT COUNTER
DIGITAL HEART BEAT COUNTER
 
BLD-AC750S.pdf
BLD-AC750S.pdfBLD-AC750S.pdf
BLD-AC750S.pdf
 
Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1
 
Assembler4
Assembler4Assembler4
Assembler4
 
Multi-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for ArduinoMulti-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for Arduino
 

Recently uploaded

(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
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
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
 
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
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
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)

(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
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
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
 
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
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
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 )
 

Interfacing with Atmega 16

  • 1. By / Ramadan Ahmed
  • 2. Digital input/output  Motor  Color Sensor  LDR Interrupt  External interrupt  Peripherals interrupt Timer  Overflow  PWM ADC  Infra red sensor
  • 3.
  • 4. ATmega16 has 32 programmable I/O lines divided into 4 PORTS(groups):  PORTA (PA0….PA7)  PORTB (PB0….PB7)  PORTC(PC0…..PC7)  PORTD(PD0…..PD7) Each Port Can be controlled by 3 Register :  DDRx(Data direction Register)  PORTx (Output Register)  PINx (Input Register) Note : Most Pins of Microcontroller are multi-tasking (more than one function)(Multiplexed)
  • 5.
  • 6.
  • 7. First we decide if the pin used as input or output Then decide the direction of register using DDRx 0 for Input 1 for Output In case we Read input from pin we use PINx register In case we Write output on pin we use PORTx register
  • 8. How to set values in Register :  DDRA = 0x55;  DDRA = 0b01010101;  DDRA = 5;
  • 9. How to set value on specific pin without changing the other:  To set the pin with 1 :  Make OR operation on the register with The pin no  Example: We want to set pin number 5 in PORTA with 1  PORTA=PORTA | (1<<PA5);  To set the pin with 0:  Make AND operation on the register with (NOT) The pin no  Example: We want to set pin number 3 in PORTB with 0  PORTB=PORTB & ( ~ (1<<PB3) );  To toggle the pin :  Make XOR operation on the register with The pin no  Example: We want to toggle pin number 2 in PORTC  PORTC=PORTC ^ (1<<PC2);
  • 10. How to check on specific pin without checking the others:  To check if input on the pin is 1 :  Make AND operation on the register with The pin no  Example: We check if pin number 5 in PORTA is 1  if (PORTA & (1<<PA5)){}  To check if input on the pin is 0 :  Make AND operation on the register with The pin no and check if equal zero OR Not the condition  Example: We check if pin number 5 in PORTA is 1  if ((PORTA & (1<<PA5)) == 0 ){}  if (!(PORTA & (1<<PA5))){}
  • 11. Application: Outputs: Motors ( DC, Stepper, Servo). LEDS. LCD. 7 segment. Inputs: Sensors. Switch. Keypad.
  • 12. Output Example: LED: We have two way to configure LED : Negative Logic Positive Logic R= 220- 330K
  • 13. Input Example: Switch:  We have two way to configure switch : Pull-up Resistor Pull-down Resistor R= 10K
  • 14. Note Atmega16 provide internal pull up resistor for all port pins In case you set any PIN as input you can activate the internal pull up resistor by setting the corresponding bit in PORTX register. Example To set the pin 2 in PORTB as input pin and use the internal pull up resistor of this pin. DDRB = DDRB & (~(1<<PB2)); PORTB= PORTB | (1<<PB2);
  • 15. Note Switch has a bouncing problem cause it’s a mechanical device so it need more time to achieve its state than the µc check the state of switch. Due to this problem, we can solve it by software. We can make a delay of 20-30 ms due to the fact that de-bounce maximum period takes this time. The basic idea is to implement a delay after the first detected edge, during which no scanning for the switch is done. after the delay period is finished, scanning can proceed.
  • 17. Dc Motor  It comes to speed, weight, size, cost... DC motors are always preferred over stepper motors. Advantage: Control motion of robot. Control its speed. Control direction of its rotation. Disadvantage: Hard to control its rotation angle.
  • 18. How to control Dc-motors using µc ?? Any Motor can be controlled by H-bridge. H-bridge can be made by 3 ways using: Switches. Relays. Transistors. IC (L293D).
  • 19. Working theory of H-bridge?  The name "H-Bridge" is derived from the actual shape of the switching circuit which control the motion of the motor. It is also known as "Full Bridge". Basically there are four switching elements in the H-Bridge as shown in the figure below.
  • 20.  Switches Current flow when both high side left and low side right are switched on
  • 22. Using Transistor (BJT & Two pin from µc)
  • 23. Using Transistor (BJT & Two pin from µc)
  • 24. Using Transistor (BJT & 4 pin from µc)
  • 25. Using H-bridge  Most common chip to control Motor is L293D  This chip can control 2 Dc motor  First DC Motor three µC pins are needed to control the DC motor (Input1, Input2, Enable1) and the motor connected to Output1 & Output2 pins.  Second DC Motor three µC pins are needed to control the DC motor (Input3, Input4, Enable2) and the motor connected to Output3 & Output4 pins.  Vss pin is connected to 5v.  Vs pin is connected to the Motor voltage 12v .
  • 26.
  • 27.
  • 28. Types of stepper motor  Variable Reluctance  Permanent Magnet & Hybrid  Unipolar stepper motor (5,6 wires)  Bipolar stepper motor (4 wires)  Bifilar (8 wires)
  • 30. Permanent Magnet & Hybrid Unipolar (5 or 6 wires) Bipolar (4 wires) Bifilar (8 wires)
  • 32. Unipolar Stepper Motor  The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil).
  • 33. Unipolar Stepper Motor  How to differentiate unipolar stepper motor ?
  • 34. Unipolar Stepper Motor  How to control unipolar stepper motor using transistors?
  • 35. Bipolar Stepper Motor  The bipolar stepper motor usually has four wires coming out of it. They have two independent sets of coils instead.
  • 36. Bipolar Stepper Motor  How to differentiate Bipolar stepper motor ?
  • 37. Stepper motors drive sequences: Full Step Sequence Half Step Sequence
  • 38. Step Angle  The angle traversed by the motor in one step.  To calculate step angle, simply divide 360 by number of steps a motor takes to complete one revolution.
  • 40. Full Step Mode:  In the full step sequence, two coils are energized at the same time and motor shaft rotates diagonal OR one coil is energized and motor shaft rotates inline. Full Steps Sequence Steps A B A’ B’ 1 1 1 0 0 2 0 1 1 0 3 0 0 1 1 4 1 0 0 1 Full Steps Sequence Steps A B A’ B’ 1 1 0 0 0 2 0 1 0 0 3 0 0 1 0 4 0 0 0 1
  • 42. Half Step Mode :  In Half mode step sequence, motor step angle reduces to half the angle in full mode. Half Mode Sequence Step A B A B 0 1 1 0 0 1 0 1 0 0 2 0 1 1 0 3 0 0 1 0 4 0 0 1 1 5 0 0 0 1 6 1 0 0 1 7 1 0 0 0
  • 44. Interfacing Unipolar Stepper Motor  Interface using L293D - H-Bridge Motor Driver  Interface using ULN2003/2004 - Darlington Arrays
  • 47. Unipolar Full step Mode (4 wires)
  • 48. Unipolar Half step Mode (4 wires)
  • 49. Unipolar Full step Mode (2 wires)
  • 50. Unipolar Full step Mode (2 wires)
  • 51. Bipolar Full step Mode (4 wires)
  • 52. Servo or RC Servo Motors are DC motors equipped with a servo mechanism for precise control of angular position. The RC servo motors usually have a rotation limit from 90° to 180°. Some servos also have rotation limit of 360° or more. But servos do not rotate continually. Their rotation is restricted in between the fixed angles.
  • 54. Servo concepts  The Servo Motors come with three wires or leads.  Two of these wires are to provide ground and positive supply to the servo DC motor.  The third wire is for the control signal.  The red wire is the DC supply lead and must be connected to a DC voltage supply in the range of 4.8 V to 6V.  The black wire is to provide ground.  The color for the third wire (to provide control signal) varies for different manufacturers. It can be yellow (in case of Hitec), white (in case of Futaba), brown etc.
  • 55. NOTE :  Unlike DC motors, reversing the ground and positive supply connections does not change the direction (of rotation) of a servo.
  • 59. LDR:  Sensor used to detect light and create voltage difference  Most common is photoresistor.  We use it in line following or detect object nearby.
  • 60. How it works It uses the principal that white color reflects lights & black color absorb light.
  • 61. How it works We connect to LDR to both sides and when : S1 = S2 (in intensity of light) -> motor moves forward S1= black (less intensity of light) -> Turn Left S2=black (less intensity of light) ->Turn Right
  • 64.
  • 66. Basically events that require immediate attention by the microcontroller. An interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. When an interrupt event occurs, the microcontroller pause its current task and attend to the interrupt by executing its corresponding Interrupt Service Routine (ISR) then microcontroller returns to the task it had pause and continue its normal operations.
  • 67. Such an event may be:  An peripheral device has finished the last task it was given and is now ready for another. For example ADC may be generate interrupt after finishing the conversion from analog to digital.  External Interrupt event on I/O Pin.  An error from a peripheral. You can think of it as a hardware-generated function call.
  • 68. ISR (Interrupt service routine)  Piece of code that should be execute when an interrupt is triggered  Should be deterministic and short as possible, as it usually set a flag to a specific task indicating a certain event is happened, or save small data in buffer.
  • 69. AVR Interrupts The AVR provides several different interrupt sources. All interrupts are assigned individual enable bits to which must be written a logic one together with the Global Interrupt Enable bit in the Status Register in order to enable the interrupt. Any Interrupt request is triggered by an event that sets its corresponding interrupt flag.
  • 70.
  • 71. REMEMBER Global interrupt enabled bit MUST be enabled for interrupts to be activated in the µC. To Set global interrupt :  sei(); // AVR microcontroller  SREG = SREG | (1<<7);  SREG = SREG | (1<<I); To clear global interrupt :  cli();  SREG = SREG & (~(1<<7));  SREG = SREG & (~(1<<I));
  • 72. Interrupt Flags and Enabled bits in AVR µC  Each interrupt is associated with two (2) bits, an Interrupt Flag Bit and an Interrupt Enabled Bit. These bits are located in the I/O registers associated with the specific interrupt: The interrupt flag bit is set whenever the interrupt event occur, whether or not the interrupt is enabled. And The flag is cleared when the ISR is executed. So it is also called “Automatic Flag”. The interrupt enabled bit is used to enable or disable a specific interrupt. Basically is tells the µC whether or not it should respond to the interrupt if it is triggered.
  • 73. Global interrupt Interrupt flag Interrupt enabled Interrupt Request
  • 74.  The AVR 8-bits microcontroller provide both internal and external interrupt sources.  The internal interrupts are associated with the microcontroller's peripherals like :  Timer/Counter  Analog to Digital Converter,  USART  The external interrupts are triggered via external pins. for an AVR 8-bit microcontroller. On this microcontroller there are four (4) external interrupts:  RESET interrupt : Triggered from pin 9.  External Interrupt 0 (INT0) : Triggered from pin 16(PD2).  External Interrupt 1 (INT1) : Triggered from pin 17(PD3).  External Interrupt 2 (INT2) : Triggered from pin 3(PB2).
  • 75. RESET interrupt  It active low interrupt which means it triggered when low voltage (0 volt) is applied on reset pin (number 9). Other 3 hardware interrupt are triggered by event that can be configured using I/O register. If any of this interrupt is enabled and triggered , they are service by an ISR (Code) which is written by programmer.
  • 76.
  • 77. GICR (General Interrupt Control Register)  It contains the interrupt enabled bit for all the external interrupts of the ATmega16. Writing a 1 to the specific interrupt bit will enable that interrupt. Don’t forget :Enable Global interrupt mask is must for interrupt to be done
  • 80. GIFR (General Interrupt Flag Register)  The GIFR register contains the interrupt flags for all the ATmega16 external interrupts. Each of these bit are set individually to logic 1 when the interrupt event for the specified interrupt occurs. Note that the flag bit of an interrupt is set, whether or not the interrupt is enabled, once the interrupt event occurs.  If the interrupt is enabled, it’s corresponding interrupt flag bit will be cleared after executing it’s ISR code.
  • 81.
  • 82. Timer is special register that can be 8-16 bit so capable of holding from 0 to 255-65536 What differ it from any register that it count up / down automatically at predefined rate and this is Timer Clock that doesn’t need CPU intervention. Timer Clock could be internal / external
  • 83.
  • 84. One of basic condition when Timer overflow( it means timer counted up to its maximum value and return back to zero). In this situation it causes interrupt and if global interrupt mask is enabled and timer interrupt enable so you have to write ISR to handle the event of the overflow
  • 85. In case you want to increase the time needed for specific operation we use timer prescalar Prescalar divide the clock frequency and produce timer clock Prescalar modes are  No prescalar (Timer Clock).  Clock/8.  Clock/64.  Clock/256.  Clock/512.  Clock/1024.  NO clock. Note CPU Clock doesn’t affected by reduction using prescalar. It remain the same
  • 86. Example for using prescalar :  If you using 1 MHZ for CPU Clock without using prescalar timer takes to count up till it overflow 256 µs  But when you use prescalar 1024 timer takes to count up till it overflow 0.26 sec  It’s easy to know the time timer need to overflow if you know Resolution.  Resolution is the smallest period taken by timer to take one count we can calculate it through formula Resolution = (1/Frequency)  So if microcontroller is clocked with 1MHz source, then 8 bit timer without prescaler will run with resolution: Resolution=1/1MHz=1µs
  • 87. So if timer take 256 counts to overflow then it takes : T= Resolution * 256 = 1µs *256 = 256 µs  And when we use 1024 as prescalar: Resolution = 1024 / 1 MHZ = 1024µs T = Resolution * 256 = 1024 * 256 = 0.256
  • 88. ATmega16/32 have 3 Timer/counter we have three Timers/Counters each one with Separate Prescaler.  Timer 0 - 8 bit timer.  Timer 1 -16 bit timer.  Timer 2 - 8 bit timer. Timer also can be operated in 3 modes :  Normal mode (Overflow).  Pulse Width Modulation mode(PWM).  Clear Timer Compare mode(CTC ).
  • 89. Timer0  Timer0 is an 8 bit timer/counter which can count from 0 to 0xFF (255).  In the timer mode this peripheral uses an internal clock signal.  In the counter mode an external signal on PIN0 in PORTB.  The timer can be operated either in the polling mode or in the interrupt mode.
  • 90.  Timer/Counter Control Register – TCCR0  Bit 7 – FOC0: Force Output Compare  The FOC0 bit is only active when the WGM00 bit specifies a non- PWM mode.  Bit 3, 6 – WGM01:0: Waveform Generation Mode
  • 91.  Bit 5:4 – COM01:00 Compare Match Output Mode
  • 92. Bit 2:0 – CS02:0: Clock Select
  • 93. Timer/Counter Register – TCNT0  This is where the 8-bit counter of the timer resides. The value of the counter is stored here and it increases automatically each clock cycle. Data can be both read/written from this register. The initial value of the counter is set by writing it.
  • 94. Output Compare Register – OCR0  The Output Compare Register contains an 8-bit value that is continuously compared with the counter value (TCNT0). A match can be used to generate an output compare interrupt, or to generate a waveform output on the OC0 pin.
  • 95. Timer/Counter Interrupt Mask Register –TIMSK  TOIE0: Timer Overflow Interrupt Enable  OCIE0: Output Compare Match Interrupt Enable
  • 96.  Timer/Counter Interrupt Flag Register – TIFR  TOV0:  The bit TOV0 is set (one) when an overflow occurs in Timer/Counter0. TOV0 is cleared by hardware when executing the corresponding interrupt handling vector. When the SREG I-bit, TOIE0 (Timer/Counter0 Overflow Interrupt Enable), and TOV0 are set (one), the Timer/Counter0 Overflow interrupt is executed.  OCF0  The OCF0 bit is set (one) when a compare match occurs between the Timer/Counter0 and the data in OCR0 – Output Compare Register0. OCF0 is cleared by hardware when executing the corresponding interrupt handling vector. When the I-bit in SREG, OCIE0 (Timer/Counter0 Compare Match Interrupt Enable), and OCF0 are set (one), the Timer/Counter0 Compare Match Interrupt is executed.
  • 97. Normal Mode (Overflow)  A timer overflow means that the counter(TCTNx) has counted up to its maximum value and is reset to zero in the next timer clock cycle.  The resolution of the timer determines the maximum value of that timer.  The timer overflow event causes the Timer Overflow Flag (TOVx) to be set in the Timer Interrupt Flag Register (TIFR).
  • 98.  Timer compare mode :  In compare mode we load a register called Output Compare Register OCRx with a value of our choice and the timer will compare the current value of timer TCTNxwith that of Output Compare Register continuously and when they match the following things can be configured to happen:  In Clear Timer on Compare mode (CTC) timer is configured to clear its count register TCNTx to “0” when matching occurs witthe output compare register OCRx.  A related Output Compare Pin can be made to go high, low or toggle automatically. This mode is ideal for generating square waves of different frequency.  It can be used to generate PWM signals used to implement a DAC digital to analog converter which can be used to control the speed of DC motors.
  • 99. Pulse Width Modulation  is the technique used to generate analogue signals from a digital device like a MCU. Almost all modern MCUs have dedicated hardware for PWM signal generation.  A digital device, like a microcontroller can only generate two levels on its output lines, HIGH=5v and LOW=0V.  But what if we want to generate 2.5v or 3.1v or any voltage between 0-5 volt output ?  For these kinds of requirement, instead of generating a constant DC voltage output we generate a square wave, which has high = 5V and Low = 0v  We will use the simplest timer, TIMER0 for PWM generation.
  • 100.
  • 101.  Pulse Width Modulation  The period (frequency) depends upon the prescaler settings. Now for PWM generation from this count sequence we have a OCR0 (Output Compare Register Zero Register). We can store any value between 0-255 in OCR0, say we store 64 in OCR0 then it would appear in the graph as follows (the RED line).  When the TIMER0 is configured for fast PWM mode, while up counting whenever the value of TIMER0 counter (TCNT0 register) matches OCR0 register an output PIN (OC0 PIN) is pulled low (0) and when counting sequence begin again from 0 it is SET again (pulled high=VCC).
  • 102.  Pulse Width Modulation Note: to be able to generate an output from the PWM in Timer0, the Output Compare Pin of Timer0 (OC0) must be set as output pin. DDRB |= PB3
  • 103.
  • 104.
  • 105.  Most data around us is analog like voltage, pressure & temperature.  So we must process data received, and this operation is inaccurate, take much time also don’t give accurate results  So to solve this problem we have to convert analog signal to digital signal.  Since MCU is digital device so it can’t understand analog signal so it converts analog signal to digital and make many processes on it.  Embedded system use analog to digital module to collect data from external world (data acquisition system)
  • 106.
  • 107. Data acquisition system  Is a system that records information about the world. The data is stored in digital form on the computer.
  • 108.  Signal(data) acquisition process  In general this process take 3 steps :  In the Real World, a sensor senses any physical parameter and converts into an equivalent analog electrical signal. Example temperature sensor.  For efficient and ease of signal processing, this analog signal is converted into a digital signal using an Analog to Digital Converter (ADC).  This digital signal is then fed to the Microcontroller (MCU) and is processed accordingly.
  • 109.  The ADC precision is the number of distinguishable ADC inputs that ADC can measure (e.g. 1024 alternatives for 10 bits ADC).  The ADC range is the maximum and minimum ADC input (e.g. 0 to +5V).  The ADC resolution is the smallest distinguishable change in input voltage that can be.  i.e. The resolution is the change in input that causes the digital output to change by 1.  𝑹𝒆𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 = 𝑨𝑫𝑪 𝑹𝒂𝒏𝒈𝒆 (𝒗𝒐𝒍𝒕𝒔) 𝑨𝑫𝑪 𝒑𝒓𝒆𝒄𝒊𝒔𝒊𝒐𝒏 = 𝟓−𝟎 𝟏𝟎𝟐𝟒 = 𝟒. 𝟖𝟖 𝒎𝒗 Don’t forget Again the goal of an analog to digital converter is to take an analog signal (0 to 5 V on our microcontroller) and convert it to a digital number (0 to 1024 on our µC).
  • 110.  In general, sensors provide with analog output, but a MCU is a digital one. Hence we need to use ADC. We can straightaway use the inbuilt ADC of the MCU. In ATMEGA16/32, PORTA contains the ADC pins.  8 channel implies that there are 8 ADC pins are multiplexed together. You can easily see that these pins are located across PORTA (PA0…PA7).  10 bit resolution implies that the digital result from the ADC after converting the analog signal to digital is 10-bits and there are 2^10 = 1024 steps.
  • 111.  The type of ADC implemented inside the AVR MCU is of Successive Approximation type.  For example: Suppose we use a 5V reference. In this case, any analog value in between 0 and 5V is converted into its equivalent ADC value as shown above. The 0-5V range is divided into 2^10 = 1024 steps. Thus, a 0V input will give an ADC output of 0, 5V input will give an ADC output of 1023, whereas a 2.5V input will give an ADC output of around 512. This is the basic concept of ADC.
  • 112.
  • 113.  ADC Prescaler:  The ADC of the AVR converts analog signal into digital signal at some regular interval. This interval is determined by the clock frequency. In general, the ADC operates within a frequency range of 50kHz to 200kHz. But the CPU clock frequency is much higher (in the order of MHz). So to achieve it, frequency division must take place. The prescaler acts as this division factor. It produces desired frequency from the external higher frequency. There are some predefined division factors –2, 4, 8, 16, 32, 64, and 128.  For example, a prescaler of 8 implies F_ADC = F_CPU/8. For F_CPU = 1MHz, F_ADC = 1M/8 = 125kHz.
  • 114.  ADMUX - ADC Multiplexer Selection Register  Bits 7:6 – REFS1:0 – Reference Selection Bits  These bits are used to choose the reference voltage. The following combinations are used.
  • 115.  Bit 5 – ADLAR – ADC Left Adjust Result  The ADLAR bit affects the presentation of the ADC conversion result in the ADC Data Register. Write one to ADLAR to left adjust the result. Otherwise, the result is right adjusted.
  • 116.  Bits 4:0 – MUX4:0 – Analog Channel and Gain Selection Bits  Used to choose between the 8 channel that can be used to take analog signal  These channel are found in PORTA (PA0..PA7) Need to mention Since there are 5 bits, it consists of 2^5 = 32 different conditions as follows. However, we are concerned only with the first 8 conditions. Initially, all the bits are set to zero.
  • 117.  ADCSRA – ADC Control and Status Register A  Bit 7 – ADEN – ADC Enable  As the name says, it enables the ADC feature. Unless this is enabled, ADC operations cannot take place across PORTA i.e. PORTA will behave as GPIO pins.  Bit 6 – ADSC – ADC Start Conversion  Write this to ’1′ before starting any conversion. This 1 is written as long as the conversion is in progress, When the conversion is complete, it returns to zero. Normally it takes 13 ADC clock pulses for this operation. But when you call it for the first time, it takes 25 as it performs the initialization together with it.
  • 118.  Bit 5 – ADATE – ADC Auto Trigger Enable  When this bit is written to one, Auto Triggering of the ADC is enabled. The ADC will start a conversion on a positive edge of the selected trigger signal. The trigger source is selected by setting the ADC Trigger Select bits, ADTS in SFIOR.  Bit 4 – ADIF – ADC Interrupt Flag  This bit is set when an ADC conversion completes and the Data Registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in SREG are set. ADIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ADIF is cleared by writing a logical one to the flag.
  • 119.  Bit 3 – ADIE – ADC Interrupt Enable  When this bit is set to ’1′, the ADC interrupt is enabled. This is used in the case of interrupt-driven ADC.  Bits 2:0 – ADPS2:0 – ADC Prescaler Select Bits  The prescaler (division factor between CPU clock frequency and the ADC clock frequency) is determined by selecting the proper combination from the following.
  • 120.  ADCL and ADCH – ADC Data Registers  The result of the ADC conversion is stored here. Since the ADC has a resolution of 10 bits, it requires 10 bits to store the result. Hence one single 8 bit register is not sufficient. We need two registers – ADCL and ADCH (ADC Low byte and ADC High byte) as follows. The two can be called together as ADC.

Editor's Notes

  1. Negative logic : Turn On Led by logic zero Positive logic : Turn Off Led by logic one
  2. Pull up check for 0 Pull down check for 1
  3. Can be Solve by hardware
  4. A simple H-bridge can be made with the help of Power BJTs like TIP31 (NPN)and TIP32 (PNP). An example and a working demo of this circuit is shown in the figure below.
  5. A simple H-bridge can be made with the help of Power BJTs like TIP31 (NPN)and TIP32 (PNP). An example and a working demo of this circuit is shown in the figure below.
  6. What’s meant by reluctance? Since the coil generate magnetic field and magnetic field tend to move in iron more than air so the motor moves due to magnetic field and comes out from the common end or vice versa
  7. Now lets discuss the operation principal of a stepper motor. When we energize a coil of stepper motor, The shaft of stepper motor (which is actually a permanent magnet) align itself according to poles of energized coil. So when motor coils are energized in a particular sequence, motor shaft tend to align itself according to pole of coils and hence rotates. A small example of energizing operation is given below. You can see in the example, when coil "A" is energized, A north-south polarity is generated at "A+A\" as shown in the figure above and magnetic shaft automatically align itself according to the poles generated. When the next coil is energized the shaft again align itself and take a step. Hence the working principal.
  8. This section of tutorial will explain you everything that you need to know about stepper motors. Stepper motors can be used in various areas of your microcontroller projects such as making robots, robotic arm, automatic door lock system etc. This tutorial will explain you construction of stepper motors (unipolar and bipolar stepper motors ), basic principal, different controlling types (Half step and Full step), Interfacing Techniques (using L293D or ULN2003) and programming your microcontroller in C and assembly to control stepper motor. ►Unipolar stepper motor The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole. ►Bipolar stepper motor The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you've got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity). As already said, we will talk mostly on "Unipolar stepper motors" which is most common type of stepper motor available in the market. A simple example of 6 lead step motor is given below and in 5 lead step motor wire 5 and 6 are joined together to make 1 wire as common.
  9. Using an ohmmeter, the individual coils of a bipolar motor can easily be identified. When dealing with unipolar motors the first task is to isolate the common wire. Using an ohmmeter, note the resistance between pairs of wires. As can be seen in the above diagram, the common wire will have half the resistance of the other wires across the coils. Once the common wire has been found attach it to a supply voltage (5v to 12v in the case of printer motors)
  10. Bipolar stepper motor The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you've got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity). As already said, we will talk mostly on "Unipolar stepper motors" which is most common type of stepper motor available in the market. A simple example of 6 lead step motor is given below and in 5 lead step motor wire 5 and 6 are joined together to make 1 wire as common.
  11. The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you've got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).
  12. Step angle of the stepper motor is defined as the angle traversed by the motor in one step. To calculate step angle, simply divide 360 by number of steps a motor takes to complete one revolution. As we have seen that in half mode, the number of steps taken by the motor to complete one revolution gets doubled, so step angle reduces to half. As in above examples, Stepper Motor rotating in full mode takes 4 steps to complete a revolution, So step angle can be calculated as... Step Angle ø = 360° / 4 = 90° and in case of half mode step angle gets half so 45°. So this way we can calculate step angle for any stepper motor. Usually step angle is given in the spec sheet of the stepper motor you are using. Knowing stepper motor's step angle helps you calibrate the rotation of motor also to helps you move the motor to correct angular position.
  13. As in above examples, Stepper Motor rotating in full mode takes 4 steps to complete a revolution, So step angle can be calculated as... Step Angle ø = 360° / 4 = 90° and in case of half mode step angle gets half so 45°. So this way we can calculate step angle for any stepper motor. Usually step angle is given in the spec sheet of the stepper motor you are using. Knowing stepper motor's step angle helps you calibrate the rotation of motor also to helps you move the motor to correct angular position.
  14. We have seen the generally used 4-wire connection method for interfacing unipolar stepper motor, but we can simplify the design to make controller use less pins with the help of 2-wire connection method. The circuit for 2-wire connection is shown below.
  15. As we have studied that, Bi-polar stepper motors has 2 different coils. The step sequence for Bipolar stepper motor is same as that of unipolar stepper motors. The driving circuit for this require an H-Bridge as it allows the polarity of the power applied to be controlled independently. This can be done as shown in the figure below: Now we have seen the methods for connecting stepper motors with your microcontroller. So keeping these circuits in mind, we will now look at the programming of microcontroller to control stepper motors. This is discussed in the next section of the tutorial. 
  16. What are Servo Motors? Servo refers to an error sensing feedback control which is used to correct the performance of a system. Servo or RC Servo Motors are DC motors equipped with a servo mechanism for precise control of angular position. The RC servo motors usually have a rotation limit from 90° to 180°. Some servos also have rotation limit of 360° or more. But servos do not rotate continually. Their rotation is restricted in between the fixed angles.
  17. The Servo motors are used for precision positioning. They are used in robotic arms and legs, sensor scanners and in RC toys like RC helicopter, airplanes and cars.
  18. The Servo Motors come with three wires or leads. Two of these wires are to provide ground and positive supply to the servo DC motor. The third wire is for the control signal. These wires of a servo motor are color coded. The red wire is the DC supply lead and must be connected to a DC voltage supply in the range of 4.8 V to 6V. The black wire is to provide ground. The color for the third wire (to provide control signal) varies for different manufacturers. It can be yellow (in case of Hitec), white (in case of Futaba), brown etc.   Futaba provides a J-type plug with an extra flange for proper connection of the servo. Hitec has an S-type connector. A Futaba connector can be used with a Hitec servo by clipping of the extra flange. Also a Hitec connector can be used with a Futaba servo just by filing off the extra width so that it fits in well. Hitec splines have 24 teeth while Futaba splines are of 25 teeth. Therefore splines made for one servo type cannot be used with another. Spline is the place where a servo arm is connected. It is analogous to the shaft of a common DC motor.
  19. This may, in fact, damage the servo motor. That is why it is important to properly account for the order of wires in a servo motor.
  20. A servo motor mainly consists of a DC motor, gear system, a position sensor which is mostly a potentiometer, and control electronics.
  21. The servo motor can be moved to a desired angular position by sending PWM (pulse width modulated) signals on the control wire. The servo understands the language of pulse position modulation. A pulse of width varying from 1 millisecond to 2 milliseconds in a repeated time frame is sent to the servo for around 50 times in a second. The width of the pulse determines the angular position. The total pulse duration for a typical servo motor should be of 20 milliseconds. The on-time duration of the control signal varies from 1ms to 2ms. This on-time variation provides angular variation from 0 to 180 degree.    It must be noted that these values are only the approximations. The actual behavior of the servos differs based on their manufacturer.   A sequence of such pulses (50 in one second) is required to be passed to the servo to sustain a particular angular position. When the servo receives a pulse, it can retain the corresponding angular position for next 20 milliseconds. So a pulse in every 20 millisecond time frame must be fed to the servo. According to the above diagram, desired angular position can be calculated by simple interpolations. For example, if the servo motor should be positioned at 45° angle, the desired output control pulse can be obtained as follows:   180° angular displacement is achieved by the pulse duration = 1 ms 1° angular displacement is achieved by the pulse duration of = 1 /180 ms 45° angular displacement is achieved by the pulse duration of = (1/180) x 45 = 0.25 ms So total on-time pulse will be = 1ms + 0.25ms =1.25 ms   Please note that the on-time duration of the control signal may vary based on the manufacturer or certain other conditions. Therefore it is imperative that the on-time pulse for 0° and 180° positions must be obtained (either from the datasheet or by hit-n-trial) before using a servo motor for an application. The servo motor used here moves to 0° at 0.55 ms pulse.     Programming Steps:    1.         Calculate the on-time duration for 1° angular displacement. 2.         Create delay function to calculate time duration. 3.         Set the pin high at which control terminal of the servo motor is connected. 4.         Call the delay function (mentioned in 3) and repeat it number of times as much angular displacement needed. 5.         Set the control pin low. 6.         Generate delay of 18 ms. 7.         Repeat the steps from 4 to 7 continuously for about 50 times to send a train of pulses. 
  22. Interrupt Service Routine (ISR) at the end of the ISR the microcontroller
  23. What happens when an interrupt occurs in AVR Microcontrollers? 1. The microcontroller completes the execution of the current instruction, clears the I bit(Global interrupt enable bit in the SREG status register) and stores the address of the next instruction that should have been executed (the content of the PC), processor status register, And all the CPU registers are pushed onto the stack. 2. The interrupt vector of the triggered interrupt (ISR start address of this interrupt) is then loaded in the PC(program counter) from the interrupt vector table and the microcontroller starts execution from that point up until reaches the end of the ISR. 3. The address that was stored on the stack in step 1 is reloaded in the PC register, Status register and all the CPU registers are popped from the stack and the I bit is re-enabled. 4. The micro-controller then continue executing the program.