DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibspoll (addr$, msg$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB cm2100zero () '**************************************************************************** 'This module contains subroutines which control the Compumotor 2100 'stepping motor system. ' 'Zachary Wolf '6/7/94, 9/11/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /cm2100/ gpibinP%, gpiboutP%, cm2100addrP$ 'Semi-permanent parameters CONST nstepsperrevP& = 50000 'stepping motor # steps per revolution CONST terminP$ = "CR EOI" 'input GPIB terminator CONST termoutP$ = "CR" 'output GPIB terminator SUB cm2100avd (a!, v!, d!) '**************************************************************************** 'This subroutine moves the motor d! revolutions. It accelerates the motor 'with acceleration a! rev/sec/sec to velocity v! rev/sec to make the move. ' 'Input: ' a!, acceleration in rev/sec/sec ' v!, velocity in rev/sec ' d!, distance in rev, can be + or - ' 'Zachary Wolf '5/6/94, 9/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Determine the number of steps to move (controller coordinates) d& = d! * nstepsperrevP& 'Keep values within limits IF a! < .1 THEN a! = .1 IF a! > 999! THEN a! = 999! IF v! < .1 THEN v! = .1 IF v! > 99! THEN v! = 99! IF ABS(d&) > 99999999 THEN PRINT "CM2100AVD: requested d& is too large" EXIT SUB END IF 'Set normal mode to move to a given position CALL gpibout(cm2100addrP$, "MN") 'Set the acceleration CALL gpibout(cm2100addrP$, "A" + LTRIM$(STR$(a!))) 'Set the velocity CALL gpibout(cm2100addrP$, "V" + LTRIM$(STR$(v!))) 'Set the distance to move CALL gpibout(cm2100addrP$, "D" + LTRIM$(STR$(d&))) 'Move CALL gpibout(cm2100addrP$, "G") 'Wait until the move is finished SLEEP 1 spoll% = 0 WHILE NOT spoll% AND 1 CALL gpibspoll(cm2100addrP$, spoll$) spoll% = VAL(spoll$) ' PRINT "Move done?, spoll = "; spoll% SLEEP 1 WEND 'Ask how many steps were taken CALL gpibout(cm2100addrP$, "P") 'Wait until the CM2100 is finished working on the request spoll% = 0 WHILE NOT spoll% AND 8 CALL gpibspoll(cm2100addrP$, spoll$) spoll% = VAL(spoll$) ' PRINT "Getting Nsteps, spoll = "; spoll% SLEEP 1 WEND 'Get the number of steps CALL gpibin(cm2100addrP$, value$) p& = VAL(value$) 'Make sure the proper number of steps were taken IF p& <> d& THEN PRINT "CM2100AVD: The wrong number of steps were taken." END IF END SUB SUB cm2100avdend (d!) '**************************************************************************** 'After cm2100avdst has started a move, this routine checks that the move is 'finished and that it was successful. ' 'Input: ' d!, distance in rev, can be + or - ' 'Zachary Wolf '5/6/94, 9/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Determine the number of steps of the move (controller coordinates) d& = d! * nstepsperrevP& 'Keep values within limits IF ABS(d&) > 99999999 THEN PRINT "CM2100AVD: requested d& is too large" EXIT SUB END IF 'Wait until the move is finished SLEEP 1 spoll% = 0 WHILE NOT spoll% AND 1 CALL gpibspoll(cm2100addrP$, spoll$) spoll% = VAL(spoll$) ' PRINT "Move done?, spoll = "; spoll% SLEEP 1 WEND 'Ask how many steps were taken CALL gpibout(cm2100addrP$, "P") 'Wait until the CM2100 is finished working on the request spoll% = 0 WHILE NOT spoll% AND 8 CALL gpibspoll(cm2100addrP$, spoll$) spoll% = VAL(spoll$) ' PRINT "Getting Nsteps, spoll = "; spoll% SLEEP 1 WEND 'Get the number of steps CALL gpibin(cm2100addrP$, value$) p& = VAL(value$) 'Make sure the proper number of steps were taken IF p& <> d& THEN PRINT "CM2100AVD: The wrong number of steps were taken." END IF END SUB SUB cm2100avdst (a!, v!, d!) '**************************************************************************** 'This subroutine moves the motor d! revolutions. It accelerates the motor 'with acceleration a! rev/sec/sec to velocity v! rev/sec to make the move. 'It does not wait until the move is finished to return. ' 'Input: ' a!, acceleration in rev/sec/sec ' v!, velocity in rev/sec ' d!, distance in rev, can be + or - ' 'Zachary Wolf '5/6/94, 9/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Determine the number of steps to move (controller coordinates) d& = d! * nstepsperrevP& 'Keep values within limits IF a! < .1 THEN a! = .1 IF a! > 999! THEN a! = 999! IF v! < .1 THEN v! = .1 IF v! > 99! THEN v! = 99! IF ABS(d&) > 99999999 THEN PRINT "CM2100AVD: requested d& is too large" EXIT SUB END IF 'Set normal mode to move to a given position CALL gpibout(cm2100addrP$, "MN") 'Set the acceleration CALL gpibout(cm2100addrP$, "A" + LTRIM$(STR$(a!))) 'Set the velocity CALL gpibout(cm2100addrP$, "V" + LTRIM$(STR$(v!))) 'Set the distance to move CALL gpibout(cm2100addrP$, "D" + LTRIM$(STR$(d&))) 'Move CALL gpibout(cm2100addrP$, "G") END SUB SUB cm2100getd (d!) '**************************************************************************** 'This subroutine gets the number of revolutions away from zero that the 'motor is currently at. ' 'Output: ' d!, position in revolutions ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Ask for the current position CALL gpibout(cm2100addrP$, "X1") 'Wait until the CM2100 is finished working on the request spoll% = 0 WHILE NOT spoll% AND 8 CALL gpibspoll(cm2100addrP$, spoll$) spoll% = VAL(spoll$) PRINT "Getting motor position, spoll = "; spoll% SLEEP 1 WEND 'Get the current position CALL gpibin(cm2100addrP$, value$) x& = VAL(value$) 'Convert to revolutions d! = (1! * x&) / nstepsperrevP& END SUB SUB cm2100init '**************************************************************************** 'This subroutine initializes the Compumotor 2100 indexer. ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Message PRINT PRINT "Resetting the Compumotor 2100..." 'Clear the CM2100 CALL gpibclrdev(cm2100addrP$) 'Wait for the CM2100 to clear SLEEP 1 'Enable the communications interface CALL gpibout(cm2100addrP$, "E") 'Set the present position to 0 CALL cm2100zero END SUB SUB cm2100setpar (gpibinf%, gpiboutf%, cm2100addr$) '**************************************************************************** 'This subroutine sets the parameters required by the CM2100. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' cm2100addr$, gpib address in a string ' 'Zachary Wolf '10/16/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "CM2100: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "CM2100: GPIB problem" EXIT SUB END IF IF cm2100addr$ = "" THEN PRINT "CM2100: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% cm2100addrP$ = cm2100addr$ END SUB SUB cm2100zero '**************************************************************************** 'This subroutine sets the Compumotor 2100 indexer position count to 0. ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Set the present position to 0 CALL gpibout(cm2100addrP$, "X0") END SUB