LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop problem

Highlighted

Hello,

 

I am sorry if this is a basic question. I am acquiring data using a DAQmx driver. I would like to make a vi that when I click on "calibrate", calculates the y-mean of the first sample of 1000 points and then subtractes this constant from each new y-amplitude. I have a problem with choosing the right loop/case structure so that the first y-mean calculated is not recalculated in each new loop.

 

Best regards,

Ninjatovitch

0 Kudos
Message 1 of 8
(1,130 Views)
Highlighted

Hi Ninjatovitch,

you don't need an extra loop. See the attached image, it shows how you can calculate the mean value. You can use the subtract function also with arrays. Store the mean value in a shiftregister of the while loop you already use.

 

Hope it helps.

Mike

0 Kudos
Message 2 of 8
(1,111 Views)
Highlighted

Hi Mike,

 

Thank you very much for your quick help! I wonder if I have mist a point. You show in your image how I can calculate the mean value but I was wondering how I could manage to keep the first mean value calculated in each new loop. I have also already tried to store the mean value in the shift register of the while loop but a new value is calculated with each loop.

 

Best regards,

Ninjatovitch

0 Kudos
Message 3 of 8
(1,097 Views)
Highlighted

Hi Ninjatovitch,

use a case structure around the mean calculation. Connect the "i" value to the selector. Write 0 in the case with the mean calculation and "default" into the other case. Write the new value into the shiftregister, but only in the 0 case. In the default case you has to use the old value from the left side of the shiftregister.

 

Mike

Message 4 of 8
(1,090 Views)
Highlighted

Hi Mike,

 

Thanks again for your help Mike. I really appreciate. May I ask you to show it to me in an image?

 

Best regards,

Ninjatovitch

0 Kudos
Message 5 of 8
(1,074 Views)
Highlighted

Hi Ninjatovitch,

see the attached image please.

 

Mike

Message 6 of 8
(1,065 Views)
Highlighted

Hi Mike,

 

Unfortunately, with the shift registers a new y-mean is calculated in each while loop. But thank you very much for your help.

 

Best regards,

Ninjatovitch

0 Kudos
Message 7 of 8
(1,010 Views)
Highlighted

Hi Ninjatovich,

what do you mean? Change the boolean to "latch when released", then it will only calculate the mean if you select calibrate.

 

Mike

Message 8 of 8
(992 Views)