                         MD-2 Dual Stepper Motor System

                                  MD2VD2S.TXT

       Visual-Basic/DOS Level 2 Motion Control Subroutines Documentation

                       Copyright (c) 1994 Arrick Robotics




The MD2VD2S.BAS subroutine library for Visual-Basic/DOS contains the
same functionality as the MD2QB2S.BAS library for Quick-Basic.  The
the documentation file MD2QB2S.TXT contains detailed information that
applies to both libraries.
   

PROGRAMMING EXAMPLES:

Controlling the MD-2 stepper motor system is simply a matter of setting
the desired motor parameters via global variables and calling the
appropriate SUB.  The following example program shows how to use
the subs and parameters.  It may be necessary to change the
MD2MINSPEED(M), MD2MAXSPEED(M), MD2SLOPE(M) and MD2MOTOR parameters
for this program to operate on your computer.  It may also be necessary
for a path to be included in the INCLUDE command depending on where you
place this file.


'$INCLUDE: 'MD2VD2S.BI'     'DECLARATIONS OF SUBS AND MODULES.

START:
    MD2SETUP                'SET DEFAULTS AND FINDS PORTS.

    'DISPLAY AVAILABLE PORTS.
    IF MD2AVAILABLE12 THEN PRINT "PORT FOR 1 & 2 IS AVAILABLE."
    IF MD2AVAILABLE34 THEN PRINT "PORT FOR 3 & 4 IS AVAILABLE."
    IF MD2AVAILABLE56 THEN PRINT "PORT FOR 5 & 6 IS AVAILABLE."

    'TURN ON MD-2 FOR MOTORS 3 & 4.
    MD2MOTOR = 3            'MOTOR 4 WOULD ALSO WORK HERE.
    MD2ON                   'TURN ON MD-2.

    'SET MOTOR PARAMETERS THAT ARE DIFFERENT THAN DEFAULTS.
    MD2MINSPEED(3) = 2500   'SET START/STOP SPEED.
    MD2MAXSPEED(3) = 1000   'SET MAXIMUM SPEED.
    MD2SLOPE(3) = 150       'SET ACCEL/DECELERATION IN STEPS.
    MD2MINSPEED(4) = 4000   'SET SPEEDS FOR MOTOR 4.
    MD2MAXSPEED(4) = 2000
    MD2SLOPE(4) = 150

    'MOVE MOTORS 3 & 4 HOME.
    MD2MOTOR = 3            'MOVE 3 HOME.
    MD2HOME
    MD2MOTOR = 4            'MOVE 4 HOME.
    MD2HOME

    'MOVE MOTOR 3 TO POSITION 275.
    MD2MOTOR = 3            'MOTOR 3.
    MD2MOVETYPE = "A"       'ABSOLUTE MOVE.
    MD2TARGET(3) = 275      'POSITION 275.
    MD2MOVE                 'MOVE THE MOTOR.
    PRINT "STATUS IS ";MD2STATUS        'DISPLAY STATUS.

    'MOVE MOTOR 4 400 STEPS FORWARD.
    MD2MOTOR = 4            'MOTOR 4.
    MD2MOVETYPE = "R"       'RELATIVE MOVE.
    MD2TARGET(4) = 400      '400 STEPS FORWARD.
    MD2MOVE
    PRINT "STATUS IS ";MD2STATUS        'DISPLAY STATUS.

    'DUAL AXIS MOVE (LINEAR INTERPOLATION).
    MD2MOTOR = 34           'BOTH MOTORS.
    MD2MOVETYPE = "R"       'RELATIVE.
    MD2TARGET(3) = 400      'MOTOR 3 TARGET.
    MD2TARGET(4) = 253      'MOTOR 4 TARGET.
    MD2MOVE                 'MOVE.
    PRINT "STATUS IS ";MD2STATUS        'DISPLAY STATUS.

    'DISPLAY MOTOR POSITIONS.
    PRINT "MOTOR 3 POSITION IS: ";MD2POSITION(3)
    PRINT "MOTOR 4 POSITION IS: ";MD2POSITION(4)

    'TURN OFF MD-2 SYSTEM.
    MD2MOTOR = 3            'SELECT MOTOR AT THAT PORT.
    MD2OFF                  'TURN OFF MD-2.

    END                     'DONE.


USING VISUAL-BASIC/DOS:

Visual-Basic for DOS is a Basic language compiler that is very easy to use.  
A Basic program normally consists of several program modules, each providing
a certain function.  The MD2VD2S.BAS subroutine library is provided
in the form of a module.  Your program will probably consist of two
modules: the MD2VD2S.BAS subroutine module and your custom program module
along with the MD2VD2S.BI include file which declares the subs and
global variables necessary for other modules to have access to MD2VD2S.BAS.
The following sequence can be used to create a custom program using
the MD2VD2S.BAS module and the MD2VD2S.BI include file.  It should be
used as a guildline only.  Your system may require different commands
and steps.  Basic knowledge of DOS, your computer and Visual-Basic/DOS
is required to accomplish this.  You must start Visual-Basic/DOS with the
/L switch in order for some functions to work.

1   Make a directory on the hard disk to contain the MD-2 files
    and programs.  Example from the DOS prompt:  MD C:\MD2 (Enter)

2   Copy the files from the distribution floppy disk to the hard
    disk.  Example from the DOS prompt:  COPY A:*.* C:\MD2 (Enter)

3   Change to the MD-2 directory.  Example:  CD \MD2 (Enter)

4   Run Visual-Basic for DOS.  Example:  VBDOS /L

5   Select ADD FILE from the FILE menu.

6   Select MD2VD2S.BAS for loading.

7   Select SAVE PROJECT AS from the FILE menu and enter a new file name.

8   Enter in your program into the new file window.  Don't forget
    to begin your program with the $INCLUDE statement as in the
    example above.

9   Select SET MAIN MODULE from the RUN menu and enter in
    your new file name as the main module.

10  Select SAVE AS from the FILE menu to save your custom program.

11  Run your program by selecting START from the RUN menu.

12  Consult your manual or on-line help for more information on
    Visual-Basic/DOS.


END OF DOCUMENTATION:
