PDA

View Full Version : HWPM higher resolution stepping



Scampy
- 26th August 2013, 17:38
Hi

I'm using hardware PWM on a 18F4520 to control two channels of LEDs for an aquarium light. Using the hpwm 1,W_PWM,750 command in PBPro, the variable W_PWM has 255 steps, however this gives a noticeable stepped phase when dimming the LEDs up and down at low values of W_PWM. Is there a way of using a higher value so that W_PWM has more resolution say 1024 steps - or is this not supported ?

HenrikOlsson
- 26th August 2013, 18:47
Hi,
No, the HPWM command is limited to 8bit resolution. Years ago Darrel wrote a routine called HPWM10 or something like that which could be used instead of the normal HPWM to get 10bit resolution and provide glitchfree operation (IIRC) search the forum and you should be able to find it.

With that said it's pretty straight forward to set the registers for the CCP manually. Plenty of examples on that as well floating around.

/Henrik.

Scampy
- 26th August 2013, 19:20
Cheers Henrik, I'll have a search and see if I can find Darrels routine