23
Signametrics
5.3 Visual Basic Front Panel Application
The Visual Basic front panel application,
SMU2064.EXE,
is an interactive control panel for the SM2060 family of
DMMs. When it loads it will take a few seconds to initialize and self calibrate the hardware before the front panel is
displayed.
The push buttons labeled
V,
I
, etc. control the DMM function. As you push a function, the front panel application
will switch the DMM to the selected range and function. Autorange mode is selected by pushing the
AutoRange
check box. The
S-Cal
box recalibrates the DMM, leaving the DMM in the same state prior to operation. (This is an
internal calibration only, and is different from the external calibration, which writes to the
SM60CAL.DAT
file.
S-Cal
is used to correct for any internal offset and gain drifts due to changes in operating temperature).
The source code file
2060Glbl.BAS
(in the
V_BASIC
directory of the distribution diskette) contains the function
declarations and the various ranges, rates and other parameters that are required. These definitions are the duplicates
of the “C” header files required to write Visual Basic applications which interact with the driver DLL, along with
some global variables required for this particular front-panel application.
5.3.1 Visual Basic Simple Application
The following is a simple panel application for Visual Basic, which includes two files, Global.Bas and
SimplePanel.frm. It has a panel that contains two objects, a
Text Box
to display the DMM readings, and a
Command Button
that acts as a reading trigger.
Global.bas module file contents:
Option Explicit
' Declare all functions we are going to be using: From SMU2060.H file.
Declare Function DMMInit Lib "SM2060.dll" (ByVal nDmm as long, ByVal calFile As String) As Long
Declare Function DMMSetRate Lib "SM2060.dll" (ByVal nDmm As Long, ByVal nRate As Long) _
As Long
Declare Function DMMSetFunction Lib "SM2060.dll" (ByVal nDmm As Long, ByVal nFunc As Long) As Long
Declare Function DMMSetRange Lib "SM2060.dll" (ByVal nDmm As Long, ByVal nRange As Long) As Long
Declare Function DMMRead Lib "SM2060.dll" (ByVal nDmm As Long, dResult As Double) As Long
' Definitions from DMMUser.H
' for DMMSetFunction()
Global Const VDCFunc = 0
Global Const VACFunc = 4
Global Const Ohm2Func = 21
Global nDmm as Long
' for DMMSetRange()
Global Const Range0 = 0
Global Const Range1 = 1
Global Const Range2 = 2
Global Const Range3 = 3
'Measurement Rate for use with DMMSetRate()
Global Const RATE_1R60= 4 '1rps with 60Hz line rejection
Global Const RATE_1R50 = 5 '1rps with 50Hz line rejection
Global Const RATE_2R60= 6 '2rps
Global Const RATE_4R60 = 8 '4rps
Global nDmm As Long ' Global store for the DMM number
SimplePanel.frm Form file contents:
Private Sub Form_Load()
'Fomr_Load allways gets executed first.
Dim i As Long
nDmm = 0
‘Set to first DMM in the system
i = DMMInit(nDmm,"C:\SM60CAL.dat") 'Initialize and load cal file
i = DMMSetFunction(nDmm, VDCFunc) 'Set DMM to DCV function
i = DMMSetRange(nDmm, Range2) 'Select the 24V range
i = DMMSetRate(nDmm, RATE_2R60) 'Set measurement rate
End Sub