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$ SUB pdibreak '**************************************************************************** 'This subroutine stops a PDI5025 measurement cycle. ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";BRK" END SUB SUB pdiindex (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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Find the index pulse PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IND," + d$ 'Wait until the index pulse is found 'synchro$ = "0" 'DO WHILE synchro$ = "0" ' CALL pdistatbits(1, statbits$) ' synchro$ = MID$(statbits$, 8, 1) 'Register 1, bit 0, position 8 in string ' PRINT "PDIINDEX: waiting for synchronization, statbits = "; statbits$ ' SLEEP 1 'LOOP END SUB SUB pdiinit '**************************************************************************** 'PDI5025INIT 'This subroutine initializes the Metrolab PDI5025 integrator. ' 'Zachary Wolf '8/3/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Message PRINT PRINT "Resetting the Metrolab PDI5025 Integrator..." 'Clear the PDI5025 PRINT #gpiboutP%, "CLEAR " + pdi5025addrP$ CALL pdibreak 'Display status information PRINT "Status: " FOR i% = 1 TO 7 CALL pdistatbyte(i%, statbyte$, statbits$) PRINT " " + statbyte$ + " " + statbits$ NEXT i% END SUB SUB pdioffset '**************************************************************************** 'This subroutine is used to do an offset adjustment on the PDI5025. ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Message PRINT PRINT "PDI-5025 Offset Adjustment" 'CHANNEL A 'Put the PDI-5025 in offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ISC,A,1" PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,A,1:" CALL pdistatbits(1, statbits$) PRINT "After offset adjust call, statbits = "; statbits$ 'Have the user adjust the offset PRINT PRINT "Adjust the offset screw on channel A" PRINT "until the integrator value is 000." INPUT "Press ENTER when finished.", a$ 'End offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,A,0" PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";BRK" PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ISC,A,0" CALL pdistatbits(1, statbits$) PRINT "After offset adjust end call, statbits = "; statbits$ 'CHANNEL B 'Only if channel B is present 'Get status byte 4, look for VFC type CALL pdistatbyte(4, statbyte$, statbits$) IF MID$(statbyte$, 1, 1) = "0" THEN GOTO aonly 'Put the PDI-5025 in offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,B,1:" 'Have the user adjust the offset PRINT PRINT "Adjust the offset screw on channel B" PRINT "until the integrator value is 000." INPUT "Press ENTER when finished.", a$ 'End offset adjustment mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ADJ,B,0" aonly: 'Clear the PDI for measurements 'CALL pdibreak END SUB SUB pdioffsetup (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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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 PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA," + LTRIM$(STR$(g%)) 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CUM,1,S" 'Use direct data transfer mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IMD,1" 'Set the end of data identifier to ^Z PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";EOD,26" 'Use the encoder for triggers PRINT "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) 'Set up the integration intervals PRINT "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" END SUB SUB pdisetpar (gpibin%, gpibout%, pdi5025addr$) '**************************************************************************** 'This subroutine sets all required PDI5025 parameters. ' 'Input: ' gpibin%, GPIB input file number ' gpibout%, 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 gpibin% < 0 OR gpibin% > 100 THEN PRINT "PDI5025: GPIB problem" EXIT SUB END IF IF gpibout% < 0 OR gpibout% > 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% = gpibin% gpiboutP% = gpibout% pdi5025addrP$ = pdi5025addr$ END SUB SUB pdispoll (spoll%) '**************************************************************************** 'PDI5025SPOLL 'This subroutine does a serial poll on the Metrolab PDI5025 integrator.' ' 'Output: ' spoll%, the value returned by the serial poll ' 'Zachary Wolf '8/3/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Do the serial poll PRINT #gpiboutP%, "SPOLL " + pdi5025addrP$ INPUT #gpibinP%, spoll% 'Print the result 'PRINT spoll% 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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Get the status information PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";STB," + LTRIM$(STR$(regnum%)) PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, 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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Get the status information as a hexadecimal byte PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";STH," + LTRIM$(STR$(regnum%)) PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, 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!()) '**************************************************************************** 'This subroutine takes n triggered integrated voltage readings '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 ' 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 ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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% > 100 THEN PRINT "PDI5025: Integrator n problem" EXIT SUB END IF 'Select the integrator channel PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA," + LTRIM$(STR$(g%)) 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CUM,1,S" 'Use direct data transfer mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IMD,1" 'Set the end of data identifier to ^Z PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";EOD,26" 'Use the encoder for triggers PRINT "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) 'Set up the integration intervals PRINT "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" 'Start the measurement 'Don't forget that the index pulse must already have been located PRINT #gpiboutP%, "OUTPUT " + 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 = "; statbits$ SLEEP 1 LOOP 'Read the data FOR i% = 0 TO n% - 1 PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, 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 "PDI5025CGNTVT: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% END SUB SUB pdivtrotencrd (c$, n%, vt!()) '**************************************************************************** 'This subroutine collects n triggered integrated voltage readings 'and returns the values. ' '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 ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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 PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Read the data FOR i% = 0 TO n% - 1 PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, 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 "PDI5025CGNTVT: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% END SUB SUB pdivtrotencsetup (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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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 PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA," + LTRIM$(STR$(g%)) 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CUM,1,S" 'Use direct data transfer mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IMD,1" 'Set the end of data identifier to ^Z PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";EOD,26" 'Use the encoder for triggers PRINT "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) 'Set up the integration intervals PRINT "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(np% / ns%)) 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" 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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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 PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA," + LTRIM$(STR$(g%)) 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CUM,1,S" 'Use direct data transfer mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IMD,1" 'Set the end of data identifier to ^Z PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";EOD,26" 'Use the encoder for triggers 'PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,E," + LTRIM$(STR$(np%)) 'Set up the integration intervals PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRI," + d$ + ",0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(4 * np% / ns%)) 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" 'Start the measurement 'Don't forget that the index pulse must already have been located PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";RUN" END SUB SUB pdivtrotencstart '**************************************************************************** 'This subroutine starts triggered integrated voltage readings. ' 'Zachary Wolf '8/30/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" 'Start the measurement 'Don't forget that the index pulse must already have been located PRINT #gpiboutP%, "OUTPUT " + 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 PRINT #gpiboutP%, "TERM IN CR LF" PRINT #gpiboutP%, "TERM OUT CR LF" '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 PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CHA," + c$ 'Set the gain PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";SGA," + LTRIM$(STR$(g%)) 'Set the PDI5025 for cumulated data storage PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";CUM,1,S" 'Use direct data transfer mode PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";IMD,1" 'Set the end of data identifier to ^Z PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";EOD,26" 'Use the internal timer for triggers PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRS,T" 'Compute the number of milliseconds between integration intervals tms% = t! * 1000 'Set up the integration intervals PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";TRI,+,0/" + LTRIM$(STR$(n%)) + "," + LTRIM$(STR$(tms%)) 'Zero the counters PRINT #gpiboutP%, "OUTPUT " + pdi5025addrP$ + ";ZCT" 'Start the measurement PRINT #gpiboutP%, "OUTPUT " + 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 = "; statbits$ SLEEP 1 LOOP 'Read the data FOR i% = 0 TO n% - 1 PRINT #gpiboutP%, "ENTER " + pdi5025addrP$ LINE INPUT #gpibinP%, 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 "PDI5025CGNTVT: Data read problem: "; dat$; ", "; value$ vt!(i%) = VAL(value$) * 10 ^ (-8) END IF NEXT i% END SUB