e003X10.pdf

(69 KB) Pobierz
002010-UK JAVA multimeter
Java is a world language. Many people think that this pro-
gramming language, which was developed by Sun
Microsystems, is only suitable for embellishing Internet pages
with cute applets. Nothing could be further from the truth.
Java is a fully-fledged programming language that can be
used for making Internet applets and stand-alone applica-
tions for all possible platforms. What about a Java applica-
tion in a ring, a credit card or your toaster? It’s all possible!
By G. Polder
Java MultiMeter (JMM)
handy software for RS232 multimeters
in the past. In addition, the information
in the log window can be stored for
subsequent processing, for example
using a spreadsheet program.
If you click on ‘Plot’, a plot window
appears that displays the measured
values in graphic form. This plotting
function works in a fairly advanced
manner. The scale is automatically
adjusted after each new measurement
point is added. You can use the mouse
to draw a rectangle over part of the
plot, and then zoom in by moving the
mouse down and to the right, or zoom
out by moving the mouse up and to
the left. If you press the ‘Fill’ button, the
full set of data is displayed again. Sev-
eral plot windows can be open at the
same time. New measurement data
are always entered in the most recently
opened window.
Figure 1. The main window of Java MultiMeter shows the settings of the multimeter con-
nected to the PC, and the measured value in the form of a number and a bar graph.
The buttons can be used to manually make a new measurement or enable the pro-
gram to automatically read in measurements at a regular interval.
Operation
Java is an object-oriented language.
This means that the programmer makes
objects that communicate with each
other and that are ‘semi-concurrently’
active. The most important objects in
JMM are the following:
In this project, Java is used for reading
data from a multimeter that has an
RS232 port (such as the Voltcraft model
3850d). For more background informa-
tion on this type of multimeter, see the
April 1997 issue of Elektor Electronics .
Java MultiMeter (JMM) has a very sim-
ple design. The main window displays
the measurement value, the range and
a bargraph (a semi-analogue mea-
surement bar), plus a number of but-
tons. The READ button at the lower right
is used to read in a value, while the
START and STOP buttons can be used to
control repetitive measurements at an
adjustable interval that can be set
using a slider (Sequence).
Up to now, this is nothing unusual. How-
ever, there is more. At the top of the
window there is a menu bar that has
two options in the Window menu,
namely ‘Plot’ and ‘Log’. If you click on
‘Log’, a logging window appears that
displays all measured values and the
time of each measurement. This can
be useful for looking at what happened
the main object, which contains the
measurement data, the buttons and
a timer that periodically sends a ‘D’ to
the RS232 port if it is enabled;
an RS232 receiver object, which col-
lects RS232 data and sends the entire
string to the main object after it
receives a <CR>(Carriage Return)
sequence;
a log object, which receives mea-
surement strings from the main
10 - 3/2000 Elektor Electronics EXTRA —————————————— PC T OPICS
138910236.003.png 138910236.004.png
Figure 2. The log window displays a summary of all measure-
ments, with their associated dates and times.
Figure 3. The plot module shows a graphic diagram of the
most recently measured values. Several plot windows can be
open at the same time.
object, attaches date and time infor-
mation to them and organises them
into a list;
ful Java programming environment;
on the Elektor CD-ROM PC Software 98-
99 (ISBN 90-5381-106-0).
Solutions Consulting serial port soft-
ware: these are Java classes (rou-
tines) and Windows DLLs that allow
Java to make use of the RS232 ports
of the computer;
(002010-1)
plot objects, among which the most
recent object graphically displays the
data that are received from the main
object.
The program JMM won the third prize in the
Netherlands division of the PC software com-
petition organised by Elektor in June 1998. All
winning entries for this competition are col-
lected on the above-mentioned CD-ROM.
PT-Plot: a Java plotting package.
Required hardware
One of the features of Java is that it is
platform-independent. This is achieved
by running Java programs on what is
called a Java Virtual
Machine. With Visual
Cafe, it is possible to
combine the Java
programs with the Vir-
tual Machine into a
single .EXE file. JMM
utilises this capability.
This however means
that a number of
Semantic DLLs must
be installed. An instal-
lation program for
these DLLs, which also
includes the remain-
ing components of
JMM, may be found
The demands placed on the computer
are not particularly high. It must of
course be a PC that runs under Win-
dows 95/98 or Windows NT.
In addition, a digital multimeter with an
RS232 port (such as the Voltcraft model
3850d) is needed to provide the mea-
surements to the computer via a serial
channel. Finally, a suitable RS232 cable
is needed to interconnect the meter
and the computer.
Required files
jmm.exe
The Java MultiMeter program.
csall
This folder contains a number of Solutions
Consulting serial port DLLs.
Place these DLLs in the folder c:\windows\sys-
tem32 (for Windows 95/98)
or c:\winnt\system32 (for Windows NT).
snjrt20.exe
Installation program for Semantic Java run-
time DLLs.
The software
libwin95
Property files for Windows 95/98.
Copy these files to the folder c:\windows\sys-
tem\lib.
The software was produced using the
following software packages:
libwinnt
Property files for Windows NT.
Copy these files to the folder c:\winnt\sys-
tem32\lib.
Symantic Visual Cafe: this is a power-
The serial protocol
Programming the communications between the PC and a digital mul-
timeter with a serial interface is fairly easy if you use a high-level pro-
gramming language such as Visual BASIC, Visual C ( Java ) or Visual
Pascal ( Delphi ).
To start with, the serial interface that is used must be initialised. For most
DMMs, it should be configured to 1200 bps, no parity bit, 7 data bits in
ASCII format, 2 stop bits and software handshaking. This completes the
preparations for transferring measurement values. All that the comput-
er or program has to do now is to request a measurement value. This is
done by sending the character ‘D’ (#68) to the DMM. In response, the PC receives a string of characters that contain the current measure-
ment value, the unit and the measurement range. The received string is 14 bytes long, as shown in the figure below. The DMM models 506
and M-3860M are exceptions to this rule. The latter model works at a data rate of 9600 baud and always sends the measurement values
for the main display and the three auxiliary displays as a single data packet that is 56 bytes long. The model 506 works at 1200 baud, but
it sends a data packet whose length varies between 6 and 15 bytes. All DMMS are rather slow in operation; new measurements are sent to
the PC no more often than once every 0.5 second.
12
3
4567890
1234
example 1:
DC –16. 23
mVCR
example 2:
RE
S
3 . 999M
O H M CR
measurement
range
measured value
unit
end
recognition
970035 - 15
PC T OPICS ————————————— Elektor Electronics EXTRA
11 - 3/2000
138910236.005.png 138910236.006.png 138910236.001.png 138910236.002.png
Zgłoś jeśli naruszono regulamin