Quote Originally Posted by krohtech View Post
Code:
DEFINE SPWM_FREQ  100               ; SPWM Frequency
DEFINE SPWM_RES   101               ; SPWM Resolution
DutyVars   VAR BYTE[16]             ; DutyCycle Variables
  CH1 VAR DutyVars[0]          ; group them in an array for easy access
  CH2 VAR DutyVars[1]          ; with FOR loops etc.
...............
  CH15 VAR DutyVars[14]
  CH16 VAR DutyVars[15]
and change the duty in this manor:
Code:
Main: 
gosub CKINPUT
CH1 = 100
CH2 = 0
............
CH15 = 0
CH16 = 0
gosub CKINPUT
PAUSE T5
CH1 = 100
CH2 = 100
CH3 = 0
CH4 = 0
...........
CH15 = 0
CH16 = 0
gosub CKINPUT
PAUSE T5
and so on... If anyone can suggest a better method I would be very interested in learning better ways to program.
I don't see what the problem is...
You've already got CH1 an as alias to DUTYCYCLE[0]...therefore:
CH1 = 0 (or whatever)
is equal to
DUTYCYCLE[0] = 0 (or whatever)
They are functionally equivalent....

Therefore, if you had to use a loop:

for temp = 0 to 16 : dutycycle[ temp ] = 0 : next temp

would be equal to

ch1 = 0
ch2 = 0
and so on until....
ch15 = 0
ch16 = 0