how to speed up this stack with an array
Posted: Mon Nov 12, 2012 8:15 am
The program loops around and stores a value say 60 times a second.
I built it to check the capas in my 37 year old Amplifier.
Code
........
c6=c5
c5=c4
c4=c3
c3=c2
c2=c1
c1=c
then on the timer I calculate the average but the numbers still go up and down.
eg c+c1+c2....../6
I also know the frequency of the loop so I would like to adjust the amount of records stored in the stack.
Here is what I have so far..
DEFLNG A-Z
REM capa program
CLS
TIMER ON
ON TIMER(1) GOSUB health
start:
OUT 956, 255
DO: t = t + 1
LOOP UNTIL INP(957) = 127
OUT 956, 0
DO: t = t + 1
LOOP UNTIL INP(957) = 63
LOCATE 1, 1
c10 = c9
c9 = c8
c8 = c7
c7 = c6
c6 = c5
c5 = c4
c4 = c3
c3 = c2
c2 = c1
c1 = c
c = t
t = 0: f = f + 1
a$ = INKEY$
IF a$ = CHR$(27) THEN END
GOTO start
health:
LOCATE 5, 1
PRINT "Test Frequency "; f
f = 0
LOCATE 6, 1
PRINT "Raw "; c; ((c - 50) * .00157)
PRINT USING "####.###"; ((((c + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10) / 11) - 50) * .00157) - 10.666
RETURN
Cheers
In advance
Wire pin 8 of printer port with 2.2 k to 10 add 10uf (new) to ground then run 2 wires pin 10 for + and ground to capa in question.
Note roughtly 6000 counts for 10 uf 1.6 nf resolution but not stable on p2 233 win 98 just doing my bit to stop ewaist.
I built it to check the capas in my 37 year old Amplifier.
Code
........
c6=c5
c5=c4
c4=c3
c3=c2
c2=c1
c1=c
then on the timer I calculate the average but the numbers still go up and down.
eg c+c1+c2....../6
I also know the frequency of the loop so I would like to adjust the amount of records stored in the stack.
Here is what I have so far..
DEFLNG A-Z
REM capa program
CLS
TIMER ON
ON TIMER(1) GOSUB health
start:
OUT 956, 255
DO: t = t + 1
LOOP UNTIL INP(957) = 127
OUT 956, 0
DO: t = t + 1
LOOP UNTIL INP(957) = 63
LOCATE 1, 1
c10 = c9
c9 = c8
c8 = c7
c7 = c6
c6 = c5
c5 = c4
c4 = c3
c3 = c2
c2 = c1
c1 = c
c = t
t = 0: f = f + 1
a$ = INKEY$
IF a$ = CHR$(27) THEN END
GOTO start
health:
LOCATE 5, 1
PRINT "Test Frequency "; f
f = 0
LOCATE 6, 1
PRINT "Raw "; c; ((c - 50) * .00157)
PRINT USING "####.###"; ((((c + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10) / 11) - 50) * .00157) - 10.666
RETURN
Cheers
In advance
Wire pin 8 of printer port with 2.2 k to 10 add 10uf (new) to ground then run 2 wires pin 10 for + and ground to capa in question.
Note roughtly 6000 counts for 10 uf 1.6 nf resolution but not stable on p2 233 win 98 just doing my bit to stop ewaist.