10-27-2015 08:40 AM
Hello NI Community,
I am having trouble building an array within a master/slave relationship. I want two arrays to be built for a set amount of iterations once the "Pressurization" button is pressed. (This data acqusition would only happen once per program run). I'm new to Labview so I apologize in advance for my messy layout.
I want the slave program of creating the two arrays and analyzing the pressurization slope to happen concurrently with the master program, and the master program to continue to aquire the same pressure data.
Is the master slave relationship even necessary here? How do I pass a variable (pressure reading from main once per loop without getting stuck in a nested loop situation?
Solved! Go to Solution.
10-27-2015 08:46 AM - edited 10-27-2015 09:04 AM
I beleive a Producer/Consumer pattern would do this easily. You acquire data in your producer loop, and you can do data analysis/data logging in your consumer loop. You have to use a Queue for lossless data transmission.
edit: Some more advices:
Edit2:
As I see, you need to perform a Linear Fit on your data. How long you wanna run this application? If you build arrays indefinitely, it will become a memory leak after a while...Of course it depends on the rate and iteration number.
Maybe you want to calculate the Linear Fit in a continuous way? In this case I would use a "Point by Point" function with a given buffer size. So you do not need to build arrays, neither no need for shift registers/feedback nodes.
http://zone.ni.com/reference/en-XX/help/371361M-01/ptbypt/linear_fit_ptbypt/10-27-2015 08:47 AM
I think what you really want is a Producer/Consumer. Use a queue instead of a notifier and send the data through the queue instead of relying on local variables. You can make the data type of the queue a cluster to hold all of the different data you need to send.
10-27-2015 09:57 AM
So would it be best to build my arrays in the producer loop, to be sent to my consumer loop for further processing? (To create an array, should I use a case structure to simulate the (if pressurization==true & i < numberofmeasurements) then ..insert into array with shift registers?)
Also, to send data from my consumer loop back to my producer loop, should I use a local variable?
Thank you for your help.
10-27-2015 10:08 AM - edited 10-27-2015 10:13 AM
No, this is not what I've adviced.
As I see you acquire one single data point in the top loop (which should be the producer loop). I hate this Express VI with the "evil" dynamic data, but I guess this is what you want, yes? So you want to measure one single pressure value at once, ok. You can Enqueue this single data point into the Queue, and send it to the Consumer loop. You do NOT need to build any array. You can continuously calculate Linear Fit coefficients for a given length using the Point_by_Point Linear Fit VI. So your array is "hidden" inside this VI.
Edit1: "Also, to send data from my consumer loop back to my producer loop, should I use a local variable?"
Why do you need to send data from the consumer loop to the Producer??? Do not use local variables when you do not need them. In your attached VI it is also wrong to use that many local variables, like the "Bottle Pressure". Send this value via the Notifier, or much better, as we said, a Queue. Just a moment, I create a small example...
10-27-2015 11:09 AM
Yes I want to use a linear fit for about 20 datapoints. I will try the point by point continous linear fit.
Also for the local variable question, I want my producer loop to respond to the slope data point I acquired. (the interval the slope is in will be associated with a method 1,2,3--> which will be used to energize a solenoid valve for an amount of time)
Thank you Blokk!
10-27-2015 11:10 AM
Here is a small example, only to show some idea (many things are not optimal in this example!!). Based on your VI which you attached, you miss many basic concepts from LabVIEW, you should go through some online training.
10-27-2015 11:13 AM
Also for the local variable question, I want my producer loop to respond to the slope data point I acquired. (the interval the slope is in will be associated with a method 1,2,3--> which will be used to energize a solenoid valve for an amount of time)
Thank you Blokk!
No problem, but then you could interact with your solenoid valve from the Consumer loop! Will be much easier. If your DAQ rate is not too high, it should be totally OK from your Consumer loop... So only collect pressure data in the top Producer loop, and do EVERYTHING else in the Consumer loop. I guess a maximum of 1 second (you have a pressure DAQ rate of 1 sec, yes?) delay for your solenoid valve should not be a problem?