DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB pdierr (er%) DECLARE SUB pdibreak () DECLARE SUB pdistatbits (regnum%, statbits$) DECLARE SUB pdistatbyte (regnum%, statbyte$, statbits$) '**************************************************************************** 'Module PDI5025 'This module contains subroutines for the Metrolab PDI-5025 precision 'digital integrator. ' 'Zachary Wolf '8/3/95 '**************************************************************************** 'Common block for this module COMMON SHARED /pdi5025/ gpibinP%, gpiboutP%, pdi5025addrP$ 'Semi-permanent parameters CONST terminP$ = "CR LF" CONST termoutP$ = "CR LF" SUB pdierr (er%) '**************************************************************************** 'This subroutine checks for command errors. ' 'Output: ' er%, 0 for no error, 1 if there was an error ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Initialize er% = 0 'Register 1 'Get the register 1 status bits in a string CALL pdistatbits(1, statbits$) 'Check the command error bit (bit 5, position 3) er$ = MID$(statbits$, 3, 1) IF er$ <> "0" THEN er% = 1 'Check the over range error bit (bit 4, position 4) er$ = MID$(statbits$, 4, 1) IF er$ <> "0" THEN er% = 1 'Print a message if there is an error IF er% = 1 THEN PRINT "PDI ERROR: Register 1 status bits = "; statbits$; ", er% = "; er% END IF 'Register 2 'Get the register 2 status bits in a string CALL pdistatbits(2, statbits$) 'Check the autotest failed bit (bit 3, position 5) er$ = MID$(statbits$, 5, 1) IF er$ <> "0" THEN er% = 1 'Check the encoder count error bit (bit 2, position 6) er$ = MID$(statbits$, 6, 1) IF er$ <> "0" THEN er% = 1 'Check the data buffer full bit (bit 1, position 7) er$ = MID$(statbits$, 7, 1) IF er$ <> "0" THEN er% = 1 'Check the trigger too fast bit (bit 0, position 8) er$ = MID$(statbits$, 8, 1) IF er$ <> "0" THEN er% = 1 'Print a message if there is an error IF er% = 1 THEN PRINT "PDI ERROR: Register 2 status bits = "; statbits$; ", er% = "; er% END IF 'Register 4 'Get the register 4 status bits in a string CALL pdistatbits(4, statbits$) 'Check the channel B overrange - bit (bit 5, position 3) er$ = MID$(statbits$, 3, 1) IF er$ <> "0" THEN er% = 1 'Check the channel B overrange + bit (bit 4, position 4) er$ = MID$(statbits$, 4, 1) IF er$ <> "0" THEN er% = 1 'Check the channel A overrange + bit (bit 1, position 7) er$ = MID$(statbits$, 7, 1) IF er$ <> "0" THEN er% = 1 'Check the channel A overrange - bit (bit 0, position 8) er$ = MID$(statbits$, 8, 1) IF er$ <> "0" THEN er% = 1 'Print a message if there is an error IF er% = 1 THEN PRINT "PDI ERROR: Register 4 status bits = "; statbits$; ", er% = "; er% END IF END SUB SUB pdiindexrd '**************************************************************************** 'This subroutine verifies that an index pulse has been found. ' 'Zachary Wolf '1/4/96 '**************************************************************************** 'Wait until the index pulse is found synchro$ = "0" DO WHILE synchro$ = "0" CALL pdistatbits(1, statbits$) cmderr$ = MID$(statbits$, 3, 1) 'Register 1, bit 5, position 3 IF cmderr$ <> "0" THEN PRINT "PDIVTROTENCINDEX: Command error" synchro$ = MID$(statbits$, 8, 1) 'Register 1, bit 0, position 8 ' PRINT "PDIINDEX: waiting for synchronization, statbits = "; statbits$ SLEEP 1 LOOP END SUB SUB pdiindexst (d$) '**************************************************************************** 'This subroutine has the PDI5025 locate the encoder index pulse. This is 'done to establish a starting point for the integrated voltage measurements. ' 'Input: ' d$, rotation direction ' 'Zachary Wolf '11/9/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Find the index pulse CALL gpibout(pdi5025addrP$, "IND," + d$) 'A command now needs to be issued to move the encoder 'PDIINDEXRD is then called to verify that an index pulse has been found END SUB SUB pdiinit '**************************************************************************** 'PDI5025INIT 'This subroutine initializes the Metrolab PDI5025 integrator. ' 'Zachary Wolf '8/3/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Message PRINT PRINT "Resetting the Metrolab PDI5025 Integrator..." 'Clear the PDI5025 CALL gpibclrdev(pdi5025addrP$) 'Put the PDI in an idle state CALL gpibout(pdi5025addrP$, "BRK") 'Set the gain to the lowest value CALL gpibout(pdi5025addrP$, "SGA,1") 'Display the version number CALL gpibout(pdi5025addrP$, "VER") CALL gpibin(pdi5025addrP$, a$) PRINT a$ 'Display status information PRINT "Status: " FOR i% = 1 TO 7 CALL pdistatbyte(i%, statbyte$, statbits$) PRINT " " + statbyte$ + " " + statbits$ NEXT i% END SUB SUB pdioffset (c$, g%) '**************************************************************************** 'This subroutine is used to do an offset adjustment on the PDI5025. ' 'Input: ' c$, the integrator channel, A or B ' g%, the gain value, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Check input variables IF c$ <> "A" AND c$ <> "B" THEN PRINT "PDI5025: Integrator channel setup problem" EXIT SUB END IF IF g% <> 1 AND g% <> 2 AND g% <> 5 AND g% <> 10 AND g% <> 20 AND g% <> 50 AND g% <> 100 AND g% <> 200 AND g% <> 500 AND g% <> 1000 THEN PRINT "PDI5025: Integrator gain setup problem" EXIT SUB END IF 'Select the integrator channel CALL gpibout(pdi5025addrP$, "CHA," + c$) 'Set the gain CALL gpibout(pdi5025addrP$, "SGA," + LTRIM$(STR$(g%))) 'Message PRINT PRINT "PDI-5025 Offset Adjustment" 'Put the PDI-5025 in offset adjustment mode CALL gpibout(pdi5025addrP$, "ADJ," + c$ + ",1:") CALL pdierr(e%) 'Have the user adjust the offset PRINT PRINT "Adjust the offset screw on channel " + c$ PRINT "until the integrator value is 000." INPUT "Press ENTER when finished.", a$ 'End offset adjustment mode CALL gpibout(pdi5025addrP$, "ADJ," + c$ + ",0") CALL pdierr(e%) END SUB SUB pdisetpar (gpibinf%, gpiboutf%, pdi5025addr$) '**************************************************************************** 'This subroutine sets all required PDI5025 parameters. ' 'Input: ' gpibinf%, GPIB input file number ' gpiboutf%, GPIB output file number ' pdi5025addr$, PDI5025 GPIB address in a string ' ' 'Zachary Wolf '9/12/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "PDI5025: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "PDI5025: GPIB problem" EXIT SUB END IF IF pdi5025addr$ = "" THEN PRINT "PDI5025: GPIB problem" EXIT SUB END IF 'Put the input parameters in the local common block gpibinP% = gpibinf% gpiboutP% = gpiboutf% pdi5025addrP$ = pdi5025addr$ END SUB SUB pdistatbits (regnum%, statbits$) '**************************************************************************** 'PDI5025STATUS 'This subroutine displays the status of the Metrolab PDI5025 integrator. ' 'Input: ' regnum%, the status register number to query ' 'Output: ' statbits$, string showing bit pattern making up the status byte ' 'Zachary Wolf '8/31/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Get the status information CALL gpibout(pdi5025addrP$, "STB," + LTRIM$(STR$(regnum%))) CALL gpibin(pdi5025addrP$, statbits$) END SUB SUB pdistatbyte (regnum%, statbyte$, statbits$) '**************************************************************************** 'PDI5025STATUS 'This subroutine displays the status of the Metrolab PDI5025 integrator. ' 'Input: ' regnum%, the status register number to query ' 'Output: ' statbyte$, contents of the status register, one byte or two characters ' statbits$, string showing bit pattern making up the status byte ' 'Zachary Wolf '8/3/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Get the status information as a hexadecimal byte CALL gpibout(pdi5025addrP$, "STH," + LTRIM$(STR$(regnum%))) CALL gpibin(pdi5025addrP$, statbyte$) 'Find the bit pattern 'Lowest 4 bits nibble0$ = MID$(statbyte$, 2, 1) IF nibble0$ = "0" THEN bits0$ = "0000" ELSEIF nibble0$ = "1" THEN bits0$ = "0001" ELSEIF nibble0$ = "2" THEN bits0$ = "0010" ELSEIF nibble0$ = "3" THEN bits0$ = "0011" ELSEIF nibble0$ = "4" THEN bits0$ = "0100" ELSEIF nibble0$ = "5" THEN bits0$ = "0101" ELSEIF nibble0$ = "6" THEN bits0$ = "0110" ELSEIF nibble0$ = "7" THEN bits0$ = "0111" ELSEIF nibble0$ = "8" THEN bits0$ = "1000" ELSEIF nibble0$ = "9" THEN bits0$ = "1001" ELSEIF nibble0$ = "A" THEN bits0$ = "1010" ELSEIF nibble0$ = "B" THEN bits0$ = "1011" ELSEIF nibble0$ = "C" THEN bits0$ = "1100" ELSEIF nibble0$ = "D" THEN bits0$ = "1101" ELSEIF nibble0$ = "E" THEN bits0$ = "1110" ELSEIF nibble0$ = "F" THEN bits0$ = "1111" ELSE PRINT "PDI5025: Problem with byte conversion" END IF 'High 4 bits nibble1$ = MID$(statbyte$, 1, 1) IF nibble1$ = "0" THEN bits1$ = "0000" ELSEIF nibble1$ = "1" THEN bits1$ = "0001" ELSEIF nibble1$ = "2" THEN bits1$ = "0010" ELSEIF nibble1$ = "3" THEN bits1$ = "0011" ELSEIF nibble1$ = "4" THEN bits1$ = "0100" ELSEIF nibble1$ = "5" THEN bits1$ = "0101" ELSEIF nibble1$ = "6" THEN bits1$ = "0110" ELSEIF nibble1$ = "7" THEN bits1$ = "0111" ELSEIF nibble1$ = "8" THEN bits1$ = "1000" ELSEIF nibble1$ = "9" THEN bits1$ = "1001" ELSEIF nibble1$ = "A" THEN bits1$ = "1010" ELSEIF nibble1$ = "B" THEN bits1$ = "1011" ELSEIF nibble1$ = "C" THEN bits1$ = "1100" ELSEIF nibble1$ = "D" THEN bits1$ = "1101" ELSEIF nibble1$ = "E" THEN bits1$ = "1110" ELSEIF nibble1$ = "F" THEN bits1$ = "1111" ELSE PRINT "PDI5025: Problem with byte conversion" END IF 'Combine the bit patterns statbits$ = bits1$ + bits0$ END SUB SUB pdivtrotenc (c$, g%, d$, np%, ns%, n%, vt!(), vtn!) '**************************************************************************** 'This subroutine takes n triggered integrated voltage readings. 'It then collects n triggered integrated voltage readings 'and returns the values. VT(0) = 0, by definition. The n'th actual 'measurement is at the same location as the 0'th. It is not used in the 'measurement record, but is returned for possible drift corrections. ' 'Input: ' c$, the integrator channel, A or B ' g%, the gain value, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 ' d$, the encoder rotation direction ' np%, the number of encoder pulses per revolution ' ns%, the number of vt samples per revolution ' n%, the number of integrated voltage samples (= ns% * #revolutions) ' 'Output: ' vt!(0 to n%-1), the measured integrated voltage values ' vtn!, the n'th integrated voltage value ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Check input variables IF c$ <> "A" AND c$ <> "B" THEN PRINT "PDI5025: Integrator channel setup problem" EXIT SUB END IF IF g% <> 1 AND g% <> 2 AND g% <> 5 AND g% <> 10 AND g% <> 20 AND g% <> 50 AND g% <> 100 AND g% <> 200 AND g% <> 500 AND g% <> 1000 THEN PRINT "PDI5025: Integrator gain setup problem" EXIT SUB END IF IF d$ <> "+" AND d$ <> "-" THEN PRINT "PDI5025: Integrator trigger rotation direction problem" EXIT SUB END IF IF np% <= 0 OR np% > 20000 THEN PRINT "PDI5025: Integrator np problem" EXIT SUB END IF IF ns% <= 0 OR ns% > np% THEN PRINT "PDI5025: Integrator ns problem" EXIT SUB END IF IF n% <= 0 OR n% > 10000 THEN PRINT "PDI5025: Integrator n problem" EXIT SUB END IF 'Select the integrator channel CALL gpibout(pdi5025addrP$, "CHA," + c$) 'Set the gain CALL gpibout(pdi5025addrP$, "SGA," + LTRIM$(STR$(g%))) 'Set the PDI5025 for cumulated data storage CALL gpibout(pdi5025addrP$, "CUM,1,S") 'Use direct data transfer mode CALL gpibout(pdi5025addrP$, "IMD,1") 'Set up the integration intervals CALL gpibout(pdi5025addrP$, "TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(4 * np% / ns%))) 'Start the measurement 'Don't forget that the index pulse must already have been located CALL gpibout(pdi5025addrP$, "RUN") 'Wait until the measurements are complete runbit$ = "1" DO WHILE runbit$ = "1" CALL pdistatbits(3, statbits$) runbit$ = MID$(statbits$, 5, 1) 'Register 3, bit 3, position 5 in string ' PRINT "PDI5025CGNTVT: waiting for data, statbits 3 = "; statbits$ ' SLEEP 1 LOOP 'Read the data 'The zero'th value, at the index pulse, is zero (int_0^0 = 0) 'This is important for angle measurements vt!(0) = 0! 'Read the data 'Fill points 1 to n%-1 from the integrator FOR i% = 1 TO n% - 1 CALL gpibin(pdi5025addrP$, dat$) IF dat$ = "" THEN PRINT "PDI5025CGNTVT: No data" ELSE value$ = MID$(dat$, 1, LEN(dat$) - 2) 'take off channel identifier IF MID$(dat$, LEN(dat$) - 1, 2) <> (" " + c$) THEN PRINT "PDI: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% 'Read the data 'There is one value remaining in the integrator at 2 * pi * n 'This value is not required in the record because we have the value at 0 'Read this value to clear the integrator and return it for drift corrections CALL gpibin(pdi5025addrP$, dat$) IF dat$ = "" THEN PRINT "PDI5025CGNTVT: No data" ELSE value$ = MID$(dat$, 1, LEN(dat$) - 2) 'take off channel identifier IF MID$(dat$, LEN(dat$) - 1, 2) <> (" " + c$) THEN PRINT "PDI: Data read problem: "; dat$; ", "; value$ vtn! = VAL(value$) * 10 ^ (-8) END IF 'Make sure the integrator has not had any errors 'Send back 0's if there was an error CALL pdierr(e%) IF e% <> 0 THEN PRINT "PDI5025: Error detected at data read" FOR i% = 0 TO n% - 1 vt!(i%) = 0! NEXT i% END IF END SUB SUB pdivtrotencrd (c$, n%, vt!(), vtn!) '**************************************************************************** 'This subroutine collects n triggered integrated voltage readings 'and returns the values. VT(0) = 0, by definition. The n'th actual 'measurement is at the same location as the 0'th. It is not used in the 'measurement record, but is returned for possible drift corrections. ' 'Input: ' c$, the integrator channel ' n%, the number of integrated voltage samples (= ns% * #revolutions) ' 'Output: ' vt!(0 to n%-1), the measured integrated voltage values ' vtn!, the n'th integrated voltage value ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Wait until the measurements are complete runbit$ = "1" DO WHILE runbit$ = "1" CALL pdistatbits(3, statbits$) runbit$ = MID$(statbits$, 5, 1) 'Register 3, bit 3, position 5 in string ' PRINT "PDI5025CGNTVT: waiting for data, statbits 3 = "; statbits$ ' SLEEP 1 LOOP 'Select the integrator channel CALL gpibout(pdi5025addrP$, "CHA," + c$) 'Read the data 'The zero'th value, at the index pulse, is zero (int_0^0 = 0) 'This is important for angle measurements vt!(0) = 0! 'Read the data 'Fill points 1 to n%-1 from the integrator FOR i% = 1 TO n% - 1 CALL gpibin(pdi5025addrP$, dat$) IF dat$ = "" THEN PRINT "PDI5025CGNTVT: No data" ELSE value$ = MID$(dat$, 1, LEN(dat$) - 2) 'take off channel identifier IF MID$(dat$, LEN(dat$) - 1, 2) <> (" " + c$) THEN PRINT "PDI: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% 'Read the data 'There is one value remaining in the integrator at 2 * pi * n 'This value is not required in the record because we have the value at 0 'Read this value to clear the integrator and return it for drift corrections CALL gpibin(pdi5025addrP$, dat$) IF dat$ = "" THEN PRINT "PDI5025CGNTVT: No data" ELSE value$ = MID$(dat$, 1, LEN(dat$) - 2) 'take off channel identifier IF MID$(dat$, LEN(dat$) - 1, 2) <> (" " + c$) THEN PRINT "PDI: Data read problem: "; dat$; ", "; value$ vtn! = VAL(value$) * 10 ^ (-8) END IF 'Make sure the integrator has not had any errors 'Send back 0's if there was an error CALL pdierr(e%) IF e% <> 0 THEN PRINT "PDI5025: Error detected at data read" FOR i% = 0 TO n% - 1 vt!(i%) = 0! NEXT i% END IF END SUB SUB pdivtrotencsetup (np%) '**************************************************************************** 'This subroutine tells the PDI5025 that a rotary encoder is being used 'for triggering. ' 'Input: ' np%, the number of encoder pulses per revolution ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Check input variables IF np% <= 0 OR np% > 20000 THEN PRINT "PDI5025: Integrator np problem" EXIT SUB END IF 'Use the encoder for triggers CALL gpibout(pdi5025addrP$, "TRS,E," + LTRIM$(STR$(np%))) 'Turn off interrupts CALL gpibout(pdi5025addrP$, "MSK,1,00") CALL gpibout(pdi5025addrP$, "MSK,2,00") 'Turn off the motor driver (use an independant stepping motor) CALL gpibout(pdi5025addrP$, "MOT,S") END SUB SUB pdivtrotencst (c$, g%, d$, np%, ns%, n%) '**************************************************************************** 'This subroutine takes n triggered integrated voltage readings. ' 'Input: ' c$, the integrator channel, A or B ' g%, the gain value, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 ' d$, the encoder rotation direction ' np%, the number of encoder pulses per revolution ' ns%, the number of vt samples per revolution ' n%, the number of integrated voltage samples (= ns% * #revolutions) ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Check input variables IF c$ <> "A" AND c$ <> "B" THEN PRINT "PDI5025: Integrator channel setup problem" EXIT SUB END IF IF g% <> 1 AND g% <> 2 AND g% <> 5 AND g% <> 10 AND g% <> 20 AND g% <> 50 AND g% <> 100 AND g% <> 200 AND g% <> 500 AND g% <> 1000 THEN PRINT "PDI5025: Integrator gain setup problem" EXIT SUB END IF IF d$ <> "+" AND d$ <> "-" THEN PRINT "PDI5025: Integrator trigger rotation direction problem" EXIT SUB END IF IF np% <= 0 OR np% > 20000 THEN PRINT "PDI5025: Integrator np problem" EXIT SUB END IF IF ns% <= 0 OR ns% > np% THEN PRINT "PDI5025: Integrator ns problem" EXIT SUB END IF IF n% <= 0 OR n% > 10000 THEN PRINT "PDI5025: Integrator n problem" EXIT SUB END IF 'Select the integrator channel CALL gpibout(pdi5025addrP$, "CHA," + c$) 'Set the gain CALL gpibout(pdi5025addrP$, "SGA," + LTRIM$(STR$(g%))) 'Set the PDI5025 for cumulated data storage CALL gpibout(pdi5025addrP$, "CUM,1,S") 'Use direct data transfer mode CALL gpibout(pdi5025addrP$, "IMD,1") 'Set up the integration intervals CALL gpibout(pdi5025addrP$, "TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(4 * np% / ns%))) 'Start the measurement 'Don't forget that the index pulse must already have been located CALL gpibout(pdi5025addrP$, "RUN") END SUB SUB pdivttimer (c$, g%, n%, t!, vt!()) '**************************************************************************** 'This subroutine takes n integrated voltage readings spaced t seconds apart 'and returns the values. ' 'Input: ' c$, the integrator channel, A or B ' g%, the gain value, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 ' n%, the number of integrated voltage samples ' t!, the time between integrated voltage samples ' 'Output: ' vt!(0 to n%-1), the measured integrated voltage values ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Check input variables IF c$ <> "A" AND c$ <> "B" THEN PRINT "PDI5025: Integrator channel setup problem" EXIT SUB END IF IF g% <> 1 AND g% <> 2 AND g% <> 5 AND g% <> 10 AND g% <> 20 AND g% <> 50 AND g% <> 100 AND g% <> 200 AND g% <> 500 AND g% <> 1000 THEN PRINT "PDI5025: Integrator gain setup problem" EXIT SUB END IF 'Select the integrator channel CALL gpibout(pdi5025addrP$, "CHA," + c$) 'Set the gain CALL gpibout(pdi5025addrP$, "SGA," + LTRIM$(STR$(g%))) 'Set the PDI5025 for cumulated data storage CALL gpibout(pdi5025addrP$, "CUM,1,S") 'Use direct data transfer mode CALL gpibout(pdi5025addrP$, "IMD,1") 'Use the internal timer for triggers CALL gpibout(pdi5025addrP$, "TRS,T") 'Compute the number of milliseconds between integration intervals tms% = t! * 1000 'Set up the integration intervals CALL gpibout(pdi5025addrP$, "TRI,+,0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(tms%))) 'Start the measurement CALL gpibout(pdi5025addrP$, "RUN") 'Wait until the measurements are complete runbit$ = "1" DO WHILE runbit$ = "1" CALL pdistatbits(3, statbits$) runbit$ = MID$(statbits$, 5, 1) 'Register 3, bit 3, position 5 in string ' PRINT "PDIVTTIMER: waiting for data, statbits = "; statbits$ SLEEP 1 LOOP 'Read the data 'The zero'th value, at t = 0, is zero (int_0^0 = 0) vt!(0) = 0! 'Read the data 'Fill points 1 to n%-1 from the integrator FOR i% = 1 TO n% - 1 CALL gpibin(pdi5025addrP$, dat$) IF dat$ = "" THEN PRINT "PDI5025CGNTVT: No data" ELSE value$ = MID$(dat$, 1, LEN(dat$) - 2) 'take off channel identifier IF MID$(dat$, LEN(dat$) - 1, 2) <> (" " + c$) THEN PRINT "PDI: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% 'Read the data 'There is one value remaining in the integrator at t = n * delta t 'This value is not used 'Read this value to clear the integrator CALL gpibin(pdi5025addrP$, dat$) 'Make sure the integrator has not had any errors 'Send back 0's if there was an error CALL pdierr(e%) IF e% <> 0 THEN PRINT "PDI5025: Error detected at data read" FOR i% = 0 TO n% - 1 vt!(i%) = 0! NEXT i% END IF END SUB