DECLARE SUB isextramp (rr!, inom!) DECLARE SUB iquadramp (rr!, inom!) 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 15 A, stabilize, ramp to 0..." 'Ramp the supply 'CALL idacramp(1!, 15!) CALL iquadramp(1!, 15!) CALL isextramp(1!, 15!) 'Stabilize SLEEP 30 'Ramp to 0 'CALL idacramp(1!, 0!) CALL iquadramp(1!, 0!) CALL isextramp(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! = 4.22 IF rampmodeP$ = "ramp" THEN rr! = 2.2 'Ramp to 100% of the desired current CALL idacrampfr(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 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 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% ' 'Have the DAC output the calculated ramp FOR i% = 0 TO nr% tstep! = TIMER CALL dac488setcv(c%, vdac!(i%)) WHILE TIMER - tstep! < dt! WEND NEXT i% ' 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