moving average, issue with types
-
Hi,
I'm planning on adding a moving average function to average an analog input and trigger some actions if that decreases too much.
for that, i'm declaring an array of the tension in the config.gglobal TensionAverage = {0,0,0,0,0,0} ;list of 6 tension to average the tension in a moving average
And in a macro called by deamon.g is the following. with parameter P being the analog senor reading
;Tension WatchDog ;tension average: list of 1 elements, move element i to i+1. scrap element 5. add current to element 0 var i = 5 var average = 0 while var.i>0 set global.TensionAverage[var.i] = global.TensionAverage[var.i-1] set var.average = var.average + global.TensionAverage[var.i] set var.i = var.i -1 set global.TensionAverage[0]=param.P set var.average = var.average + global.TensionAverage[0] set var.average = var.average /6 echo "average: "^{var.average} if var.average < global.TensTreshold*0.5 m98 P"/sys/tension-error.g"
But in line 7, i got this error:
"error: in file macro line 7 column 70: meta command: Cannot index into variable or parameter 'TensionAverage^' of non-array type"so, my question is, is there a more efficient way to get the moving average with Gcode/metacomands?
how can i cast it to an array?
Thanks! -
@Paski firmware version?
-
@dc42 RRF 3,5.4
-
@Paski can you try firmware 3.6.0-rc.2 ? I think this may have been fixed already.
-
@dc42 Will try. Thanks David