Dave - What is your definition of 'erratic'?
width = mon*1
Oh... Can you tell me what is the point of the *1 part of this line?
Basically your program states that if mon is >2 then your HPWM will be at around 12.5% otherwise it will be solid ON. There's not much else that happens... or at least it would do if you remembered a GOTO MAIN after the last IF statement!!! Because as it is, your code is slamming straight into the OneP section.
You could rewrite your code as...
I'm also assuming you've set TRISIO and such properly.Code:Main: ADCIN 3, mon ' Read channel AN3 to Mon width = mon if width > 2 then hpwm 1,32,2000 else hpwm 1,255,2000 endif pause 1000 goto main




Bookmarks