News:

Let's find out together what makes a PIC Tick!

Main Menu

Hi, I need slow frequency 16bit pwm

Started by Maxi, May 26, 2022, 08:10 AM

Previous topic - Next topic

Maxi

Hello,
I need slow frequency pwm out at 8mhz osc (5hz to 500hz, 16bit)
maybe ready some simple code or library code

Im check les`s codes but its working 8bit pwm
need much detail

thank you for help

top204

#1
The newer devices have built in 16-bit PWM peripherals that can be used, because they operate on lower frequencies anyway. Or an interrupt based software PWM generator can be created for such low frequencies.

The sample program "Slow_PWM_Interrupt_Driven.bas" shows one method of generating PWM using an interrupt, and to make its resolution larger, use a 16-bit variable for the duty instead of an 8-bit variable. It will automatically become slower because it has more to do. However, it may be too slow because of the 16-bit duty accumulator because it requires an awful lot of interrupts to toggle a pin with a 16-bit duty. :-)



Maxi

#2
hi Les, I try "Slow_PWM_Interrupt_Driven.bas"
how can I rise up pwm frequency?
its very very slow pwm and its not linear control out

ps: Im looking now 12F1572, it has 16bit pwm module

top204

For your application, I think you would be better off using a device with the 16-bit PWM peripherals because they can operate quite slowly. If even slower is required, there may be mechanisms to use an interrupt as a post-scaler for even slower operations by firing an interrupt on the PWM cycle. I know this is possible with the CCP peripherals, but not quite sure about the PWM peripherals.

PicNoob

Only way to do it on an 8bit is to run the processor really slow (like 4mhz instead of 40mhz) or to setup an interrupt based PWM system.