Anyway, I took the delay word out of node 617 and put a simple counting loop in node 616 which asserts the 'right' port (which is common to the nodes) when the loop finishes. Then node 617 waits till its 'right' port is asserted, then continues with code to load the sine value into the DAC port.
This makes the sine wave much more stable. With the value of 500 in the go loop the sine wave is precisely 799.9Hz and stays rock solid on that value. I doubt if a crystal would make it much more stable but I'll try a crystal next.
With the following code, make sure 866 and 868 are loaded in block 200 to ensure they are compiled. Then '870 load' will start the app.
866 list
sine wave generator
,
617
node
0
org
,
0
,
40
,
80
,
120
,
170
,
,
220
,
280
,
370
,
511
,
,
hart 3300; -.00433 .07943
-.64589 1.57079
,
cos
tri
2* 2* . triangle
dup *.
2
poly
-281
,
5203
,
-42329
,
37407
,
push drop pop *. + ;
scaled
2/
8000
. +
8191 12
interp ;
dac!
io b!
155
or !b ;
start
1f
128
phaseinc
dup dup or
begin
dup cos scaled
synch
right b! @b drop
dac!
over . +
end
868 list
timer count cycles
,
616
node
0
org
,
hold
for . . unext ;
,
ms
for
27063
for
. . . unext
next;
start
08 right b!
1
ms
,
go
500
hold
!b go ;
870 list
sine wave loader
host load loader load
using default ide paths
kill boots
0 708
hook
0
-hook
setup application
616
+node
616
/ram
8
/p
617
+node
617
/ram
1f
/p
visit sine path
panel pause
2
ship
No comments:
Post a Comment