LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

temperature stablization criteria

  Hello everyone,

 

       I tried to be concise at the topic but I have quite a few things to take care of. I am working on a temperature application and I need to automate the process.

 

       I have a code that can control the thermostat of an environmental chamber by sending 1 or 0 to a digital IO board, acquiring temperature data from a thermocouple continuously and collecting data from an optical spectrum analyzer when the temperature value (acquired temperature data) meets a certain criteria.

 

1) I want to be able to graph thermocouple data along with the time that it is acquired while the program is running. With the current code I have I need to stop the program to be able to see that. What i see with the current code is thermocouple readings versus data points. Also, I want to write this (time-thermocouple reading) to an excel file while the program is running.

2) Also, I want to define a stabilization criteria for the temperature. I want to compare a thermocouple reading with the previous one and to see whether the temperature is stable or not.

3) After the temperature is stabilized, the code can go into the case structure and trigger "write trace to file.VI" to collect the optical spectrum analyzer data automatically. (When I tried to do this seperately -with another temperature stabilization criteria- I had a problem with the loop's getting stuck. That's the program quit acquiring temperature data and just collected optical spectrum analyzer data after it got into the case structure, it did not return to the beginning) The program should run the loop that is collecting the data every 30 seconds as long as the temperature stays stable.

4) Also, after the data is collected the thermostat control of the oven should be set to be on for another 30 seconds and the same thing is to be repeated for the other temperature setting.

5) Another thing is the control of the thermostat. Currently, I am controlling the thermostat according to thermocouple reading. I want to make timely control of it. That's I want to keep it on certain amount of time.

     

     I attached the current codes that I have. Any comments or suggestions will be greatly appreciated.

 

Thanks

 

Deniz

 

 

 

 

 

 

 

0 Kudos
Message 1 of 17
(3,822 Views)

A few comments to get you started.

 

1.  You actually aren't writing to an Excel file.  You have given the file names an .xls extension, but they are actually text files with the data saved in a format that can be imported by Excel.

2.  In order to save the data while the program is running, you will have to put your Write to Spreadsheet File VI's inside the loop and append data.

3.  The reason your VI gets stuck inside the case structure is that you have a while loop inside the Write Trace to File VI.  Since it is called as a subVI, its front panel won't open.  And the only way to stop that VI is to hit the stop button on its front panel.  A catch-22.

4.  That subVI really doesn't make sense.  It has a loop where every 6 seconds, it opens a file, writes data to it (overwriting the data already there) then closes it.  And it is always writing the same data because the data it uses comes from outside the loop.  Is this a VI that you took and modified yourself?  Don't.

5.   You want to completely redo the architecture on this program.

 

A.  Use a state machine.  Since you have a series of steps:  Heat up, stabilize, wait, go to another temperature and repeat.  Each of those should be a step within a state machine.

B.  Use a producer consumer architecture to communicate data.  One loop will be the state machine.  Another loop, (a producer) will acquire data.  Another loop (consumer) will graph the data.  Another loop (consumer) will log the data to a file.  Another loop (probably consumer), will be your temperature control loop.  Using Queues and Notifiers will allow you to pass data from the producer to the consumer loops and also notify your state machine when to change states.

0 Kudos
Message 2 of 17
(3,809 Views)

  Thanks for the response but I could not even get started. The problem is so involved.

At first, I need to take 6 sets of data as reference measurement and then the program needs to turn the thermostat on and take another 6 sets of data and so on. The thing is all these are to be automatically done.

 How can I make the program Write Trace to File.VI to trace the OSA data automatically-without asking for user feedback- .

It asks the user whether or not to trace data when a certain condition is met.

  Also, can I use a template to implement the state machine?

0 Kudos
Message 3 of 17
(3,777 Views)

What user feedback are you talking about?

 

For the state machine template, go to File /  New....  then see attached.

Message Edited by Ravens Fan on 10-19-2009 01:31 PM
0 Kudos
Message 4 of 17
(3,765 Views)

 

The four VIs inside of the library "86140B Trace_Screen Capture(2).llb." work synchronously and they can not be seperated. In my previous code, when the temperature stabilized it asked me whether or not to trace data as seen in the picture. That's the input that I am talking about.

 

 Besides, can you suggest me another way of checking temperature stability? Like comparison of the current temperature value with the previous ones   (Right now I need to define temperature values for checking that and I need to do that without any need of user input)

0 Kudos
Message 5 of 17
(3,760 Views)

Where did you get that .llb file from?

 

It is very poorly written.  I had already mentioned the issue with the while loop inside the Write Trace to File.VI.  The issue with it asking for a file name seems to come from the VI called Image Xfer.VI.

 

Inside is a Write to Binary File with no wire going into the file path.  So it will ask you for a filename each time that VI is called.  And whoever wrote that VI didn't even bother putting a File Path control in it and wiring it to the connector panel so you could programmatically define the file to write to.

 

Go find out who created that .llb and beat them over the head with it.  Then figure out how it works and rewrite it so it works properly.  The VI's aren't that complicated.

 

Ultimately, you will have to define for yourself what temperature stabilization means.  Does it mean that the you have two consecutive identical temperature measurements?  If it was me, I would say the average of the last 10 readings in the past minute and the average of the last 10 readings before that have a difference of less than let's say 2 degrees.  I would write a subVI that keeps track of the last 20 readings, does the math on them, and outputs a True or a False based on that criteria.  I would probably make it an action engine  (see Action Engine Nugget) so that I could have some initialization and reset cases to clear and reset the data.

Message 6 of 17
(3,756 Views)
Hey Ravens Fan you should tell us what you really think about that VI.
Tim
GHSP
0 Kudos
Message 7 of 17
(3,753 Views)

aeastet wrote:
Hey Ravens Fan you should tell us what you really think about that VI.

 

No.  I want to keep the message clean.Smiley Wink
0 Kudos
Message 8 of 17
(3,751 Views)

 Thank you all for your replies

 

 

I modified the code as attached. It is not even half done. I  need to make a whole lot of improvements but can you please comment on the code? Am I in the correct direction?

    The code will acquire the thermocouple reading as long as it runs. Also it will take 6 sets of data when it is first run. (by the way I need to make the filenames that the  wavelength power data is saved different everytime the code is executed.)

 Also, the the thermostat will be turned on depending on the temperature stability condition. (depending on thermocouple reading) How can I pass elapsed time and thermocouple reading data between the loops?

Download All
0 Kudos
Message 9 of 17
(3,699 Views)
Deniz-

Are you trying to send data between different “states” in your state machine?  You can use shift registers for that.  This sets up a way to send data to the next iteration of the loop “state”. 

In your code, you will need to setup a way to move between different states.  Take a look at the Developer Zone Articles listed below for more information on this.

NI Developer Zone: Application Design Patterns: State Machines
http://zone.ni.com/devzone/cda/tut/p/id/3024

NI Developer Zone: Module 7: State Machines
http://zone.ni.com/devzone/cda/tut/p/id/7532

NI Developer Zone: Using a State Machine (Event Driven) Architecture
http://zone.ni.com/devzone/cda/tut/p/id/2926
Regards,

Mike S
NI AE
0 Kudos
Message 10 of 17
(3,675 Views)