beautypg.com

Measurement Computing Data Acquisition Systems rev.10.4 User Manual

Page 21

background image

Daq device errors will send the program into the error handling routine. This is the error handler. Program
control is sent here on error.

ErrorHandler:
errorString$ = "ERROR in ADC1"
errorString$ = errorString$ & Chr(10) & "BASIC Error :" + Str$(Err)
If Err = 100 Then errorString$ = errorString$ & Chr(10) & "DaqBook Error

: " + Hex$(daqErrno&)

MsgBox errorString$, , "Error!"
End Sub


One-Step Command Acquisitions

This section shows the use of several one-step analog
input routines. These commands are easier to use than
low-level commands but are less flexible in regard to
scan configuration. These commands provide a single
function call to configure and acquire analog input data.
This example demonstrates the use of the 4 Daq device’s
one-step ADC functions. Functions used include:

VBdaqAdcRd&(handle&,chan&, sample%,

gain&)

VBdaqAdcRdN&(handle&,chan&, Buf%(),

count&, trigger%, level%, freq!,
gain&,flags&)

VBdaqAdcRdScan&(handle&,startChan&,

endChan&, Buf%(), gain&, flags&)

VBdaqAdcRdScanN&(handle&,startChan&

, endChan&, Buf%(), count&,
triggerSource&, level%, freq!,
gain&, flags&)


This program will initialize the Daq device hardware,
then take readings from the analog input channels in the
base unit (not the expansion cards). For transporting data
in and out of the Daq device driver, arrays are
dimensioned.

Dim sample%(1), buf%(80), handle&,

ret&, flags&, gain&

The following code assumes that the Daq device has been successfully opened and the

handle&

value is a

valid handle to the device. All the following one-step functions define the channel scan groups to be
analog unipolar input channels. Specifying this configuration uses the

DafAnalog

and the

DafUnipolar

values in the

flags

parameter. The

flags

parameter is a bit-mask field in which each bit specifies the

characteristics of the channel(s) specified. In this case, the

DafAnalog

and the

DafUnipolar

values are

added together to form the appropriate bit mask for the specified

flags

parameter.

The next line requests 1 reading from 1 channel with a gain of ×1. The variable

DgainX1&

is actually a

defined constant from DaqX.bas, included at the beginning of this program.

Note:

DafSigned

does not work in conjunction with DaqBook/100.

ret& = VBdaqAdcRd&(handle& 0, sample%(0), DgainX1&,

DafAnalog&+DafUnipolar&+DafSigned&)

Print Format$“& ####”; “Result of AdcRd:”; sample%(0)

The next line requests 10 readings from channel 0 at a gain of ×1, using immediate triggering at 1 kHz.

ret& = VBdaqAdcRdN&(handle&,0, buf%(), 10, DatsImmediate&, 0, 1000!,

DgainX1&, DafAnalog&+DafUnipolar&)

Print “Results of AdcRdN: ”;
For x& = 0 To 9

Print Format$ “#### ”; buf%(x&);

Next x&

Programmer’s Manual

988594

API Programming, General Models 2-11