DECLARE SUB imagrampfr (rr!, fr!, ifin!) DECLARE SUB hp3457cmon (c%) DECLARE SUB dac488hrgetv (dacv!) DECLARE SUB dac488hrv (v!) '**************************************************************************** 'Module IMAG 'This module contains drivers to set and measure the magnet current. ' 'The param.inc file must include the following parameters 'imagpervdacP!, power supply amps per DAC volts 'vtransperimagP!, transductor voltage per magnet amp 'imaghpchanP%, the HP3457 channel for the transductor voltage ' 'Zachary Wolf '5/31/94 '**************************************************************************** 'Include the parameters used in the module REM $INCLUDE: 'param.inc' SUB imagramp (rr!, 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 ' ifin!, the desired magnet current ' 'Parameters from param.inc ' imaghpchanP%, the HP3457 channel used to monitor the magnet current ' 'Zachary Wolf '4/18/94, 7/11/94 '**************************************************************************** 'Simplify the notation c% = imaghpchanP% 'Set the DVM so the current can be monitored CALL hp3457cmon(c%) 'Ramp to the final current CALL imagrampfr(rr!, 1!, ifin!) END SUB SUB imagrampfr (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 ' 'Parameters from param.inc: ' imagpervdacP!, the magnet current per DAC volt ' 'Zachary Wolf '4/18/94 '**************************************************************************** 'Simplify the notation iperv! = imagpervdacP! '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! tinit! = TIMER CALL dac488hrv(vdac!(i%)) DO WHILE TIMER - tinit! < dt! LOOP NEXT i% END SUB