
So we find a start to controlling ISCAD with a stepping program and hardware. A quad comparator. TI LM339 and the parallax 8x32 bit microprocessor. It doesn't have to be these pieces but this is what on hand. Ill set up a small circuits and see if we can step a sinus signal.
Open Source code.
''Demonstration of PWM version of NCO/PWM counter mode
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long parameter
PUB go  x
cognew(@entry, @parameter)
repeat
repeat x from 0 to 90 'linearly advance parameter from 0 to 100
parameter := cos(x,90) << 16 + sin(x,90) 'a constant here locks to value x percent high
waitcnt(1_000_000 + cnt) 'wait a little while before next update
repeat x from 90 to 0 'linearly advance parameter from 0 to 100
parameter := cos(x,90) << 16 + sin(x,90) 'a constant here locks to value x percent high
waitcnt(1_000_000 + cnt) 'wait a little while before next update
PUB sin(degree, range) : s  c,z,angle
angle := (degree*91)~>2 ' *22.75
c := angle & $800
z := angle & $1000
if c
angle := angle
angle = $E000>>1
angle <<= 1
s := word[angle]
if z
s := s
return (s*range)~>16 ' return sin = range..+range
PUB cos(degree,range)
return sin(degree+90,range)
DAT
'assembly cog which updates the PWM cycle on APIN
'for audio PWM, fundamental freq which must be out of auditory range (period < 50?S)
org
entry mov dira, diraval 'set APIN to output
mov ctra, ctraval 'establish counter A mode and APIN
mov ctrb, ctrbval 'establish counter A mode and APIN
mov frqa, #1 'set counter to increment 1 each cycle
mov frqb, #1 'set counter to increment 1 each cycle
mov time, cnt 'record current time
add time, period 'establish next period
:loop rdlong value, par 'get an up to date pulse width
mov a, value
shl a, #16
shr a, #16
mov b, value
shr b, #16
waitcnt time, period 'wait until next period
neg phsa, a 'back up phsa so that it
neg phsb, b 'back up phsa so that it
jmp #:loop 'loop for next cycle
diraval long 11 'APIN=0
ctraval long 101 << 26 + 1 << 9 + 0 'NCO/PWM APIN=0
ctrbval long 101 << 26 + 3 << 9 + 2 'NCO/PWM APIN=0
period long 90 '888kHz (1.25?S period) (_clkfreq / period)
time res 1
value res 1
a res 1
b res 1
REV.1
''Demonstration of PWM version of NCO/PWM counter mode
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long parameter
word cs,sn
PUB go  x,y,z
cognew(@entry, @parameter)
repeat
repeat x from 0 to 359 step 15 '15 deg steps
cs:= cos(x,256) '+8bit resolution
sn:= sin(x,256) '+8bit resolution
parameter := cs << 16 + sn 'pack cosine and sine
'waitcnt(1000 + cnt) 'wait a little while before next update
PUB sin(degree, range) : s  c,z,angle
angle := (degree*91)~>2 ' *22.75
c := angle & $800
z := angle & $1000
if c
angle := angle
angle = $E000>>1
angle <<= 1
s := word[angle]
if z
s := s
return (s*range)~>16 ' return sin = range..+range
PUB cos(degree,range)
return sin(degree+90,range)
DAT
'assembly cog which updates the PWM cycle on APIN
'for audio PWM, fundamental freq which must be out of auditory range (period < 50?S)
org
entry mov dira, diraval 'set APIN to output
mov ctra, ctraval 'establish counter A mode and APIN
mov ctrb, ctrbval 'establish counter A mode and APIN
mov frqa, #1 'set counter to increment 1 each cycle
mov frqb, #1 'set counter to increment 1 each cycle
mov time, cnt 'record current time
add time, period 'establish next period
:loop rdlong value, par 'get an up to date pulse width
mov a, value
shl a, #16 'unpack a
shr a, #16 'unpack a
mov b, value
shr b, #16 'unpack b
cmp a, #$1FF wc 'test for 16bit signed value
if_nc or a, mask 'sign extend
cmp b, #$1FF wc 'test for 16bit signed value
if_nc or b, mask 'sign extend
cmps a, #0 wc 'wave change
muxnc outa, #16 'status display
if_c movs ctra, #2 'out pin 2
if_c neg a, a 'flip sign
if_nc movs ctra, #0 'out pin 0
cmps b, #0 wc 'wave change
muxnc outa, #32 'status display
if_c movs ctrb, #3 'out pin 3
if_c neg b, b 'flip sign
if_nc movs ctrb, #1 'out pin 1
neg phsa, a 'back up phsa
neg phsb, b 'back up phsb
waitcnt time, period 'wait until next period
jmp #:loop 'loop for next cycle
diraval long 1111 'APIN=0
ctraval long 100 << 26 + 0 'NCO/PWM APIN=0
ctrbval long 100 << 26 + 1 'NCO/PWM APIN=0
period long 256 '800kHz (1.25?S period) (_clkfreq / period)
mask long $FFFF0000
time res 1
value res 1
a res 1
b res 1
