Foreground acquisition with one-step commands – Measurement Computing Personal Daq rev.6.0 User Manual

Page 122

Advertising
background image

At this point, the data is in
the buffer provided by the
user in binary format.

At this point, the data is in
the buffer provided by the
user in binary format.

At this point, the data is in
the buffer provided by the
user in binary format.

User Code

User Code

User Code

Read 1 sample from
1 channel.

daqAdcRd

Read multiple samples from
1 channel.

daqAdcRdN

daqAdcRdScan

Read 1 sample from multiple
channels.

Foreground Acquisition with One-Step Commands

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

VBdaqAdcRdSingle&(ByVal handle&, ByVal chan&,
sample!, ByVal gain&, ByVal flags&)

VBdaqAdcRdNSingle&(ByVal handle&, ByVal chan&,
buf!(), ByVal ScanCount&, ByVal triggerSource&,
ByVal rising&, ByVal level%, ByVal Freq!, ByVal
gain&, ByVal flags&)

VBdaqAdcRdScanSingle&(ByVal handle&, ByVal
startChan&, ByVal endChan&, buf!(), ByVal gain&, ByVal
flags&)

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

Dim sample!(1), buf!(80), handle&, ret&, flags&, gain&

The following code assumes that the Personal 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 value 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 value is used as the bit mask for the specified flags parameter.

The next line requests 1 reading from 1 channel with a gain of ×1. The variable PgainX1& is actually a defined
constant from

PDAQX.BAS

.

ret& = VBdaqAdcRdSingle&(handle&, 1, sample!(0), PGainX1&, DafAnalog)
Print "Result of AdcRd: " & Format$(Str$(sample%(0)), "0000")

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

ret& = VBdaqAdcRdNSingle&(handle&, 1, buf!(), 10, DatsImmediate&, 0, 0, 1000!, _
PGainX1&, DafAnalog)

Print "Results of AdcRdN: ";
For x& = 0 To 9
Print Format$(str$(buf%(x&)), "#### ");
Next x&

The program will then collect one sample of channels 1 through 8 using the VBdaqAdcRdScan function.

ret& = VBdaqAdcRdScanSingle&(handle&, 1, 8, buf!(), PGainX1&, DafAnalog)
Print "Results of AdcRdN: ";
For x& = 0 To 7
Print "Channel: " & Str$(x + 1) & " Data: " + Format$(buf%(x&), "#### ")

Next x&

A-4 API Custom Program Modules Appendix A,

878495

Personal Daq User’s Manual

Advertising
This manual is related to the following products: