We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Assume a constant frequency PWM. Assume that a period begins on the low to high transition. Suppose an application needs to change the duty cycle. Question 1. Should (must) changes to the duty cycle be done on the same edge (i.e. low to high)? Can the change be done on _any_ part of the cycle? Question 2. Are there scenarios where the duty cycle should be changed gradually? For example, consecutive cycles could see only one bit change until the new duty cycle is reached.
You have to look at your system a little to determine some of these parameters. As an example, if the object you are controlling has a limit of 1 khz, then sending changes faster than this will not effectively do anything to the system. The inertia of the object acts as a low pass filter, only allowing changes below a certain frequency to take effect. Some systems have filters designed into them to smooth out changes to the hardware. These can be simple RC filters, or more complex designs with op-amp(s) and multiple poles to assist with the operation. Often it is simpler (and more effective) to add a filter in hardware than in software. There have been some excellent articles in Embbeded Systems magazine on this subject. You can get a CD from them with all issues and the pertaining articles. http://www.embedded.com is the website.