Making Measurements
4
Using the SREAL output format
The following program shows how to convert 10 readings output in the SREAL
format.
10OPTION BASE 1!COMPUTER ARRAY NUMBERING STARTS AT 1
20INTEGER Num_readings!DECLARE VARIABLE
30Num_readings=10!NUMBER OF READINGS = 10
40ALLOCATE REAL Rdgs(1:Num_readings)!CREATE ARRAY FOR READINGS
50ASSIGN @Dvm TO 722!ASSlGN MULTIMETER ADDRESS
60ASSIGN @Buffer TO BUFFER [4*Num_readings]
!ASSIGN BUFFER I/O PATH
NAME
70OUTPUT @Dvm;"PRESET NORM;OFORMAT SREAL;NRDGS";Num_readings
75!TRlG SYN, SREAL OUTPUT FORMAT, 1 PLC, DCV AUTORANGE, 10 READINGS
80TRANSFER @Dvm TO @Buffer;WAIT!SYN EVENT; TRANSFER READINGS
90FOR I=1 TO Num_readings
100ENTER @Buffer USING "#,B";A,B,C,D!ENTER ONE 8-BIT BYTE INTO
101!EACH VARIABLE, (# =STATEMENT TERMINATION NOT REQUIRED, B = ENTER ONE
105!8-BIT BYTE AND INTERPRET AS AN INTEGER BETWEEN 0 AND 255)
110S=1!CONVERT READING FROM SREAL
120IF A>127 THEN S=-1!CONVERT READING FROM SREAL
130IF A>127 THEN A=A-128!CONVERT READING FROM SREAL
140A=A*2- 127!CONVERT READING FROM SREAL
150IF B>127 THEN A=A+1!CONVERT READING FROM SREAL
160IF B<=127 THEN B=B+128!CONVERT READING FROM SREAL
170Rdgs(I)=S*(B*65536.+C*256.+D)*2^(A-23)!CONVERT READING FROM SREAL
180Rdgs(I)=DROUND(Rdgs(I),7)!ROUND READING TO 7 DIGITS; YOU
181!MUST DO THIS WITH SREAL TO ENSURE ANY OVLD VALUES ARE ROUNDED TO
185!1.E+38 (WITHOUT ROUNDING, THE VALUE MAY BE SLIGHTLY LESS)
190IF ABS(Rdgs(I))=1.E+38 THEN!IF OVERLOAD OCCURRED:
200PRINT "Overload Occurred"!PRINT OVERLOAD MESSAGE
210ELSE!IF NO OVERLOAD OCCURRED:
220PRINT Rdgs(I)!PRINT READING
230END IF
240NEXT I
250END
Keysight 3458A User's Guide
153