
Originally Posted by
HenrikOlsson
Hi,
Took a quick look at the code you PM'd me and found this:
Code:
'If light=1 then ' If the variable is 1 then output full PWM to lights
' hpwm 1,255,200
' hpwm 2,255,200
'endif
'If light=0 then ' If the variable is low then set value to 0 an turn off the lights
' hpwm 1,0,200
' hpwm 2,0,200
'endif
If this is where you're trying to set 100% dutycycle but ends up with a "jumpy" signal not at 100% then the problem is most likely that you're trying a frequency (200Hz) far below the specified minimum. If you look at the manual you'll see that for a 18F device running at 20MHz the minimum frequency is 1221Hz.
The only other place in the code where HPWM was used had a frequency of 5kHz so that
should've worked - did it?
/Henrik.
Hi,
That section had been commented out from when I was using the hardware modules. It was intended as a manual over-ride so that I could turn the lights on or off via the push of a button. I never ran the module at high frequencies as the LED driver requires a PWM frequency of 100 hz - 1khz and at 1 Khz they resonated with a high pitched sound.
The original code had
Code:
'*******************************************************************************
'Send pulses to drivers
hpwm 1,W_PWM,200
hpwm 2,B_PWM,200
'*******************************************************************************
Where W_PWM and B_PWM increased from 0 to 255 or decreased from 255 to 0 to fade the LEDs up and down
Bookmarks