Tektronix M5000 User manual

Software
Model 5000
Software Developer’ s Guide V1.1
81840 Rev. B / 6-98
WARRANTY
Hardware
Keithley Instruments, Inc. warrants that, for a period of one (1) year from the date of shipment (3 years for Models 2000, 2001, 2002, and 2010), the Keithley Hardware product will be free from defects in materials or workmanship. This warranty will be honored provided the defect has not been caused by use of the Keithley Hardware not in accordance with the instructions for the product. This warranty shall be null and void upon: (1) any modification of Keithley Hard­ware that is made by other than Keithley and not approved in writing by Keithley or (2) operation of the Keithley Hardware outside of the environmental speci­fications therefore.
Upon receiving notification of a defect in the Keithley Hardware during the warranty period, Keithley will, at its option, either repair or replace such Keithley Hardware. During the first ninety days of the warranty period, Keithley will, at its option, supply the necessary on site labor to return the product to the condi­tion prior to the notification of a defect. Failure to notify Keithley of a defect during the warranty shall relieve Keithley of its obligations and liabilities under this warranty.
Other Hardware
The portion of the product that is not manufactured by Keithley (Other Hardware) shall not be covered by this w arranty, and Keithley shall have no duty of obli­gation to enforce any manufacturers' warranties on behalf of the customer. On those other manufacturers’ products that Keithley purchases for resale, Keithley shall have no duty of obligation to enforce any manufacturers’ warranties on behalf of the customer.
Software
Keithley warrants that for a period of one (1) year from date of shipment, the Keithle y produced portion of the software or firmw are (Keithley Software) will con­form in all material respects with the published specifications provided such Keithley Software is used on the product for which it is intended and otherwise in accordance with the instructions therefore. Keithley does not warrant that operation of the Keithley Softw are will be uninterrupted or error-free and/or that the Keithley Software will be adequate for the customer's intended application and/or use. This warranty shall be null and v oid upon an y modification of the K eithle y Software that is made by other than Keithley and not approved in writing by Keithley.
If Keithley receiv es notification of a K eithle y Software nonconformity that is co v ered by this warranty during the w arranty period, K eithle y will review the con­ditions described in such notice. Such notice must state the published specification(s) to which the Keithley Software fails to conform and the manner in which the Keithley Software fails to conform to such published specification(s) with sufficient specificity to permit K eithle y to correct such nonconformity. If Keithley determines that the Keithley Software does not conform with the published specifications, Keithley will, at its option, provide either the programming services necessary to correct such nonconformity or develop a program change to bypass such nonconformity in the Keithley Software. Failure to notify Keithley of a nonconformity during the warranty shall relieve Keithley of its obligations and liabilities under this warranty.
Other Software
OEM software that is not produced by Keithley (Other Software) shall not be covered by this w arranty, and Keithley shall have no duty or obligation to enforce any OEM's warranties on behalf of the customer.
Other Items
Keithley warrants the following items for 90 days from the date of shipment: probes, cables, rechar geable batteries, diskettes, and documentation.
Items not Covered under Warranty
This warranty does not apply to fuses, non-rechargeable batteries, damage from battery leakage, or problems arising from normal wear or failure to follow instructions.
Limitation of Warranty
This warranty does not apply to defects resulting from product modification made by Purchaser without Keithley's express written consent, or by misuse of any product or part.
Disclaimer of Warranties
EXCEPT FOR THE EXPRESS WARRANTIES ABOVE KEITHLEY DISCLAIMS ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMIT ATION, ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. KEITHLEY DIS­CLAIMS ALL WARRANTIES WITH RESPECT TO THE OTHER HARDWARE AND OTHER SOFTWARE.
Limitation of Liability
KEITHLEY INSTRUMENTS SHALL IN NO EVENT, REGARDLESS OF CAUSE, ASSUME RESPONSIBILITY FOR OR BE LIABLE FOR: (1) ECO­NOMICAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT, SPECIAL, PUNITIVE OR EXEMPLARY DAMAGES, WHETHER CLAIMED UNDER CONTRACT, TORT OR ANY OTHER LEGAL THEORY, (2) LOSS OF OR DAMAGE TO THE CUSTOMER'S DATA OR PROGRAMMING, OR (3) PEN­AL TIES OR PENALTY CLAUSES OF ANY DESCRIPTION OR INDEMNIFICA TION OF THE CUST OMER OR OTHERS FOR COSTS, DAMAGES, OR EXPENSES RELATED TO THE GOODS OR SERVICES PROVIDED UNDER THIS WARRANTY.
Keithley Instruments, Inc. • 28775 Aurora Road • Cleveland, OH 44139 • 440-248-0400 • Fax: 440-248-6168 • http://www.keithley.com
CHINA: Keithley Instruments China • Yuan Chen Xin Building, Room 705 • 12 Yumin Road, Dewai, Madian • Beijing 100029 • 8610-62022886 • Fax: 8610-62022892 FRANCE: Keithley Instruments SARL • BP 60 • 3 Allée des Garays • 91122 Palaiseau Cédex • 33-1-60-11-51-55 • Fax: 33-1-60-11-77-26 GERMANY: Keithley Instruments GmbH • Landsberger Strasse 65 • D-82110 Germering, Munich • 49-89-8493070 • Fax: 49-89-84930759 GREAT BRITAIN: Keithley Instruments, Ltd. • The Minster • 58 Portman Road • Reading, Berkshire RG30 1EA • 44-1189-596469 • Fax: 44-1189-575666 ITALY: Keithley Instruments SRL • Viale S. Gimignano 38 • 20146 Milano • 39-2-48303008 • Fax: 39-2-48302274 NETHERLANDS: Keithley Instruments BV • Avelingen West 49 • 4202 MS Gorinchem • 31-(0)183-635333 • Fax: 31-(0)183-630821 SWITZERLAND: Keithley Instruments SA • Kriesbachstrasse 4 • 8600 Dübendorf • 41-1-8219444 • Fax: 41-1-8203081 TAIWAN: Keithley Instruments Taiwan • 1FL., 85 Po Ai Street • Hsinchu, Taiwan • 886-3-572-9077 • Fax: 886-3-572-9031
Model 5000
Software Developer’s Guide
©1998, Keithley Instruments, Inc.
All rights reserved. Cleveland, Ohio, U.S.A. First Printing, June 1998
Document Number: 81840 Rev. B
Manual Print History
The print history shown below lists the printing dates of all Revisions and Addenda created for this manual. The Revision Level letter increases alphabetically as the manual undergoes subsequent updates. Addenda, which are released between Revi­sions, contain important change information that the user should incorporate immediately into the manual. Addenda are num­bered sequentially. When a new Revision is created, all Addenda associated with the previous Revision of the manual are incorporated into the new Revision of the manual. Each new Revision includes a revised copy of this print history page.
Revision A (Document Number 81840)...............................................................................................August 1996
Revision B (Document Number 81840)................................................................................................... June 1998
All Keithley product names are trademarks or registered trademarks of Keithley Instruments, Inc. Other brand and product names are trademarks or registered trademarks of their respective holders.
About this manual
Quality control
Keithley Instruments manufactures quality and versatile products, and we want our documenta­tion to reflect that same quality. We take great pains to publish manuals that are informative and well organized. We also strive to make our documentation easy to understand for the novice as well as the expert.
If you have comments or suggestions about how to mak e this (or other) manuals easier to under­stand, or if you find an error or an omission, please fill out and mail the reader response card at the end of this manual (postage is prepaid).
Conventions
Procedural
Keithley Instruments uses various conventions throughout this manual. You should become familiar with these conventions as they are used to draw attention to items of importance and items that will generally assist you in understanding a particular area.
WARNING
CAUTION
NOTE
When referring to pin numbering, pin 1 is always associated with a square solder pad on the actual component footprint.
A warning is used to indicate that an action must be done with great care. Otherwise, personal injury may result.
A caution is used to indicate that an action may cause minor equip­ment damage or the loss of data if not performed carefully.
A note is used to indicate important information needed to perform an action or information that is nice-to-know.
Notational
A forward slash (/) preceding a signal name denotes an active LOW signal. This is a standard Intel convention.
Caret brackets (<>) denote keystrokes. For instance <Enter> represents carriage-return-with­line-feed keystroke, and <Esc> represents an escape keystroke.
Driver routine declarations are shown for C and BASIC (where applicable). Hungarian notation is used for software parameters. In other words, the parameter type is
denoted by a one or two letter lower case prefix:
c character, signed or unsigned s short integer, signed
w short integer, unsigned
l long integer, signed
dw long integer, unsigned
For example, wBoardAddr would be an unsigned short integer parameter.
An additional p prefix before the type prefix indicates that the parameter is being passed by ref­erence instead of by value. (A pointer to the variable is being passed instead of the variable itself).
For example, pwErr would be an unsigned short integer parameter passed by reference. This notation is also used in BASIC although no distinction between signed and unsigned vari-
ables exists. In BASIC, all parameters also have a type suffix:
$ character, signed or unsigned
% integer, signed or unsigned & long integer, signed or unsigned
Routine names are printed in bold font when they appear outside of function declarations, e.g., ReadStatus.
Parameter names are printed in italics when they appear outside of function declarations, e.g. sControls.
Constants are defined with all caps, e.g., ALL_AXES. Underscores {_} must be replaced by periods {.} for use with BASIC.
Combinational logic and hexadecimal notation is in C convention in many cases. For example, the hexadecimal number 7Ch is shown as 0x7C.
C relational operators for OR and AND functions — “| |” and “&&” — are used to minimize the confusion associated with grammar.
Table of Contents
1 Programming Overview
Installing the 5000 software ............................................................................................................................... 1-2
Compiling and linking ....................................................................................................................................... 1-2
Microsoft C or Microsoft QuickC .............................................................................................................. 1-2
Borland or Turbo C/C++ ............................................................................................................................ 1-3
Microsoft QuickBASIC ............................................................................................................................. 1-3
Borland Turbo Pascal ................................................................................................................................. 1-4
Programming fundamentals ............................................................................................................................... 1-4
2 Example Programs
Introduction ........................................................................................................................................................ 2-2
Trapezoidal point-to-point move ........................................................................................................................ 2-2
Move program in C .................................................................................................................................... 2-2
Move program in BASIC ........................................................................................................................... 2-3
Move program in Pascal ............................................................................................................................ 2-4
Velocity mode .................................................................................................................................................... 2-5
Homing ............................................................................................................................................................... 2-6
Reading position ................................................................................................................................................ 2-8
3 Move Parameters
Ranges ................................................................................................................................................................ 3-2
Velocity units ..................................................................................................................................................... 3-2
Acceleration/deceleration units .......................................................................................................................... 3-3
Distance units ..................................................................................................................................................... 3-3
4 Interrupt Handling
Introduction ........................................................................................................................................................ 4-2
Enabling interrupts ..................................................................................................................................... 4-2
Interrupts in C or Pascal ..................................................................................................................................... 4-2
Interrupts in BASIC ........................................................................................................................................... 4-2
General notes on using interrupts ....................................................................................................................... 4-3
i
5 Routine Summary
Introduction ........................................................................................................................................................ 5-2
Initialization and hardware control routines ....................................................................................................... 5-2
Axis command routines ...................................................................................................................................... 5-2
Axis data reporting routines ............................................................................................................................... 5-3
A Driver Routine Descriptions
Notational conventions ...................................................................................................................................... A-3
Acceleration ....................................................................................................................................................... A-3
Load acceleration register .......................................................................................................................... A-3
Clockoff ............................................................................................................................................................. A-4
Disable motor output ................................................................................................................................. A-4
Deceleration ....................................................................................................................................................... A-5
Load deceleration register ......................................................................................................................... A-5
DisableIRQ ........................................................................................................................................................ A-6
Disable IRQ lines ...................................................................................................................................... A-6
Distance ............................................................................................................................................................. A-6
Load distance register ................................................................................................................................ A-6
DownPoint ......................................................................................................................................................... A-7
Load downpoint register ............................................................................................................................ A-7
EnableIRQ ......................................................................................................................................................... A-7
Enable IRQ line ......................................................................................................................................... A-7
InitBoard ............................................................................................................................................................ A-8
Initialize board ........................................................................................................................................... A-8
InitSw ................................................................................................................................................................ A-9
Initialize software ...................................................................................................................................... A-9
InputAlertOff ..................................................................................................................................................... A-9
Disable input interrupt ............................................................................................................................... A-9
InputAlertOn .................................................................................................................................................... A-10
Enable input interrupt .............................................................................................................................. A-10
InterruptHooks ................................................................................................................................................. A-10
Install interrupt hooks .............................................................................................................................. A-10
IOControl ......................................................................................................................................................... A-11
Write I/O control register ........................................................................................................................ A-11
ISBusy ............................................................................................................................................................. A-11
Read busy bit ........................................................................................................................................... A-11
LowVelocity .................................................................................................................................................... A-12
Load start velocity register ...................................................................................................................... A-12
ModeSelect ...................................................................................................................................................... A-12
Load mode select register ........................................................................................................................ A-12
Multiplier ......................................................................................................................................................... A-13
Load multiplier register ........................................................................................................................... A-13
OutputHigh ...................................................................................................................................................... A-14
Set GP output HIGH ................................................................................................................................ A-14
OutputLow ....................................................................................................................................................... A-14
Set GP output LOW ................................................................................................................................. A-14
PulsesLeft ........................................................................................................................................................ A-15
Return distance left .................................................................................................................................. A-15
ReadState ......................................................................................................................................................... A-15
Read state buffer ...................................................................................................................................... A-15
ReadStatus ....................................................................................................................................................... A-16
Read status register .................................................................................................................................. A-16
ii
StartStop .......................................................................................................................................................... A-17
Load start-stop register ............................................................................................................................ A-17
Velocity1 ......................................................................................................................................................... A-18
Load FH1 register ................................................................................................................................... A-18
Velocity2 ......................................................................................................................................................... A-19
Load FH2 register ................................................................................................................................... A-19
WriteReg ......................................................................................................................................................... A-19
Write register ........................................................................................................................................... A-19
Profile Utility
Executing the program ...................................................................................................................................... B-2
Base address .............................................................................................................................................. B-2
Color number ............................................................................................................................................ B-2
Main menu ................................................................................................................................................ B-3
Navigating inside the program .................................................................................................................. B-3
Monitoring axis configuration .................................................................................................................. B-3
Single axis menu ....................................................................................................................................... B-4
Global menu .............................................................................................................................................. B-8
Save file/load file ...................................................................................................................................... B-9
Clock ......................................................................................................................................................... B-9
Register display ....................................................................................................................................... B-10
Exit program ........................................................................................................................................... B-10
C Visual C++ Demonstration Program
Product overview .............................................................................................................................................. C-2
System requirements ......................................................................................................................................... C-2
Installation ......................................................................................................................................................... C-2
Operation ........................................................................................................................................................... C-2
Program architecture ......................................................................................................................................... C-3
D Visual BASIC Demonstration Program
User’s guide ...................................................................................................................................................... D-2
Product overview ...................................................................................................................................... D-2
Installation ................................................................................................................................................. D-2
Operation ................................................................................................................................................... D-3
Menu items ................................................................................................................................................ D-5
Developer’s guide ............................................................................................................................................. D-6
Program architecture ................................................................................................................................. D-6
Program organization ................................................................................................................................ D-7
iii
List of Illustrations
A Driver Routine Descriptions
Figure A-1 State buffer .............................................................................................................................................. A-15
Figure A-2 Status buffer ............................................................................................................................................ A-16
Figure A-3 Command buffer ..................................................................................................................................... A-17
B Profile Utility
Figure B-1 Single axis menu screen ............................................................................................................................ B-3
Figure B-2 Active axis: a menu screen ........................................................................................................................ B-4
Figure B-3 Trapezoidal parameters ............................................................................................................................. B-5
Figure B-4 Status buffer .............................................................................................................................................. B-7
Figure B-5 State buffer ................................................................................................................................................ B-7
Figure B-6 Execute global move menu screen ............................................................................................................ B-8
Figure B-7 Save file/load file ...................................................................................................................................... B-9
C Visual C++ Demonstration Program
Figure C-1 5000 C++ demonstration program main user window .............................................................................. C-3
D Visual BASIC Demonstration Program
Figure D-1 5000 Profiler main user window ............................................................................................................... D-3
Figure D-2 Flow diagram for 5000 Visual BASIC Profiler ........................................................................................ D-6
Figure D-3 Text box value assignments for 5000 Profiler main user window ............................................................ D-7
v
List of Tables
3 Move Parameters
Table 3-1 Permissible velocity and acceleration ranges ............................................................................................. 3-2
5 Routine Summary
Table 5-1 Notational conventions .............................................................................................................................. 5-2
B Profile Utility
Table B-1 PRO5000 color selections ......................................................................................................................... B-2
Table B-2 Selecting a clock speed ............................................................................................................................. B-9
D Visual BASIC Demonstration Program
Table D-1 Physical data fields .................................................................................................................................... D-4
Table D-2 Velocity data fields ................................................................................................................................... D-5
Table D-3 Accel and decel data fields ........................................................................................................................ D-5
Table D-4 Miscellaneous data fields .......................................................................................................................... D-5
Table D-5 Code module descriptions ......................................................................................................................... D-8
Table D-6 Form module descriptions ......................................................................................................................... D-8
vii
1
Programming Overview
1-2 Programming Overview Model 5000 Software Developer’s Guide
Installing the 5000 software
The 5000 driver includes the batch file, INSTALL.BAT, to install the software. The batch file takes one argument, which is the path where you will install the software. For e xample, to install the software on the C drive into a subdirectory called 5000, enter on the command line:
install c:000
Use the same path for the installation of all drivers. This puts all include files, examples, etc., together. This is especially important when using QuickB ASIC, where you will ha ve to combine many libraries into a quick library.
A BASIC subdirectory, a C subdirectory, and a Pascal subdirectory will be created off the direc­tory you specify, and you may delete any unneeded subdirectories to save disk space.
Compiling and linking
The following paragraphs describe how to compile a program using the 5000 dri v er with the v ar ­ious supported compilers. It is assumed that the source file is named DEMO.C for C, DEMO.BAS for BASIC, and DEMO.PAS for Pascal.
Microsoft C or Microsoft QuickC
To compile and link on the command line, enter the following:
cl /Ax /Gs demo.c te5000x.lib qcl /Ax /Gs demo.c te5000x.lib
where x is:
s small model m medium model c compact model l large model
Turn stack-checking off with the /Gs switch (option) if you use interrupts. For CodeView com­patibility, include the /Zi switch.
To use the 5000 driver in the QuickC environment, perform the following steps:
1. In the Make menu, select the Set Program List option.
2. After naming the Make file, select Edit Program List, and enter the names of the source file (DEMO.C) and the appropriate library (e.g., te5000s.lib for small model).
3. In the Options/Make menu, select the Compiler Flags option and set the appropriate memory model (this model must match the library in the make list). If you use interrupts, turn stack­checking off.
(C) (QuickC)
Model 5000 Software Developer’s Guide Programming Overview 1-3
Borland or T urbo C/C++
To compile and link on the command line, enter the following:
tcc -m bcc -m
where x is:
s small model m medium model c compact model
l large model For Turbo Debugger compatibility, include the -v option. To use the 5000 driver in the Borland environment, perform the following steps:
1. In the Project/Open Project menu, enter in the name of the project file you want to create.
2. In the Project/Add Item menu, enter the names of the source file (DEMO.C) and the appro-
priate library (e.g., te5000s.lib for small model).
3. In the Options/Compiler/Code Generation menu, set the appropriate memory model (this
model must match the library in the Make list). If you use interrupts, turn stack-checking off.
x
demo.c te5000
x
demo.c te5000
Microsoft QuickBASIC
If you use compiled BASIC exclusively and never program in the QuickBASIC environment, you can link the library te5000b.lib into your application.
x
.lib
x
.lib (Borland C)
(Turbo C)
bc demo.bas;
link demo.obj,,,te5000b.lib
To compile and link for CodeView compatibility, enter the following:
bc /Zi demo.bas;
link /CO demo.obj,,,te5000b.lib
If you use the QuickBASIC environment, you must first run the batch file, QLB5000.BAT. This batch file will need modification, depending on which QuickBASIC version you use. The neces­sary modifications are explained by the remarks in the batch file itself.
The batch file creates two files: te5000qb.qlb and te5000qb.lib. Library te5000qb.qlb is a quick library for use in the QuickBASIC environment, and te5000qb.lib is the command line equiva­lent. Therefore, you will develop your program with te5000qb.qlb and then in the final compila­tion, link with te5000qb.lib.
To use the 5000 driver in the QuickBASIC environment, enter the following:
qb demo.bas /lte5000qb.qlb
To compile on the command line:
bc demo.bas;
link demo.obj,,,te5000qb.lib
To compile and link for CodeView compatibility:
bc /Zi demo.bas;
link /CO demo.obj,,,te5000qb.lib
1-4 Programming Overview Model 5000 Software Developer’s Guide
The libraries te5000b.lib and te5000qb.lib are similar but not identical. Library te5000b.lib calls two routines not contained in the library itself: MoveDone and InputAlert. These two routines must be be included in your source code if you need to link te5000b.lib into the application pro­gram. The file, INTR5000.BAS, contains stub versions of these routines that you can use as a guide, or you can compile and link the file itself into the application. Since te5000b.lib has unre­solved references, it cannot be converted into a quick library.
The library te5000qb.lib is created by the batch file by compiling INTR5000.BAS and linking the resulting object file with te5000b.lib. It has no unresolved references and can be converted into the quick library te5000qb.qlb. A program developed in the QuickBASIC environment using te5000qb.qlb can be compiled on the command line and linked with te5000qb.lib without modifying the source code. See the information on using interrupts with BASIC.
Borland T urbo Pascal
To compile and link on the command line, enter the following:
tpc /$S- demo
If you use interrupts, be sure to turn stack-checking off. Turn off stack-checking by including /$S on the command line as shown or by including the line {$S-} in the program source code.
To compile for Turbo Debugger compatibility, include the /v option. To use the 5000 driver in the Turbo Pascal environment, enter the following:
turbo demo
The source file must include the line: uses te5000p ;. If you use interrupts, be sure to turn stack­checking off. Turn off stack-checking through the Options/Compiler menu or by including the line {$S-} in the program.
Programming fundamentals
To quickly write simple applications for the 5000, follow the structure of the example programs provided in Section 2. For C, include the te5000.h file. For BASIC, include the TE5000.BAS file. For Pascal, always specify the te5000p unit.
Call InitSw first to initialize the software. Then call InitBoard once for every 5000 board in the system. To use the other driver routines, you must be familiar with the concept of board and axis numbers.
Each board in the system will be sequentially assigned a number from 0 to 5, called the board number, used to identify the board in calls to other routines. Each time InitBoard is called, another board number is assigned. If only one board is installed in the system, calling InitBoard once assigns a board number of zero.
Likewise, each axis in the system will be sequentially assigned an axis number from 0 to 17, used to identify a particular axis in calls to other routines. Each time InitBoard is called, three more axis numbers are assigned.
2
Example Programs
2-2 Example Programs Model 5000 Software Developer’s Guide
Introduction
The following code segments show the steps needed to use the 5000 softw are. Examples of com­mon applications are shown. The first example is shown in C, BASIC, and Pascal. The other examples are shown only in C, but the ideas extend to BASIC and Pascal. The values used in these examples for position, velocity, acceleration, etc., are arbitrary. The actual values depend upon your system requirements.
T rapezoidal point-to-point move
The following code illustrates the simplest of examples. Values for distance, velocity, and accel­eration are specified, and a trapezoidal move is started. Interrupts are set up for demonstration only and serve no useful purpose in these examples.
Move program in C
This routine shows how to move the motor to a specified point.
#include <te5000.h>
static void MoveDone(unsigned short *pwAxis); static void InputAlert(unsigned short *pwAxis);
main() {
unsigned short wBoardAddr = 0x300; unsigned short wAxisNum = 0, wBoardNum = 0, wIRQNum = 3;
/* initialize the software */ InitSw();
/* initialize the board */ InitBoard(wBoardAddr); InterruptHooks(MoveDone, InputAlert);
/* enable interrupts */ EnableIRQ(wBoardNum, wIRQNum); InputAlertOn(wAxisNum); /* load the parameters */ Distance(wAxisNum, 10000); Multiplier(wAxisNum, 100); LowVelocity(wAxisNum, 1); Velocity1(wAxisNum, 1000); Acceleration(wAxisNum, 1000); Deceleration(wAxisNum, 1000); DownPoint(wAxisNum, 610);
/* select preset mode and the move direction of "down" */ ModeSelect(wAxisNum, POSMODE_DOWN);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE */
Model 5000 Software Developer’s Guide Example Programs 2-3
/* start move */
StartStop(wAxisNum, START1_MOVE);
/* wait for move to be complete */
while(IsBusy(wAxisNum));
/* disable interrupts before exiting the program */
DisableIRQ(); }
void MoveDone(unsigned short *pwAxis) {
/* end-of-move interrupt handling goes here */ }
void InputAlert(unsigned short *pwAxis) {
/* input interrupt handling goes here */ }
Move program in BASIC
'$INCLUDE: 'TE5000.BAS'
CONST BOARD.ADDR = &H300 CONST IRQ.NUM = 3
AxisNum% = 0 BoardNum% = 0
'initialize the software X% = InitSw
'initialize the board X% = InitBoard(BOARD.ADDR)
'enable interrupts X% = EnableIRQ(BoardNum%, IRQ.NUM) X% = InputAlertOn(AxisNum%)
'load the parameters X% = Distance(AxisNum%, 10000) X% = Multiplier(AxisNum%, 100) X% = LowVelocity(AxisNum%, 1) X% = Velocity1(AxisNum%, 1000) X% = Acceleration(AxisNum%, 1000) X% = Deceleration(AxisNum%, 1000) X% = DownPoint(AxisNum%, 610)
'select preset mode and the move direction of "down" X% = ModeSelect(AxisNum%, POSMODE.DOWN)
'always reset move before starting up X% = StartStop(AxisNum%, RESET.MOVE)
2-4 Example Programs Model 5000 Software Developer’s Guide
'start the move X% = StartStop(AxisNum%, START1.MOVE)
' wait for move to be complete do loop while IsBusy(AxisNum%)
'disable interrupts before exiting the program X% = DisableIRQ
'Interrupt Stub routines are supplied to satisfy the linker SUB MoveDone (AxisNum%)
' end-of-move interrupt handling goes here
END SUB
SUB InputAlert (AxisNum%)
' input interrupt handling goes here
END SUB
Move program in Pascal
program example;
uses te5000p;
const
BOARD_ADDR = $300; IRQ_NUM = 3;
var
wAxisNum : word; wBoardNum : word; wVersion : word; sRetCode : integer;
procedure MoveDone (var pwAxis : word); far; begin end;
procedure InputAlert (var pwBoard : word); far; begin end;
begin
wAxisNum := 0; wBoardNum := 0;
{ initialize the software } wVersion := InitSw;
{ initialize the board }
Model 5000 Software Developer’s Guide Example Programs 2-5
sRetCode := InitBoard(BOARD_ADDR);
{ enable interrupts } InterruptHooks(MoveDone, InputAlert); sRetCode := InputAlertOn(wBoardNum); sRetCode := EnableIRQ(wBoardNum, IRQ_NUM);
{ load the parameters } sRetCode := Distance(wAxisNum, 10000); sRetCode := Multiplier(wAxisNum, 100); sRetCode := LowVelocity(wAxisNum, 1); sRetCode := Velocity1(wAxisNum, 1000); sRetCode := Acceleration(wAxisNum, 1000); sRetCode := Deceleration(wAxisNum, 1000); sRetCode := DownPoint(wAxisNum, 610);
{ select preset mode and the move direction of "down" } sRetCode := ModeSelect(wAxisNum, POSMODE_DOWN);
V elocity mode
{ always reset move before starting up } sRetCode := StartStop(wAxisNum, RESET_MOVE);
{ start the move } sRetCode := StartStop(wAxisNum, START1_MOVE_INT);
{ wait for move to be complete } while (IsBusy(wAxisNum) <> 0) do; sRetCode := DisableIRQ;
end.
This code segment shows how to run the motor in velocity mode.
unsigned short wAxisNum = 0;
/* initialize the software */ InitSw();
/* initialize the board */ InitBoard(0x300);
/* load the parameters */ Multiplier(wAxisNum, 100); LowVelocity(wAxisNum, 1); Velocity1(wAxisNum, 1000); Acceleration(wAxisNum, 1000); Deceleration(wAxisNum, 1000); DownPoint(wAxisNum, 610);
/* select velocity mode, move direction of "down" */ ModeSelect(wAxisNum, VELMODE_DOWN);
2-6 Example Programs Model 5000 Software Developer’s Guide
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE */
/* start move */ StartStop(wAxisNum, START1_MOVE);
/* to change velocity, use "other" slew velocity register */ Velocity2(wAxisNum, 1500); StartStop(wAxisNum, START2_MOVE);
Homing
This routine homes the motor by running it until it hits a limit, reverses the direction, and then looks for the home input.
unsigned short wAxisNum = 0;
/* enter parameters */ Multiplier(wAxisNum, 1000); DownPoint(wAxisNum, ); LowVelocity(wAxisNum, 1); Velocity1(wAxisNum, 10); Acceleration(wAxisNum, 0x3FFF); Deceleration(wAxisNum, 0x3FFF);
/* select down direction and velocity mode */ ModeSelect(wAxisNum, VELMODE_DOWN);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE */
/* start move */ StartStop(wAxisNum, START1_MOVE);
/* wait for limit to stop move */ while (IsBusy(wAxisNum));
/* select origin return mode */ ModeSelect(wAxisNum, HOMEMODE_UP);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE */
/* start move */ StartStop(wAxisNum, START1_MOVE);
/* wait for axis to home */ while (IsBusy(wAxisNum));
/* for future moves, put in position mode*/ ModeSelect(wAxisNum, POSMODE_UP);
Model 5000 Software Developer’s Guide Example Programs 2-7
Another method for homing the motor is to run it in one direction until it hits a mechanical stop, and then run it in the other direction until encountering the Home input. This method can be used when limit switches are not used and the motor can SAFELY run against a mechanical stop.
unsigned short wAxisNum = 0;
/* enter parameters */ /* choose a large enough value for the move distance */ /* such that the motor is sure to hit the mechanical stop */ Distance(wAxisNum, 0x0FFFFFF); Multiplier(wAxisNum, 1000); LowVelocity(wAxisNum, 1); Velocity1(wAxisNum, 10); Acceleration(wAxisNum, 0x3FFF); Deceleration(wAxisNum, 0x3FFF);
/* select down direction and position mode */ ModeSelect(wAxisNum, POSMODE_DOWN);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE);
/* start move */ StartStop(wAxisNum, START1_MOVE); /* wait for move to complete */ while (IsBusy(wAxisNum));
/* select origin return mode */ ModeSelect(wAxisNum, HOMEMODE_UP);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE);
/* start move */ StartStop(wAxisNum, START1_MOVE);
/* wait for axis to home */ while (IsBusy(wAxisNum));
/* for future moves, put in position mode */ ModeSelect(wAxisNum, POSMODE_UP);
These are fairly common methods of homing the motor, and they offer better repeatability than simply running to a limit switch or a mechanical stop.
2-8 Example Programs Model 5000 Software Developer’s Guide
Reading position
This routine moves the motor and displays the value of the down-counter. The down-counter value represents the distance in pulses left to move.
unsigned short wAxisNum = 0;
/* enter parameters */ Distance(wAxisNum, 100000); Multiplier(wAxisNum, 100); LowVelocity(wAxisNum, 1); Velocity1(wAxisNum, 1000); Acceleration(wAxisNum, 1000); Deceleration(wAxisNum, 1000); DownPoint(wAxisNum, 610);
/* select down direction and position preset mode */ ModeSelect(wAxisNum, POSMODE_DOWN);
/* always reset move before starting up */ StartStop(wAxisNum, RESET_MOVE);
/* start move */ StartStop(wAxisNum, START1_MOVE);
/* report position until move is complete */ do{ /* read and display the down-counter */ printf("Down Counter = %ld", PulsesLeft(wAxisNum)); } while (IsBusy(wAxisNum));
3
Move Parameters
Loading...
+ 53 hidden pages