SlideShare a Scribd company logo
1 of 32
PULSE WIDTH MODULATION
(PWM)
K.saideep
Why use pwm?
• Generally all microcontrollers are provided
with analogue to digital converter to convert
analogue values to digital values. But there is
no such thing like DAC’s in AVR’s. In such case
pwm is closest solution.
• It is used generally for light dimmer controls
and motor speed controls by varying it’s
dutycycle
• Dutycycle: It is defined as duration for which
waveform is in active state to the total time
under consideration
• Dutycycle=(t/T)
• t=time for which waveform is in active state
• T=timeperiod of waveform
• Outputvoltage=(dutycycle)*(input voltage)
Simple pwm generator
• A simple wave generator(may be triangular ,
ramp etc.) can be combined with a
comparator to generate pwm.
• By varying the value of input given to negetive
terminal of comparator waveforms of different
timeperiod are obtained.
• They are used in applications like servos which
require a pulse of time period of 2.5ms
Output pwm waveform
• Comparator used to vary only duty cycle, then
how to change time period of the output
signal?
• This is possible using timers and based on
microcontroller number of timers and pwm
channels varies and generally the value which
we give for comparison is also given through
timers.
Timer
• Timer: There are two types of timers present
in ATMEGA16 and ATMEGA8:
• 1.8bit timer-(0-255)
• 2.16 bit timer-(0-65535)
• It’s value increases at a predetermined rate
known as timerclock (given by user) which is
free from cpu’s intervention
Basic concepts of timer
• Prescalar : It is the constant with which clock
frequency is to be divided to get desired timer
frequency
• Prescalar = clock frequency/desired timer
frequency.
• Generally prescalars are available in multiples
of 2 i.e, 1,8,32,64,128,1024
• If any timer has multiple pwm channels then
they share same value of prescalar.
• Interrupt:When the timer counter reaches a
specific value then CPU stops it’s normal
functioning and executes the action which is
given in terms of interrupt
• Syntax for interrupt service routine(ISR)
• ISR(TIMER1_COMP_VECT)
• {
• }
Basic registers in timer
• In the previous waveforms the compare value
is given by OCRX(output compare register)
and top value is given by ICRX(Input capture
register) and each timer is provided separate
counters and they are designated by TCNTX
and X indicates the timer which is being used.
Inputs and outputs of timer in pwm
operation
Clock:
• This is either the speed of any external crystal you have used
or the internal clock speed of your microcontroller. When you
compile your program you normally (in AVRlib) have to set the
F_CPU variable to this value. Obviously there is only one clock
speed per microcontroller.
• Compare:
• This value is generally given as register
variable to the timer
• PWM out: The number of pwm channels are
nothing but pwm output pins , whose number
depend on microcontroller.
• For example ATMEGA8 has 3 channels
Things to be considered before pwm
operation
• Bits of accuracy
• Modes of pwm
• Compare output mode
• Modes of pwm
• 1.fast pwm
• 2.phase correct pwm
• 3.phase and frequency correct pwm
FAST PWM
Phase correct and phase and
frequency correct pwm
• There is no general difference between this
two types of pwm
• But there is difference compared to first type
as in this type a triangular waveform
generator is used which increases time period
by two times when compared to previous
method
Difference between Input waveforms
Input and Output waveform
Bits of accuracy
• This refers to possible range of values for
comparator are possible based on TOP value
• If the TOP value is 7 then it is possible to get 8
different values from 0-7 so the bits of
accuracy is 3.
Compare output modes
• Pwm turned off
• Inverted pwm
• Non inverted pwm
• Toggle pwm
• The first mode is self explanaratory
• Inverted pwm: It will set output pins high
when counter value is greater than
comparator value
• Non inverted pwm: It will set output pin low
when counter value is greater than
comparator value
• Toggle pwm: It will toggle the output pin when
counter value reaches comparator value
Timers in ATMEGA8
• TIMER0
• TIMER1:
• TCCR1A,TCCR1B
• TIMER2
• Timer0 is not used for pwm application as it
executes an interrupt when timercounter
exceeds the value of TOP value which is not
desirable in pwm motor control
Registers in TIMER1
COM1A1:0 compare output mode for channel A
COM1B1:0 compare output mode for channel B
This four cells controls the functionality output compare
pins (OC1A and OC1B) respectively.
Before using this register corresponding compare pins
should be assigned as output pins using DDR register
The operation being performed according to the value
given to bits varies with the mode of pwm we are using
• FOC1A:force output compare for channel A
• FOC1B:force output compare for channel B
• When this cells are assigned as logic one the
CPU is forced to do operations based on the
setting given according to the last four bits of
TCCR1A register. It is generally preferred to
assign them as logic zero for satisfactory
operation.
TCCR1B register
CS10:2 :-These three bits are clock select bits which are used
to select the timer frequency for the timer(i.e, prescalar)
Prescalar selection
• WGM13:0 :-This is generally used to select the
mode of operation of pwm based on which
waveform is generated by waveform
generator.
• ICNC1(Input capture noise canceller): when
this is activated the filtering of input at ICP1
takes place and due to this there is delay in
output for four cycles
• ICES1(Input capture edge select):when the cell
is assigned as one then ICR1 is made equal to
counter value at the rising edge on the pin
ICP1.
• If it is assigned as zero then the ICR1 is made
equal to counter value at the falling edge on
pin ICP1
TIMSK(Timer interrupt mask register)
OCIE1A:when this value of bit is written as one , then
only an interrupt is executed when the counter value
reaches the OCR1A value
OCIE1B(output compare interrupt enable):similar to
functioning of cell OCIE1A for TCCR1B
TIFR(Timer interrupt flag register)
OCF1A:The cell is automatically set to one when OCR1A
matches with TCNT1 and it is automatically erased when the
interrupt is executed
OCF1B:The functionality is similar to OCF1A which is done in
TCNT1 matches with OCR1B
Output pins of timers in ATMEGA8
Calculation of OCR1A
• Value of OCR1A=(timer frequency)/(required
frequency at which interrupts are to be
executed)

More Related Content

What's hot

8086 Microprocessor
8086 Microprocessor 8086 Microprocessor
8086 Microprocessor Vijay Kumar
 
Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6Ananda Gopathoti
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersCorrado Santoro
 
8051 Timers / Counters
8051 Timers / Counters8051 Timers / Counters
8051 Timers / CountersPatricio Lima
 
Pwm(Pulse Width Modulation) presentation
Pwm(Pulse Width Modulation) presentationPwm(Pulse Width Modulation) presentation
Pwm(Pulse Width Modulation) presentationHabitamuAsimare
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionDr. Pankaj Zope
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
Pipelining approach
Pipelining approachPipelining approach
Pipelining approachGopinathD17
 
Module 2 ARM CORTEX M3 Instruction Set and Programming
Module 2 ARM CORTEX M3 Instruction Set and ProgrammingModule 2 ARM CORTEX M3 Instruction Set and Programming
Module 2 ARM CORTEX M3 Instruction Set and ProgrammingAmogha Bandrikalli
 
Phase Locked Loop (PLL)
Phase Locked Loop (PLL)Phase Locked Loop (PLL)
Phase Locked Loop (PLL)Debayon Saha
 
Embedded Systems - Training ppt
Embedded Systems - Training pptEmbedded Systems - Training ppt
Embedded Systems - Training pptNishant Kayal
 
Bus Structure, Memory and I/O Interfacing
Bus Structure, Memory and I/O InterfacingBus Structure, Memory and I/O Interfacing
Bus Structure, Memory and I/O InterfacingHetauda City College
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...Shrishail Bhat
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller918007165995
 

What's hot (20)

Lecture 2 timers, pwm, state machine IN PIC
Lecture 2   timers, pwm, state machine IN PIC Lecture 2   timers, pwm, state machine IN PIC
Lecture 2 timers, pwm, state machine IN PIC
 
8086 Microprocessor
8086 Microprocessor 8086 Microprocessor
8086 Microprocessor
 
Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F Microcontrollers
 
8051 Timers / Counters
8051 Timers / Counters8051 Timers / Counters
8051 Timers / Counters
 
Pwm(Pulse Width Modulation) presentation
Pwm(Pulse Width Modulation) presentationPwm(Pulse Width Modulation) presentation
Pwm(Pulse Width Modulation) presentation
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb Instruction
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
SRAM Design
SRAM DesignSRAM Design
SRAM Design
 
Pipelining approach
Pipelining approachPipelining approach
Pipelining approach
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Module 2 ARM CORTEX M3 Instruction Set and Programming
Module 2 ARM CORTEX M3 Instruction Set and ProgrammingModule 2 ARM CORTEX M3 Instruction Set and Programming
Module 2 ARM CORTEX M3 Instruction Set and Programming
 
Phase Locked Loop (PLL)
Phase Locked Loop (PLL)Phase Locked Loop (PLL)
Phase Locked Loop (PLL)
 
Embedded Systems - Training ppt
Embedded Systems - Training pptEmbedded Systems - Training ppt
Embedded Systems - Training ppt
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
Bus Structure, Memory and I/O Interfacing
Bus Structure, Memory and I/O InterfacingBus Structure, Memory and I/O Interfacing
Bus Structure, Memory and I/O Interfacing
 
8 bit microcontroller
8 bit microcontroller8 bit microcontroller
8 bit microcontroller
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 

Viewers also liked

Introduction to Atmel's 8-bit AVR Microcontrollers
Introduction to Atmel's 8-bit AVR Microcontrollers Introduction to Atmel's 8-bit AVR Microcontrollers
Introduction to Atmel's 8-bit AVR Microcontrollers Premier Farnell
 
Arm assembly language by Bournemouth Unversity
Arm assembly language by Bournemouth UnversityArm assembly language by Bournemouth Unversity
Arm assembly language by Bournemouth UnversityStephan Cadene
 
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...Mikhail Vink
 
pulse width modulation pwm | Communication Systems
pulse width modulation pwm | Communication Systemspulse width modulation pwm | Communication Systems
pulse width modulation pwm | Communication SystemsLearn By Watch
 
Speed Control of DC Motor under Varying Load Using PID Controller
Speed Control of DC Motor under Varying Load Using PID ControllerSpeed Control of DC Motor under Varying Load Using PID Controller
Speed Control of DC Motor under Varying Load Using PID ControllerCSCJournals
 
Temperature Controller with Atmega16
Temperature Controller with Atmega16Temperature Controller with Atmega16
Temperature Controller with Atmega16Siddhant Jaiswal
 
pulse width modulated inverter techniques
pulse width modulated inverter techniquespulse width modulated inverter techniques
pulse width modulated inverter techniquesSAURABH KUMAR
 
Advanced techniques of PULSE WIDTH MODULATION.
Advanced techniques of PULSE WIDTH MODULATION.Advanced techniques of PULSE WIDTH MODULATION.
Advanced techniques of PULSE WIDTH MODULATION.Subashini Puchalapalli
 
Sine Pulse Width Modulation Inverter
Sine Pulse Width Modulation InverterSine Pulse Width Modulation Inverter
Sine Pulse Width Modulation InverterAditya Parmar
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 prsamurti
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVRDaksh Raj Chopra
 
MPPT Based Optimal Charge Controller in PV system
MPPT Based Optimal Charge Controller in PV systemMPPT Based Optimal Charge Controller in PV system
MPPT Based Optimal Charge Controller in PV systemMalik Sameeullah
 
maximum power point tracking (mppt)
maximum power point tracking (mppt)maximum power point tracking (mppt)
maximum power point tracking (mppt)Shashikumar Jeevan
 

Viewers also liked (20)

Introduction to Atmel's 8-bit AVR Microcontrollers
Introduction to Atmel's 8-bit AVR Microcontrollers Introduction to Atmel's 8-bit AVR Microcontrollers
Introduction to Atmel's 8-bit AVR Microcontrollers
 
Arm assembly language by Bournemouth Unversity
Arm assembly language by Bournemouth UnversityArm assembly language by Bournemouth Unversity
Arm assembly language by Bournemouth Unversity
 
Pulse width-modulation
Pulse width-modulationPulse width-modulation
Pulse width-modulation
 
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...
Elvira I. Baygildina, "Matrix frequency converter based on full-controlled IG...
 
pulse width modulation pwm | Communication Systems
pulse width modulation pwm | Communication Systemspulse width modulation pwm | Communication Systems
pulse width modulation pwm | Communication Systems
 
Speed Control of DC Motor under Varying Load Using PID Controller
Speed Control of DC Motor under Varying Load Using PID ControllerSpeed Control of DC Motor under Varying Load Using PID Controller
Speed Control of DC Motor under Varying Load Using PID Controller
 
Temperature Controller with Atmega16
Temperature Controller with Atmega16Temperature Controller with Atmega16
Temperature Controller with Atmega16
 
Data logger
Data loggerData logger
Data logger
 
Chapter 6 edit
Chapter 6 editChapter 6 edit
Chapter 6 edit
 
pulse width modulated inverter techniques
pulse width modulated inverter techniquespulse width modulated inverter techniques
pulse width modulated inverter techniques
 
Advanced techniques of PULSE WIDTH MODULATION.
Advanced techniques of PULSE WIDTH MODULATION.Advanced techniques of PULSE WIDTH MODULATION.
Advanced techniques of PULSE WIDTH MODULATION.
 
Sine Pulse Width Modulation Inverter
Sine Pulse Width Modulation InverterSine Pulse Width Modulation Inverter
Sine Pulse Width Modulation Inverter
 
AT mega8 basics
AT mega8 basicsAT mega8 basics
AT mega8 basics
 
Timers
TimersTimers
Timers
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 p
 
Advance Microcontroller AVR
Advance Microcontroller AVRAdvance Microcontroller AVR
Advance Microcontroller AVR
 
Ccna complete notes
Ccna complete notesCcna complete notes
Ccna complete notes
 
555 timer ppt by vishnu
555 timer ppt by vishnu555 timer ppt by vishnu
555 timer ppt by vishnu
 
MPPT Based Optimal Charge Controller in PV system
MPPT Based Optimal Charge Controller in PV systemMPPT Based Optimal Charge Controller in PV system
MPPT Based Optimal Charge Controller in PV system
 
maximum power point tracking (mppt)
maximum power point tracking (mppt)maximum power point tracking (mppt)
maximum power point tracking (mppt)
 

Similar to Timers and pwm

timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptxSujalKumar73
 
What isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationWhat isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationOmar BOUZOURRAA
 
Enhanced phase width modulation in TMS320F28335D
Enhanced phase width modulation in TMS320F28335DEnhanced phase width modulation in TMS320F28335D
Enhanced phase width modulation in TMS320F28335DSatya Sahoo
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programmingMohamed Ali
 
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...Waqas Afzal
 
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSPIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSVISHNU KP
 
20ME702– MECHATRONICS -UNIT-4.ppt
20ME702– MECHATRONICS -UNIT-4.ppt20ME702– MECHATRONICS -UNIT-4.ppt
20ME702– MECHATRONICS -UNIT-4.pptMohanumar S
 

Similar to Timers and pwm (20)

PWM in ARM LPC2148.pptx
PWM in ARM LPC2148.pptxPWM in ARM LPC2148.pptx
PWM in ARM LPC2148.pptx
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptx
 
What isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationWhat isn’t told about timers in stm32 application
What isn’t told about timers in stm32 application
 
AVRTIMER.pptx
AVRTIMER.pptxAVRTIMER.pptx
AVRTIMER.pptx
 
8051e
8051e8051e
8051e
 
Enhanced phase width modulation in TMS320F28335D
Enhanced phase width modulation in TMS320F28335DEnhanced phase width modulation in TMS320F28335D
Enhanced phase width modulation in TMS320F28335D
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programming
 
PLC PPT.ppt
PLC PPT.pptPLC PPT.ppt
PLC PPT.ppt
 
Microcontroller part 3
Microcontroller part 3Microcontroller part 3
Microcontroller part 3
 
Lpc 1768 timers
Lpc 1768 timersLpc 1768 timers
Lpc 1768 timers
 
PLC.pdf
PLC.pdfPLC.pdf
PLC.pdf
 
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
 
digital Counter
digital Counterdigital Counter
digital Counter
 
Timing & Control.pptx
Timing & Control.pptxTiming & Control.pptx
Timing & Control.pptx
 
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSPIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
 
ie450pp10.ppt
ie450pp10.pptie450pp10.ppt
ie450pp10.ppt
 
plc1.ppt
plc1.pptplc1.ppt
plc1.ppt
 
PLC Basics
PLC BasicsPLC Basics
PLC Basics
 
PCM-Part 1.pptx
PCM-Part 1.pptxPCM-Part 1.pptx
PCM-Part 1.pptx
 
20ME702– MECHATRONICS -UNIT-4.ppt
20ME702– MECHATRONICS -UNIT-4.ppt20ME702– MECHATRONICS -UNIT-4.ppt
20ME702– MECHATRONICS -UNIT-4.ppt
 

Recently uploaded

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Recently uploaded (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

Timers and pwm

  • 2. Why use pwm? • Generally all microcontrollers are provided with analogue to digital converter to convert analogue values to digital values. But there is no such thing like DAC’s in AVR’s. In such case pwm is closest solution. • It is used generally for light dimmer controls and motor speed controls by varying it’s dutycycle
  • 3. • Dutycycle: It is defined as duration for which waveform is in active state to the total time under consideration • Dutycycle=(t/T) • t=time for which waveform is in active state • T=timeperiod of waveform • Outputvoltage=(dutycycle)*(input voltage)
  • 4. Simple pwm generator • A simple wave generator(may be triangular , ramp etc.) can be combined with a comparator to generate pwm. • By varying the value of input given to negetive terminal of comparator waveforms of different timeperiod are obtained. • They are used in applications like servos which require a pulse of time period of 2.5ms
  • 6. • Comparator used to vary only duty cycle, then how to change time period of the output signal? • This is possible using timers and based on microcontroller number of timers and pwm channels varies and generally the value which we give for comparison is also given through timers.
  • 7. Timer • Timer: There are two types of timers present in ATMEGA16 and ATMEGA8: • 1.8bit timer-(0-255) • 2.16 bit timer-(0-65535) • It’s value increases at a predetermined rate known as timerclock (given by user) which is free from cpu’s intervention
  • 8. Basic concepts of timer • Prescalar : It is the constant with which clock frequency is to be divided to get desired timer frequency • Prescalar = clock frequency/desired timer frequency. • Generally prescalars are available in multiples of 2 i.e, 1,8,32,64,128,1024 • If any timer has multiple pwm channels then they share same value of prescalar.
  • 9. • Interrupt:When the timer counter reaches a specific value then CPU stops it’s normal functioning and executes the action which is given in terms of interrupt • Syntax for interrupt service routine(ISR) • ISR(TIMER1_COMP_VECT) • { • }
  • 10. Basic registers in timer • In the previous waveforms the compare value is given by OCRX(output compare register) and top value is given by ICRX(Input capture register) and each timer is provided separate counters and they are designated by TCNTX and X indicates the timer which is being used.
  • 11. Inputs and outputs of timer in pwm operation
  • 12. Clock: • This is either the speed of any external crystal you have used or the internal clock speed of your microcontroller. When you compile your program you normally (in AVRlib) have to set the F_CPU variable to this value. Obviously there is only one clock speed per microcontroller. • Compare: • This value is generally given as register variable to the timer
  • 13. • PWM out: The number of pwm channels are nothing but pwm output pins , whose number depend on microcontroller. • For example ATMEGA8 has 3 channels
  • 14. Things to be considered before pwm operation • Bits of accuracy • Modes of pwm • Compare output mode • Modes of pwm • 1.fast pwm • 2.phase correct pwm • 3.phase and frequency correct pwm
  • 16. Phase correct and phase and frequency correct pwm • There is no general difference between this two types of pwm • But there is difference compared to first type as in this type a triangular waveform generator is used which increases time period by two times when compared to previous method
  • 18. Input and Output waveform
  • 19. Bits of accuracy • This refers to possible range of values for comparator are possible based on TOP value • If the TOP value is 7 then it is possible to get 8 different values from 0-7 so the bits of accuracy is 3.
  • 20. Compare output modes • Pwm turned off • Inverted pwm • Non inverted pwm • Toggle pwm • The first mode is self explanaratory
  • 21. • Inverted pwm: It will set output pins high when counter value is greater than comparator value • Non inverted pwm: It will set output pin low when counter value is greater than comparator value • Toggle pwm: It will toggle the output pin when counter value reaches comparator value
  • 22. Timers in ATMEGA8 • TIMER0 • TIMER1: • TCCR1A,TCCR1B • TIMER2 • Timer0 is not used for pwm application as it executes an interrupt when timercounter exceeds the value of TOP value which is not desirable in pwm motor control
  • 23. Registers in TIMER1 COM1A1:0 compare output mode for channel A COM1B1:0 compare output mode for channel B This four cells controls the functionality output compare pins (OC1A and OC1B) respectively. Before using this register corresponding compare pins should be assigned as output pins using DDR register The operation being performed according to the value given to bits varies with the mode of pwm we are using
  • 24. • FOC1A:force output compare for channel A • FOC1B:force output compare for channel B • When this cells are assigned as logic one the CPU is forced to do operations based on the setting given according to the last four bits of TCCR1A register. It is generally preferred to assign them as logic zero for satisfactory operation.
  • 25. TCCR1B register CS10:2 :-These three bits are clock select bits which are used to select the timer frequency for the timer(i.e, prescalar)
  • 27. • WGM13:0 :-This is generally used to select the mode of operation of pwm based on which waveform is generated by waveform generator. • ICNC1(Input capture noise canceller): when this is activated the filtering of input at ICP1 takes place and due to this there is delay in output for four cycles
  • 28. • ICES1(Input capture edge select):when the cell is assigned as one then ICR1 is made equal to counter value at the rising edge on the pin ICP1. • If it is assigned as zero then the ICR1 is made equal to counter value at the falling edge on pin ICP1
  • 29. TIMSK(Timer interrupt mask register) OCIE1A:when this value of bit is written as one , then only an interrupt is executed when the counter value reaches the OCR1A value OCIE1B(output compare interrupt enable):similar to functioning of cell OCIE1A for TCCR1B
  • 30. TIFR(Timer interrupt flag register) OCF1A:The cell is automatically set to one when OCR1A matches with TCNT1 and it is automatically erased when the interrupt is executed OCF1B:The functionality is similar to OCF1A which is done in TCNT1 matches with OCR1B
  • 31. Output pins of timers in ATMEGA8
  • 32. Calculation of OCR1A • Value of OCR1A=(timer frequency)/(required frequency at which interrupts are to be executed)