10-04-2006 02:32 AM
10-04-2006 08:09 AM
This sounds like a good place for a simple functional global that uses an uninitialized shift register. Search the site for those terms and you should find lots of info and some examples.
A shift register works like a local variable for a loop. The one on the left holds the value prior to a loop iteration and the one on the right should be wired with the value to be held at the end of an iteration. Whatever you wire to the right on one iteration is what will come out from the left on the next iteration. An "unitialized" shift register is one where no value is wired from outside the loop to the left-side shift register. Such a beast will remember its shift register values from one function call to the next. This is the LabVIEW method for creating the equivalent of a C static variable.
Your main program would call this functional global and pass in the most recent 128 samples. Inside the functional global, the input array will be wired to a right-hand-side shift register. Also inside the functional global, the value coming out of the left-hand-side shift register (which is the array you passed in on the previous call) will be subtracted from your input array. Pass the difference out to an output terminal. Voila!
Here's an extremely simple example. I would recommend you consider adding some logic to verify that the arrays are equally-sized before subtracting them. You may have other checks you'd like to do too, but this illustrates the bare-bones of the solution.
-Kevin P.
10-06-2006 05:20 AM
Ok,
I managed to implement the algorthim in Labview using the Subtract routine mentioned and using local variables.
All was working well for a while I was charting both the raw signal and the subtracted signal fine, from a USB-6009 device the sampling rate was 64 and the number of samples was 256. The arrays I have defined and the for loop I have indexed run from 0 to 255 BUT now I am suddenly having performance issues in running this VI. On completion of the For loop the VI stops freezes for a few seconds before continuing on the next For loop run. I am at a loss as to why the VI has suddenly started behaving this way.
Any help greatly appreciated.
Best regards
Javed
10-06-2006 09:05 AM