From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect when temperature has reached steady state using on-off controller

Hello, I'm currently attempting to simulate the effect of thermostat using Labview and cDAQ. So I'm using an on-off controller to turn the refrigerator on and off using desired temperatures. But what I wish to do is I want to change the on and off temperatures once my refrigerator has reached a steady state. 

 

So, there are 7 options on a thermostat, with changes in the on-off temperatures. I want it to start with 1 setting, and once the temperature of the refrigerator is in steady state, e.g. it starts at 10 degrees and ends up consistently cycling between 4 and 6 degrees, I want to change the value of the on-off temperatures. I have attached an image of a manual test I did which shows how I want steady state to change. 

 

So my question is, how do I detect this steady cycle of temperatures of the refrigerator. I'm taking temperature readings every 1 minute in a while, and it usually take 1-2 hours for the refrigerator to reach steady state on 1 setting. Is there any function or another way in which I can detect that my temperature readings are getting consistent highs and lows and so it can move on to a different reading. 

 

I would appreciate any help, thank you for reading!

 

PS, I have already tried using the amplitude function but it doesn't work as it only gives the amplitudes of the 1 minute sample instead of the entire cycle. 

0 Kudos
Message 1 of 6
(1,910 Views)

Take min/max readings and put them in arrays of x length. Check the standard deviation of the min and max arrays, if the standard deviation is <= a desired value call it stable.

0 Kudos
Message 2 of 6
(1,875 Views)

Here are some "part science, part art" thoughts.

 

1. At least roughly characterize the refrigerator's time constants for both active cooling and passive build up of temperature.

2. Use this info to set more appropriate sample rates.  If you can know when the compressor is turning on and off, you could sample faster during the active cooling phase.   The main idea is to get multiple samples (let's say at least 5-10) during each half-cycle.

3. So you'll probably sample temperature more often than once a minute.

4. Retain some history of these temperatures, maybe as much as an hour's worth.  The amount that's useful will depend on your system.

5. Use a function like the "Peak Detector" to identify indices for several successive cycle maxes, maybe 3-5 cycles worth.  Fewer if cycle periods are particularly long.

6. You can now extract a subset of temperature data representing an integer # of temperature cycles.  This sets you up to avoid a variety of "edge effects" with the simple math to follow.

7. Characterize this subset of data.  When I did a project with a similar need for automatic steady-state detection, I used a combo of standard deviation and best fit line (notably the slope) as my criteria.   

   You can calculate an estimate for a reasonable nominal std dev at true steady state for your temp range.  That'll help you set a comparison threshold.  And you know the slope should be somewhere near 0 at steady state (assuming an integer # of cycles, and a regular sample timing pattern).  The right tolerance to set will again be system-dependent.  A mostly-wild-but-slightly-educated guess for starting out might be +/- ~1/4 of the rate of passive temperature build up from #1 above.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 6
(1,867 Views)

Hi, I'm sorry I am confused about a few parts that I'd like to ask you. I'm very new to using Labview so please forgive me if my questions are too simple.

So I'd like to summarize what you've said to make sure I understand it properly. You're saying I get more than 5-10 samples per half cycle so keep sampling time according to that. Keep the last hour worth of temperature readings and pass that as input to the Peak Detector function. And since my idea of steady state is 3 cycles where the temperature is the same, I can check the past 3 cycles and calculate the standard deviation of them to make sure the peaks are constant?

One confusion is that since my readings are being taken in a while loop, my initial data for the first few minutes where cycling would not have started would also be going to the Peak Detector function, this would not cause any problems right?

Thank you for your response, I am getting a feeling that this might work.

0 Kudos
Message 4 of 6
(1,815 Views)

Well in our testing we describe temperature stabilization as "Four consecutive measurments at 15 minute intervals that are within 2 degrees.

 

Take a temperature measurements every 15 minutes and store it in an array

 

When you have four measurements do a Min-Max on the array and calculate the difference between Min and Max

 

Keep taking measurements at regular intervals replacing the oldest measurement with the newest measurement in your array (keep only the last four measurements)

 

When the difference <= 2 degrees you are stable

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(1,792 Views)

I think the other responders are assuming that your "steady state" is a flat, constant temperature.  I'm interpreting the pic you attached in msg #1 to mean that "steady state" is a repeating cycling pattern due to the fact you're montoring a system under active control.

 

For clarity:

- none of the ideas I presented are LabVIEW-specific.  They're all general ideas that can be understood apart from having a lot of LabVIEW knowledge or experience.

- the approach I suggested *does* depends on regular & predictable timing between samples so that each sample carries the appropriate "weight" in any subsequent math you do.  If you took 80 samples during the first cycle and only 12 during the next, the analysis would be greatly skewed to weight the first cycle's values more heavily than the second.  The easiest way to do this is to figure out the highest rate you need and make that the constant rate you use all the time.

- the approach very much depends on your ability to identify cycle start and end points so you can extract data corresopnding to exactly 1 or N cycles.  (You may or may not find the need to use interpolation to get even more exact).

- once you do that, there are many kinds of things you could do to decide whether the last 3 cycles are showing you the "same-enough" behavior for you to consider it steady-state.   Offhand, I think slope of the best fit line will be a more straightforward criterion than standard deviation.  The target value of slope for steady-state behavior will be 0.  Pretty simple to look for a small-enough absolute value.   The target value of std dev for steady-state behavior depends very much on the *shape* of the cooling and warming temperature waveform.  And that may not be *quite* the same throughout the entire range of setpoints.  Specifically, I'd expect warmup time to depend on the difference between setpoint and external ambient.

- RE: your question about the first few minutes before cycling starts - I don't know the whole scope of what you're doing.  In general, your program will need to know at any given time whether it needs to collect and retain data or not.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 6
(1,786 Views)