So there I am in my simple little world, using the PWM command to vary the DC level on an output pin (using a LPF). I need to do this on six output (ie differeing PWM duty cycles on six different oupt pins).
It came as a bit of a shock to find out last night that there's the concept of PWM 'channels'...could someone please explain brifley why we need different 'channels' & how we control them?
For example, here's a little bit of my code...
Increase_PWM:
pause 5
DEBUG "Increasing PWM........... DC IN = ",DEC DC_In, " DutyCycle = ", dec dutycycle, 13,10
IF dutycycle < duty_upper_limit THEN
dutyCycle = dutycycle +4
pwm RC0pin16, dutycycle , dutyCycle_Repeat
ENDIF
goto Decide_Gain
pwm RC0pin16, dutyCycle, dutyCycle_Repeat
GoTo Decide_Gain
ie...I simplyI alter the PWM duty cycle, depending on the incoming DC level - I didn't have to specify a PWM 'channel'. I just said essentially "slap some PWM output on pin RC0pin16" ...when would I need seperate channels - can't I just send the PWM to another output pin? 9if I need channels, how do I address them?)
Also (to save starting a new thread)...what's a good command to have an "IF" condition along the lines of "if DC_In = Optimum plus or minus 3" (where Optimum was set earlier i the program & DC_IN is a bog standard variable that changes with the D Ccoming in to a ADC pin).
At the minute, I'm having to use two concurrent IFs...
"if DC_In < Optimum +3 then blah"
followed by
"if DC_In > Optimum -3 then blah"
(I tried googling for al the above - to no avail!)
thanks,
Hank.
Bookmarks