LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire mA continuously and average only when the "average" button is pressed.

Solved!
Go to solution

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:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 15
(690 Views)

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

0 Kudos
Message 12 of 15
(679 Views)

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?

 

check.png

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 15
(670 Views)

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.

0 Kudos
Message 14 of 15
(660 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 15
(658 Views)