DECLARE SUB cm2100avdin (ain!, vin!, din!) DECLARE SUB cm2100avd (a&, v&, d&) DECLARE SUB cm2100getx (x&) '**************************************************************************** 'This module contains subroutines which control the Compumotor 2100 and 'linear stepping motor system. ' 'Required parameters in param.inc 'stepsperrevP&, the # steps per revolution (for a and v) 'stepsperinchP&, the# steps per inch ' 'Zachary Wolf '6/7/94 '**************************************************************************** 'Include parameters REM $INCLUDE: 'param.inc' SUB cm2100avd (a&, v&, d&) '**************************************************************************** 'This subroutine moves the motor d& steps. It accelerates the motor with 'acceleration a& steps/sec/sec to velocity v& steps/sec to make the move. ' 'Input: ' a&, acceleration in steps/sec/sec ' v&, velocity in steps/sec ' d&, distance in steps ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' hp3457addrP%, the HP3457 GPIB address ' stepsperrevP&, # steps per revolution for motors, used for a and v ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the CM2100 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% cm2100addr% = cm2100addrP% 'Put the address number into a string cm2100addr$ = STR$(cm2100addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR EOI" PRINT #gpibout%, "TERM OUT CR" 'Express a and v in terms of revolutions for the indexer ar! = a& / stepsperrevP& vr! = v& / stepsperrevP& 'Keep values within limits IF ar! < .1 THEN ar! = .1 IF ar! > 999! THEN ar! = 999! IF vr! < .1 THEN vr! = .1 IF vr! > 99! THEN vr! = 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 PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";MN" 'Set the acceleration PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";A" + LTRIM$(STR$(ar!)) 'Set the velocity PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";V" + LTRIM$(STR$(vr!)) 'Set the distance to move PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";D" + LTRIM$(STR$(d&)) 'Move PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";G" 'Wait until the move is finished SLEEP 1 spoll! = 0 WHILE NOT spoll AND 1 PRINT #gpibout%, "SPOLL " + cm2100addr$ INPUT #gpibin%, spoll! ' PRINT "spoll = "; spoll! SLEEP 1 WEND 'Ask how many steps were taken PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";P" 'Wait until the CM2100 is finished working on the request spoll! = 0 WHILE NOT spoll AND 8 PRINT #gpibout%, "SPOLL " + cm2100addr$ INPUT #gpibin%, spoll! ' PRINT "spoll = "; spoll! SLEEP 1 WEND 'Get the number of steps PRINT #gpibout%, "ENTER " + cm2100addr$ INPUT #gpibin%, p& '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 cm2100avdin (ain!, vin!, din!) '**************************************************************************** 'This subroutine moves the linear motor. Its input parameters are in 'inches. It converts these to steps, the units of the 2100 commands, 'and calls the cm2100avd move routine. ' 'Input: ' ain!, acceleration in inches/sec/sec ' vin!, velocity in inches/sec ' din!, distance in inches ' 'Zachary Wolf '5/7/94 '**************************************************************************** 'Convert from inches to steps a& = ain! * stepsperinchP& v& = vin! * stepsperinchP& d& = din! * stepsperinchP& 'Move the motor CALL cm2100avd(a&, v&, d&) END SUB SUB cm2100getx (x&) '**************************************************************************** 'This subroutine gets the number of steps away from zero that the motor 'is currently at. ' 'Output: ' x&, position in steps ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' hp3457addrP%, the HP3457 GPIB address ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the CM2100 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% cm2100addr% = cm2100addrP% 'Put the address number into a string cm2100addr$ = STR$(cm2100addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR EOI" PRINT #gpibout%, "TERM OUT CR" 'Ask for the current position PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";X1" 'Wait until the CM2100 is finished working on the request spoll! = 0 WHILE NOT spoll AND 8 PRINT #gpibout%, "SPOLL " + cm2100addr$ INPUT #gpibin%, spoll! ' PRINT "spoll = "; spoll! ' SLEEP 1 WEND 'Get the current position PRINT #gpibout%, "ENTER " + cm2100addr$ INPUT #gpibin%, x& END SUB SUB cm2100gohome '**************************************************************************** 'This subroutine moves the motor back to its home position. ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'See where we are CALL cm2100getx(x&) 'Convert the acceleration and velocity to steps a& = ainP! * stepsperinchP& v& = vinP! * stepsperinchP& 'Go the the negative of the present position CALL cm2100avd(a&, v&, -x&) END SUB SUB cm2100init '**************************************************************************** 'This subroutine initializes the Compumotor 2100 indexer. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' cm2100addrP%, the Compumotor 2100 GPIB address ' 'Zachary Wolf '5/6/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the cm2100 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% cm2100addr% = cm2100addrP% 'Put the address number into a string cm2100addr$ = STR$(cm2100addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR EOI" PRINT #gpibout%, "TERM OUT CR" 'Message PRINT PRINT "Resetting the Compumotor 2100..." 'Clear the CM2100 PRINT #gpibout%, "CLEAR " + cm2100addr$ 'Wait for the CM2100 to clear SLEEP 1 'Enable the communications interface PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";E" 'Set the present position to 0 PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";X0" 'Set the direction of positive motion PRINT #gpibout%, "OUTPUT " + cm2100addr$ + ";H+" END SUB