Measurement Computing TempBook rev.3.0 User Manual
Page 114

10-18 Enhanced API Programming Models (TempBook)
TempBook User’s Manual
Temperature Acquisition Using TC Conversion Functions
This example demonstrates the general-purpose data-transfer functions
coupled with TC-specific conversion routines. This method first configures
the channel scan group for thermocouple input, then acquires the raw A/D
data from the thermocouple input, and finally, converts the raw A/D data to
temperature units in degrees C.
•
VBdaqOpen&(daqName$)
•
VBdaqAdcSetFreq& (handle&, freq!)
•
VBdaqAdcSetAcq& (handle&, mode&, preTrigCount&,
postTrigCount&)
•
VBdaqAdcSetScan& (handle&, channels&(),
gains&(), flags&(), chanCount&)
•
VBdaqAdcSetClockSource&(handle&, clockSource&)
•
VBdaqAdcSetTrig& (handle&, triggerSource&, rising&,
level%, hysteresis%, channel&)
•
VBdaqAdcTransferSetBuffer&(handle&, buf%(),
scanCount&, transferMask&)
•
VBdaqAdcTransferStart& (handle&)
•
VBdaqAdcArm&(handle&)
•
VBdaqWaitForEvent(handle&, event&)
•
VBdaqAdcTransferGetStat& (handle&, active&,
retCount&)
•
VBdaqCvtTCSetupConvert(nscan&, cjcPosition&, ntc&,
tcType&, bipolar&, avg&, counts%(), scans&,
temp%(), ntemp&)
•
VBdaqClose&(handle&)
The following list defines the necessary constants and variables for
temperature acquisition and conversion.
Const Scans& = 10
Const Level% = 0
Const Rising& = 0
Const Start& = 0
Const End& = 7
Const NumTcChans& = End& - Start& + 1
Const TotalChans& = NumTcChans + 3
Const TcGain& = TbkBiTypeJ&
Const CjcGain& = TbkBiCJC&
Const TcType& = TbkTCTypeJ&
Const Freq! = 1000.0
Const AvgType& = 0
Const Gain& = TbkBiTypeJ&
Const Flag& = DafUnsigned& + DafDifferential& + DafBiPolar&
Const Chans& = End& - Start&+1
Dim
buf%(Scans& * TotalScans&)
Dim temp%(NumTcChans&)
Dim handle&
Dim
I&,j&, active&, retCount&
Dim Gains&(TotalChans&)
Dim Chans&(TotalChans&)
Dim Flags&(TotalChans&)
First, we need to open the TempBook/66 device. This example uses a device named “TempBook0”. The
device name must be for a valid configured device.
‘ Open TempBook/66 device
handle& = VBdaqOpen&(“TempBook0”)
Next, build the channel scan group configuration. The following code sets up the configuration arrays that
define the channel scan group. The channels are configured with the appropriate gain, mode and polarity
definitions.
‘ Configure CJC and shorted channel