![]() ![]() There are two CCP modules in our PIC MCU (CCP1 And CCP2), this means we can generate two PWM signals on two different pins (pin 17 and 16) simultaneously, in our tutorial we are using CCP1 to generate PWM signals on pin 17. The resolution of our PWM signal is 10-bit, that is for a value of 0 there will be a duty cycle of 0% and for a value of 1024 (2^10) there be a duty cycle of 100%. PWM signals can be generated in our PIC Microcontroller by using the CCP (Compare Capture PWM) module. In our tutorial we will set a frequency of 5KHz. ![]() One Period is complete ON and OFF of a PWM signal as shown in the above figure. The frequency of a PWM signal determines how fast a PWM completes one period. If the signal is always ON it is in 100% duty cycle and if it is always off it is 0% duty cycle.ĭuty Cycle =Turn ON time/ (Turn ON time + Turn OFF time) The percentage of time in which the PWM signal remains HIGH (on time) is called as duty cycle. There are two important parameters for a PWM as discussed below: The time during which the signal stays high is called the “on time” and the time during which the signal stays low is called the “off time”. This signal is set high (5v) and low (0v) in a predefined time and speed. Pulse Width Modulation (PWM) is a digital signal which is most commonly used in control circuitry. Further, in this tutorial we will use a RC circuit and a LED to convert the PWM values to Analog voltage and use it for dimming the LED light. PWM module also uses timers to set its frequency hence learn how to use timers beforehand here. To vary the duty cycle we are using a potentiometer, hence it is recommended to learn ADC tutorial before starting with PWM. Here, we will generate a PWM of 5 kHz with a variable duty cycle from 0% to 100%. In this tutorial, we will learn How to generate PWM signals using PIC PIC16F877A. Our PIC MCU has a special module called Compare Capture module (CCP) which can be used to generate PWM signals. If you are an absolute beginner, then please visit the complete list of PIC tutorials here and start learning. Till now, we have covered many basic tutorials like LED blinking with PIC, Timers in PIC, interfacing LCD, interfacing 7-segment, ADC using PIC etc. This is our 10th tutorial of Learning PIC microcontrollers using MPLAB and XC8. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |