
5-4
IM 704310-12E
5.4
Example of Output in BINARY Format
'*********************************************************************
'* *
'* TA520 Sample Program3 for GP-IB interface *
'* Microsoft QuickBASIC 4.0/4.5 Version *
'* *
'*********************************************************************
'* *
'* Outputs the data measured in time stamp mode in binary format. *
'* *
'*********************************************************************
'
REM $INCLUDE: 'qbdecl4.bas'
'
DEVICE$ = "DEV1": CALL IBFIND(DEVICE$, TA%)
CALL IBSIC(TA%)
BORD$ = "GPIB0": CALL IBFIND(BORD$, BD%)
CALL IBSIC(BD%)
V% = 1: CALL IBSRE(BD%, V%)
CALL IBCLR(TA%)
'
CMD$ = "MEASURE:MODE TSTAMP"
'Hardware histogram mode
CALL IBWRT(TA%, CMD$)
CMD$ = "MEASURE:FUNCTION TI,AB"
'Time interval measurement
CALL IBWRT(TA%, CMD$)
CMD$ = "SAMPLE:GATE:MODE EVENT"
'Event gate
CALL IBWRT(TA%, CMD$)
CMD$ = "SAMPLE:GATE:EVENTSIZE 1000"
'Sampling size to 1000 points
CALL IBWRT(TA%, CMD$)
'
CMD$ = "STATUS:FILTER1 RISE"
'Set transition filter
CALL IBWRT(TA%, CMD$)
CMD$ = "STATUS:EESR?"
'Clear extended event register
CALL IBWRT(TA%, CMD$)
RES$ = SPACE$(100)
CALL IBRD(TA%, RES$)
'
CMD$ = "SSTART"
'Start single measurement
CALL IBWRT(TA%, CMD$)
CMD$ = "COMMUNICATE:WAIT 1"
'Wait for measured data to become valid
CALL IBWRT(TA%, CMD$)
'
CMD$ = "MEMORY:DATASELECT MEASUREDATA"
'Set the type of data to retrieve
CALL IBWRT(TA%, CMD$)
CMD$ = "MEMORY:FORMAT BINARY;BYTEORDER LSBFIRST"
'Set the format
CALL IBWRT(TA%, CMD$)
'
ST% = 1: ED% = 1000
'Set the start and end points
FOR I% = ST% TO ED% STEP 50
'Retrieve 50 points at a time
CMD$ = "MEMORY:START" + STR$(I%) + ";END" + STR$(I% + 49)
CALL IBWRT(TA%, CMD$)
CMD$ = "MEMORY:SEND?"
'Request measured data
CALL IBWRT(TA%, CMD$)
RES$ = SPACE$(250)
CALL IBRD(TA%, RES$)
'Receive measured data
J% = VAL(MID$(RES$, 2, 1))
'Analyze the header section
K% = VAL(MID$(RES$, 3, J%)) / 4
N% = J% + 3
FOR M% = 1 TO K%
L% = CVI(MID$(RES$, N%, 2))
'Convert binary to real number
IF L% < 0 THEN D# = L% + 65536# ELSE D# = L%
H% = CVI(MID$(RES$, N% + 2, 2))
IF H% < 0 THEN D# = D# + (H% + 65536#) * 65536# ELSE D# = D# + H% * 65536#
D# = D# * .000000000025#
PRINT I% + M% - 1, D#
'Display measured values
N% = N% + 4
NEXT M%
NEXT I%
'
V% = 0: CALL IBSRE(BD%, V%)
'
END
Output Example
1 .000000024075
2 .0000000259
3 .000000027850
4 .000000024225
5 .000000030625
6 .000000026425
7 .00000002
8 .0000000322
9 .00000002785
10 .0000000268
: :
: :
5.4 Example of Output in BINARY Format