Text preview for : 24421B(MSTEP-3).pdf part of Keithley 24421B(MSTEP-3) Keithley Misc 24421B(MSTEP-3).pdf



Back to : 24421B(MSTEP-3).pdf | Home

MSTEP-3
Triple Stepper Motor Controller Board
User Guide
User Guide

for the



MSTEP-3

Triple Stepper Motor

Controller Board




vision B - April 1992
Copyright % Keithley Data Acquistion. 1991
Part Number: 24421




KEITHLElY DATA ACQUISITION - KEXTHLEY METRAIWIWASYST
440 MYLES STANDISH BLVD., Taunton, MA 02780
TEL. 508/880-3000, FAX 508/880-0179




.. .
- 111 -
Warranty information

All products manufactured by Keithley MetraHyte are warranted against defective
materials and worksmanship for a period of one year horn the date of delivery to
the original purchaser. Any product that is found to be defective within the
warranty period will, at the option of Keithkey MetraHyte. be repaired or replaced.
This warranty does not apply to products damaged by improper use.




Warning

Keithley MetraByte assumes no liability for damages consequent to the
use of this product. This product is not designed with components of a
level of reliability suitable for use in life support or critical applications.




Disclaimer

Information furnished by Keithley Mett-aByte is believed to be accurate and
reliable. However, the Keithley MetraByte Corporation assumes no responsibility
for the use of such information nor for any iniiingements of patents or other rights
of third parties that may result from its use. No license is granted by implication
or otherwise under any patent rights of Keithley Me&Byte Corporation.




Note:

Keithley MetraBytc'" is a trademark of Keithley Data Acquisition.


Basic"' is a trademark of Dartmouth College.


IBM@ is a registered trademark of International Business Machines Corporation.


PC, XT, AT, PS/2, and Mho Channel ArchitecturG are trademarks of Intema-
tional Business Machines Corporation.


Microsoft@ is a registered trademark of Microsoft Corporation.


Turbo C@ is a registered trademark of Borland International.




- iv -
Contents

CHAPTER 1: INTRODUCTION

1.1 Description ....................................... l-l
1.2 General Areas Of Application ............................. l-3
1.3 Utility Software ..................................... l-4
1.4 Technical Support. ................................... l-4
1.5 Accessories ....................................... l-4


CHAPTER 2: INSTALLATION

2.1 Backing Up The Disk ................................. .2-l
2.2 Unpacking & Inspecting ............................... .2-l
2.3 Switch & Jumper Settings .............................. .2-l
2.4 Hardware Installation ................................. .2-3


CHAPTER 3: PROGRAMMING

3.1 General ........................................ .3-l
3.2 Register Locations & Functions ........................... .3-2
3.3 PPMC-103A Stepper Controller Internal Registers ................. .3-4
3.4 Loading The Machine-Language Call Routine MSTEP.BIN ............ .3-5
3.5 Structure Of The Call Statement ........................... .3-6
3.6 Error Codes ...................................... .3-8
3.7 Stepper Motor Fundamentals ............................ .3-9
3.8 CALL Modes .................................... .3-10


CHAPTER 4: MODE CALLS

4.1 MODE 0: Emergency Stop .............................. .4-l
4.2 MODE 1: Decelerating Stop ............................. .4-2
4.3 MODE2:JogOrSingleStep. ............................ .4-2
4.4 MODE 3: Step With Acceleration/Deceleration ................... .4-4
4.5 MODE 4: Step At Constant Speed .......................... .4-5
4.6 MODE 5: Move To Outer Limit At Constant Speed ................. .4-7
4.7 MODE6:MoveToLimitAtHighSpeed. ...................... .4-9
4.8 MODE 7: Move To Base Point At Constant Speed ................. 4-l 0
4.9 MODE 8: Read Motor Status. ............................ 4-l 1
4.10 MODE 9: Load Divider ................................ 4-15
4.11 MODE 10: Read All Ports .............................. 4-15
4.12 MODE 11: Write All Ports .............................. 4-16
4.13 MODE 12: Write Data To One Port ......................... 4-17
4.14 MODE 13: Toggle Auxiliary Bit. ........................... 4-18
4.15 MODE 14: Enable/Disable Interrupt ......................... 4-18
4.16 MODE 15: Initialization ................................ 4-20
4.17 Interpreted BASIC (GW, Compaq, IBM, Etc. .................... 4-26
4.18 QuickBASIC. .................................... .4-27
4.19 Muttiple MSTEP-3s In One System ......................... 4-29


CHAPTER 5: USING THE ACCESSORIES

5.1 MS-Drive Description ................................. .5-i
5.2 Connecting The M3-Drive .............................. .5-l

-v-
Contents

5.3 Power Supply Selection ................................ 5-2
5.4 Connecting A Motor To The M3-Drive ........................ 5-2
5.5 Direct Connections To The MSTEP-3 ........................ 5-3


CHAPTER 6: STEPPER MOTORS 81 TRANSLATORS

6.1 How A Stepper Motor Works ............................. 6-1
6.2 Torque Versus Speed ................................. 6-3
6.3 Resonance. ...................................... 6-3
6.4 Full- & Half-Step Operation .............................. 6-4
6.5 Translators & Indexers. ................................ 6-5
6.6 Mechanical Design. .................................. 6-5


CHAPTER 7: TESTING & MAINTENANCE


CHAPTER 8: FACTORY RETURNS




APPENDICES

Appendix A: PPMC-103A Specifications & Programming
Appendix B: Sources For Stepper Motors & Assemblies
Appendix C: STEP-MOT1 Specifications
Appendix D: MSTEP-3 & M3-Drive Specifications




- vi-
CHAPTER 1

INTRODUCTION

1 .I DESCRIPTION
Keithley MetraByte's MSTEP-3 is a plug-in, 3-axis, stepper-motor, motion-control board for the IBM
PC/XT/AT and compatibles. The Board is 12 inches long and requires a full-length expansion slot.
All connections necessary for operation with Keithley MetraByte's accessories are made through the
rear plate using a standard 50-pin insulation-displacement (mass-termination) connector. Keithley
MetraByte offers as options a stepper-motor driver (M3-DRIVE), a compatible power supply (M3-
PWR-241, a popular type of stepper motor (STEP-MOTl), as well and a screw-terminal adapter (STA-
50) that allows the MSTEP-3 to be connected to drivers other than the M3-DRIVE. Figure l-1 is a block
diagram of the MSTEP-3.

Each independent stepper channel consists of a Sil-Walker PPMC-103C intelligent controller chip
capable of executing a variety of motion control commands. The F'PMC-103C is one of the more
popular Japanese robotics chips, providing essential features with simplicity of use. Keithley
MetraByte's driver software further enhances the ease of stepper-motor control by personal computer.

Once a command is loaded into the PPMC-103C controller chip, the host computer is no longer
burdened by the execution of the particular motion but may monitor its status as needed. The
associated stepper motor may be moved any number of steps up to 24 bits of resolution (+16,777,216
steps) either with a controlled acceleration/deceleration profile or constant stepping rate. Associated
with each motor are 5 limit switch inputs as well as a motor-enable input. The limit switches provide
normal and emergency stop limits at both ends of travel, plus a home or reference point at any
intermediate point. A normal stop is defined as a normal deceleration to rest without loss of the step
count due to inertial effects, an emergency stop is a sudden stop that may lead to run on of the motor
and hence loss of location from the step count and would normally require recalibration by return to
the reference or home point. The emergency stop amounts to an immediate cessation of step pulses
regardless of what the motor is doing at the time. In addition to controlling the number of steps
travelled by the motor (normal motion), the PPMC-103C controller executes the following commands
described below:


Initialization Controls number of phases driven (3,4 or 5), logic levels of phase
excitation, (normal, inverted), internal/external step clock select and
switching excitation on/off at standstill. In addition this command sets
the start up, acceleration/deceleration and high speed run rates. The
components of this command that relate to the motor configuration
cannot be altered by a further initialization command without resetting
the PPMC-103C controller.
Move Normal Moves the motor the desired number of steps with a controlled rate
and acceleration/deceleration.

Move Constant Rotates motor at constant speed for a specified number of steps.
Find Limit Rotates motor to an outer limit switch.




l-l
MSTEP-3 USER GUIDE




a--
PuLARm
TO P2 SWITCHES
I I _
--.- PULL UP - L,MlT ,
OUT 12.345
_ RESISTORS _ L,M,T 2
cLoc% PHASE OUTPUTS
- BUFFERS - LIMIl 3
IN -drMOR _ LIMIT t
PPMC- 1 WA - GATES - HOME
STEPPER MOTOR
MOTOR ON
CONTROLLER
STEP
BUS
::
=-7
---7
ADDRESS

DECODE,

BUS BUFFER,
A AXIS
I
DIRECTION
HOLO
AUX BIT



TO P2
%
?
d - 1 LIMIT 1
PHASE OUTPUTS UMrr 2
3 CLOCK
LIMIT ,
IN LIMIT 4
8 PPMC-103A
HOME
STEPPER MOTOR


BUS
CONTROLLER
-_
MOTOR ON
FTEP
DIRECTION
HOLD
B AXIS AUX BIT



TO P2




EXT. CLOCK INPUT M"X OUT
CLOCK
LIMIT 1
LIMIT 2
LIMIT J




4i
DMDER IN UMIT 4
PPMC-1OJA
HOME
STEPPER MOTOR
MOTOR ON
CONTROLLER
STEP


c AXIS A"X BIT


BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
a ;; OCTAL LATCH
II-H BIT
BIT
1
0




BIT 7
OCTAL FLIP-FLOP BIT 6
BIT 5
-_ PULL UP BIT 4
-- RESISTORS SIT 3
BIT 2
OCTbL LATCH BIT 1
EIT 0
I I/O PORT B




Figure: Block diagram of the MSTEP-3.



Find High-Speed Limit Rotates motor to a high-speed or inner-limit switch.
Find Base Point Rotates motor to home or reference-limit switch.
Read status Read PPMC-103C controller status.
Decelerating Stop Stops motor normally.
Emergency Stop Instantly stops motor by removing drive pulses (may lead to loss of true
location from step count).
Single Step Single step or "jog" command.


Each stepper channel provides two different types of outputs. One is a counter-clockwise/clockwise
(CCW/CW) signal plus a pulse-train output corresponding to the number of steps to be moved. This
is suitable for driving the MS-DRV as well as a wide variety of standard stepper-motor translators


1-2
CHAPTER 1: INTRODUCTION

available from most stepper-motor manufacturers. The other set of signals consists of 5-phase outputs
used to drive power transistors to switch the stepper motor windings directly. The number of outputs
enabled and the stepping sequence are controlled by the initialization command and can be matched
to 3-, 4-, or S-phase motors.

The M3-DRIVE sets up quickly to drive most small to medium size (i.e. 1-2 Amps /phase) stepper
motors directly. This is a bipolar-chopper type of driver which provides better efficiency and often
better torque at high speeds than R/L drives. Since this type of driver is superior for most
applications, it is the only one sold by MetraByte for the MSTEP-3. However, if you desire to interface
with an R/L driver, the necessary signals are accessible on the MSTEP-3 either through connector Jl at
the rear of the card or connector P2 on the top edge of the card.

The step rate is controlled by the clock frequency. The PPMC-103A chip has an internal clock of 25
KHz. This clock has a programmable divider that can divide it by any number in the range of 13-255
(20-255 if not in turbo mode) giving corresponding step rates from 98 to 1923 pps (pulses per second).
This range is often adequate, but you also have the option of selecting an external clock. There are two
possible sources for this external clock. One is an on-board 800 KHz crystal controlled clock, and the
other is a user supplied clock. Whichever source is selected is, in turn, passed through an 8254 clock
divider before being fed to the PPMC-103A. Software determines which external clock is being used
and the division ratio of the 8254. The division ratio must be selected so that with the chosen clock
source, the input to the PPMC-103A is less than 267 KHz. This allows step rates as high as 19,000 pps.
With the on-board 800 KHz clock, the lower limit is less than one pulse every 20 seconds (of course
with the user supplied clock, there is no lower limit on the pulse rate).

All communications with the MSTEP-3 is via I/O ports (no memory address space is used); 16
contiguous addresses are used in I/O space. The Base Address is selected on a DIP switch and can be
anywhere in the range 0 - 3F8 hex; lOO-3F8or 200-3F8 is the usual usable range in an IBM PC/AT/XT.
More than one MSTEP-3 may be installed in a PC for multiple-axis control. The number is limited
only by available expansion slots.

The PPMC-103C stepper controller chips can also generate interrupts on completion of commands and
certain other conditions. This is supported in the MSTEP-3 hardware, interrupts may be jumper
selected to any of the IBM PC Interrupt Levels 2-7 and in conjunction with the PPMC-103C Status
Registers makes interrupt handshaking a simple procedure and allows the programmer to perform
background control.




1.2 GENERAL AREAS OF APPLICATION
Many manufacturers produce stepper motors, stepper motor assemblies such as X-Y tables, etc. A
short summary of sources appears in Appendix B. Keithley MetraByte can provide from stock a
standard 5V, lA, 200-step/revolution motor (STEP-MOTl); see Appendix C for specifications. These
devices are representative only of typical hardware that can be used with the MSTEP-3.

Generally, stepper motors are suited to applications requiring variable torque, low speeds (not
exceeding 500 rpm) and maximum position retention. They also offer the simplicity of open-loop
position control simply by counting the number of steps. If your needs dictate higher speeds, fast
acceleration and deceleration, and the ability to return to a set position regardless of load
perturbations, a closed-loop DC servo drive may be more suitable. This type of drive is generally
more complex and costly than a stepper drive but has characteristics that may be essential in certain
applications.

The MSTEP-3 may be combined with other Keithley MetraByte measurement and control boards to

1-3
MSTEP-3 USER GUIDE

implement complex "move and measure" type of instrumentation. It has obvious applications in
robotics, optics and lasers, mechanical assemblies, remote control, etc.




1.3 UTILITY SOFTWARE
It is possible to program the MSTEP-3 directly using normal I/O port commands (INP and OUT etc.).
This is explained in Section 3 and Appendix A, but for the programmer who wants fast results, our
accompanying utility software (MSTEP.BIN) will simplify the use of the MSTEP-3 and save a lot of
programming time. The utility software is provided on a single-sided PC-DOS 1.10 format 5-l/4"
floppy disk (upward compatible with DOS 2.0 and higher revisions):

1. A Microsoft Basic callable driver (MSTEP.BIN) is provided for control of the basic stepper and
encoder functions. The fully commented assembly source for this driver (MSTEPASM) is also
provided. The object module, MSTEP.OBJ, is also on the disk for linking when using compiled
BASICS (for example, IBM BASIC Compiler, Microsoft QuickBASIC, etc.).
2. Examples and demonstration programs. A comprehensive demonstration program (DEMO.BAS,
DEMO.EXE) is provided. This is excellent both as a programming example and a way of getting
the "feel" of the PPMC motion commands and driver software features. It will also be useful in
your system setup and test. For further details see Chapters 3 and 7.
3. Instructions for ASSEMBLY LANGUAGE, C, Pascal and Fortran programmers are included in
Appendix E.




1.4 TECHNICAL SUPPORT
If you have a problem or need information or advice, please call us at 508/880-3000 and ask for
Applications Engineering . We will do our best to assist you. If for any reason you are dissatisfied with
any Keithley MetraByte product or find it is unsuited to your requirements, you are welcome to return
it within the first 30 days of purchase for a full refund. Please call us first for an RMA (Return
Material Authorization) number before sending back any hardware. The MSTEP-3 and accessories are
warranted against defects in manufacture and material for one year from the date of original
purchase.




1.5 ACCESSORIES
Several optional accessories to facilitate the use of the MSTEP-3 are available from Keithley MetraByte.
These include:

M3-DRIVE This is a driver which, with the addition of a power supply like the M3-PWR-24, allows
the MSTEP-3 to control a stepper motor requiring from 1 to 2 Amps per phase. Screw
terminals allow easy connections to M3-PWR-24, the motor, and limit or home switches,
as well as one of the two general purpose I/O pork of the MSTEP-3. Up to three M3-
DRIVE's can be connected to each MSTEP-3. They are connected in "daisy chain" (the
MSTEP-3 is connected to the axis A M3-DRIVE, the Axis A unit is connected to the Axis B
unit, and the Axis B unit to the Axis C).
M3-PWR-24 This is a power supply capable of supplying the power needed by one M3-DRIVE.



1-4
CHAPTER 1: INTRODUCTION


CDAS-2000 This is the cable to connect the Axis A M3-DRIVE to the MSTEP-3, or the Axis B M3-
DRIVE to the Axis A output, or the Axis C M3-DRIVE to the Axis B output.

STA50 This is a screw terminal adapter which would be used by customers not using M3-
DRIVE's to drive their motors.
STEP-MOT1 This is a stepper motor compatible with the MSTEP-3 and the M3-DRIVE.


A complete 3 axis system can be built with one MSTEP-3, three STEP-MOTls, three M3-DRIVES, three
M3-PWR-24s, and three CDAS2000s. n




1-5
MSTEP3 USER GUIDE




cl




1-6
CHAPTER 2

INSTALLATION

2.1 BACKING UP THE DISK
The back-up software supplied with MSTEP-3 is in DOS 1.10 format and is compatible with DOS 2.0
and higher revisions. You are urged to use this utility to back up your MSTEP-3 Distribution Software
at the earliest opportunity. For a direct backup, use the DOS DISKCOPY utility or alternatively COPY
*.* to a preformatted disk. For a hard disk, simply use COPY *.* to transfer your Distribution Software
to a directory of your choice (the Distribution Software is not copy protected). If for any reason you
should misplace or destroy your MSTEP-3 Distribution Software, please contact Keithley MetraByte
for a replacement copy.




2.2 UNPACKING AND INSPECTING
After you remove the wrapped board from its outer shipping carton, proceed as follows:

1. Place one hand firmly on a metal portion of the computer chassis (the computer must be turned
Off and grounded) to discharge static electricity from the package and your body, thereby
preventing damage to board components.
2. Carefully unwrap the board from its antistatic wrapping material.
3. Inspect the board for signs of damage. If any damage is apparent, return the board to the factory.
4. Check the contents of your package against its packing list to be sure the order is complete.
Report any missing items to MetraByte immediately.


You may find it advisable to retain the packing material in case the board must be returned to the
factory.




2.3 SWITCH & JUMPER SETTINGS

Base Address Switch
MSTEP-3 requires 16 consecutive address locations in I/O space. Some I/O addresses will already be
in use by internal I/O and your other peripheral devices. Avoid setting the MSTEP-3 to the same
address as any other device already installed in your machine. A conflict of addresses will not cause
physical damage but may cause malfunction of the MSTEP-3 and the conflicting adapter and, in some
circumstances, the Power On Self Test (POST) diagnostic messages. To avoid conflict with these
devices, you may change the MSTEP3's preset I/O address by resetting the Base Address DIP switch;
any new setting should be on an 16-bit boundary anywhere in the PC's available I/O space.

The PC-XT I/O address space extends from decimal 512-1023 (Hex 200-3FF) and the PC-AT I/O
address space extends from decimal 256 to 1023 (Hex 100-3FF). In either case, the available space is
never likely to be fully occupied and is more than enough to accommodate more than one MSTEP-3 in
a single computer.

For your convenience, the reserved I/O addresses for standard IBM devices are detailed in the


2-1
MSTEP3 USER GUIDE

following table.

HEX RANGE USAGE HEX RANGE USAGE

OOOtolFF Internal System 37F to 387 LPTl:
200 to 20F Game 380 to 38C SDLC comm.
210 to 217 Expansion unit 380 to 389 Binary comm. 2
220 to 24F Reserved 3A0 to 3A9 Binary comm. 1
278 to 27F Reserved 3B0 to 3BF Mono dsp/LPTl:
2F0 to 2F7 LPT2: 3co to 3CF Reserved
2F8 to 2FF COM2: 3D0 to 3DF Color graphics
300 to 31F Prototypecard 3E0 to 3E7 Reserved
320 to 32F Harddisk 3F0 to 3F7 Floppy disk
3F8 to 3FF COMl:


This list covers the standard IBM I/O options (most compatibles are identical), but if you have other
I/O peripherals (special hard disk drives, special graphics boards, prototype cards, etc.), they may be
making use of I/O addresses not listed in the table.

Usually, a good starting choice of Base Address is 300h or 310h (768 or 784 Decimal). (Note if you are
using an IBM prototype board, it uses the 300-31F (Hex) address space and would conflict; 330h or
340h would be a good alternative in this case).

An aid to setting the Base Address DIP switch is the graphical program DIPS W.EXE , in your
Distribution Software. This program may be run from the DOS prompt by typing DIPSW .

When you get the Desired base address? prompt, type in your choice in decimal or IBM
&H-- format and press < Enter > . The program rounds your address to the nearest 8-bit boundary,
checks for conflicts with standard I/O devices (and warns you if so), and displays the correct positions
of the seven toggles on the Base Address DIP switch. For additional details on Base Address switch
settings, see the following diagram.
BASE ADDRESS SWITCH INTERRUPT LEVEL
ADDRESS ADDRESS LINE VALUES: SELECTION
LINE DECIMAL HEX



IRO LEVEL (X = INACTIVE)
2 3 4 5 6 7 x



1 2 3 4 5 6




JUMPER IS IN THE X POSITION




Base Address switch and Interrupt Level selection.




Interrupt Level Selection
Referring to the diagram, the choice of Interrupt Level depends on the placement of a jumper. Very
likely, you will not initially make use of the interrupt capabilities of the MSTEP-3 and can place the
IRQ LEVEL jumper in the X position. If your programming will use interrupts from the MSTEP3,

2-2
CHAPTER 2: INSTALLATION

then select the Interrupt Level (2 thru 7) you intend to use. Take care to avoid selecting a level in use
by another adapter card (for example, Level 6 is always used by the floppy disk controller, Level 4 by
COMI:, Level 3 by COM2: etc.). For more information on interrupt programming, see MODE 11 in
Chapter 3.



HOME/LIMIT Polarity Switch.
DIP Switch Sl controls polarity of the Home and Limit switch inputs. For example, if any axis of your
system does not need limit switches you may want to set the Limit Switch for that axis to On (Up
position), as this will allow the motor to move with no limit-switch inputs. You may also use this
position if you use normally open limit switches.

If, however, fail-safe operation is important, you may want to set the appropriate switch to Off (Down
position). Under these conditions, normally closed limit switches must be used to insure that if any
wire from a switch to the MSTEP-3 should open up, the MSTEP-3 will cause the motor for that axis to
stop.

Similarly, the Home Switches are set for the polarity of the Home Switch used in each axis. Setting a
Home Switch On will cause the MSTEP-3 to be looking for a low input when searching for Home,
while the Off position will cause the board to look for a high level.

It should be noted that all Limit and Home Switch inputs have a pull-up resistor to +5 Volts and are
then buffered through a Schmitt trigger IC in the "Ls" family.




2.4 HARDWARE INSTALLATION
WARNING: ANY ATTEMPT TO INSERT OR REMOVE A BOARD WITH THE COMPUTER
POWER ON COULD DAMAGE YOUR COMPUTER!


1. Turn Off power to the PC and all attached equipment.
2. Remove the cover of the PC as follows: First remove the cover-mounting screws from the rear
panel of the computer. Then, slide the cover of the computer about 3/4 of the way forward.
Finally, tilt the cover upwards and remove.
3. Choose any available option slot. Loosen and remove the screw at the top of the blank adapter
plate. Then slide the plate up and out to remove.
4. Hold the Board in one hand placing your other hand on any metallic part of the PC/AT chassis
(but not on any components). This will safely discharge any static electricity from your body.
5. Make sure the board switches have been properly set (refer to the preceding section).
6. Because of the length of the 50-pin rear connector, you are advised to set its retainer latches out
straight (an elastic band will hold them in position), and then to pass it through the rear slot and
pivot the Board down into the edge connector. The Board is shaped to allow for this maneuver.
7. Gently press the board downward into the socket. Secure the Board in place by inserting the rear-
panel adapter-plate screw.
8. Replace the computer's cover. Tilt the cover up and slide it onto the system's base, making sure
the front of the cover is under the rail along the front of the frame. Replace the mounting screws.
9. Plug in all cords and cables. Turn the power to the computer back on.



2-3
MSTEP3 USER GUIDE


Remember, TURN OFF THB POWER whenever installing or removing any peripheral board, as it
can cause costly damage to the electronics of your computer and/or the MSTEP-3 board.

If for any reason you later remove the MSTEP-3 board, Keithley MetraByte recommends that you
retain the special electrostatically shielded packaging and use it for storage. n




2-4
CHAPTER 3

PROGRAMMING


3.1 GENERAL
At the lowest level, the Stepper Motor Controller is programmed using I/O input and output
instructions. In BASIC, these are the N'(X) and OUT X,Y functions. In Assembly Language, they are
IN AL,DX & OUT DX,AL. Most other high level languages have equivalent instructions. Use of these
functions usually involves formatting data and dealing with absolute I/O addresses. Although not
demanding, this can require many lines of code and necessitates an understanding of the devices, data
format, and architecture of the MSTEP-3. To simplify program generation, a special I/O driver
routine "MSTEP.BIN" is included in the MSTEP-3 software package. This may be accessed from
BASIC by a single line CALL statement. The CALL MSTEP will perform frequently used sequences of
instructions. An example is Mode 1 which performs a normal stop. A routine to perform this
operation in BASIC using INP's and OUT's would require many lines of code and would be rather
slow and very tedious to program.

A sequence of BASIC INP's and OUT's to write the Stop Command to PPMC channel A would be as
follows:


x10 BASADR% = CH300 'Set BASE ADDRESS.
x20 cmR% = INP (BASADR%t4) 'Read current data select req.
x30 OUT (BASADRtQ),&Hl 'Set AORSEL = 1 to read status req.
x40 STAT% = INP (BASADR%tl) 'Read Axis A status Req.
x50 'Motor stopped?
x60 IF (STAT% AND 6H4) = 0 GOT0 140 'Yes, restore data select req; exit.
x70 'Input buffer full?
x80 IF (STAT% AND &H2) <> 0 GOT0 40 'Yes, try again !
x90 CONFB = INP (BASADR%) 'Read and save configuration Req.
xl00 CONF% =CONF% AND &HFB
xl10 OUT BASADR%t4,CONF% 'Disable Axis A Interrupt.
x120 OUT BASADR%+4,&Hl 'Set AORSEL = 1 to write status req.
x130 OUT BASADR%tl,&H40 'Stop motor.
x140 OUT BASADR%tl, CNR% 'Restore data select req. value.
x150 STOP



All this code can be circumvented by using the driver:

x10 MD%=1 'command - decelerating stop
x20 D%(0) = 0 'select channel A
x30 CALL MSTEP (MD%, D%(O), STP#, FLAG%)



Obviously, the MSTEP.BIN driver greatly reduces programming time and effort. Both methods of
programming are described (see Appendix A for programming the PPMC-103A directly) and you are
free to choose either. Usually the BASIC programmer will find the CALL routine method very much
simpler to implement. The MSTBP.BIN driver also provides an example interrupt service routine. It
is not possible to program interrupt routines directly in BASIC and the driver is the only way of
utilizing interrupts from the MSTEP-3 hardware.




3-1
MSTEP-3 USER GUIDE



3.2 REGISTER LOCATIONS & FUNCTIONS
The following tables describe the locations and functions of the registers within the MSTEP-3 hoard.




Base Address +0
Configuration Select Register


BIT: 7 6 5 4 3 2 1 0

READ/WRITE: xcc CXB XCA EINTC EINTB EINTA OEPB OEPA

XCA, XCB, XCC: These bits determinethe source of the clock frequency input into the
8254 dividerfor each respectiveaxis. Setting any bit low results in the internal
8OOKHz clock being used, while setting it high results in the user-suppliedclock of Pin
51-25 being used. The outputof each respectivefrequencydivideris used by the
PPMC-103A wheneveran external clock is specified.
EINTA, EINTB, EINTC: Setting any of these bits high enables the respectiveaxis to
generate an interruptwhen the motor stops moving. Note that the jumper on the card
mustbe set to the appropriateInterruptLevel, or the PC will not receive the interrupt.
OEPA, OEPB: These bits control the OutputEnable function of Ports A and B,
respectively. Setting the Enable Bit of a port high sets the entire port for Output. Both
ports can be read whetherthey are configuredfor Outputor Input.




Base Address + 1
A Axis PPMC-103A: this is the address to read or write to the A Axis PPMC-103A. Refer to the Sil-
Walker data sheet for more information.




Base Address +2
B Axis PPMC-103A: This is the address to read or write to the B Axis PPMC-103A. Refer to the Sil-
Walker data sheet for more information.



Base Address +3
C Axis PPMC-103A: This is the address to read or write to the C Axis PPMC-103A. Refer to the Sil-
Walker data sheet for more information.




3-2
CHAPTER 3: PROGRAMMING


Base Address +4
Data Select Register


BIT: 7 6 5 4 3 2 1 0

READ/WRITE: X X X X X X X AORSEL

READ: X X X X \INTB -

Does matter.
Controls A0 both the
Use = to a or the
Use = to or data.
WB, These are low the stops; remain
until by the STATUS.




Address
I/O A: is general-purpose, I/O It be to read any but
data to will output on appropriate of Jl Port is for
by OEPA Base +0




Base +6
Port This a B-bit port. can written or at time, the
written it be only the pins Connector if A set Output
setting at Address high.



Address Through Address I
addresses not in current design.




Address 12
Counter (A This corresponds Counter of 8254, controls
division that 8254 to 800KHz or user-supplied for A For
information using divider, to 8254 sheet.



Address
8254 1 Axis): address to 1 the which the
ratio the applies the clock the clock the Axis.
more on this refer an data




3-3
MSTEP-3 USER GUIDE


Base Address +14
8254 Counter 2 (C Axis): This address corresponds to Counter 0 of the 8254, which controls the
division ratio that the 8254 applies to the 8OOKHzclock or the user-supplied clock for the C Axis. For
more information on using this divider, refer to an 8254 data sheet.



Base Address + 15
This address corresponds to the Control Word of the 8254. For more information on using this
divider, refer to an 8254 data sheet.




3.3 PPMW03A STEPPER CONTROLLER INTERNAL REGISTERS
Each PPMC-103A Stepper Controller is a specialized microprocessor that controls the stepper motor
for one axis. The I/O address (Base Address +l, +2, or +3,) selects which axis is being addressed.
When addressing a PPMC-103A, the AORSEL bit (Bit 0 of Base Address +4) determines which register
within the device is being addressed.

AORSEL READ WRITE

0 DATA DATA
1 STATUS COMMAND



Motion commands are issued to the PPMC controller by writing a command code to the Command
Register (with AORSEL = 1). Since the PPMC may be busy executing a command, you must always
read the STATUS register to determine whether the PPMC is ready to receive the command. After a
command is issued, it may require or produce a variable number of data bytes (depending on the
command) which are written or read from the Data Registers (with AORSEL = 0). Apart from
controlling access to the Command Register, the Status register also provides additional information
on the operation of the PPMC controller.

There are eight motion-control commands as well as the INITIALIZATION command that set the
operating conditions of the controller. The functions of the Command and Status Registers are as
follows:

INITIALIZATION Selects the motor type, method of excitation acceleration/deceleration
rate, internal/ external step clock, phase output logic type and start up
and high speed pulse rate. Once the initialization command has been
sent, it may not be overwritten by a further initialization command. The
PPMC controller must be reset either by turning the computer power off
and on or more conveniently by issuing a hardware clear command (see
Sections 3.2.4 and 3.8.13 - mode 12).
OPERATION This is the user interface mode in which COMMAND selects any of eight
motion-control commands. The length of the data to follow depends on
the specific command.
STATUS Before/after the completion of an operation command, the status register
provides data on the limit switches, motor in motion or at standstill and
input/output data buffer full or valid. It also enables you to read the
number of steps remaining to be travelled etc.

3-4
CHAPTER 3: PROGRAMMING

Direct programming of the PPMC-103A controllers and their full specification is more fully covered in
Appendix A.




3.4 LOADING THE MACHINE-LANGUAGE CALL ROUTINE MSTEP.BIN
In order to make use of the CALL routine MSTEP.BIN, it must first be loaded into memory. You must
avoid loading it over any part of memory that is being used by the main body of your program, DOS,
or programs such as RAM disks that use high memory. If you do collide with another program, your
computer will usually hang up although sometimes the results can be more peculiar. Often you will
need to turn the power off and restore it to re-boot the machine, the usual Ctrl-Alt-Delete reset may
fail to restore DOS. This may sound ominous, but apart from the frustration, no damage will ever
result!

MSTEP.BIN uses about 3 Kbytes of memory and is best loaded outside BASIC's workspace. A typical
loading sequence isas follows:

xx100 DEF SEG = &Ii3000 'segment of memory to load link
(choose an empty area e.g. @@ 192K)
xx110 BLOAD "MSTEP.BIN",O 'load driver . . Continue program



The above initializing steps will be the same for any interpreted BASIC program. A more
comprehensive example is provided on the disk in DEMO.BAS. Note that the DEF SEG = &H3000
statement in line 100 specifies the load location for the MSTEP.BIN driver. All subsequent CALL's will
occur to the last DEF SEG address, so if you add other DEF SEG's in your program, remember to
precede your CALL's to MSTEP-3 with the same DEF SEG = &H3000 that you used to load the link
(see CALL and DEF SEG in your BASIC reference manual).

Finding a place to load MSTEP.BIN is seldom much of a problem now that most PC's are equipped
with at least 256K of memory. The following explanation provides some insight into the process of
choosing a memory location for the driver and what to do if memory is in short supply.

DOS occupies the bottom of memory, the amount of memory required being dependent on the
version (it grows as each new revision adds extra features!). The simplified memory map below shows
what happens after booting up BASICA.

DOS 1.1 DOS 2.1 DOS 3.0

Bottom: OK ------- OK ------- OK --_-__
DOS
19K ---_---
DOS
DOS
47K -------
BASIC 63K -_----
BASIC
BASIC
98K ____---
Free
126K _-_____
Free 140K ----__
memory
Free
memory


3-5
MSTEP-3 USER GUIDE


MSTEP.BIN should be loaded somewhere in the free memory area so that it does not interfere with
either BASIC or DO!% This would be above 98K (&H1880) for DOS l.l,126K (&HlF80) for DOS 2.1 or
140K (&H2300) for DOS 3.0. If you have 256K (&H4000) or more of memory, then loading the link at
DEF SEG = &H2800 or &H3000 is a good solution for all versions of DO!? One further small detail is
that if you are using a PC compatible that does not have BASIC in ROM (like the IBM PC), then BASIC
(for example, GWBASIC) is usually loaded as an .EXE file from the top of memory down. This is
likely to fill up to 64K of the top segment of memory. Some virtual disks or print spoolers will do the
same. Also if you are accustomed to using DOS resident programs such as Borland's Sidekick, etc., be
aware that these will push the loading floor of BASIC up and require a compensating increase in the
location of MSTEP.BIN.

If you are memory limited, or you have so much resident material that there is no longer 64K left for
BASIC to load in, then BASIC will attempt to make the most of what it can find. Instead of getting the
message when BASIC has loaded:

The IBM Personal Computer Basic
Version A2.0 Copyright IBM Corp. 1981, 1982, 1983
60865 Bytes free
OK


You may get only 49345 bytes free (or something less than 60000 bytes) for example. In this case make
a note of what space BASIC has found. You can then contract this space further using the CLEAR
function and load the link at the end of BASIC. This is more complicated, but just as effective.

Let's suppose you get the message 52000 bytes free. MSTEP.BIN will use 3K bytes, so to be on the safe
side let's force BASIC to use 48K. The initializing code would now be:

xx100 CLEAR, 48000 'contracts BASIC workspace



Next, you must find out where BASIC has loaded in memory, add 48000 to it and load MSTEP.BlN
just after the end of BASIC workspace. Memory locations &H510 and &H511 always contain BASIC's
load segment:

xx110 DEF SEG = 0 'set up to read &H510 and &H511
x120 LS = 256*PEEK(CH5ll)+PEEK(&H510) 'load segment
x130 SG = LS + 48000/16 'remember segment addresses are on
'16-byte (paragraph) boundaries
x140 DEF SEG = SG 'set up to load link
x150 BLOAD "MSTEP.BIN",O 'load link


Proceed with your program as before. Note that this procedure does not work with GW BASIC.




3.5 STRUCTURE OF THE CALL STATEMENT
If you are unfamiliar with CALL statements, this explanation may assist you in understanding how
the CALL transfers execution to the machine language (binary) driver routine (also see CALL in your
Basic Reference Manual). Prior to entering the CALL, the DEF SEG = SG statement sets the segment
address at which the CALL subroutine is located. The CALL statement for the MSTEP.BlN driver
must be of the form

xxxx CALL MSTEP (MD%, D%(O), STP#, FLAG%)


3-6
CHAPTER 3: PROGRAMMING


Let us examine the parameters after CALL one by one:

MSTEI' In interpreted BASIC this is a variable that specifies the offset of the start of our routine
from the segment defined in the last DEF SEG statement. In our case its value is always
set to zero (MSTEP = 0). In compiled BASIC (and most other compiled languages)
MSTEP has a different significance - it is the name of the external routine that the linker
will look for. Note: We would have liked to use the name STEP instead - it's a better
mnemonic than MSTEP, but be warned that STEP is a reserved word (as in FOR I=0 TO 6
STEP 2) and CALL STEP would produce a syntax error.
MD% This is an integer variable that specifies the operation that we wish the driver to perform
e.g. MD%=0 performs an emergency stop, MD% = 12 initializes a channel etc. In the
case of this driver, valid mode numbers range from 0 to 12.
D%(9) This is a lo-element integer array that passes data to and from the driver. The
signifigance of particular data items varies according to the mode (MD%) selected. Not
all elements of D%(*) are used in all modes.
STr# This is a double precision variable that specifies the direction and number of steps to
travel or returns optical shaft encoder counts. The sign indicates the direction, +
clockwise, - counter-clockwise. Not all modes utilize the STP# data , however it must
always be included in the call parameter list.
FLAG% Returns an error code if any of the specifying D%(*) or MD% are out of range or if the
motor is busy or at standstill in certain commands. In the case of no error, FLAG% is
returned zero.


The four variables within brackets are known as the CALL parameters. On executing the CALL, the
addresses of the variables (pointers) are passed in the sequence written to BASIC's stack. The CALL
routine unloads these pointers from the stack and uses them to locate the variables in BASIC's data
space so data can be exchanged with them. Three important format requirements must be met, as
follows:

1. The CALL parameters are positional. The subroutine knows nothing of the names of the
variables, just their locations from the order of their pointers on the stack. If you write:
xxxxx CALL MSTEP (D%(O), FLAG%, MD%, STP#)

you will mix up the CALL routine, since it will interpret D%(O) as the mode data, and FLAG% as
the D%(O) data variable etc. The parameters must always be written in the correct order, as
follows: mode #, data, step count, errors
2. The CALL routine expects its parameters to be of correct type and will write and read to the
variables on this assumption: integer, integer array, double precision, integer
If you slip up and use the wrong variable types in the CALL parameters, the routine will not
function correctly and may hang up the program.
3. You cannot perform any arithmetic functions within the parameter list brackets of the CALL
statement. There can only be a list of variables. Also you are not allowed to replace variables by
constants.
Apart from these restrictions, you can name the variables what you want, the names in the examples
are just convenient mnemonics. You should always declare the variables before executing the CALL
so that BASIC has reserved memory locations for them before entering the CALL. In the case of the
integer array, the first element D%(O) should be specified in the CALL parameter list as the data
variable so that the CALL routine can locate all of the other remaining data items in the array
correctly.

3-7
MSTEP3 USER GUIDE


3.6 ERROR CODES
Some value checking is performed on entry data and any errors discovered are returned in FLAG%.
This is primarily to prevent you setting up the CALL with obviously incorrect data such as interrupt
level 9, mode number -6, base address 2000, byte output data 299 etc. and is intended to help avoid a
bad setup of the hardware which could hang the computer. Also certain commands, such as an
emergency or decelerating stop are redundant if the motor is already at standstill (FLAG% = 7) and
the PPMC controller may not be receptive to further commands if it is already busy executing a
command (FLAG% = 1). If a non-zero error code is returned in any mode, execution of that mode will
have been abandoned without action since error checking precedes any I/O to the hardware.

ERROR CODE # PROBLEM

0 No error, OK.
1 Motor busy.
2 Driver not initializedon Channel A.
3 Driver not initializedon Channel B.
4 Drive