Determining an Effective Analog Sampling Rate
Q: How often should my equipment make measurements?
A: This question often arises when people draft plans to automatically measure a physical quantity such as temperature, pressure, acidity, liquid level, and so on. You can approach this problem in several ways, from an educated guess to a mathematical analysis of your system. The examples that follow use temperature measurements because people measure temperature more than any other physical characteristic.
Suppose you have a large tank of solvent that must remain at 70°C, ±2°. One or several sensors will let a computer measure the temperature periodically to determine when to turn on a heater to maintain the solvent temperature. Assume the tank sits in a factory with an ambient temperature of 20°C. How fast should you measure the solvent temperature? You can choose one of the four methods below or devise one of your own to fit a given situation. Of course engineers can use control theory to derive a transfer function for a process and thus help determine a suitable sample rate. Control theory goes beyond the scope of this article, though. For an introduction to closed-loop control, visit: http://www.electronics-tutorials.ws/systems/closed-loop-system.html.
On to the four methods:
Method 1. Let the solvent cool and measure the time it takes for the temperature to reach 69° and then 68°. If the solvent temperature takes about 15 minutes to drop to 69° and about the same time to reach 68°, a measurement taken every minute should suffice. The temperature doesn’t change rapidly enough to justify taking more data. (Of course you may take more measurements if you wish.) And timing errors of a few seconds one way or the other won’t make much difference.
Method 2. In a similar approach you could use a stand-alone data logger to take temperature samples at regular intervals, say, every second in our temperature example. DATAQ Instruments, for example, has a Model DI-245 data logger that will measure voltages and can connect directly to many types of thermocouples. DATAQ also provides data-capture and -analysis software and software to control the DI-245. Sample rates run from 2000 samples/sec to about one sample/hour. I have used the DATAQ Model DI-145 voltage logger to measure temperature from a sensor with a voltage output.
Sealevel Systems offers a variety of products that can be used to measure temperature. The Relio R3 and Relio R4 industrial computers use Sealevel’s SeaRAQ boards for I/O expansion, and two are designed specifically for temperature monitoring. The SeaRAQ 6511 has 6 inputs for measuring temperatures using RTD sensors, while the SeaRAQ 6512 connects 6 thermocouples. (Find out the differences between RTDs and thermocouples here). Users can write their own application program in a high level language or choose third party software like Azeotech’s DAQFactory to quickly build monitoring and control applications.
After you capture data for a long period, you can better see how temperature varies over time and decide how often you should make measurements. When you import data into an Excel spreadsheet you can plot it, average readings over a given period, and perhaps run a Fourier analysis to look for any high-frequency signal components. (More about data analysis in later discussions.)
Method 3. Even though you can approximate a temperature sample rate by analyzing experimental data, it helps confirm or justify a sampling rate. Again, temperature measurements serve as an example. Many processes have other characteristics such as pressure, conductivity, and pH, for which you can create a mathematical model. Again, we run into control theory.
According to my ancient college-physics text, Isaac Newton discovered that ‘…the combined rate of heat transfer to or from an object due to conduction, convection, and radiation is approximately proportional to the difference between the object and its surroundings.’ (Ref 1.).
So, according to Newton, the cooling rate of our solvent depends on its controlled temperature (70°C ±2°C), the ambient temperature (20°C), and the time t it took for the solvent to get to a temperature of T(t). To obtain temperature data you let the solvent cool for seven hours (420 minutes) and then measure the temperature: 48°C. Now you have the information below:
Newton’s Law provides the following equation for the solvent temperature at time t, given a starting temperature of 70° and an ambient temperature at 20°:
Here e represents the value 2.718. (For more information about the value of e and natural logarithms, visit: http://en.wikipedia.org/wiki/Natural_logarithm.)
Substitute the temperature and time values into the equation to yield:
Use algebra to find the value of the cooling constant, k, which has the units 1/min. I’ll spare you the details. The constant, k, equals 1.38 X 10-3 per minute. With this constant, you can calculate the time it takes the solvent to cool to 68°:
The plot in Figure 1 shows the temperature vs. time relationship as calculated from Newton’s equation.
Figure 1. This plot of temperature vs. time shows cooling according to Newton’s Law.
So unless you want a detailed record of small temperature changes, you could probably take a solvent-temperature measurement every 30 or 60 seconds. Such long intervals between measurements gives your equipment more time to handle other operations or make measurements at higher sample rates for other sensors.
Method 4. This method relies on the rate of change in measurements to help you determine how fast to sample a signal. The 70°C solvent temperature mentioned earlier has a ±2°C tolerance. That translates into a +2.8-percent or a -2.9-percent change from 70°C. Suppose you take the empirical temperature measurements and analyze them to determine when a change of 0.1-percent occurs. That means you take the 70°C measurement and determine at what time the temperature becomes:
70°C * 0.999 or 69.93°C
That condition appears at about one minute after the measurements start. When does the temperature drop by another 0.1-percent increment from the 69.9°C value:
69.9°C * 0.999 or 69.86°C
That temperature measurement occurred at about two minutes. Using this percentage technique, you come up with a fairly constant measurement period of one minute. Luckily, the temperature plot shows a fairly linear plot of temperature vs. time, so a fixed measurement works well. You might decide to make measurements at a faster rate when the temperature goes below 69°C just to ensure you get better time resolution. Of course, in a control loop, the control system would use the temperature measurements to anticipate further temperature changes and start a heater.
Figure 2 shows a plot that identifies the points at which the solvent decreases in one-percent increments from the previous one-percent drop. I created this diagram so you can see how the measurement times appear almost equally spaced at about 12 minutes. Toward the right side of the plot, the curve has a smaller slope, so the measurement periods lengthen to 13 minutes.
Figure 2. The vertical lines in this plot indicate temperatures that vary by one percent from their neighbors. Sampling at the sample rate you can obtain from this plot gives you timely information that varies in small amounts.
If a signal from a sensor looks much like a sine wave (Figure 3) and you look for a point-to-point percentage change in amplitude of, say, two percent, you will see the fastest sampling rate at the points where the sine wave has the steepest slope. We’ll look at sample rates and signal frequencies in another Q&A session.
Figure 3. A plot of a sine-wave signal shows it will change most rapidly when the sine value crosses zero on the y axis. The cosine values reach a peak or valley when the fastest sampling of the sine wave should occur. Unfortunately, few signals prove this easy to analyze.
|Look at sensor response, too.|
The original question about sample rates has another answer when the value of the physical quantity you want to measure changes quickly. In this type of situation, consider how quickly the selected sensor will respond. Say a sheathed thermocouple measures temperatures in a reaction chamber. You must consider the thermal time constant of the thermocouple. That means the thermocouple might take several seconds to reach equilibrium with the temperature in the reaction chamber. In some cases, the lag time might not interfere with measurements, but in others, you might need to use a sensor that offers a faster response time. Check the sensor manufacturer’s specifications for more information about response times and time constants under various conditions.
Q: OK, I think I know how to figure out an appropriate sampling rate, although I might have to experiment a bit.
A: Remember that industrial networks such as Profibus, EtherCAT, and Modbus, often called “fieldbuses,” cause some latency between the time a controller requests a sample from a sensor and when the remote measuring device returns sampled information to the controller. Likewise, fieldbuses cause a short delay when the controller requests an action, such as turning on a heater or turning off a pump. According to Cisco, an industrial Ethernet can have latencies between 10 and 50 milliseconds. In most industrial systems, that small delay will not cause any problems. (Ref. 2.) Because the delay can vary depending on the location of devices on a network and the delay in instruction execution in the controller, we call most fieldbus communications non-deterministic. We cannot determine the exact time at which an action on the network will occur. Your measurement might experience a 44-msec delay and then a 13-msec delay. You cannot predict or control timing, although timing differences are usually small compared to the overall time between measurements in industrial applications.
In some cases a control system might need to act in a deterministic manner. A mathematical operation such as filtering requires samples taken at a fixed and known interval. In this case you might choose computer equipment that offers real-time response. The real-time version of Microsoft Windows, for example, provides a 1-millisecond response time. Some real-time operating systems (RTOSs) can work with Windows RT to offer time resolution down to one microsecond. You also could use a stand-alone real-time operating system that runs in a PC. For more information about RTOSs, I recommend the Wikipedia entry available here: http://en.wikipedia.org/wiki/Real-time_operating_system.
1. Sears, F. W. and M. W., “University Physics,” 3rd ed., Volume 1. Addison Wesley Publishing Co., 1963.
2. “Industrial Ethernet: A Control Engineer’s Guide,” Cisco Systems, 2010. http://www.cisco.com/web/strategy/docs/manufacturing/industrial_ethernet.pdf
- Case Studies
- Quickstart Guides
- Press Releases
- White Papers