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/ 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 '**************************************************************************** 'Message PRINT PRINT "Initial power supply turn on." PRINT "Ramp the supply to 5 A, stabilize, ramp to 0..." 'Ramp the supply CALL idacramp(1!, 5!) 'Stabilize SLEEP 5 '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 'First ramp to 90% of the desired current CALL idacrampfr(rr!, .9, inom!) 'Next ramp to 99% of the desired current at 10% of the ramp rate CALL idacrampfr(.1 * rr!, .9, inom!) 'Now finish the the remaining 1% of the ramp at 1% of the initial ramp rate CALL idacrampfr(.01 * rr!, 1!, inom!) 'Let the power supply and magnet stabilize at the final current SLEEP imagtstableP% END SUB SUB idacrampfr (rr!, fr!, ifin!) '**************************************************************************** 'This subroutine generates a fraction of the magnet current ramp. 'The complete ramp (fr!=1) would be from the present current to ifin!. 'This routine generates a fraction fr! of this 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 c% = imagdacchanP% iperv! = imagpervdacP! 'Define a local parameter, the time between ramp steps dt! = .1 'Find the voltage the DAC is putting out CALL dac488getcv(c%, vini!) 'Find the DAC final voltage we need vfin! = ifin! / 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 'Find the size of each voltage step vstep! = (vfin! - vini!) / nr% 'Compute the voltage at each step DIM vdac!(0 TO nr%) FOR i% = 0 TO nr% vdac!(i%) = vini! + vstep! * i% NEXT i% 'Have the DAC output fraction fr! of the calculated ramp FOR i% = 0 TO nr% * fr! tstep! = TIMER CALL dac488setcv(c%, vdac!(i%)) WHILE TIMER - tstep! < dt! WEND NEXT i% 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