The PWM PWM principle of pic single chip microcomputer

Source: Internet
Author: User



1, what is PWM



What is PWM, the professional point of the pulse width modulation , popular point is the constant output high and low level. For example, the microcontroller 40ms time output high and then 60ms time output low and then continuously periodically alternating output and low level this is the typical PWM wave. High-level output time 40ms is the legendary pulse width , 40ms+60ms=100ms is the PWM cycle. Suppose we set the cycle to 100ms. We can increase or decrease the high-level time according to our needs, such as high-level output time to 80ms. Then the low-level time becomes 20ms. It is also possible to reduce the high-level output time to 20ms. Then the low-level time becomes 80ms. That is, the pulse width modulation is this high level of time. At high level (pulse width) in the period, the proportion of time occupied is called the duty cycle. A mathematical formula is used to denote the time/period of the high level = duty cycle.



2, How to implement PWM



How do we let the microcontroller output PWM wave. There are two ways to directly use the I/O output, another way to take advantage of the module.



2.1 Output PWM with I/O port



If your microcontroller does not have a PWM output function module, then you can write your own program output PWM wave. Because PWM is not high and low level. an I/O in addition to a timer, for any single-chip computer is easy to do.



2.2 Using the module output PWM



for Pic MCU, the function module with output PWM is provided. Using the module output PWM is actually simpler and more accurate than using the I/O output PWM.



3, The role of PWM



PWM can be used to do what PWM more typical application is the LED dimming and motor speed regulation. The PWM is how to adjust the light and speed, actually also very good understanding. To give the LED dimming as an example. The LED is the brightest that always has a power led. Do not give the LED power off LED is not bright. That if in a very short period of time to the led constantly power off. The feeling of the eye is that the LED is bright, but the brightness is low.



If the single-chip microcomputer gaoping output LED is bright. The longer the high-level output in the PWM wave, the brighter the LED, and the darker the vice.



To be continued ........ ........ Hi! You've been there all the time.



The PWM PWM principle of pic single chip microcomputer


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.