ChartScan Program Examples Appendix D
D-10 ChartScan User’s Manual
PRINT “The ChartScan is currently collecting pre-trigger data..”
PRINT “The ChartScan has not been triggered..”
PRINT “Hit a key to start a trigger event ..”:
WHILE INKEY$ = “”: WEND
PRINT #1, “output07;@X”
WHILE (S% AND 2) <> 2
PRINT #1, “SPOLL 07"
INPUT #2, S%
WEND
PRINT “A Start Trigger has been detected..”
PRINT “Waiting for acquisition complete..including Post and Post-Stop
Scans”
Using the event status register command “U0X”, we now wait until the acquisition complete event which
includes the stop event.
WHILE (E% AND 1) <> 1
PRINT #1, “OUTPUT 07;U0X”
PRINT #1, “ENTER 07"
INPUT #2, E%
WEND
PRINT “The Acquisition is now complete”
Before reading the data, the F command is sent, instructing the ChartScan to return the data in a binary
format where every value will be 2 bytes in length. This command could have been issued anytime after the
initial reset and stays in effect until the unit is reset again or another F command is issued.
PRINT #1, “OUTPUT 07;F0,1X”
During or after the acquisition has been completed, the internal buffer can be queried for the amount of data
available for transfer. The U6 command will return the trigger block number, the current scan number, the
current read pointer, the trigger time/date stamp, the scan number where the stop event occurred, the stop
time/date stamp, the scan number of the end of the trigger block, and the block complete flag.
This example uses the last parameter in the return string as an indicator of how much data is available to
transfer to the controller. QuickBASIC’s MID$ function extracts 6 characters from the string U$ starting at
character 8.
‘Query the ChartScan for the # of scans available in the Buffer
PRINT #1, “OUTPUT 07;U6X”
PRINT #1, “ENTER 07"
LINE INPUT #2, U$
PRINT U$
UA$ = MID$(U$, 9, 7)
UA% = VAL(UA$)
PRINT UA%
PRINT “The ChartScan collected ”; UA%; “ scans of data”
After calculating the number of scans, an integer-type buffer is then prepared for the data. The offset and
segment pointers are supplied to the IEEE 488 driver so that the data can be transferred using DMA (direct
memory access).
The R2 command instructs the ChartScan to supply the entire block of data that is presently available.
CHANNELS = 16
DIM CBUFFER%(UA% * CHANNELS)
SE% = VARSEG(BUFFER%(0))
OF% = VARPTR(BUFFER%(0))
B& = UA% * CHANNELS * 2
PRINT “Total number of Bytes available : ”; B&
PRINT #1, “OUTPUT 07;R2X”
PRINT “Uploading data..”
WHILE INKEY$ = “”: WEND
PRINT #1, “ENTER 07 #”; B&; “BUFFER ”; SE%; “:”; OF%; “ DMA”
At the completion of the DMA transfer, the integer data is now in the buffer BUFFER%. To convert the
integer data into temperatures, a simple calculation is performed.
BINARY DATA%/10 = °C