a microcontroller-based data logging system

advertisement
A MICROCONTROLLER-BASED DATA LOGGING SYSTEM
S. J. Pérez 1, M. A. Calva2 , R. Castañeda1
ABSTRACT
This work describes a microcontroller-based data logging system to record temperature and relative humidity for acoustic
measurement applications. The system is simple to use, requires no additional hardware and allows the selection of
amount of data and the time intervals between them. The collected data can easily be exported to a PC computer via a
serial port.
1. INTRODUCTION
2. DESIGN CONSIDERATIONS
Due to the relationships between sound velocity and
temperature, as well as between sound velocity and
relative humidity, it is necessary to monitor these
environmental variables in acoustic measurements in
which the sound velocity is involved (reverberation time,
resonance frequency, etc.)[1]. The type of measurement
defines the amount of required data, but it is always
necessary to make subsequent data analysis or graphic
and digital storage .
The Acoustic Laboratory of the Centro de Instrumentos,
has an anechoic chamber and a reverberant chamber.
Temperature and relative humidity measurements are
necessary in both chambers. These measurements are
taken during several hours but the time between data
point is variable; it takes from seconds to minutes. In
addition, temperature and relative humidity transducers
are placed far from the control and monitor room;
therefore, the MDLS design should meet the following
requirements:
There are several solutions to this problem: First, a
recorder such as the CT485 could be used [2], but with
this option it is not possible to obtain a statistical analysis
of digitally stored data or any other type of analysis.
Second, microprocessor-based equipment with some
interface (parallel, GPIB, etc.) for PC computers could be
used [3]. In this case, we will have all the advantages of
a PC computer, but the problem is that it will perform as
a slave device while the data gathering takes place.
a.- It should be easily programmable. The user must be
able to choose measurement rates from 1 s to 99 min.
b.- It should backup data when system
momentarily disrupted, or removed entirely.
power is
We have developed another attractive approach: a
microcontroller-based data logging system (MDLS) with
a PC computer serial interface. Thus, automatic data
collection is possible without giving up PC resources.
Data Loggers can be broadly defined as data acquisition
systems whose functions are programmed from the front
panel and provide data storage [4].
c.- It should have remote sensing devices for
temperature and relative humidity measurement.
The design that we propose exploits the characteristic of
the nonvolatile Embedded RAM area of the most
advanced microcontrollers. Thus, this approach is
implemented without a backup battery [5]. Also, the
1 Sección de
de Instrumentos,
MDLS
isAcústica,
very Centro
compact
because it employs few
Universidad Nacional Autónoma de México, Apdo. Postal 70-186,
integrated
circuits
wich
also
makes
it less expensive.
04510, México, D.F.
3. DESCRIPTION
d.- It should be able to export data to a PC computer
via a serial port.
e.- It should be simple and inexpensive.
The temperature and relativity humidity sensors used
were an HX93C kit [6]. Its principal characteristics are
shown in Table I. Both output sensors are current form
(4-20 mA current loops) and they require conditioned
circuits. These current loops are standard in the process
control industry. This approach takes advantage of the
2 Pino 3718 Col. Satelite. Chihuahua, Chih.
Received: May 29, 1996. Accepted: December 10, 1996.
Journal of the Mexican Society of Instrumentation
Revista de la Sociedad Mexicana de Instrumentación, A.C.
24
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
fact that the remote amplifier can be powered by the same
wires that connect its signal output.
• Initial loading of the application software into the
DS5000T is possible from either a parallel or a serial
interface to the host system. This function allows
initialization of the nonvolatile areas of the device,
including Program/Data RAM and configuration
parameters. Serial loading uses the on-chip serial I/O port
to accept incoming data from a host computer with an
RS232 port, such as a PC-based development system.
Not only is it possible to initially boot via the serial port
in the end system, but also any subsequent software
reloading can be done at will during system operation
without removing the device.
The user interacts with the system through an alphanumeric
display and a simple keyboard (two keys only). Through the
keyboard the user selects the rates. The whole block diagram
of the MDLS is shown in Fig. 1.
• The DS5000T also provides a full complement of I/O
functions, including two 16-bit event counter/timers, a
full duplex serial I/O port capable of asynchronous or
synchronous operation, 32 parallel I/O lines and a
watchdog timer. If additional external memory beyond
the embedded Program/Data RAM is desired, 18 parallel
I/O lines may be assigned to serve the Expanded Bus
function. The Microcontroller incorporates these
functions in a device which its instruction set and pin are
compatible with the standard 8051 microcontroller. Fig. 2
shows the block diagram of the DS5000T.
Figure 1. MDLS block diagram.
3.1 The Microcontroller
We analyzed three possible solutions. The first selection
was the INTEL 8051, an industrial standard, with a
Nonvolatile Static RAM from XICOR. We also
considered the TEXAS INSTRUMENTS TSS400-S1.
This system contains an SMPL (sensor macro
programming language) interpreter and software routines
in its ROM, which can be called as the user needs them.
The user program is stored in external EEPROMs
(X24C04 from XICOR ).
The third possibility was a microcontroller DS5000T [7].
We selected the
DS5000T due to the following
advantages:
• The DS5000T is a high performance 8-bit CMOS
microcontroller that offers "softness". This is
accomplished through the extensive use of nonvolatile
technology to preserve all information in the absence of
Vcc system. The entire Program/Data Memory is
implemented using high speed, nonvolatile static CMOS
RAM. Furthermore, internal data register and key
configuration registers are also nonvolatile. As a result, a
virtually unlimited number of variables and/or data can
be updated and maintained on the DS5000T without
being lost during a power fluctuation.
25
Instrumentation and Development Vol. 3 Nr. 8/1997
Instrumentación y Desarrollo Vol. 3 No. 8/1997
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
converter defines the voltage span of analog inputs (the
difference between Vin(+) and Vin(-)) over which 4096
positive output codes exist, a reference voltage of
4.095 V should be selected for a resolution of 1
milliVolt. Nevertheless, MDLS final accuracy depends
on sensor accuracy (see Table I).
The ADC 1205 makes the conversion to two bytes. The
first byte is the most significant. The output format is 2's
complement with extended sign and right justified. With
CS low and STATUS high (CS and RD low enables the
TRI-STATE output buffer) the MSB (DB12 - DB8) will
be enabled in the output buffers the first time RD goes
low. When RD goes low a second time, the LSB (DB7 DB0) will be enabled. The WR and CS lines are used to
start the conversion. The end of the conversion is
indicated by INT going low.
3.3 The Display
We employed an IEE S03601-92-020 display (one-line
and 20 characters wide) [9], because it can be used as a
console display providing alphanumeric information that
is easily readable in bright ambient light.
This device consists of a vacuum fluorescent tube display
and minimal amount of electronic hardware. Primary
complexity is contained within the microcontroller
software, which controls all display functions. A single
+ 5 V DC power supply is required for operation. All the
display characters (which are formed using a 5 X 7 dot
matrix) and standard control codes can be accessed in an
8 -bit format. All inputs are TTL compatible.
Figure 2. DS5000T microcontroller block diagram.
3.2 Acquisition Unit
The schematic diagram of the MDLS is illustrated in
Fig. 3. The analog circuit of MDLS is shown in Fig. 4.
The circuits shown in these figures illustrate the
simplicity of the digital design due to the use of the µP
DS5000T.
This unit is based on a 12-bit plus sign microprocessor
(µP) compatible successive approximation A/D converter,
ADC1205 [8]. In this device an unipolar input can be
accommodated with a single 5 V power supply.
4. SOFTWARE
The nonvolatile Embedded RAM area of the DS5000T
Because the voltage applied to the reference input of the
Journal of the Mexican Society of Instrumentation
Revista de la Sociedad Mexicana de Instrumentación, A.C.
26
Figure 3. MDLS digital diagram.
Journal of the Mexican Society of Instrumentation
Revista de la Sociedad Mexicana de Instrumentación, A.C.
24
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
Figure 4. MDLS analog diagram.
27
Instrumentation and Development Vol. 3 Nr. 8/1997
Instrumentación y Desarrollo Vol. 3 No. 8/1997
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
Table I
Characteristics
Temperature
R.Humidity
Range
-20 to 75 oC
0 to 100 %
Accuracy
± 0.6 oC
± 2%
Output
4 to 20 mA.
4 to 20 mA
Voltage Supply
12 V
12 V
Table I. Sensor characteristics.
system. The hardware provides the mechanism for the
KIT5K software to take control of the DS5000T via the
RS232 cable, place the device in its Serial Program Load
Mode, and transmit new software to the device. We
developed all the software with this tool and used it as an
interface communication to the PC. Finally, the KIT5K
software allows us to dump memory to an INTEL HEX
file. Records in an INTEL HEX file have the following
format:
can be used as Program Memory, Data Memory, or a
combination of both. The Embedded RAM is initially
loaded by invoking the Serial Bootstrap Loader and
instructing it to load the contents of an incoming INTEL
Hex file into the RAM. The Serial Bootstrap Loader is
also used to initialize the mapping of the Embedded Ram
area. The range Address defines the upper limit of the
Embedded Ram area (we selected 32 Kbytes). This
parameter can be set only via the Serial Loader. The
Partition Address defines the boundary between Program
and Data Memory areas in Embedded RAM. We selected
this parameter as 2 Kbyte.
Header Hex information terminator.
The specific record elements are detailed as follows:
: || aaaa tt ddd..dd xx (spaces are printed for clarity)
where:
:
Indicates a record beginning
||
Indicates record length
aaaa Indicates the 16 bit load address
tt
Indicates record type
dd
Indicates hex data
xx
Indicates checksum
Most of the methods for generating INTEL Hex files
include assemblers and compilers. We used a DS5000TK
evaluation kit from DALLAS SEMICONDUCTOR. The
kit supports in-system serial downloading of DS5000T
from an IBM PC host and provides the KIT5K software.
Record type 00 indicates a data record, and type 01
indicates an end record. An end record will appear as: 00
000 01 FF. Begin address of the data memory is 2010
and has the following form:
KIT5K manages all of the communication with the
DS5000T. The in-system loader hardware consists of an
RS232 cable that connects to the RS232 fixtures which
house the appropriate interface circuitry and provides a
40 pin zero-insertion-force socket for the DS5000T. The
fixture in turn attaches to the 40 pin target cable which
connects to the microcontroller socket in the target
:2010 Dt Ut dt 00 Dh Uh dh 00 (spaces are printed for
clarity), where:
Dt
Ut
dt
Dh
Uh
dh
Temperature data, tens
Temperature data, units
Temperature data, decimal
R. humidity data, tens
R. humidity data, units
R. humidity data, decimal
5. RESULTS
The final system has enough memory to store 3068
temperature data points and 3068 relative humidity data
points with rates from 1 s to 99 min.
A measurement of sound absorption by the reverberation
room method [10] was made to test the performance of
the system. In this method when the excitation signal is
turned off, the sound pressure level will decrease and the
rate of decay may be determined from measurements of
the average time for the sound pressure level in a
specified frequency band to decay through 60 dB of
range (reverberation time). Usually this measurement
takes several hours when a complete octave analysis is
necessary. Changes in temperature and relative humidity
Figure 5. Temperature data from reverberant chamber.
29
Instrumentation and Development Vol. 3 Nr. 8/1997
Instrumentación y Desarrollo Vol. 3 No. 8/1997
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
during the course of a measurement may have a large
effect on reverberation time, especially at high frequency
and low relative humidity. The standard [10] demands
that at least the following conditions be satisfied:
temperature variations during all measurements within
3 oC; relative humidity variations during all
measurements within 3%. The MDLS allows us to
monitor the fulfillment of these demands.
end
end
[b,a]=butter(2,.5);
t2= filter(b,a,t);
h2=filter(b,a,h);
t2=t2';
h2=h2';
disp(texto1);
pregunta=input('¨Desea guardar los datos si/no? ','s');
if pregunta=='si'
nom_arch2=input('Dame el nombre y trayectoria para guardar los datos
de tem ','s');
nom_arch3=input('Dame el nombre y trayectoria para guardar los datos
de hume ','s');
eval(['save ',nom_arch2,'.dat',' t2 ','-ascii'])
eval(['save ',nom_arch3,'.dat',' h2 ','-ascii'])
else disp('termine')
end
end
Figure 5 shows temperature data obtained from a sound
absorption measurement. In this figure the data was
plotted in a similar way to the CT485 recordings. Fig. 5
is obtained in MATLAB reading the INTEL Hex file and
transforming the data to ASCII characters. A program to
implement this procedure is included in appendix A.
function p= convdato(a)
% funcion para convertir datos de un archivo Intel hex
% el dato de entrada debe ser un una
% cuerda de 6 caracteres como lo escribe el
% archivo INTEL HEX
bit=isstr(a);
if bit==0,
error('El dato debe ser una cuerda');
end
tam=length(a);
if tam 6,
error('El dato debe una cuerda de 6 caracteres')
end
n1=setstr(hex2dec(a(1:2)));
n2=setstr(hex2dec(a(3:4)));
n3=setstr(hex2dec(a(5:6)));
d=[n1,n2,'.',n3];
p=eval(d);
end
It should be emphasized that data storage allows us to
make other analyses (for example the methods for
correcting the reverberation times proposed by other
authors [11,12]).
6. CONCLUSION
A microcontroller-based data logging system has been
described. It appears to be both an effective tool in
intensive routine measurements and for research. It is
now successfully applied for acoustic measurement in our
laboratory.
APPENDIX
ACKNOWLEDGMENTS
hex_dt.m
% programa para leer datos de un archivo INTEL HEX
% version hecha en febrero de 1996
%
clear
texto=' ejemplo c:\hex\data.hex
';
texto1='
';
disp(texto)
archi_nom=input('Dame el nombre del archivo, con trayectoria y
extension ','s');
disp(texto1);
disp('ESPERE, ESTOY PROCESANDO');
fid=fopen(archi_nom,'r');
F =fread(fid);
status=fclose(fid);
p=length(F);
alfa=setstr(F(1+257*77:p))';
clear F;
long=length(alfa);
datosutil=long-13;
nolineas=(datosutil)/77;
a=[9 25 41 57];
b=[15 31 47 63];
a2=[17 33 49 65];
b2=[23 39 55 71];
for i=1:nolineas-1,
for j= 1:4,
t(4*(i-1)+j)=convdato(alfa(1+a(j)+(i-1)*77:b(j)+(i-1)*77));
h(4*(i-1)+j)=convdato(alfa(1+a2(j)+(i-1)*77:b2(j)+(i1)*77));
Journal of the Mexican Society of Instrumentation
Revista de la Sociedad Mexicana de Instrumentación, A.C.
The authors are very grateful to Ulises Sandoval Paredes
for his help in designing the printed boards and Rosa
Maria Lozano for help with the text.
REFERENCES
1. A. Bohn, "Environmental effects on the Speed of
Sound". J. Audio Eng. Soc. 36, (4), 223-231, (1988).
2. Temperature/RH Recorder model CT485, (Omega
Engineering Inc.), (1993).
3. P. D. Fisher, "Microprocessors Simplify Humidity
Measurements", IEEE Transactions on Instrumentation and Measurement, IM-30, (1), 57-63, (1981).
4. E. Noltingk, Instrumentation Reference Book, 2d Ed.,
(Butterworth - Heinemann), 4, 141-142, (1995).
5. Negro V. C., "A Battery Operated Bubble Memory
Data-acquisition System", IEEE Transactions on
30
A microcontroller-based data logging system. S. J. Pérez, et al. 24-30
Instrumentation and Measurement 37, (2), 305-308,
(1988).
10. ISO 354(E) "Acoustics. Measurement of Sound
Absorption in a Reverberation Room", ISO, (1985).
6. Temperature/Relative Humidity transmitter kit model
HX93C, (Omega Engineering Inc., Stamford), (1993).
11. Y. Hidaka, et al, "Correction for the Effect of
Atmospheric Sound Absorption on the Sound
Absorption Coefficients of Materials Measured in a
Reverberation Room", J. Acoust. Soc. Jpn. E(9), 511,(1988).
7. User's Guide DS5000 Soft Microcontroller, (Dallas
Semiconductor, Dallas, Texas), (1990).
8. Data book, (National Semiconductor, Santa Clara,
California), (1980).
12. G. Benedetto, R. Spagnolo, "A Method for Correcting
the Reverberation Times of Enclosures as a Function
of Humidity and Temperature", App. Accs., 16, 463 470, (1983).
9. Data Sheet: Vacuum Fluorescent Display S03601-92020, (Industrial Electronic Engineers Inc., Van Nuys,
California), (1992).
31
Instrumentation and Development Vol. 3 Nr. 8/1997
Instrumentación y Desarrollo Vol. 3 No. 8/1997
Download