Measurement Computing Data Acquisition Systems rev.10.4 User Manual
Page 36

2-26 API Programming, General Models
988594
Programmer’s
Manual
Public Sub LinearConvert()
Dim buffer1%(80), buffer2%(80), flags&(3), hz!(20), psi!(10)
Dim ret&, handle&, chan&, x%
' Initialize DaqBook
handle& = VBdaqOpen&("DaqBook0")
'Set Channel 16 to be a DBK7. This will configure and auto-
'calibrate all channels on the DBK7 which includes channels
'16,17,18, and 19. This step not required for a DBK13
ret& = VBdaqAdcExpSetBank(handle&, 16, DbankDbk7&)
'Set channel option common to all DBK7 channels.
'This step not required by a DBK13.
For chan& = 16 To 19
ret& = VBdaqAdcExpSetChanOption(handle&, chan&, DcotDbk7Slope&, 1)
ret& = VBdaqAdcExpSetChanOption(handle&, chan&, DcotDbk7DebounceTime&,
DcovDbk7DebounceNone&)
ret& = VBdaqAdcExpSetChanOption(handle&, chan&, DcotDbk7MinFreq&, 50!)
ret& = VBdaqAdcExpSetChanOption(handle&, chan&, DcotDbk7MaxFreq&, 60!)
Next chan&
'Channel configuration:
'DaqBook Channels 16, 17: DBK7 channels 0,1
'DaqBook Channel 32: DBK13 channel 0
'Configure the pacer clock, arm the trigger, and acquire 10
'scans. The gain setting of Dbk7X1 (X1 gain) will be applied
'to all channels. The acquisition frequency is set to 100 Hz.
'All channels are unsigned - bipolar.
ret& = VBdaqAdcRdScanN&(handle&, 16, 17, buffer1%(), 10, DatsAdcClock&, 0,
0, 100!, Dbk7X1&, DafUnsigned& + DafBipolar&)
'Now do the same for the DBK13 channel, using gain Dbk13X1000
ret& = VBdaqAdcRdN(handle, 32, buffer2%(), 10, DatsAdcClock&, 0, 0, 100!,
Dbk13X1000&, DafUnsigned& + DafUnipolar&)
'Convert channels 16 and 17 to Hertz where -5 volts corresponds
'to 50 Hz and 5 volts corresponds to 60 Hz.
ret& = VBdaqCvtLinearSetupConvert(2, 0, 2, 50!, -5!, 60!, 5!, 1, buffer1%(),
10, hz!(), 20)
'Convert channel 32 to PSI where 1mV corresponds to 0 PSI and
'4 mV corresponds to 1000 PSI. DBK13 channel 0 has 1000x gain,
'so 1mV at Dbk13 input gives 1V output at DaqBook input.
ret& = VBdaqCvtLinearSetupConvert(1, 0, 1, 0!, 1!, 1000!, 4!, 1, buffer2%(),
10, psi!(), 10)
'Print results
Print "Results:"
For x = 0 To 9
Print Format(hz!(x * 2), "#0.00 Hz "); Format(hz!(x * 2 + 1), "#0.00 Hz
"); Format(psi(x), "0000.0 psi")
Next x
ret& = VBdaqClose(handle&)
End Sub