Measurement Computing TempBook rev.3.0 User Manual
Page 104

10-8 Enhanced API Programming Models (TempBook)
TempBook User’s Manual
ret& = VBdaqAdcRdN(handle&, Start&, temps%(), Scans&, DatsImmediate&,
Rising&, Level&, Freq!, TbkBiTypeJ&, Flags&)
The averaging of the temperature values into a single temperature value is performed through the following:
sum! = 0.0
For I& =0 To Scans&
sum! = sum! + temps%(I&)
Next I&
sum! = sum!/Scans&
The averaged temperature can now be printed out.
Print "Results of daqAdcRdN: (“,Scans&,” readings averaged)"
Print "Channel”, Start&, “ Temperature: “, sum!/10.0, “C”
Next, a single scan will be retrieved for a multiple channel scan configuration. The following statement
configures the scan from the Start& (0) to the End& (0) and configures each channel as a type J
thermocouple. The returned values for each channel will be placed in the temps% array and will be 16-bit
words representing tenths of degrees C.
ret& = VBdaqAdcRdScan& (handle&, Start&, End&, temps%(), TbkBiTypeJ&,
Flags&)
Print "Result of daqAdcRdScan (Single Readings) : "
For I& = Start& To End&
Print "Channel “, I&,” Temperature “, temps%(I&)/10.0, “ C “
Next I&
Finally, we will retrieve multiple scans for a multiple-channel scan configuration. The scan will be defined
using type J thermocouples for each channel in the scan group configuration. The scan group will start at
Start& (0)
and go to End& (0); and all channels will be type J thermocouples. The returned
values will be placed in the temps% array and will be 16-bit words representing tenths of degrees C.
ret& = VBdaqAdcRdScanN& (handle& , Start&, End& , temps%, Scans&,
DatsImmediate&, Rising&, Level&, Freq!, Gain&, Flags&)
The following code will average all samples collected for each channel and display the results.
‘ Zero the totals
For I& = Start& To End&+1
totals!(I&) = 0.0
Next I&
‘ Average the temperatures
For I& = 0 To Scans&
For j& = Start& To End&
totals!(j&) = totals!(j&) + temps%(I&*Chans& + j&)
Next j&
Next I&
‘ Divide the totals
For I& = 0 To Chans&
totals!(I&) = totals!(I&)/Scans&
Next I&
‘ Print "Results of daqAdcRdScanN: "
For I& = 0 To Scans&
Print "Channel”, I&, “ Temperature: “, totals!(I&)/10.0, “C”
Next I&
‘ Close the TempBook/66
ret& = VBdaqClose&(handle&)