Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pwm pic 18 f

7,930 views

Published on

Implementação de PWM utilizando microcontroladores da linha PIC 18F

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Pwm pic 18 f

  1. 1. PWM– PIC 18FProf. Ilton L Barbacena 2012.2
  2. 2. PWM – Pulse Width Modulation• É o recurso mais usado dos módulos CCPs;• Pode-se obter uma tensão analógica a partir de um sinal digital (DAC), naturalmente com utilização de filtros na saída; 2 /99
  3. 3. PWM A tensão média será: Onde: V(t) = Vpulsos para 0<= t <=tp V(t) = 0 para tp < t <= T• A tensão média é diretamente proporcional ao duty cycle ou ciclo ativo. 3 /99
  4. 4. PWM• Para se obter um conversor digital analógico a partir do pino CCPx, basta implementar um sinal PWM e adicionar em sua saída um filtro passa baixa com frequência de corte menor que a própria frequência do PWM. – Supor um filtro RC, onde fcorte = 1 / (2*pi*R*C); – Neste caso, deve-se adotar sempre:• Quando não é necessária obter uma tensão média contínua, a implementação do filtro é descartada;• No caso de resistores de aquecimento ou motores DC o filtro é dispensável, uma vez que estes componentes já atuam como filtros, desde que a frequência do PWM não seja muito baixa. 4 /99
  5. 5. PWM - DAC 5 /99
  6. 6. PWM com filtro RC1 – Escolhe p/ gerar pulsos 2- Tensão de pico (5V)3 – duty = 10% 4 – freq. Do PWM 6 /99
  7. 7. PWM com filtro RC Duty = 10% Duty = 70%Veja alguns exemplos em:http://ww1.microchip.com/downloads/en/AppNotes/00655a.pdfhttp://aquaticus.info/pwm-sine-wavehttp://www.wpi.edu/Pubs/E-project/Available/E-project-042711-190851/unrestricted/PWM_Techniques_final.pdf 7 /99
  8. 8. PWM com filtro RC Filtro RC com 2 polos Sinal de entrada pwm de 19kHz e duty de 70%Veja o resultado da simulação com um sinal PWM aplicado emutilizando um filtro RC com 2 estágios, para geração de um sinalsenoidal. 8 /99
  9. 9. PWM com filtro LC Sinal de entrada pwm Filtro LC com 2 polos de 19kHz e duty de 80%• Veja o resultado da simulação com um sinal PWM aplicado em utilizando um filtro LC com 2 estágios, para geração de um sinal senoidal.• Em não havendo necessidade de obter tensão média contínua, utiliza-se o PWM sem filtros (aquecimento e acionamento de motores), desde que a frequência do PWM não seja muito baixa. 9 /99
  10. 10. Diagrama simplificado do PWM no PIC 18FO registrador de duty cycle possui 10 bits: 8 em CCPxL e 2 em CCPxCON 10 /99
  11. 11. PWM no PIC 18F 11 /99
  12. 12. Timer2 no PIC 18F Timer 2 Contador de 8 Bits Calculadora timer2: http://pictimer.picbingo.com/http://www.best-microcontroller-projects.com/pic-timer-2.html 12 /99
  13. 13. Timer2 no PIC 18F• Timer2 é um contador de 8 bits;• Usa somente o clock interno ou o cristal;• Possui um prescaler (1, 4, 16 e 16) e um postscaler (1,2,3,..,15, 16), ambos configuráveis;• A saída do Timer2 pode ser associada ao modo MSSP (Master Synchronous Serial Port Module) e PWM;• TMR2 é um registrador contador de leitura e gravação de 8 bits;• PR2 é um registrador de leitura e gravação de 8 bits e sempre inicializado a 0xFFh no Reset.• O registrador contador TMR2 do Timer2 incrementa de 0 até o valor gravado em PR2 (8 bits);• Quando PR2=0xFF ou 255, ocorre a contagem máxima;• Observar que o postscaler de timer 2 não afeta o PWM; 13 /99
  14. 14. Timer2 no PIC 18F• Fout - A frequência de saída após a divisão /overflow / .• Tout - O tempo de ciclo após a divisão.• Fclk é a frequência do cristal. Não se deve usar oscilador externo.• Contagem - Um valor numérico para ser colocado para obter a frequência desejada - fout.• (PR2 - TMR2) - O número de vezes que o contador irá contar. 14 /99
  15. 15. Exemplo de Timer2 no PIC 18FExemplo: Cálculo de uma interrupção a cada 1s com TIMER2 (1Hz)Assumiremos os seguintes parâmetros:Cristal=8MHz, Prescaler 1:1, Postscaler 1:16, TMR2=0 e PR2=255 Count = clock / (4*prescaler*(PR2-TMR2) * Postscaler * Fout) Count = 8M / (4*1*(255-0)*16*1) Count = 488 Para se obter uma interrupção a cada 1s dever utilizar uma variável global Count, iniciando com zero, e o tempo de 1s vai ocorrer quando o valor atingir 488. 15 /99
  16. 16. Exemplo de Timer2 no PIC 18Fhttp://pictimer.picbingo.com/ 488 x 2048000nS = 1s 16 /99
  17. 17. PWM no PIC 18F• Nesta família existem 2 canais PWM (CCP1 e CCP2) / 2 pinos de saída;• Resolução máxima de 10 bits, logo o duty cycle pode variar de 0 a 1023;• O ciclo ativo do sinal é definido pelo valor armazenado em CCPRxL (8 bits) e CCPxCON (bit DCxB1 e bit DCxB2);• O período do PWM é controlado diretamente pelo Timer 2, através do registrador PR2; • O contador do timer2, TMR2, começa de zero e vai incrementando até quando TMR2 = PR2, voltando para zero novamente. Neste momento quando o timer2 é ressetado, o postscaler é incrementado. Quando o postscaler, contador de estouros, atingir o valor programado, é gerado uma interrupção associado a timer2; • O postscaler varia de 1 a 16; • O período e a frequência PWM é dado por: Tpwm = (PR2 + 1) * 4 * Tosc * (Prescaler do TMR2) (1) PWMfreq = 1 / Tpwm No PIC não se define duty cycle, mas o tempo de pulso em nível alto, que é dado por: (2) 17 /99
  18. 18. PWM no PIC 18F• A largura do pulso é ajustada em 10 bits: 8 bits do registrador CCPxL e 2 bits do registrador CCPxCON (os bits 5 e 4);• O duty depende exclisivamente dos 10 bits (8 em CCPxL e 2 em CCPxCON);• Veja que PR2 (8 bits), que controla o Tpwm, é multiplicado por 4 para poder igualar-se aos 10 bits. Com isso, se PR2 for ajustado para um valor menor que 255, será necessário um valor menor que 10 bits, para atingir um PWM com 100% de duty;• Observar que o postscaler de timer 2 não afeta o PWM;• A resolução ou a quantidade máxima de bits para o PWM é dado por: Em bits (3) 18 /99
  19. 19. Exemplo de PWM no PIC 18F• Supor um PWM de 20KHz, com um clock de 8MHz e prescaler do timer 2 de 1:1; De (1) (4) (5) Em (5), para fpwm = 10KHz , p=1 e clock=8MHz , teremos PR2 = 99 Hz 19 /99
  20. 20. PWM no PIC 18F• A resolução do sinal PWM é inversamente proporcional à frequência do sinal, ou seja, quanto maior a freq. PWM, menor será sua resolução;• Com isso, para obter um sinal PWM com frequência maior, é necessário gravar o registrador PR2 com um valor menor.• A resolução de 10 bits somente se consegue quando se grava em PR2 com o valor 0xFF. Para obter-se frequências maiores, é necessário diminuir este valor, diminuindo assim os o número de passos no ciclo ativo; Exemplos: http://www.todopic.com.ar/foros/index.php?topic=30740.0;wap2 Atividade: gerar um PWM de 3KHz (fpwm = 3KHz) com duty variável de 20% a 80%. 20 /99
  21. 21. Exemplo de PWM no PIC 18F• Supor um PWM de 20KHz, com um clock de 8MHz, configurar os registradores; Calculadora de PWM para PIC: http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html Neste caso, é somente transcrever para o programa no PIC; 21 /99
  22. 22. Resolução de PWM no PIC 18F• A resolução do sinal PWM é inversamente proporcional à frequência do sinal, ou seja, quanto maior a freq. PWM, menor será sua resolução;• Com isso, para obter um sinal PWM com frequência maior, é necessário carregar o registrador PR2 com um valor menor.• A resolução de 10 bits somente se consegue quando se carrega PR2 com o valor 0xFF. Para obter-se frequências maiores, é necessário diminuir este valor, diminuindo assim os o número de passos no ciclo ativo; Dados extraídos do manual do PIC18F4520 na pag. 147 22 /99
  23. 23. Atividade para PWM no PIC 18F• Gerar um PWM de 20KHz, com um clock de 8MHz. Variar o duty proporcionalmente ao valor de tensão analógica presente em um potenciômetro conectado a uma entrada analógica;• Mostra mudança no duty com as mudanças na posição do potenciômetro no LCD;• Implementar o programa no simulador Proteus;• Detalhar todas as considerações feitas na elaboração do programa;• Entrega no dia 30/10 .• Pode usar a calculadora, mas tem que explicar os resultados;• Colocar identificações nos arquivos fontes e escrever no LCD o seu nome e data, no inicio do programa; 23 /99

×