DECLARE SUB mc4movestatussetup () DECLARE SUB mc4movestatus (moving$) '**************************************************************************** 'Module MC4 'This module contains I/O subroutines for the MC4 Klinger stepping motor 'controller. ' 'The following parameters must be present in param.inc. 'gpibinP%, the GPIB input file number 'gpiboutP%, the GPIB output file number 'mc4addrP%, the HP3457 GPIB address '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' SUB mc4err '**************************************************************************** 'This subroutine reports errors from the MC4 Klinger stepping motor 'controller. ' 'Zachary Wolf '1/22/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Display the error message PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";?" PRINT #gpibout%, "ENTER " + mc4addr$ LINE INPUT #gpibin%, e$ PRINT e$ END SUB SUB mc4init '**************************************************************************** 'This subroutine initializes the MC4 Klinger stepping motor controller. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' mc4addrP%, the MC4 GPIB address ' 'Zachary Wolf '8/24/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Message PRINT PRINT "Resetting the MC4 stepping motor controller..." 'Display the MC4 status PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";FS0F" PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";?" PRINT #gpibout%, "ENTER " + mc4addr$ LINE INPUT #gpibin%, s$ PRINT s$ 'Display the MC4 front panel display PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";DA" PRINT #gpibout%, "ENTER " + mc4addr$ LINE INPUT #gpibin%, d$ PRINT d$ END SUB SUB mc4moveabs (x!) '**************************************************************************** 'This subroutine moves the stages to position x (cm). ' 'Input: ' x!, the position to move the stages to, in cm ' 'Zachary Wolf '1/22/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Convert from cm to number of steps xstep& = x! * stepspercmP% 'Set up the MC4 to respond to questions about its moving status CALL mc4movestatussetup 'Move the stages PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";PA" + LTRIM$(STR$(xstep&)) + ".0" 'PRINT "OUTPUT " + mc4addr$ + ";PA" + LTRIM$(STR$(xstep&)) + ".0" 'Wait until the move is finished moving$ = "y" WHILE moving$ <> "n" SLEEP 1 CALL mc4movestatus(moving$) WEND END SUB SUB mc4moverel (dx!) '**************************************************************************** 'This subroutine moves the stages a distance relative to their present position. ' 'Input: ' dx!, the distance to move, in cm ' 'Zachary Wolf '1/15/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Get the direction IF dx! >= 0! THEN absdx! = dx! direction$ = "+" ELSE absdx! = -dx! direction$ = "-" END IF 'Convert from cm to number of steps nstep& = absdx! * stepspercmP% rstep% = velcmsP! * stepspercmP% 'Check IF rstep% < 32 THEN rstep% = 32 PRINT "Rate out of range, set to 32 steps/sec." END IF IF rstep% > 4000 THEN rstep% = 4000 PRINT "Rate out of range, set to 4000 steps/sec." END IF 'Set up axis x1 PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";N" + x1P$ + LTRIM$(STR$(nstep&)) '# steps PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";R" + x1P$ + LTRIM$(STR$(rstep%)) 'rate PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";" + direction$ + x1P$ 'direction 'Set up axis x2 PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";N" + x2P$ + LTRIM$(STR$(nstep&)) '# steps PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";R" + x2P$ + LTRIM$(STR$(rstep%)) 'rate PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";" + direction$ + x2P$ 'direction 'Set up the MC4 to respond to questions about its moving status CALL mc4movestatussetup 'Move the stages PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";" 'Wait until the move is finished moving$ = "y" WHILE moving$ <> "n" SLEEP 1 CALL mc4movestatus(moving$) WEND END SUB SUB mc4movestatus (moving$) '**************************************************************************** 'This subroutine tells whether the stages are moving (moving$ = "y") 'or not (moving$ = "n"). ' 'Output: ' moving$, "y" or "n" telling if the stages are moving or not ' 'Zachary Wolf '1/22/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Get the moving status 'The MC4 needs to have already received the following command: 'PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";FS01" PRINT #gpibout%, "ENTER " + mc4addr$ LINE INPUT #gpibin%, status$ 'PRINT status$ 'Determine if a stage is moving moving$ = "n" 'default IF MID$(status$, 1, 1) = "0" THEN 'check for moving status header IF MID$(status$, 2, 1) <> "@" THEN moving$ = "y" 'bit pattern 40H END IF 'PRINT moving$ END SUB SUB mc4movestatussetup '**************************************************************************** 'This subroutine sets up the MC4 to indicate if any stages are moving 'when a status request is sent. ' 'Zachary Wolf '1/27/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Set up the MC4 to give the moving status PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";FS01" END SUB SUB mc4setup '**************************************************************************** 'This subroutine sets up the MC4 Klinger stepping motor controller. ' 'Inputs from param.inc: ' gpibinP%, GPIB input file number ' gpiboutP%, GPIB output file number ' mc4addrP%, the MC4 GPIB address ' 'Zachary Wolf '1/21/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Set the acceleration 'PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";ACA.4" 'Set the velocity PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";RA4000" 'Enable holding torque PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";KAE" END SUB SUB mc4zero '**************************************************************************** 'This subroutine zeros the MC4 Klinger stepping motor controller. ' 'Zachary Wolf '1/15/95 '**************************************************************************** 'Get the GPIB I/O file numbers and the MC4 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% mc4addr% = mc4addrP% 'Put the address number into a string mc4addr$ = STR$(mc4addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF" PRINT #gpibout%, "TERM OUT CR LF" 'Zero all axes PRINT #gpibout%, "OUTPUT " + mc4addr$ + ";AA" END SUB