LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Collecting Temperature Data Over a Long Period

I am creating a temp monitoring vi that will display temps in real time on a waveform chart. I have done a similar project before using a thermistor. What is different this time is that it need to log temperatures over the course of a week so I need to limit the number of data point I take. I would like record the temperature something like every 10 minutes. But I don't want just 1 data point collected every 10 minutes. For example, on the 9th minute, I want to start collecting hundreds of data points and then report the average temperature on the 10th minute.

 

I understand the process of setting up the thermistor circuit and collecting the data. I'm looking for the most efficient way to get the timing part right. Thanks! 

0 Kudos
Message 1 of 10
(4,131 Views)

I like using a FGV (functional global variable) for cases like your application, where exact timing isn't super critical and you need to know the elapsed time. You could use the the timing FGV to check when 9 minutes has passed, then start collecting data. And then after 1 minute has elapsed, stop collecting data and do your calculations. Then start all over again waiting for 9 minutes to elapse.

 

I have attached one of my timing FGV's to help get you started.

 

This is just one of many many ways and I'm sure other developer's will have some awesome suggestions as well. 

dK
Message 2 of 10
(4,108 Views)

You need to look into a state machine architecture.  Your timing code would go in an idle state that does nothing except check the elapsed time.  When nine minutes have passed, you need to switch to a "gather" state, where you record the data as necessary.  After a minute of that, go back to the idle state and wait. 

 

I prefer the JKI State Machine template, which you can find on VIPM.  It may take you a little bit to figure out what is going on but it is worth it. 

aputman
Message 3 of 10
(4,099 Views)

Would a state machine be better than a sequence structure? I was thinking of a 2 sequence structure with the first panel waiting for 9 minutes(540,000 milliseconds). Then the next sequence panel would have a for loop that would run for 60 iteration with a wait time of 1 second.

0 Kudos
Message 4 of 10
(4,096 Views)

State machines are infinitely better.  You should build your app upon a good foundation, a good architecture, that allows for expansion and growth.  Sequence structures do not provide this.  They have their place in programming but this is not it.

 

Do not use the wait command.  This locks the front panel and the program is unresponsive until the wait is complete.  You have no way to exit the app during this period except to forcefully kill it or wait until the 540k ms are passed.  And then you will be stuck in the next loop that waits for a minute.  Very bad.  Instead use the Elapsed Time VI in a loop to check if the specified amount of time has passed.

 

aputman
Message 5 of 10
(4,089 Views)

I agree with aputman. Starting with a good architecture will save you a lot of headache in the future. The state machine would work perfectly here.

dK
0 Kudos
Message 6 of 10
(4,081 Views)

I made a quick example in the JKI template.  Upon press of a button, the first state is called where the program sits for 9minutes, checking the elapsed time.  It also checks the idle state for any event structure activity.  Once time has elapsed, Gather Temp Data state is called.  That state runs for 1 minute, gathering data and also checking the event structure for activity.

wait.PNG

gather.PNG

 

aputman
0 Kudos
Message 7 of 10
(4,075 Views)

wrote:

Would a state machine be better than a sequence structure? I was thinking of a 2 sequence structure with the first panel waiting for 9 minutes(540,000 milliseconds). Then the next sequence panel would have a for loop that would run for 60 iteration with a wait time of 1 second.


A State Machine is ALWAYS better than a sequence structure!!!!

========================
=== Engineer Ambiguously ===
========================
Message 8 of 10
(4,066 Views)

Looks good! but I do not recognize the orange symbols that appear to be combining the strings. The piece that "macro: Initialize" is connected to and the piece following that.

0 Kudos
Message 9 of 10
(4,056 Views)

As I said, you need to get the JKI State Machine code from VIPM.  These are VIs from that package.

aputman
0 Kudos
Message 10 of 10
(4,053 Views)