Home
Pulse Width Modulation
Contents
1. ELET 3232 Topic 19 Timer Counter with PWM objectives To understand the operation of an 8 bit timer counter in an AVH microcontroller o understand how to use the timer counter to generate a PWM signal understand how PWM signals are used to control servo motors o Position control o Speed control 11 29 2010 Modes of Operation Four modes of operation for Timer Counter O o Normal Mode we have used this mode to develop timing loops o Phase Correct PWM he mode we will use in PWM o CIC Mode Clear Timer on Compare Match o Fast PWM Fast Pulse Width Modulation 11 29 2010 3 Modes of Operation s We will discuss o Normal Mode on Timer Counter 8 bit counter s we have used this mode to develop timing loops o Phase Correct PWM on Timer Counter O he mode we will use in PWM o Phase Correct PWM on Timer Counter 1 A 16 bit Timer Counter 11 29 2010 Normal Mode Example Timing Loop Idi r16 0x07 set the prescaler for the counter out TCCRO r16 prescaler 1024 ATmega128 initialize timer counter 0 TCNTO r16 starts the counter r17 TCNTO read timer counter value r17 0x63 is it 63 if not 63 read it again until 63 11 29 2010 5 Normal Mode CCHO r16 0x07 set the prescaler for the counter TCCRO r16 prescaler 1024 ATmega128 Step 1 Initialize the Timer Counter initialize timer counter 0 TCNTO r16 starts the counter r1
2. 128 o 16MHz System Clock o 50Hz Timer Clock ms 0 1 5ms 90 2ms 180 11 29 2010 Setup using CodeVision P CodeWizardAVR untitled cwp File Help External IAG Timers USARTO USART Analog Comparator ADC SFI 2 1 Wire 2 Wire 2 LCD Bit Banged Project Information Chip External SAAM Forts A Chip ATmegal28 Clock 16 000000 Crystal Oscillator Divider Enabled Check Reset Source Program Application 11 29 2010 Select the ATmega chip and the frequency Setup using CodeVision 11 29 2010 amp CodeWizardAVR untitled cwp E9 File Help Analog Comparator ADC SFI 1 2 Wire Chip External Ports External IAG Timers USARTO USARTI Timer 2 Timer3 Bit Banged Project Information Clock Source System Clack v Clock Value Timer 1 Stopped Mode Normal tap FFFFh Input Capt Noise Cancel Interrupt Timer 1 Overfloyy Vale 0 h Inp Capture 0 ul Ss Comp amp 0 h Bjo jh Co Select the ATmega chip and the frequency Click on the Timers tab and then on the Timer tab 63 Setup using CodeVision E CodeWizardAVR untitled File Help Analog Comparator ADC 1 wire 2 Wire I2 Bit Banged Project Information Chip External SRAM For
3. Initial Timer Counter value is 0 gets the counter started Then it will count down to 0 then up to some maximum then down to 0 etc 11 29 2010 23 Phase Correct PWM The Timer Counter will count up to OxFF Max mnl The timer will count up eventually getting to the value in OCRO It will then continue to count to OxFF and then start counting down eventually getting to the value in OCRO again then continuing its count down to 0 11 29 2010 Phase Correct PWM The Timer Counter will count up to OxFF Max 2 Output signal l Every time the Timer Counter gets to the value in OCRO the output on toggles 11 29 2010 Phase Correct PWM The Timer Counter will count up to OxFF Max 2 Output signal on Non inverted Every time the Timer Counter gets to the value in OCRO the output toggles Setting the COM01 0 bits in TCCRO to 2 will produce a non inverted PWM An inverted PWM output can be generated by setting the COM01 0 to 11 29 2010 Calculations he big questions o How do we calculate the values How do we calculate which prescaler value to use How do we calculate the value s Lets assume we are using the positioning servo motor shown on the next page 11 29 2010 2 DC Servo Motor Control ht
4. OCR1A 1000 OCRIBH 0x00 OCRIBL 0x00 OCRICH 0x00 OCRICL x 70 Setup using CodeVision This will position the servo motor while 1 OCRIA 1000 position the servo to the left 0 degrees delay ms 5000 delay for 5 seconds OCRIA 2000 position the servo to the right 180 degrees delay ms 5000 delay for 5 seconds 11 29 2010 71 Summary a In this topic we discussed o The operation of an 8 bit timer counter in an AVR microcontroller o How to use the timer counter to generate a PWM signal o How PWM signals are used to control servo motors s Position control s Speed control 11 29 2010
5. this example assume a 16MHz system clock and that we want a 20ms period t 50Hz We need to calculate the value for TOP fociPwu 2 N oOo __ 2 N 11 29 2010 1 Generating PWM signals using Timers in the chip mil ufl Calculations For this example TOP could be Prescaler N 1 then TOP ICR1 160000 Prescaler N 8 then TOP ICR1 20000 Prescaler N 64 then TOP ICR1 2500 Prescaler N 256 then TOP ICR1 625 Prescaler N 1024 then TOP ICR1 156 25 11 29 2010 58 Calculations For this example TOP could be Prescaler N 8 then TOP ICR1 20000 Prescaler N 64 then TOP ICR1 2500 Prescaler N 256 then TOP ICR1 625 You cannot use prescaler or 1024 to generate a 50 Hz PWM witha 16 MHz system clock Prescaler cannot be used since 160000 too large to fit in TCRI TCRI is a 16 bit register with a range from to 65535 Prescaler 1024 should not be used since you cannot put decimals into ICRI although you could approximate with 156 11 29 2010 Calculations Chambers suggests o A prescaler of 8 o Set ICH1 to 20000 a his will allow you to change OCH1A 11 29 2010 between 1000 and 2000 to obtain 1 2 ms high pulses o Simple even numbers 1 Generating PWM signals using Timers in the ATMega chip http mil ufl edu achamber servoPWMfaq html Setup using CodeVision For this example o ATmega
6. 7 TCNTO read timer counter value We are most concerned with bits 2 r17 0x63 is it 63 1 and 0 They control the prescaler if not 63 read it again until 63 Timer Counter Control Hegister TCC HO Bit 7 5 4 3 2 1 0 wGMoo 1 comoo WGMO1 csoz CS0 TCCRO Ww R N R N S00 FieadWnte RW Fay Fa RAW Initial Value 0 0 11 29 2010 6 Normal Mode CCHO Table 56 Clock Select Bit Description o o eyestrompesaen OOOO w i 128 From prescaler abs EN 1 _1_ 024 From prescaler J Timer Counter Control Register TCCRO Bit FieadWnte Initial Value 11 29 2010 We can turn off the counter We can use the system clock or We can use a slower signal based on the system clock Normal Mode CCHO Figure 42 Timer Counter Timing Diagram di TIL System Clock assume 10MHz If we used the system clock no prescaling to increment the counter it would be incremented every 100ns T 1 f 1 10MHz 100ns Timer Counter Control Register TCCRO Bit W n RAW FW RAW RAW FW RAN FieadWnte Initial Value D 11 29 2010 8 Normal Mode CCHO Figure 42 with Prescaler fako il JUI Ul system Clock assume 10 clk clk 8 If we used prescaler of 8 to d usd om omm me increment the counter
7. 9 2010 35 Speed Control ADC motor needs a voltage and current to make it rotate 11 29 2010 37 for Speed Control A voltage it rotates faster 5v Lower voltage it rotates slower 11 29 2010 for Speed Control But the AVR will output 5v or not 1 5 or 3 2 etc a Are we limited to full soeed or stop for Speed Control But the AVR will output 5v or not 1 5 or 3 2 etc a What is the approximate average voltage of the waveform below assume 50 duty cycle for Speed Control But the AVR will output 5v or not 1 5 or 3 2 etc a What is the approximate average voltage of the waveform below assume 50 duty cycle for Soeed Control We change the average voltage of the PWM signal by changing the value in OCRO Output 11 29 2010 42 for Speed Control If we increase the value in OCHO the average voltage increases Output Output zl m 11 29 2010 43 Speed Control A change in the duty cycle will change the average voltage and therefore the speed of the motor Speed Direction Control for the 311 Direction for motor M1 PD5 PD6 1 2 3 4 M1 0 0 off off off off off coast Forward 0 1 off on on off forward 1 0 on off of on reverse 1 1 off off on on off brake VBOOST VCC ey Reverse TB6612F
8. J21 5 c 0 voltage V motor speed opeed Direction Control for the Speed Control 4 _ 8 i D 4 In the 3 1 speed control is accomplished using special PWM in outputs of the main microcontroller that are linked to the internal he 0 timers Timer0 and Timer2 This means that you can set PWM duty cycle of the two motors once and the hardware will continue time ms to produce the PWM signal in the background without any further PWM speed control showing gradual attention deceleration The set_motors function in the Pololu AVR Library see Section 6 a for more information lets you set the duty cycle and it uses 8 bit precision a value of 255 corresponds to 100 duty cycle For example to get 67 on M1 and 33 on 2 you would call 3 Note 171 67 of 255 and 84 33 of 255 set_motors 171 84 11 29 201 3 From the Pololu 3Pi User s manual http www pololu com docs 0J21 5 c 0 opeed Direction Control for the Speed Control 4 _ 8 i D 4 In the 3 1 speed control is accomplished using special PWM in outputs of the main microcontroller that are linked to the internal he 0 timers Timer0 and Timer2 This means that you can set PWM duty cycle of the two motors once and the hardware will continue time ms to produce the PWM signal in the background without any further PWM speed control showing grad
9. NG motor driver and motors 11 29 2010 45 C28 0 1 uF Speed Direction Control for the 311 Direction for motor M2 PD3 PB3 1 2 3 4 2 0 0 off off off off off coast Forward 0 1 off on off forward 1 on off off on reverse 1 1 off off on on off brake VBOOST VCC ey Reverse TB6612FNG motor driver and motors C28 0 1 uF 11 29 2010 Speed Direction Control for the 311 10 PWM signal RM 8 22 5 N 0 N 0 0 5 10 15 20 time ms PWM speed control showing gradual deceleration Speed Control Speed control is achieved by rapidly switching the motor between two states in the table Suppose we keep PD6 high at 5 V also called a logical 1 and have PD5 alternate quickly between low 0 V or 0 and high The motor driver will switch between the forward and brake states causing M1 to turn forward at a reduced speed For example if PD6 is high two thirds of the time a 67 duty cycle then M1 will turn at approximately 67 of its full speed Since the motor voltage is a series of pulses of varying width this method of speed control is called pulse width modulation PWM An example series of PWM pulses is shown in the graph at right as the size of the pulses decreases from 100 duty cycle down to 0 the motor speed decreases from full speed down to a stop 11 29 201 3 From the Pololu 3Pi User s manual http www pololu com docs 0
10. VR Project Board AVR JTAG GPS Simulator and Trainer DIY Projects DIY Projects gt DC Servo Motor Control The R C Servo Motors are used in model aircraft R C Truc R C motorboats and robots Radio Control Servo motors are position servo syst fns that are controlled digitally through PWM The usual range is about 180 degrees The connections to the motor are Interface 5x7 dotmatrix LED Display A typical Servo looks like below Minimum Pulse Digital RPM Meter for Automobiles Incremental Encoder Interface Technical Notes Neutral Position Downloads Sales The PWM signal to control the position should have a pulse duration between 10 30 msec and the on time determin Promotions position of servo A 1 5 msec on time makes the Servo position at the middle the pulse is given below Contacts Renister http www digisoft com pki amp Internet S 100 11 29 2010 Text LCD On Project um 1 GND Black TOME raphic 2 VCC Red Controller 3 Control White Swipe Card Reader 3 pins Gnd Vcc and Control The PWM signal should have a period of 10 to 30ms A pulse 0f 1 5ms sets the neutral position 90 1ms sets the left position 0 and 2ms sets the right position 180 k Period 20 ms Pulse Width 1 ms min 2 ms max BB dl oF Pulse Width 1 ms 56 Calculations For
11. WM We will need the following registers o TCCRO Timer Counter Control Register 0 To initialize the Timer Counter and set the prescaler o Timer Counter 0 hold the value of the counter o Output Compare Register O Holds the count value for which the PWM signal will toggle 11 29 2010 Phase Correct PWM Initial Timer Counter value is 0 gets the counter started 11 29 2010 Phase Correct PWM Max And starts counting up N Initial Timer Counter value is 0 gets the counter started 11 29 2010 18 Phase Correct PWM The Timer Counter will count up to OxFF Max mdi N Initial Timer Counter value is 0 gets the counter started 11 29 2010 19 Phase Correct PWM The Timer Counter will count up to OxFF Max 2 N Then it will count down to 0 Initial Timer Counter value is 0 gets the counter started 11 29 2010 20 Phase Correct PWM 7 The Timer Counter will count up to OXFF N Then it will count down to 0 then up to some maximum Initial Timer Counter value is 0 gets the counter started 11 29 2010 21 Phase Correct PWM 7 The Timer Counter will count up to OXFF N Then it will count down to 0 then up to some maximum then down to 0 Initial Timer Counter value is 0 gets the counter started 11 29 2010 22 Phase Correct PWM Timer Counter will count up to OxFF TAA
12. al Position Downloads Sales The PWM signal to control the position should have a pulse duration between 10 30 msec and the on time determin Promotions position of servo A 1 5 msec on time makes the Servo position at the middle the pulse is given below Contacts Renister http www digisoft com pki amp Internet S 100 11 29 2010 Text LCD On Project um 1 GND Black TOME raphic 2 VCC Red Controller 3 Control White Swipe Card Reader 3 pins Gnd Vcc and Control The PWM signal should have a period of 10 to 30ms A pulse 0f 1 5ms sets the neutral position 90 1ms sets the left position 0 and 2ms sets the right position 180 k Period 20 ms Pulse Width 1 ms min 2 ms max BB dl oF Pulse Width 1 ms 29 Calculations o calculate the prescaler the AT Mega data sheet gives the following formula pg102 Calculations o calculate the prescaler the AT Mega data sheet gives the following formula pg102 N 510 Assuming we have a system clock of 1OMHz and we are using prescaler of 1024 we would have 10x10 foco NL y 1024 510 foco foco 19 15 Hz Toco 52 2ms Too high 11 29 2010 i Calculations o calculate the prescaler the AT Mega data sheet gives the following formula pg102 N 510 Assuming we have a system clock of 1OMHz and we are using a pr
13. ame three files the c file the prj file and the cwp file Setup using CodeVision ff Timer Counter 1 initialization 47 Clock Source System Clock 77 Clock value FO00_000 EHZ 77 Mode Ph correct PUM top ICEl This is the section of code generated by CodeVision output Hon Inv output Dizcon OCLC output Dizcon Noise Canceler Off Input Capture on Falling Edge Timer Overflow Interrupt Off Input Capture Interrupt Off Compare A Match Interrupt Off Compare B Match Interrupt Compare C Match Interrupt TCCRLA xSz TCCRIB xlz TCNTlIH x TCNTlL 2 x 0 4 OCRLAH Ox03 O OCRIBH x OCRIBL O0x00 OCRICH 0x00 OCBRICL Ox00 Note decimal values could be entered here instead of the hex values in the wizard if ff Clock source System Clock 77 Clock value 2000 000 ff Mode Ph amp fr cor PWM top ICRl ff output Hon Inv ff output Discon ff output Discon 77 Moise Canceler Off 77 Input Capture on Falling Edge ff Timer 1 Owerflow Interrupt Off 77 Input Capture Interrupt Off 77 Compare Match Interrupt Off 77 Compare B Match Interrupt Off 77 Compare Match Interrupt Off TCCBRLA O0x80 TCCBRLB Oxl TCNTLH 0x00 TCNTLL 0Ox00 Tiner Counter 1 initialization 0000
14. ave a pulse duration between 10 30 msec and the on time determines the Promotions position of servo A 1 5 msec on time makes the Servo position at the middle the pulse is given below Contacts Renicster http www digisoft com pkJ amp Internet 100 11 29 2010 2 DC Servo Motor Control http www digisoft com pk Projects dc servo motor control File Edit View Favorites Tools Help x Google position servo motor og Ej Bookmarksy 253 Yr Check Autolink 5 E Suggested Sites Web Slice Gallery M E http www coe uncc eduj TE DC Servo Motor Control X AutoFill m Sendtow 22 Settings sly Favorites desktop ini fp Cl mm Page Safety Home Products AVR Project Book AVR Project Board AVR JTAG GPS Simulator and Trainer DIY Projects DIY Projects gt DC Servo Motor Control The R C Servo Motors are used in model aircraft R C Truc R C motorboats and robots Radio Control Servo motors are position servo syst fns that are controlled digitally through PWM The usual range is about 180 degrees The connections to the motor are Interface 5x7 dotmatrix LED Display A typical Servo looks like below Minimum Pulse Digital RPM Meter for Automobiles Incremental Encoder Interface Technical Notes Neutr
15. escaler of 1024 we would have 6 hoc 10 10 256 5 0 foco 76 59 Hz Toco 13 05 ms foco 11 29 2010 32 Calculations a If we had a system clock of 16MHZ we would have 16x10 foco 1024 510 foco 30 63 Hz Toco 32 64ms A little too long But let s go back to the 1OMHz system clock and the 77Hz 13ms period clock 11 29 2010 33 Phase Correct PWM Max Output signal on A Non inverted It s probably easier to use a non inverted signal Set COMO01 0 to 2 in TCCRO CS02 0 to 7 for a prescaler of 1024 WGM01 to 0 and WGM00 to 1 for PC PWM Timer Counter Control 5 4 3 2 0 Register TCCRO Bit 7 6 TCCRO RAW RW RW RAW RW RW RW k W 0 0 0 Initial salue 11 29 2010 Phase Correct PWM Max Output signal on Non inverted A full count from to Max down to 0 through and then back up to OCRO would be one cycle highlighted above This represents a count of 256 twice or a count to 512 which represents 13ms 1 77Hz so e acount to 40 represents about 1 ms 07 count from 20 down to 0 and up to 20 total of 40 OCR0 20 e acount to 59 represents about 1 5ms 90 count from 30 down to 0 and then up to 30 total of 60 OCRO 30 acount to 78 represents about 2ms 180 count from 39 down to 0 and up to 39 iia of 78 OCRO 39 11 2
16. g Out A Out B and Out C 1 wire 2 Wire BitBanc Bit Banged Project Information Chip _ External SRAM Ports We are only going to control one servo to start off ExtemallRG Timers USARTO USART TmerT lala Select Non Inv from the Out A pull down menu Clock Source System Clock Note If this option isn t shown you chose the wrong selection under Mode Clock Value 2000000kHz Dut A v Dut Discon Dut E Ea Value h Inp Capture O oh Comp amp 0 h Jh cjo D h 11 29 2010 66 Setup usin using CodeVision CodeWizardAVR untitled cwp Fle Help Input Capture is the ICRI value and allows you to set the Analog Comparator ADC SPI 120 TOP value for the timer dwie 2wi ell2c LCD Bit Banged Project Information Chip ExtemalSRAM Pots We are going to use ICRI 20000 to generate a 50 Hz ExtemallR Timers LISARTO USART signal Timer 0 Timer Timer 2 Timer3 CodeWizard requires you to enter the value in HEX 20 000 Clock Source System Clock 4E20 Clock Value 2000 000 kHz v It could be left blank and changed manually in the code Mode Ph correct PWM top ICR1 corect Pw Ph correct PWM top ICRT v RI 8 OCRIA allows you to set the position of the servo Out Discon CodeWizard requires you to enter the value in HEX It could be left b
17. it would be TCNTn jJ BOTTOM BOTTOM 1 incremented every 8 clock pulse 8 100ns 8 800ns Timer Counter Control Register TCCRO Bit W n RAW FW RAW RAW FW RAN FieadWnte Initial Value 11 29 2010 Normal Mode CCHO Figure 42 Timing with Prescaler fako il JUI Ul system Clock assume 10 clk 78 If we used a prescaler of 1024 to d ud om omm m increment the counter it would be TCNTn jJ BOTTOM BOTTOM 1 incremented every 1024 clock pulse 1024 100ns 1024 102 4us Timer Counter Control Register TCCRO Eit W uu FW FW FieadWnte Initial Value 11 29 2010 Normal Mode Example Timing Loop 11 29 2010 r16 0x07 TCCRO r16 TCNTO r16 r17 TCNTO r17 0x63 Timer Counter Control Register TCCRO set the prescaler for the counter prescaler 1024 ATmega128 initialize timer counter 0 starts the counter read timer counter value is it 63 if not 63 read it again until 63 Bit Read rite Initial Value y W 0 Moi RAN Step 1 Initialize the Timer Counter We used a prescaler of 1024 so bits 0 7 in the Timer Counter Control Register were set to 1 S00 RAW Normal Mode Example Timing Loop 11 29 2010 r16 0x07 TCCRO r16 TCNTO r16 r17 TCNTO r17 0x63 set the prescaler for the counter prescaler 1024 ATmega128 i
18. lank and changed manually in the code Input Capt Deen Noise Cancel on Ovation 29 OCR1A 1000 0x03e8 Value oh Inp Capture 4220 h Comp 0328 hh jh 11 29 2010 67 Setup using CodeVision ay CodeWizardAVR untitled cwp 5 File Help Analog Comparator ADC 1 wire 2 Wire 2 LCD Bit Banged Project Information External IH Timers USARTO LISARTI Chip Extemal SRAM Ports Port amp Fort E Por D 41 Data Direction Fulup Output Value Bit In T Bit Bit 1 In T Bit 1 Bit2 ln Bit2 Bit3 ln T Bit 3 Bit4 In T Bir5 0 Bit 5 In TI RHE Click on bit to toggle skate Bit In 11 29 2010 Now we need to set the output pin for our servo OCRIA is the alternative port function for PORT B 5 Click the Ports tab and then the Port B tab Click on the word In to change it to Out Leave the output value at 0 Setup using CodeVision amp CodeWizardAVR untitled cwp File Help Ly Mew Oper Save da Save s a Program Preview i Generate Sawe and Exit X Exit Bit1 In Bit2 In Bit 3 In Bit4 In Bit5 Out In Bit In 11 29 2010 T Bit TJ Bit2 T T Bit4 O BES TJ T Bit Click on the File menu and select Generate Save and Exit to generate the code You will be asked the n
19. nitialize timer counter 0 starts the counter read timer counter value is it 63 if not 63 read it again until 63 Step 1 Initialize the Timer Counter Step 2 Start the Timer Counter placing a 0 in the Timer Counter Register starts it Normal Mode Example Timing Loop Idi r16 0x07 out TCCRO r16 TCNTO r16 r17 TCNTO r17 0x63 11 29 2010 set the prescaler for the counter prescaler 1024 ATmega128 initialize timer counter 0 starts the counter read timer counter value is it 63 if not 63 read it again until 63 Step 1 Initialize the Timer Counter Step 2 Start the Timer Counter Step 3 check for the calculated value In this case the Timer Counter will increment its count every 1024 clock pulses every 102 4 us This loop keeps checking until the Timer Counter gets to 99 0x63 So the timer delays for 100 102 4 us 10 24ms Note count from 0 to 99 is 100 Phase Correct PWM We will use Phase Correct PWM most of the time o PWM for short as opposed to fast CTC modes 11 29 2010 Phase Correct PWM We will need the following registers o TCCRO Timer Counter Control Register O o INCTO Timer Counter O o OCHO Output Compare Register O he generated PWM waveform will appear on the OCO pin 11 29 2010 1 Generating PWM signals using Timers in the ATMega chip http mil ufl edu achamber servoPWMfaq html Phase Correct P
20. t the prescaler o TNCT1 Timer Counter 1 hold the value of the counter ICR1 Input Compare Register 1 Holds the upper limit of our counter makes T C1 more flexible o OCH1x Output Compare Register 1 Holds the count value for which the PWM signal will toggle 11 29 2010 Phase Correct PWM The Timer Counter will count up to OXFFFF or the number in ICRI Max Output signal on Initial Timer Counter value is 0 gets the counter started Every time the Timer Counter gets to the value in OCRIx the output OC1x toggles There are three OCRIx registers OCRIA OCRIB OCRIC There are three OC1x output lines OCIB and OC1C 11 29 2010 54 Calculations o calculate the prescaler the AT Mega data sheet gives the following formula pg129 2 N TOP OP is the value in ICH 1 For this example assume a 16MHz system clock and the same servo as before fociPwu File Edit View Favorites Tools Help x Google position servo motor og Ej Bookmarksy 253 Yr Check Autolink 5 E Suggested Sites Web Slice Gallery M E http www coe uncc eduj TE DC Servo Motor Control X AutoFill m Sendtow 22 Settings sly Favorites desktop ini fp Cl mm Page Safety Home Products AVR Project Book A
21. tp www digisoft com pk Projects dc servo motor contro Calculations DC Servo Motor Control DigiSoft Software for digital world Windows Internet Explorer digisoft com pk Projects dc servo mot File Edit View Favorites Tools Help x Google G position servo motor Go gA ER YY Bookmarks 253 blocked Check Autolink ep Sendtov 22 Settings Sie Favorites Suggested Sites 4 web Slice Ga T desktop ini T 3 pins Gnd Vcc and Control The PWM signal should have a period of 10 to 30ms Products AVR Project Book AVR Project Board AVR JTAG GPS Simulator and Trainer Y DIY Projects Text LCD On Project Book DIY Projects gt DC Servo Motor Control The R C Servo Motors are used in model aircraft R C Trucks R C motorboats and robots Radio Control Servo motors are position servo syst ms that are controlled digitally through PWM The usual range is about 180 degrees The connections to the motor are 1 GND Black Graphic LCD 2 VCC Red Controller 3 Control White Swipe Card Reader Interface 5x7 dotmatrix LED Display A typical Servo looks like below Digital RPM Meter for Automobiles Incremental Encoder Interface Technical Notes Downloads Sales The PWM signal to control the position should h
22. ts External IAG Timers USARTO USARTI 11 29 2010 Timer 0 Timer Timer 2 Timer3 L1 Clock Source System Clack v Clock Value Timer 1 Stopped Timer 1 Stopped 16000 000 kHz Dut A 250 000 kHz Dut C 15 E25 kHz Input Capt Noise Cancel Interrupt orc Timer 1 Overfloyy Value oh Inp Capue D h Comp A 0 h jh co Select 2000 000 kHz for the Clock Value These clock values are calculated by taking the System clock you entered on the first page and dividing it by the various prescalers What you are actually setting here is what to divide the system clock by in order get these various Timer speeds 64 setup using CodeVision CodeWizardAVR untitled cwp EA aa Under Mode select Ph amp fr PWM top ICR1 Analog Comparator ADC SPI 1Wie 2 Wire 2 LCD SS amr prp m This is Phase and Frequency correct PWM mode with ICRI Chip External SRAM Pots holding the top value ExtemallRQ Timers USARTO USARTI Cut A Fast PYM top 03F Fh ut A Ph amp fr Pw M tepsI CRT Input correct Pw CTC Fast PM Fast PYM tap DICH TA Value Comp 4 0 h En 11 29 2010 65 Setup using CodeVision E CodeWizardAVR untitled File Help Timer on the ATMegal128 can control different servos Analog Comparator ADC SPI usin
23. ual attention deceleration Note To get a slowly decreasing PWM sequence like the one shown in the graph you would need to write a loop that gradually decreases the motor speed over time The set_motors function in the Pololu AVR Library see Section 6 a for more information lets you set the duty cycle and it uses 8 bit precision a value of 255 corresponds to 100 duty cycle For example to get 67 on M1 and 33 on 2 you would call 3 Note 171 67 of 255 and 84 33 of 255 set_motors 171 84 11 29 201 3 From the Pololu 3Pi User s manual http www pololu com docs 0J21 5 c 0 PWM on Timer Counter 1 a 16 bit Timer Counter 11 29 2010 50 Phase Correct PWM 11 29 2010 We will need the following registers o CCH1 Timer Counter Control Register 1 o TNCT1 Timer Counter 1 ICR1 Input Compare Register 1 s Sets the duration of the signal Period or Frequency OCR1x Output Compare Register 1 Sets the pulse width of the PWM signal Can control up to 3 PWM signals with one Timer Counter 1 Generating PWM signals using Timers in the ATMega chip http mil ufl Phase Correct PWM There are 3 OCR1x registers o OCH1A OCH1B OCH1C here are OC1x pins on which the generated PWM signals may appear OC1B OC1C Phase Correct PWM We will need the following registers o CCH1 Timer Counter Control Register 1 To initialize the Timer Counter and se
Download Pdf Manuals
Related Search
Related Contents
Andante 16 - ave Stuttgart Purelumn System His-tag Binding Buffer(取扱説明書) HR Pro-Tracker Manual for Excel 2007-10 users Philips Disney Suspension light 71758/31/16 MODULE DE REDUCTION DE L`ORDRE D`UN Guia do usuário Zebra GK420d™ - Zebra Technologies Corporation Copyright © All rights reserved.
Failed to retrieve file