10-13-2019 12:48 PM - edited 10-13-2019 12:53 PM
Hi Ayoob,
your VI makes absolutely no sense…
Your DAQAssistent is set to read 4 channels at 1kS/s samplerate, reading 1000 samples per call. This will take about 1s, so why is there an additional wait of 1s in your loop?
Then you convert the DDT wire to a 1D array - 5 times!? Why do you create a 1D array from the DDT? I guess you need either a 2D array or an array of waveforms to store 1000 samples for each of the 4 channels…
Why do you index 4 elements from that 1D array (which represents just one channel!)? Why do you use 4 IndexArray nodes when one would be sufficient? They can be changed in size!
Why is there a button without a label? Would you create variables in text-based programming languages without a label???
Why do you use MergeSignal and FromDDT, when you need a simple BuildArray node?
Simplified version of your VI:
10-14-2019 12:26 AM
Hi GerdW,
Thanks for the reply
That vi I uploaded was the very first one I made before even getting your guidance. I uploaded that vi here only to show how I did the averaging at that time. I know that vi is a bunch of mistakes. The last vi (attached) issue is only that it is giving a moving average which is not helping my experient. As I said when i press stop, Im trying to get a single average of all values between pressing start and stop
10-14-2019 01:09 AM - edited 10-14-2019 01:34 AM
Hi Ayoob,
@Ayoob wrote:
The last vi (attached) issue is only that it is giving a moving average which is not helping my experient. As I said when i press stop, Im trying to get a single average of all values between pressing start and stop
That last VI still has an unneeded wait function in the main loop…
Why do you need the queue?
And why don't you follow my suggestions?
Edit:
You should also handle errors from DAQAssistent.
You can calculate the resulting "mean of all" already in the loop by using one more shift register…
Why did you use MatrixSize to determine the ArraySize? Why did you create a 2D array from a 1D array just to determine the number of elements?
10-14-2019 01:43 AM
Thanks GerdW,
I used the queue because I want to see the live readings always irrespective of averaging. You suggested the producer-consumer method before.
Averaging must start only when I press start averaging and stop when I press stop averaging, then show the average of samples acquired at that time. I will try your suggestions now.
10-14-2019 01:47 AM
Hi Ayoob,
@Ayoob wrote:
Averaging must start only when I press start averaging and stop when I press stop averaging, then show the average of samples acquired at that time.
Use a conditional output tunnel at the while loop, connected to your "Averaging" button…