LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Temperature dependent data acquisition with PID control

Nathan, Thanks for the great help. I have new questions regarding saving data ! 

 

   I have modified my PID controller VI and It no longer runs in the backround. First I set the temperature at a certain point using a sub vi which asks the start - end temperatures and also the step temperature. Than, this sub VI creates an array of temperature set points. This array than is connected to a for loop, which runs as the same size number as the array.Then, I use 2 checks of temperature after I set the temperature, If the temperature is stable in the range of 2k, I run the measurement (which is done by VDP sub VI). After measurement finishes, I want to save the data to a file also during the measurement, I want to observe the data from the graphs. I have problem monitoring the data from graphs and saving them. Can you help me what is wrong in my file ? When I created indicators outside of the for loop, I can see the data at the end of the whole run. But my goal is to have immediate graphs and save the file at the end. I havent used shift registers because after the measurement is done, I dont use it in the next loop as well as the temperature set points are being calculated in a separete sub VI. 

 

Thanks ! 

0 Kudos
Message 11 of 18
(2,697 Views)

Glad to hear you're closer to get it working.

 

I highly recommend that you learn about state machines in LabVIEW.  A state machine is not the same as a sequence structure.  You need only one while loop, with a shift register containing an enumeration representing the current state. Inside the while loop, put a case structure with the state connected to the selector ('?') terminal.  LabVIEW includes a template for this design (select File->New... and look under VI->From Template), and there are many examples on this forum.

 

Avoid sequence structures - especially stacked sequences.  They are almost never necessary.  Also, there's no need for the "Build Cluster Array" functions - just wire directly to the chart terminals.

 

I don't understand what your problem is with the graphing and saving data.  Are you saying that you want to see the graphs update constantly instead of waiting until the temperature is stable?

 

If possible, when you attach a VI, please include all subVIs.  The easiest way to do this is generally to zip the entire folder and attach the ZIP archive instead of the VI.

0 Kudos
Message 12 of 18
(2,690 Views)

I have checked the state machine structure but I possibly need another for loop for the temperature set points that contains the state machine since I couldnt see another way to put the array of temperature set points in the state machine. Also I want to have these four cases : Initialize temperature - check temperature stability (rough) - check temperature stability (fine) and - take measurements but in the enum constant there are initialize and stop cases only and when I try to add cases it becomes red and I cannot add any cases. (Question 1 )

 

Now, since I already made a VI using stacked sequences, I might want to be able to save the data and finish the program first and try to make a new VI with state machines later.If I use state machine the enums will be constant cos the only thing that is changing will be the temperature points which is calculated as an array of number and fed into for loop in my early mesage.

 

 Going back to my last question. How can I save the data from the measurements at each temperature point (there is 6 different data coming out of the VDP measurement VI). Should I make an array out of them? Put them in the shift register? Also, I want to see the graphs at each measurement, in other words, when a temperature point is stabilized and the measurement is made, I wanna see it on the graph before the program goes to the next state. I can add the sub VI's also but those sub Vi's has 20 more sub Vi's in it. Should I add them all ? (Question 2)

 

Summary of my Program

- Using the Temperature Set Points Sub VI, an array of desired temperature points are created (example : 300, 350, 400, 450, 500)

- At those temperature points, I need to take measurements (at each T point, I will run VDP sub VI which takes measurements and gives the outputs - say a, b, c, d, e, f, g )

- At each temperature point, after the measurement I wanna see the graphs updates ( I want six graphs - a as a function of T, b as a function of T etc..)

- Save the measured values of a, b, c, d, e, f, g on a text file ( I dont know how to put delimeter or comma ? )  which I can open in an excel sheet and plot them as a function of temperature)

 

Thanks, 

0 Kudos
Message 13 of 18
(2,682 Views)

For question 1: have you used type definitions before?  You need to edit the items in the type definition in order to add new values.  After you edit the enumeration, then you can add the corresponding case in the case structure.

 

It's not worth going forward with code that uses stacked sequence structures, they'll cause more problems because they're not flexible.  Make the switch to a full state machine now.  With a proper state machine you also will not need a for loop nor the inner while loop that waits for the temperature to stabilize.  Instead of the inner while loop, you just stay in the same state until the temperature is stable.  Instead of the for loop, you could keep the array in a shift register.  Use Index Array to get the first element of the array and use that as the temperature setpoint.  When you reach that temperature and take the measurement, delete that element from the array, so that when you next set the temperature it will use the next array element.  Stop when the array is empty.

 

For question 2: To save all the data only once when the program finishes, yes, you'll want to store the data in an array and keep that array in a shift register so you can add new data to it at each temperature step.  This is another advantage to a state machine: you have the while loop so adding a shift register for the data is easy.

 

What do you mean about "add the subVIs"?  Add to what?  What is the function of those subVIs?  I'm not sure what you are asking here.

 

On your graphs, you're looking for your data as a function of temperature, right?  But right now you have charts, not graphs, which means you do not have control over the X axis.  If you need to plot against temperature, you need to use an XY graph, and you'll need to pull the appropriate data out of the array in the shift register to display.

 

Saving an array to a comma-delimited file that you can open in Excel is easy, look at the "Write to Spreadsheet File" function, or if you need more control, use "Array to Spreadsheet String" and "Write to Text File."

0 Kudos
Message 14 of 18
(2,673 Views)

   Just as a simple demonstration, attached I have two states, first one supposed to add 100 to the first element of the array (which represents the Temperature). Than I will save this output data and delete the first element, move to the new Temperature state (which will be the new first element). I am getting errors and sending the file on the attachment. Do I suppose to connect the shift registers together? How do I initiate the first output register? 

 

Note, this is just a simple trial file to help setting up my bigger actual state machine. Thanks

0 Kudos
Message 15 of 18
(2,668 Views)

That's almost the right idea.  If you can't understand why you're getting errors, you may want to work through some of the LabVIEW basics and tutorials, since shift registers are a fundamental concept in LabVIEW.  I'm attaching a rough example of how I would do this.

Example State Machine.png

Download All
0 Kudos
Message 16 of 18
(2,662 Views)

Thanks, I want to write the data to file each time (append data) before the loop exits because these experiements might last 20 hours and If we loose the power or If something goes wrong we might loose the data. I tried to put the save data to file inside the while loop, however, Should  take it from the shift register or something else such as a local variable or reference node? I have the tendency to use a third case called 'save' and save it in there but have problem transferring tha data (1)

 

When I bundle x and y values ( x is temperature and y is one of the output variables of my measurement file ) and build array and connect them to the x y graph, it does updates the limits of the graph accordingly, however, It does not show me the data points why is that ? (2)

 

 

0 Kudos
Message 17 of 18
(2,653 Views)

In your previous messages you wrote that you want to save all the data at the end.  If in fact you want to save after each measurement, adding an additional state is a reasonable way to do it.  Alternatively you can do the saving in the same state where you take the measurement.  If you use two separate states, a shift register is the best way to transfer the data.

 

I can't make any guesses at what's going on with your graphs.  It's really difficult to understand what you are doing when you write vague descriptions such as "problem transferring the data" with no explanation of the error and without any code.  If you want help, make it easy for the forums users to help you by providing as much information about the problem as possible.

0 Kudos
Message 18 of 18
(2,644 Views)