Quote Originally Posted by StoneColdFuzzy View Post
I've been playing with this code to change HPWM depending on a monitored voltage. The original code at the top of this thread works, but it's erratic.

I've changed things around a bit to fit my needs and it runs a little bit better, but it's still erratic, probably due to refreshing the duty cycle all of the time. I'm looking for suggestions to make this run a little more smooth. Any suggestions?

~ Dave

Code:
Mon var Word
Width var byte
Pause 100

Main:
    ADCIN 3, mon ' Read channel AN3 to Mon
    width = mon*1
    if width <= 2 then OneP
    if width > 2 then twoP
    
OneP:
    hpwm 1,255,2000
    pause 1000
    goto main
    
TwoP:
    hpwm 1,32,2000
    pause 1000
    goto main
    
end
Anyone?

~ Dave