beautypg.com

Measurement Computing Data Acquisition Systems rev.10.4 User Manual

Page 28

background image

Generating DAC FIFO Waveforms

This program demonstrates the use of the
DAC FIFO to generate waveforms. The
DAC is configured for output on both
channels, and the user waveform is
constructed. Output begins after the
waveform is assigned to a channel. At this
point, the program continues while the
waveforms are generated.

The following example shows how to
generate a pre-defined waveform using
these functions:

VBdaqDacWaveSetTrig&(handle&, deviceType&, chan&, triggerSource&,
rising%)

VBdaqDacWaveSetClockSource&(handle&, deviceType&, chan&, clockSource&)

VBdaqDacWaveSetFreq&(handle&, deviceType&, chan&, freq!)

VBdaqDacWaveSetMode&(handle&, deviceType&, chan&, mode&, updateCount&)

VBdaqDacWaveSetBuffer&(handle&, deviceType&, chan&, buf%(), scanCount&,
transferMask&)

VBdaqDacWaveSetPredefWave&(handle&, deviceType&, chan&, waveType&,
amplitude&, offset&, dutyCycle&, phaseShift&)

VBdaqDacWaveArm&(ByVal handle&, ByVal deviceType&)

When using the pre-defined waveform generation, program the waveform parameters common to both
channels. The double star (**) indicates the value must be the same on both channels of a DaqBoard.

For chan = 0 To 1 Step 1
' set the output mode to static waveform
ret& = VBdaqDacSetOutputMode&(handle&, DddtLocal&, chan&, DdomStaticWave&)

' The trigger source must be set to immediate for static waveform.**
err& = VBdaqDacWaveSetTrig&(handle&, DddtLocal&, chan&, DdtsImmediate&, 1)

' set the internal dac clock
ret& = VBdaqDacWaveSetClockSource&(handle&, DddtLocal&, chan&,

DdcsDacClock&)


' the frequency of the internal clock. **
ret& = VBdaqDacWaveSetFreq&(handle&, DddtLocal&, chan&, 10!)

' must be infinite for static mode
ret& = VBdaqDacWaveSetMode&(handle&, DddtLocal&, chan&, DdwmInfinite&, 0)
Next chan

' buffer cylce on, retransmit mode. **
' update count is the buffer length. **
ret& = VBdaqDacWaveSetBuffer&(handle&, DddtLocal&, chan&, buf0%(),

updateCount&, DdtmCycleOn&)


' set the buffer for channel 1
ret& = VBdaqDacWaveSetBuffer&(handle&, DddtLocal&, chan&, buf1%(),

updateCount&, DdtmCycleOn&)


' program the waveform parameters specific to dac channel 0
ret& = VBdaqDacWaveSetPredefWave&(handle&, DddtLocal&, 0, DdwtTriangle&,

32768, 32768, 90, 0)


' program the waveform parameters specific to dac channel 1
ret& = VBdaqDacWaveSetPredefWave&(handle&, DddtLocal&, 1, DdwtSquare&,

32768, 32768, 40, 0)


' buffer must be configured before the arm command is called. All channels
' will be armed.

2-18 API Programming, General Models

988594

Programmer’s

Manual

ret& = VBdaqDacWaveArm(handle&, DddtLocal&)