DECLARE SUB hp3457cmon (c%) DECLARE SUB dac488hrgetv (dacv!) DECLARE SUB dac488hrv (v!) DECLARE SUB hp3457cv (c%, v!) DECLARE SUB imagrampfr (rr!, iperv!, fr!, ifin!) DECLARE SUB imagsleep (dt!) SUB imagmeas (c%, vperi!, imag!) '**************************************************************************** 'This subroutine gets the transductor output voltage. It then applies 'the calibration constant to get the magnet current. ' 'Input: ' c%, the HP3457 channel used to measure transductor voltage ' vperi!, the conversion factor from magnet current to transductor voltage ' 'Output: ' imag!, the measured magnet current ' 'Zachary Wolf '4/21/94 '**************************************************************************** 'Measure the voltage from the transductor CALL hp3457cv(c%, v!) 'Apply the conversion factor imag! = v! / vperi! END SUB SUB imagramp (rr!, iperv!, ifin!) '**************************************************************************** 'This subroutine controls the ramp of the magnet current. It calls other 'routines which actually perform the ramp. These routines use the timer 'in BASIC to update the DAC output. ' 'Input: ' rr!, the initial current ramp rate ' iperv!, the magnet current per DAC volt ' ifin!, the desired magnet current ' 'Zachary Wolf '4/18/94 '**************************************************************************** 'Set the DVM so the current can be monitored CALL hp3457cmon(3) 'First ramp to 90% of the final current CALL imagrampfr(rr!, iperv!, .9, ifin!) 'Next ramp to 99% of the final current at 10% of the ramp rate CALL imagrampfr(.1 * rr!, iperv!, .9, ifin!) 'Now finish the the remaining 1% of the ramp at 1% of the initial ramp rate CALL imagrampfr(.01 * rr!, iperv!, 1!, ifin!) 'Let the power supply settle at the final current SLEEP 30 END SUB SUB imagrampfr (rr!, iperv!, 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 ' iperv!, magnet current per DAC volt ' fr!, the fraction done of the ramp from the present current to ifin! ' ifin!, the desired magnet current ' 'Zachary Wolf '4/18/94 '**************************************************************************** 'Define a local parameter, the time between ramp steps dt! = .1 'Find the voltage the DAC is putting out CALL dac488hrgetv(vini!) 'Find the DAC final voltage we need vfin! = ifin! / iperv! 'See if we need to ramp IF vfin! = vini! THEN EXIT SUB '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! '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! CALL dac488hrv(vdac!(i%)) CALL imagsleep(dt!) NEXT i% END SUB SUB imagsleep (dt!) '**************************************************************************** 'This subroutine is used to wait a specified period of time between each 'step of a magnet current ramp. The BASIC timer is used and it us updated 'about every .05 sec. The desired sleep time should be larger than this. ' 'Input: ' dt!, the desired sleep time ' 'Zachary Wolf '5/21/94 '**************************************************************************** 'Get the initial time tinit! = TIMER t! = tinit! 'Loop while dt! elapses DO WHILE t! - tinit! < dt! t! = TIMER LOOP END SUB