From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-11-2009 07:20 AM
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
05-11-2009 07:43 AM
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
05-11-2009 08:30 AM
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
05-11-2009 08:43 AM
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
05-11-2009 09:18 AM
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
05-11-2009 09:27 AM
Hi Ninjatovitch,
see the attached image please.
Mike
05-12-2009 05:32 AM
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
05-12-2009 06:44 AM
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