MD-2 Dual Stepper Motor System Level 1 Motion Control Subroutines Documentation Copyright (c) 1993 Arrick Robotics FILE NAMES: File names describe their contents. Here are SOME of the posibilities: MD2QB1S.BAS <---- .BAS = Basic source code. | | || .TXT = (Text) documentation file. | | || .BI = Basic include file. | | || .EXE = Executable program. | | || .MAK = Make file. | | || .FRM = Form. | | || .INI = Configuration & parameters. | | || | | | ------------- S=Subroutine Library. | | | E1=Example program #1, etc. | | | F1=Form #1, etc. | | | T=Programming tools. | | | | | ----------- 1 = Level 1 subroutine library. | | 2 = Level 2 subroutine library, etc. | | | --------- QB = Quick Basic. | QI = Q Basic Interpreter. | VD = Visual Basic for DOS. | VW = Visual Basic for Windows. | BI = Basic Interpreter with line #'s. | QC = Quick C. | -------- MD2 = MD-2 Dual Stepper Motor System. See the MD-2 manual for other information on hardware and software. LEVEL 1 SUBROUTINE LIBRARY OVERVIEW: Different levels of motion control subroutines are available to provide different levels of sophistication, features and performance. The level 1 subroutines offer the most basic features needed to move the motors of the MD-2 system. There are not any fancy features such as ramping, linear interpolation, multi-motor moves, or units conversion. The library includes all the subroutines necessary to control up to 6 motors. All motor parameters are global variables. The programmer simply sets the desired parameters such as speed, direction and distance and calls the subroutine. The libraries are very easy to use and can be easily connected to other subroutine libraries such as those provided with data aqusition systems. To select a level 1 subroutine library, choose a language from the list above such as QB for Quick-Basic, then print out the documentation file (MD2QB1S.TXT in this case) and review it. You may also print example programs to help you out. For example, if you were going to write a program in Visual Basic for Dos, you can get a list of all associated files by typing the following command at the DOS prompt: DIR MD2VD1*.* for other languages, simply replace the VD with the 2 letter code for that language from the chart above. The rest of this file is a general overview of the level 1 subroutine libraries. Consult the documentation (.txt) file for the specific language for more detailed information. These subroutines have the following features: Complete control of all motion parameters - speed, direction, etc. Control up to 6 motors on one computer. Single motor moves only. Only constant speed moves, no ramping. Relative moves only, (step count & direction). Motor homing using switches. THE MD-2 SYSTEM: The MD-2 dual stepper motor system is a complete dual axis motion control system that connects to any IBM style personal computer. The system comes complete with 2 motors, cables, drive electronics, software and documentation. Simply connect the MD-2 to a printer port and load the software. These motors can be used to control a wide range of items including robotic arms, telescopes, cameras and lazers. The operator and programmer have complete control over the speed, direction and other parameters of the motors. Sophisticated motion control programs can be created to accomplish almost any job. PARALLEL PRINTER PORTS: The MD-2 dual stepper motor system connects to the parallel printer port of any IBM style personal computer using a standard printer cable. There can be as many as 3 parallel printer ports on a single computer. Since each port can be attached to an MD-2, a total of 6 motors can be controlled with a single computer. Each port has its own address. The three possible addresses are 3BC, 378 and 278. When adding a new printer port, make sure that no two ports have the same address. The MD-2 software refers to the motors connected to the MD-2 which is connected to port 3BC as 1 & 2, port 378 as 3 & 4, and port 278 as 5 & 6. Your system may only have one or two ports. Since the motor numbers are determined by which port they are connected to, your system may have motors 3 & 4 or 5 & 6 but not 1 & 2. You may wish to keep your 3BC port connected to your printer so it can be refered to as LPT1: or PRN: in which case your MD-2 motors would be 3 & 4 or 5 & 6. Parallel printer port cards are very inexpensive and are normally available at local computer stores or by mail-order. SUBROUTINE DESCRIPTION: The level 1 subroutine source code file contains several subroutines that can be used by the programmer to control the MD-2 system. All motor parameters are in the form of global variables. To use, the programmer simply sets the motor parameter variables to the desired settings and calls the subroutine by name. The subroutines are listed below: NAME DESCRIPTION ---- ----------- MD2SETUP Used at the beginning of a program to initialize motor parameters to their default values. Use this subroutine before any other. MD2ON Turns on an MD-2 controller. MD2OFF Turns off an MD-2 controller. MD2HOME Moves a motor to the Home position by watching the home switch. Current position is set to zero. MD2MOVE Moves a motor using the selected motor parameters. MOTOR PARAMETERS AND VARIABLES: Motor parameters are global variables. Each one begins with the letters 'MD2' to minimize naming conflicts. NAME TYPE DESCRIPTION ---- ---- ----------- MD2HOLD INTEGER -1=Leaves the motor energized after a move to cause the motor to hold its position. 0 causes the motor to turn off after a move which conserves power and reduces heat. MD2MOTOR INTEGER The selected motor to act upon. 1,2,3,4,5 or 6. MD2SPEED(M) INTEGER Delay count between steps. 0=fast, 32766=slow. Actual motor speed depends on the computer. M is the motor number 1,2,3,4,5 or 6. MD2POSITION(M) LONG Current motor position for each motor (M=motor #) relative to home in steps. Negative are reverse from home and positive are forward from home. M is the motor number 1,2,3,4,5 or 6. MD2STATUS STRING Completion status. O=motion completed OK, K=a keypress stopped the motion, B=Bad parameter. MD2TARGET(M) LONG The number of steps to move. Positive numbers are forward, negative numbers are reverse. M is the motor number 1,2,3,4,5 or 6. HOMING MOTORS: Each motor on the MD-2 system has a home switch associated with it. At the beginning of a program, the software does not accuratly know the positions of the motors. Homing causes the motor to seek the home switch to establish the home position (position zero). All moves are relative to this home position. The programmer or operator can, at any time, home the motors to insure accurate positioning. This is not necessary in most situations where the home function is only used at the beginning of a program once. The MD2HOME subroutine moves the motor reverse (clockwise as viewed from the front of the motor) until the home switch is activated, then forward until the switch is deactivated. This sequence has the effect of preloading the mechanical system in the forward direction which will increase the accuracy of systems which have backlash or belt stretch. A new home position can be established by homing the motor normally, moving to the desired location, then setting the MD2POSITION(M) parameter to zero. All motions thereafter will be relative to this new home position. This can be used to duplicate motion sequences for step and repeat operations without modifications to the fundamental program. During home moves, the motor will move at a constant speed. The home switches may also be used for general purpose inputs by reading them with input statements. MOVING MOTORS: A motor is moved by setting the motor parameters and calling the MD2MOVE subroutine by name. The MD2MOTOR parameter determines which motor is to be moved (1,2,3,4,5 or 6). The MD2TARGET(M) parameter determines how many steps the motor will move and the direction. Positive numbers will move forward and negative numbers will move reverse. The motor will move at a constant speed determined by the MD2SPEED(M) parameter. See the section on motor speeds for more information. The MD2POSTION(M) parameter will be set to the motor's position relative to home in steps. A motor move can be stoped by pressing any key on the keyboard. The home switches are ignored. The motor may be left energized or de-energized depending on the value of the MD2HOLD parameter. If MD2HOLD=0 then the motor will be de-energized, if -1 then power will be left on the motor which results in holding torque and motor heat. MOTOR SPEEDS: Motor speeds are given in delay counter values. This number is the delay time between steps which determines the motor speed. A small number will move the motor fast, a large number will move the motor slower. Speed values depend greatly on the computer's speed. Fast computers will require higher speed values in order to achieve the same speed as slower computers with smaller numbers. This means that a motion control program may act differently on different computers. The operator needs to have the option of changing the speed values for optimum operation on a particular computer. Finding the correct speed values requires experimentation. If the speed value is to small (fast), the motor may just vibrate without moving. This condition does not harm the motor or driver. Increase the speed value (slower) until the motor begins to move without missing steps or vibrating, then increase the value another 30% or so to give a margin of error. If a motor ever misses steps, then the MD2POSITION(M) variable will not accurately represent its current position. Select motor speeds that are slow enough to prevent missed steps causing this condition. Homing the motors can be used to resyncronize the system. END OF DOCUMENTATION: