SlideShare uma empresa Scribd logo
1 de 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)

Mais conteúdo relacionado

Mais procurados

Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processorRAMPRAKASHT1
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionDr. Pankaj Zope
 
Case Study of Embedded Systems
Case Study of Embedded SystemsCase Study of Embedded Systems
Case Study of Embedded Systemsanand hd
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architectureDr.YNM
 
Interfacing external memory in 8051
Interfacing external memory in 8051Interfacing external memory in 8051
Interfacing external memory in 8051ssuser3a47cb
 
Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberasodariyabhavesh
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller Gaurav Verma
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...manishpatel_79
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Dhaval Kaneria
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontrollerAshish Ranjan
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailedAnkita Tiwari
 

Mais procurados (20)

ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processor
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb Instruction
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
Case Study of Embedded Systems
Case Study of Embedded SystemsCase Study of Embedded Systems
Case Study of Embedded Systems
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Interfacing external memory in 8051
Interfacing external memory in 8051Interfacing external memory in 8051
Interfacing external memory in 8051
 
Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furber
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Unit vi (1)
Unit vi (1)Unit vi (1)
Unit vi (1)
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 

Destaque

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
 

Destaque (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
 
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
 

Semelhante a 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
 

Semelhante a 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
 

Último

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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)