DECLARE SUB ls450setrange (r%) DECLARE SUB hp3457cntvtrig (c%, n%, t!, v!()) DECLARE SUB dac488digout (linenum%, lohi%) DECLARE SUB dac488flytrig () DECLARE SUB hp3458getntv (n%, v!()) DECLARE SUB hp3458startntv (n%, t!) DECLARE SUB hp3458flysampv (n%) DECLARE SUB hp3458flyreadv (n%, v!()) DECLARE SUB gp3setrange (r%) DECLARE SUB hp3457inttrig () DECLARE SUB gp3getb (B!) DECLARE SUB hp3457flysampv (n%, c%) DECLARE SUB hp3457flyreadv (n%, v!()) DECLARE SUB hp3457readv (v!) DECLARE SUB hp3457setupv (c%) DECLARE SUB hp3457cmon (c%) DECLARE SUB hp3457cv (c%, v!) DECLARE SUB dac488setcv (c%, v!) DECLARE SUB idacramp (rr!, inom!) DECLARE SUB idaccheckpar (ok$) DECLARE SUB dac488getcv (c%, v!) DECLARE SUB idacrampfr (rr!, fr!, ifin!) '**************************************************************************** 'Module IDAC 'This module contains drivers to set and measure the magnet current using 'the IO Tech DAC488. ' 'Zachary Wolf '11/25/95 '**************************************************************************** 'Parameters used in this module COMMON SHARED /idac/ rampmodeP$, imagdacchanP%, imagpervdacP!, imagtstableP%, imaghpchanP%, vtransperimagP! SUB idaccheckpar (ok$) '**************************************************************************** 'This subroutine checks that all required parameters have been assigned 'values. ' 'Output: ' ok$, "y" if parameter assignments are ok, "n" otherwise ' 'Zachary Wolf '9/18/95 '**************************************************************************** 'Default value ok$ = "n" 'imagdacchanP% IF imagdacchanP% < 1 OR imagdacchanP% > 4 THEN PRINT "IDAC: imagdacchan has improper value" EXIT SUB END IF 'imagpervdacP! IF imagpervdacP! <= 0 OR imagpervdacP! > 5000 THEN PRINT "IDAC: imagpervdac has improper value" EXIT SUB END IF 'imagtstableP% IF imagtstableP% < 0 OR imagtstableP% > 120 THEN PRINT "IDAC: imagtstable has improper value" EXIT SUB END IF 'imaghpchanP% IF imaghpchanP% < 0 OR imaghpchanP% > 9 THEN PRINT "IDAC: imaghpchan has improper value" EXIT SUB END IF 'vtransperimagP! IF vtransperimagP! <= 0 OR vtransperimagP! > 2 THEN PRINT "IDAC: vtransperimag has improper value" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB idacgeti (imag!) '**************************************************************************** 'This subroutine gets the transductor output voltage. It then applies 'the calibration constant to get the magnet current. ' 'Output: ' imag!, the measured magnet current ' 'Zachary Wolf '4/21/94, 1/5/95 '**************************************************************************** 'Make sure all parameters have been assigned reasonable values CALL idaccheckpar(ok$) IF ok$ <> "y" THEN imag! = 0! EXIT SUB END IF 'Simplify the notation c% = imaghpchanP% vperi! = vtransperimagP! 'Measure the voltage from the transductor CALL hp3457cv(c%, v!) 'Apply the conversion factor imag! = v! / vperi! END SUB SUB idacinit '**************************************************************************** 'This subroutine does the initial turn on of the power supply to a small 'current. ' 'Zachary Wolf '10/1/95 '**************************************************************************** 'Don't need this 'EXIT SUB 'Message PRINT PRINT "Initial power supply turn on." PRINT "Ramp the supply to 20 A, stabilize, ramp to 0..." 'Ramp the supply CALL idacramp(1!, 20!) 'Stabilize SLEEP 30 'Ramp to 0 CALL idacramp(1!, 0!) END SUB SUB idacmonitor '**************************************************************************** 'This subroutine sets up the HP3457 to monitor the transductor. ' 'Zachary Wolf '7/27/95 '**************************************************************************** 'Make sure all parameters have been assigned reasonable values CALL idaccheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB 'Set the DVM so the current can be monitored CALL hp3457cmon(imaghpchanP%) END SUB SUB idacramp (rr!, inom!) '**************************************************************************** 'This subroutine supervises the ramp of the magnet current. ' 'Input: ' rr!, the magnet current ramp rate ' inom!, the desired magnet current ' 'Zachary Wolf '1/1/95 '**************************************************************************** 'Make sure all parameters have been assigned reasonable values CALL idaccheckpar(ok$) IF ok$ <> "y" THEN EXIT SUB IF rampmodeP$ = "standardize" THEN rr! = .637 IF rampmodeP$ = "ramp" THEN rr! = 1.067 'Create ramp rate array DIM rate!(0 TO 3) rate!(0) = 1.067 rate!(1) = .133 rate!(2) = .033 rate!(3) = .017 'Create current array to ramp to DIM cur!(0 TO 5) cur!(0) = 1 cur!(1) = 0 cur!(2) = 1 cur!(3) = 0 cur!(4) = 1 cur!(5) = 0 'Loop over ramp rate FOR i% = 0 TO 0 'Loop over current FOR j% = 0 TO 0 'Ramp to 100% of the desired current CALL idacrampfr(rate!(i%), 1!, cur!(j%)) 'Let the power supply and magnet stabilize at the final current SLEEP imagtstableP% NEXT j% NEXT i% END SUB SUB idacrampfr (rr!, fr!, ifin!) ' '**************************************************************************** 'This subroutine generates a fraction of the magnet current ramp. 'The points making up the ramp are updated every 0.1 second. 'This routine can be called several times to approach the final magnet 'current at a low ramp rate. ' 'Input: ' rr!, the magnet current ramp rate ' fr!, the fraction of the ramp to be done from the present current to ifin! ' ifin!, the desired final magnet current ' 'Zachary Wolf '4/18/94 '**************************************************************************** ' 'Simplify the notation cdac% = imagdacchanP% chp% = imaghpchanP% iperv! = imagpervdacP! vperi! = vtransperimagP! 'Define a local parameter, the time between ramp steps dt! = .1 'Find the voltage the DAC is putting out CALL dac488getcv(cdac%, vini!) 'Find the fraction of the final current to ramp to iini! = vini! * iperv! frfin! = fr! * (ifin! - iini!) + iini! 'PRINT "Ramping: "; iini!; frfin!; rr! 'Find the DAC final voltage we need vfin! = frfin! / iperv! 'Compute the DAC voltage ramp rate rrdac! = rr! / iperv! 'Compute the number of ramp points to give approximately this rate nr% = (ABS(vfin! - vini!) / rrdac!) / dt! 'See if we need to ramp IF nr% = 0 THEN EXIT SUB 'Compute the voltage at each step (cosine ramp waveform) DIM vdac!(0 TO nr%) pi! = 3.14159265# FOR i% = 0 TO nr% vdac!(i%) = (vini! + vfin!) / 2! - ((vfin! - vini!) * COS(i% * pi! / nr%)) / 2! NEXT i% 'Find the number of points to wait for 5% sampling n% = CINT(.05 * nr%) IF n% = 0 THEN n% = 1 END IF 'Find the array size for storing the 5% sampling IF (nr% MOD 2 = 1) AND (n% > 1) THEN num% = CINT((nr% + 1) / n%) ELSE num% = CINT(nr% / n%) END IF IF (n% * num%) < nr% THEN num% = num% + 1 END IF 'Add five points for one before and four after ramp loop for filter num% = num% + 5 'Create arry for current, field, and time measurement DIM mfield!(0 TO num%) DIM mcur!(0 TO num%) DIM mtime!(0 TO num%) 'Set the range on the hall probe CALL gp3setrange(1) 'CALL ls450setrange(2) 'Set up hp3458 for sampling with an ext. trig CALL hp3458flysampv(num%) 'Set up hp3457 for sampling with an ext. trig CALL hp3457flysampv(num%, chp%) 'Set count for 5% sampling cnt% = 0 'Make the first measurement mtime!(cnt%) = TIMER CALL dac488flytrig WHILE TIMER - mtime!(cnt%) < dt! WEND 'Have the DAC output the calculated ramp FOR i% = 0 TO nr% tstep! = TIMER CALL dac488setcv(cdac%, vdac!(i%)) 'Check for 5% sampling plus look for last point IF (i% = cnt% * n%) OR (i% = nr%) THEN SLEEP 1 cnt% = cnt% + 1 mtime!(cnt%) = TIMER CALL dac488flytrig END IF WHILE TIMER - tstep! < dt! WEND NEXT i% 'Make two last measurement FOR j% = 0 TO 3 cnt% = cnt% + 1 mtime!(cnt%) = TIMER CALL dac488flytrig WHILE TIMER - mtime!(cnt%) < dt! WEND NEXT j% 'Get the data from the hp3458 CALL hp3458flyreadv(num%, mfield!()) 'Get the data from the hp3457 CALL hp3457flyreadv(num%, mcur!()) 'Check to make sure a ramp occured before writing to file IF rampmodeP$ = "ramp" THEN 'Check to see if user wants to write data to a file 'INPUT ; "Write to file"; ans$ 'PRINT 'IF (ans$ = "Y") OR (ans$ = "y") THEN PRINT "Writing on the fly data to a file" PRINT rr! filenum% = FREEFILE datfile$ = "flyrmp.dat" OPEN datfile$ FOR APPEND AS filenum% 'Print the results 'The maximum voltage from the hall probes analog signal maxv! = 3 'The range of the hall probe for which the readings are taking place range! = .03 FOR i% = 0 TO num% PRINT #filenum%, USING " ###.####"; mtime!(i%) - mtime!(0); PRINT #filenum%, USING " ##.####"; mcur!(i%) / vperi; PRINT #filenum%, USING " ##.######"; mfield!(i%) * (range! / maxv!) NEXT i% 'CLOSE file CLOSE filenum% 'END IF END IF END SUB SUB idacsetmode (mode$) rampmodeP$ = mode$ END SUB SUB idacsetpar (imagdacchan%, imagpervdac!, imagtstable%, imaghpchan%, vtransperimag!) '**************************************************************************** 'This subroutine sets parameter values for a DAC488 controlling a power supply. ' 'Input: ' imagdacchan%, DAC488 channel to use (1 to 4) ' imagpervdac!, magnet current per DAC volt ' imagtstable%, wait time after a ramp ' imaghpchan%, HP3457 channel for transductor read ' vtransperimag!, transductor volts per amp ' 'Zachary Wolf '9/21/95 '**************************************************************************** 'Place the parameters in the local common block for future use imagdacchanP% = imagdacchan% imagpervdacP! = imagpervdac! imagtstableP% = imagtstable% imaghpchanP% = imaghpchan% vtransperimagP! = vtransperimag! END SUB