08-12-2009 08:46 PM
I am writing a VI and need to set a reference point before I perform my operation.
Is there a way to hold the values of all 8 channels that I am measuring in a number constant at the press of a button?
If I had this, I could just have the VI subtract those baseline values out and get my reference.
Thanks!
Solved! Go to Solution.
08-12-2009 08:53 PM
Could you please post your code so we can see what you are doing?
Yes it is possible using either an event structure or case structure.
From then on, you could just subtract that value from each data point.
08-12-2009 09:07 PM
I'm not at my school computer and don't have a labview license here but essentially all it does is takes in data from an 8 channel DAQ and computes a value based on an equation I program.
How would I have to setup my case/event structure to capture when a button is pressed? If it's not too much trouble could you post an example? If it's too time consuming to make it, an explanation would be much appreciated.
08-12-2009 09:29 PM
Sure, I'll make a quick example, give me a minute.
Since you dont have LabVIEW on your computer, I'll just post a picture.
08-12-2009 09:49 PM
OK:
This is what is going on:
The function outside of the while loop, to the left, configures your port.
This only needs to be done once, and I'm assuming if you are reading in data, you already figured this part out.
For an example, I enabled the port to use termination characters.
That way, I could perform 8 reads, each of which stop when they hit a termination character.
This is to simulate reading in 8 channels.
Heres the important part:
After the data is passed out of the For loop, it is build into an array.
The array is a 1D array, with 8 elements.
Each element is a single data point for each channel.
If the 'calibrate' button is pressed, this 1D array will be passed to a shift register.
If it is not pressed, that first array of data will be carried between iterations.
From then on, all data that is read in will have the baseline subtracted.
The (calibrated) data will then be built into a shift register.
This will collect all of your data into a 2D array of size 8xN where N is the number of data points collected.
You can then pass the data to an array indicator or a graph, or save it to a file.
08-12-2009 09:51 PM
I didn't show the False case of the case structure.
Just wire the shift register straight across so the value of the wire doesnt change.
08-12-2009 10:33 PM
Thanks for the help.
Just a couple questions:
So will this code "capture" the current value of the data when I set boolean to true and then subtract it from all the subsequent values?
If I press set to false, will the program send the non-baselined values?
Essentially, what I'm trying to do here is when I move boolean to true, I want the program to capture all the values at that point and then subtract them from all subsequent values. When I go back to boolean condition false, I want the program to not subtract anything.
For clarifications sake. I am reading in all 8 analog samples in one array sampled continuously at 2048 samples/sec and then dequeing by element to get my values. Not sure if this changes anything though I think it might.
Sorry for the confusion...I am new to LabView but not new to programming and haven't had a lot of time to acquaint myself...
08-13-2009 01:51 AM
Typically you would keep the reference value in a shift register or feedback node.
Here's a simple example (LV 8.0)
08-13-2009 08:59 AM
You slightly misunderstood how the boolean works.
The first time the boolean is true, it will capture each of the 8 values.
Then the boolean should switch to false.
From then on, all values will subtract the baseline.
If you change the boolean to true later on, it will capture a new baseline,
and use the new values to subtract.
So really, it only needs to be set to True once.
08-13-2009 09:56 AM - edited 08-13-2009 09:58 AM
Cory K wrote:You slightly misunderstood how the boolean works.
A latch action boolean will only do half of the requirements. It will re-zero whenever it is pressed, but there is no way to disable all subtractions later. My example allows that, but your program would need a few more things. 😉
(Granted, this new requirement came after you posted your example ("Essentially, what I'm trying to do here is when I move boolean to true, I want the program to capture all the values at that point and then subtract them from all subsequent values. When I go back to boolean condition false, I want the program to not subtract anything."). Your example matches the original specifications. 🐵