EEGbiofeedback
USA
Asked
— Edited
Resolved by Dunning-Kruger!
Hello,
I'm getting this error "Error on line 19: Variable is an array: $MvAvgTouch".
I'm trying to smooth out all the noise coming in from my ADC0 from my graphite sensor I have going to the digital and vcc pin of the ADC0 port. It fluctuates +-100 units.
I'm making a biped lift it's feet above an object when it kicks into something unmovable.
My line 19 is:
$AvgTouch=($MvAvgTouch[1]+$MvAvgTouch[2]+$MvAvgTouch[3]+$MvAvgTouch[4]+$MvAvgTouch[5]+$MvAvgTouch[6]+$MvAvgTouch[7]+$MvAvgTouch[8]+$MvAvgTouch[9]+$MvAvgTouch[10])/10
$S1Back=85
$S2Back=85
DefineArray( $MvAvgTouch, 15, 1 )
#$MvAvgTouch[0]=0
$AvgTouch=0
$n=0
Servo(D0, $S1Back)
sleep(1000)
Servo(D1, $S2Back)
$Touch=0
:Top
$Touch=GetADC(adc0)
$n=$n+1
$MvAvgTouch[$n]=$Touch
if ($n>10)
$n=0
EndIf
$AvgTouch=($MvAvgTouch[1]+$MvAvgTouch[2]+$MvAvgTouch[3]+$MvAvgTouch[4]+$MvAvgTouch[5]+$MvAvgTouch[6]+$MvAvgTouch[7]+$MvAvgTouch[8]+$MvAvgTouch[9]+$MvAvgTouch[10])/10
sleep(100)
if ($Touch>220)
$S1Back=$S1Back+5
$S2Back=$S2Back+5
print($Touch)
Servo(D0, $S1Back)
sleep(500)
Servo(D1, $S2Back)
EndIf
if ($Touch95)
$S1Back=$S1Back-5
$S2Back=$S2Back+5
#print($Touch)
Servo(D0, $S1Back)
sleep(500)
Servo(D1, $S2Back)
if ($S2Back>35)
goto(Over)
EndIf
EndIf
goto(Top)
:Over
$Touch=GetADC(adc0)
sleep(100)
if ($Touch<220)
$S1Back=$S1Back+5
$S2Back=$S2Back-5
print($Touch)
Servo(D0, $S1Back)
sleep(500)
Servo(D1, $S2Back)
EndIf
goto(Over)
Thanks much,
Bill
@Bill see this thread... Wayne had a similar issue... we did find a work around but that's as far as it got... Adding array values
Thanks Richard,
Sorry I waited so long to mark this as resolved but I thought there would have been another solution.
I will make a feature request to do array addition and division so I'll be able to do DSP for things like vibration signature analysis to test faulty metal parts.
I suspect it's probably a little late in the game now, but here's a very well developed open source programming language we could be customized for robotics: http://ahkscript.org/
All the best,
Bill
Hi DJ,
Thanks for your efforts but I replicated your code and the error persists with the 04.04.2015 update. I've attached a screen shot with the code and the error which might be helpful in solving this one.
Cheers,
Bill
I do not believe you have updated... this works as expected....
And I also tried it with this..
Excellent DJ!
Thanks so much for the quick fix. It's working perfectly now.
BTW that's a very powerful feature for the com port readers also. I've been reeling with ideas.
Best,
Bill