MotionBASIC Hypertext Manual

Hard Copy Edition GN3-MBHh

Copyright (c) 1995

Ormec Systems Corp.

All rights reserved.

19 Linden Park

Rochester, NY 14625

(716) 385-3520

May 24, 1995 Copyright Notice

Copyright 1993 by Ormec Systems Corporation. All rights reserved. This manual and the software it describes, remain the exclusive property of Ormec Systems Corporation. No part of either may be reproduced in any form without the prior written permission of Ormec.

Warranty

Ormec extends no warranty with respect to the merchantability or fitness for any particular purpose for this software. It is the customer's responsibility to determine whether it is suitable for the specific application and whether it meets performance, reliability, and safety requirements when used in that application.

Terms and Conditions of Sale

All software sold or otherwise provided by Ormec is made available subject to Ormec's published Standard Terms And Conditions Of Sale. MotionBASIC Reference Manual (MB v2.1) Revision: 21.4 Introduction Introduction to this Manual MotionBASIC Overview Overview of the MotionBASIC Programming Language Motion Controllers ORMEC’s Generation III Motion Controllers MotionPRO ORMEC’s MotionBASIC Program Development Software Hypertext Keys Hypertext Function Key Description Commands MotionBASIC Commands Statements MotionBASIC Statements Functions MotionBASIC Functions Operators MotionBASIC Operators Constants Use of constants in MotionBASIC Variables Variable Types supported by MotionBASIC ORMEC Variables ORMEC Pre-defined Variables for Motion Control Error Codes Description of MotionBASIC error codes Troubleshooting Troubleshooting guide & System Status LEDs ASCII Table Table showing all ASCII codes in decimal and hex Keywords Alphabetical List of all Keywords and Statements

Copyright (c) 1989-1995, Ormec Systems Corp., All Rights Reserved

-1- MotionBASIC Hypertext Manual Introduction

This manual is designed to help you learn about the features of MotionBASIC as well as provide on-line programing assistance when writing MotionBASIC programs.

It is written in "hypertext", and if you would like a tutorial on how to use our hypertext system, do the following:

* press the F2 function key,

* select the HYPERTXT.HYP manual using the Up and/or Down Arrow keys,

* and press the Enter key.

Once you’ve learned how to use our hypertext system, a good way to continue is with the MotionBASIC Overview, and to link to the detailed technical information from that chapter.

MotionBASIC Overview

ORMEC’s Generation III motion controllers are programmed using the world’s most widely used programming language, BASIC... now enhanced with features for high performance motion control.

MotionBASIC is an industrial strength multi-tasking programming language with all the simplicity and power of BASIC, yet designed and built from the ground up for motion control. It incorporates BASIC’s strengths... the simplicity of using an interpreter, its powerful string handling, the richness of the language, plus English like keywords and syntax... into a multi-faceted software solution for industrial servo control.

MotionBASIC was designed to be highly compatible with Microsoft BASIC, but it incorporates a number of enhancements for industrial control: • powerful, English-like motion statements for multi-axis servo control; • than 100 pre-defined ORMEC variables for motion & I/O control; • MotionBASIC includes program labels and block control structures for structured programming, allowing you to create programs that are more easily written and maintained, and also run faster;

-2- MotionBASIC Overview

• MotionBASIC is a ROM based interpreter built on a multi-tasking operating system. Motion control, I/O, timing functions, event processing and error processing are fully serviced.

• the set data- and a number of set operators have been added to allow powerful and easy-to-use multi-axis motion programming;

• the user program can automatically execute on powerup in addition to operating in the modes: direct and indirect.

• user program variables (except string variables) are maintained thru power-down in non-volatile memory, see: Program Initialization

• MotionBASIC functionality can be extended with special device drivers or with additional statements and functions via MotionCARDs.

MotionBASIC program development is supported by MotionPRO, which runs on an IBM-PC or compatible.

Keywords MotionBASIC keywords, such as IF, THEN, GOTO, MOVE and RETURN, are integral to statements or commands. In addition to BASIC keywords, MotionBASIC includes keywords that create motion and that refer to the pre-defined ORMEC variables. Keywords are also called reserved words. They cannot be used as user variables or labels. They are stored in memory as tokens (of 1 or 2-bytes) for efficient memory usage.

Commands Commands are executable instructions in MotionBASIC which are primarily used for writing, editing, or running programs. Most commands are used in direct mode.

Statements Statements are executable instructions in MotionBASIC which cause it to perform a desired action such as "perform a computation" or "move a servomotor". Statements can be executed in direct mode, but they are primarily put together in a logical sequence to create programs.

Motion Statements are instructions which create servo motion. Included are MOVE, GEAR, and HALT.

"Programs" are collections of statements which are stored in Program Files which are loaded into controller memory to be executed in indirect mode.

Program statements must conform to a standard line format. The MotionBASIC line editor is used to enter or modify MotionBASIC program statements in controller memory.

MotionPRO development software includes a text editor which is used to edit programs stored in Program Files on disk.

Constants, Variables & Expressions Constants are static values which MotionBASIC uses during execution of a program. Variables are names which represent changeable values used in a program. Most variables have their names chosen by the

-3- MotionBASIC Overview

programmer, but MotionBASIC includes a number of special pre-defined variables that are used to access motion values and I/O. Expressions may be string or numeric constants, or they may combine constants and variables with operators and functions to produce a single value.

Functions MotionBASIC provides both arithmetic (or numeric) and string functions. Arithmetic Functions are used to perform numeric calculations. Sine SIN, cosine COS, tangent TAN and arctangent ATN are examples of MotionBASIC’s numeric functions. String Functions operate on (i.e. groups of characters). INPUT$ and INKEY$ are examples of string functions which input character strings from the console.

MotionBASIC redefines the standard for industrial motion control as far as completeness, elegance and ease-of-use.

MotionBASIC is a registered trademark of Ormec Systems Corp.

Differences from GWBASIC

• Motion Statements have been added as well as more than 100 pre-defined ORMEC variables for motion control and machine I/O.

• The set data-type has considerable impact on the language, adding considerable functionality to operators and motion statements.

• The default variable type is integer (i.e. DEFINT A-Z).

• Arrays must be explicitly DIMed as opposed to GW BASIC where arrays receive a default of 10 elements.

• You cannot have a variable name used as an array name the same it is used as a scalar. That is, A$(10) and A$ cannot be used in the same program.

• The maximum length of a program line is limited to 128 characters.

-4- Differences from GWBASIC

• Multi-character relational operators must be specified in the proper sequence without spaces. Use the documented operators.

• Trailing spaces up to the next comma or end of line are not truncated.

• The apostrophe character (’) always starts a comment unless it is inside quotation marks. Therefore the DATA statement 10 DATA Motor’s Speed in GWBASIC must be written 10 DATA "Motor’s Speed" in MotionBASIC

• Branching out of a subroutine,aFOR, NEXT,oraWHILE, WEND loop (using GOTO) leaves old information on the control stack. If done repeatedly without executing a STACK CLEAR statement, an "Out of Memory" error will occur.

• The string value returned by the function STR$ does not include a leading space, even if the number is positive.

• The COLOR statement does not allow background color numbers above 7.

• Operator precedence is for the unary negation ( - ) operator to be higher than the exponentiation ( ^ ) operator.

• The RUN command does not clear user program variables. User variables (other than string variables) are maintained across power cycles in non-volatile memory, as described in the program initialization chapter.

• The CLEAR command does not reset error trapping established by ON ERROR.

• The command will not generate an error when the to be deleted is non-existent.

• The command will not generate an error when the directory to be deleted is non-existent.

• The CHAIN command will clear program variables if the MERGE option is not specified.

In additional to the above, the following highlights most of the incompatibilities in Random Access File support between MotionBASIC and GWBASIC.

• MotionBASIC does not support simultaneous FIELD statements like GWBASIC does. A FIELD statement for the same file number in MotionBASIC overwrites the previous one.

• MotionBASIC supports direct input/output of binary information while GWBASIC does that through the functions (MKI$, MKD$, MKS$, CVI, CVD, CVS).

-5- Differences from GWBASIC

• GWBASIC does not initialize records that do not exist while MotionBASIC does fill them with zeros. This occurs when the user wants to a record beyond the current end of file.

• The FIELD statement must be specified before any PUT or GET statement in MotionBASIC.

• ERASE of a field variable will cause PUT/GET to generate an error while GWBASIC does not.

• A field variable of type string reverts back to a regular variable if used on the LHS in GWBASIC while MotionBASIC errors out if the field width associated with that string variable does not match its length.

• MotionBASIC allows the sharing of one field variable by multiple FIELD statements for different devices while GWBASIC only recognizes the last FIELD statement containing that particular field variable.

• MotionBASIC will error out if end of file is encountered during the reading of a binary value. This is especially true in floating point file variables.

• The string variable given to a FIELD statement will not survive through power cycle and thus the FIELD statement itself. The user should redeclare the FIELD statement before any PUT or GET.

Structured Programming

MotionBASIC is designed to encourage structured programming, which is the use of specific block programming constructs such as the block IF...THEN...ELSE, the FOR...NEXT the WHILE...WEND loop and the GOSUB or implied GOSUB, as well as the ON...GOSUB and the ON EVENT...GOSUB.

The use of the GOTO construct in any form is strongly discouraged. This especially applies to any use that "escapes" from a FOR...NEXT,a WHILE...WEND or a subroutine. Repeated GOTO "escapes" from these structures will eventually cause program failure due to a BASIC control stack overflow, generating an Error #1801: Out of Memory.

The RETURN statement is the proper method for leaving a subroutine. This does not mean however, that this should be used from within a WHILE...WEND,aFOR...NEXT, or a block IF construct. The same control stack overflow problem can occur with repeated "escapes" from these structures with the RETURN statement.

-6- Program Labels

MotionBASIC implements program labels to allow you to symbolically mark reference points in your programs. Labels are composed of any number of contiguous alphanumeric characters & "periods" [.], starting with an alpha character and followed by a colon [:]. e.g. LABEL.NAME: All labels must be the first item on a program line. References to a label should not include the :.

MotionBASIC performs an implied GOSUB when a label is used by itself as a command or statement. This is the same as a GOSUB to that label. e.g. You can execute the M5 subroutine below by typing M5 and pressing the Enter key. To distinguish implied GOSUBs from labels in programs, always follow them with a space if they’re not at the end of a line.

Example: 10 M5: ’establish a label entitled M5 20 MODE@ = 5 ’set mode@ to position mode 30 RETURN 524 M5 :PRINT "Position Mode" ’call the M5 subroutine (implied GOSUB)

MotionBASIC Powerup Operation

If the red RESET button is pressed, or power is cycled, Generation III controllers perform on-line diagnostics, & check the black PB1 button.

If PB1 is held in, the controller checks for a Memory Disk, and for a program file on it named, "PB1LOAD.BAS". If found, this file is loaded into non-volatile memory. Program execution is inhibited.

If PB1 is not held in, the controller checks for a Memory Disk, and for a program file on it named, "AUTOLOAD.BAS". If found, this file is loaded into non-volatile memory. Whether or not a file was loaded, MotionBASIC then checks non-volatile memory contents for a line number 0. If found, indirect program execution is initiated at line 0.

User functions & variables, other than strings, are non-volatile, as described in the Program Initialization section.

While a program file is being "loaded" from a Memory Disk, the User 1 LED will flash to indicate that the load is occurring.

Serial communications can be initiated with the controller by sending two ASCII Carriage Return characters. MotionBASIC will print a "Sign-on message" and either continue indirect operation or go to direct mode.

-7- Direct Mode Operation

After powerup or reset of a Gen III Controller, MotionBASIC will respond to two consecutive ASCII Carriage Return characters received at its RS-232 serial port. When received, MotionBASIC prints out a "Sign-on message" to the serial port. If a powerup program is resident the "Sign-on message" will state that "Program execution is in progress". If not, MotionBASIC enters direct mode operation displaying the "OK" prompt.

In direct mode, MotionBASIC statements and commands will be executed "directly" as they are entered at the keyboard of the IBM PC or compatible running MotionPRO software. This mode of operation provides a convenient method of startup, program development, testing, and troubleshooting.

Direct mode operation is enhanced in MotionBASIC by a facility called implied GOSUB, which allows the user to write a variety of subroutines and execute them via indirect mode by simply typing their "name", or label, from direct mode.

Pressing Ctrl-C from direct mode operation will stop all commanded motion.

Indirect Mode Operation

MotionBASIC is operating via "indirect mode" when it executes programs from its non-volatile memory. Indirect mode is initiated automatically at powerup from user program line 0 (if it exists), or initiated manually from a direct mode command.

Indirect execution of program code commences manually from the direct mode by typing and entering a RUN, GOSUB,orGOTO command or by executing an implied GOSUB by simply typing and entering a label.

NOTE: RUN resets many parameters!! (See: Program Initialization)

Program code is installed into controller non-volatile memory with a variety of direct mode commands, MotionPRO utilities, or from a Memory Disk at powerup.

Program execution can be ABORTED from the MotionPRO development computer attached to the RS-232 serial port by pressing Ctrl-C, which generates an error. This error is normally used to return operation to direct mode.

-8- MotionBASIC Program Initialization

Powerup, RUN and CLEAR have the effects described in the table below: Powerup RUN CLEAR CHAIN

Array dimensions ------RESET --- String space size ------DEFAULT --- String variables RESET --- RESET --- Non-string User variables ------RESET --- User data types ------INTEGER --- ORMEC axis variables DEFAULT DEFAULT DEFAULT --- ORMEC unit parameters DEFAULT ------Key definitions RESET RESET --- RESET ON EVENT, ON ERROR, etc. RESET RESET --- RESET Ports CLOSE CLOSE CLOSE --- User Functions ------RESET --- TRACE & BREAK RESET ------TRACE VAL RESET --- RESET --- ERR & ERL ------RESET --- Abs Encoder quad feedback DISABLE DISABLE DISABLE ---

Line Format

Program statements in MotionBASIC must conform to the following line format conventions:

• must begin with a line number (or a line number preceded by spaces)

• the line number may be any integer between 0 and 65529

• each numbered line can have between 1 and 127 characters

• each line may contain multiple statements, with each statement separated by a colon (:)

• lines of MotionBASIC will be executed in numerical order, with multi-statement lines executed from left to right unless otherwise directed by an individual MotionBASIC statement.

-9- MotionBASIC Line Editor

MotionBASIC provides an integrated line editor for directly editing programs in non-volatile memory of the Motion Controller. This editor is accessed whenever you type EDIT or AUTO while at the command level in MotionBASIC.

In addition, if a MotionBASIC program encounters a syntax error while executing, it sends you the syntax error message and automatically puts you in the line editor with the cursor positioned at the point in the line that it developed the syntax error.

A number of edit keys, such as the arrow keys, are supported for powerful interactive line editing.

This editor is not to be confused with the text editor provided with MotionPRO, which is for editing DOS text files.

MotionBASIC Line Editor Keys

Home Moves the cursor to the first character of the line End Moves the cursor to the end of the line Left Arrow Moves the cursor left one character Right Arrow Moves the cursor right one character Ctrl-Left Moves the cursor left one word Ctrl-Right Moves the cursor right one word

Backspace Deletes the character to the left of the cursor Delete Deletes the character at the cursor Ctrl-Home Deletes all characters to the left of the cursor Ctrl-End Deletes all characters to the end of the line Insert Toggles between insert and overwrite mode

Enter Accept changes and the line editor Esc Restores the original line and exit the line editor Up Arrow Accept changes and move to the previous program line Down Arrow Accept changes and move to the next program line

Word

A word is a contiguous group of characters made up exclusively of the following:

* the upper and lower case alphabet - A-Z a-z * the number characters - 0-9 * the special characters - %&!#$@

Any character other than those listed will delineate words.

-10- Expressions

Expressions may be simply string or numeric constants, or they may combine constants and variables with operators and functions to produce a single value. Automatic type conversion will be performed during expression analysis if appropriate.

The term numexpr is used in the function and statement descriptions to refer to any numeric expression. It can be of any numeric data type, including integer, long integer, and both single and double precision floating point. It can also be set although it may not much sense in most situations.

The term intexpr is used to refer to numeric expressions which either are, or will be converted to, integer by the statement or function. Any fractional part of intexpr will be rounded, and expressions which evaluate to values out of the integer range will cause a syntax error.

The term lngexpr is used to refer to numeric expressions which either are, or will be converted to, integer or long integer by the statement or function. If the expression starts out as single or double precision floating point, MotionBASIC will first attempt to convert to integer, and if not possible, will attempt to convert to long integer. Any fractional part of lngexpr will be rounded, and expressions which evaluate to values out of the long integer range will cause a syntax error.

The term setexpr is used to refer to numeric expressions which either are, or will be converted to, set by the statement or function. If the expression starts out as single or double precision floating point, a "type mismatch" expression error will be generated.

Generation III Motion Controllers

MotionBASIC is the language used to program ORMEC’s Generation III family of multi-axis motion controllers. These controllers utilize a multi-processor architecture combining Intel’s premier line of microprocessors with Texas Instruments’ DSPs through a shared-memory interface that brings unprecedented computer power to multi-axis electronic motion control.

Two Generation III Motion Controllers are currently available.

The Model 20 has 2 expansion slots providing the capability to control as many as 4 servo motors.

The Model 40 has 4 expansion slots providing the capability to control as many as 8 servo motors.

Both the Model 20 and the Model 40 have a 12 MHz Intel 80C186 main processor, an optional 80C187 math co-processor, and one megabit of internal non-volatile memory standard.

-11- Generation III Motion Controllers

Feedback control for a pair of axes, is accomplished by a Dual DSP Axis Module which uses a Texas Instruments TMS-320C25 40 MHz Digital Signal Processor. The DSP communicates to the main processor through a shared memory interface. The DSP closes the position and velocity servo control loops as fast as 5,000 times per second, and the DSP solves these control loops with digital algorithms for maximum precision.

Real-time multi-axis motion coordination for a virtually unlimited number of axes is provided by the MotionDATA DSP to DSP pipeline communications. MotionDATA operates synchronously at 612.5 K-bits per second using an error-correction protocol for system integrity. The GEAR statement is used for electronic gearing applications.

Generation III Controllers are part of an integrated line of servo control products including fully compatible AC-Brushless servomotors and drives with continuous torque ratings of 1.6 to 560 in-lbs.

Model 40 Motion Controller

General Specifications: Programming: • 19.2"hx6"wx10.5" d • Programs with MotionBASIC • Operating Temperature 0-50C • Powerful yet easy-to-use • Humidity, 90%, non-condensing English-like motion statements • 115/230 VAC, 50/60 Hz • Pre-defined motion and I/O variables Motion Control: • Exact user units conversion • Intel 80C186 (12 MHz) with rational numbers • Option: 80C187 math coprocessor • Multi-tasking, multi-processor • controls up to 8 axes operating system • TMS320C25 DSP Axis Modules • Programs and data stored in one with shared memory interface megabit of non-volatile memory • All digital control algorithms • Two Memory Card slots • Modulo Position capability • 32-bit integer & floating • Electronic Limit Switches point capability • Watchdog Timers & Integral • Program development via IBM-PC Fail-safe operation or compatible • Drive Fault Protection • Context-sensitive on-line help

-12- Model 40 Motion Controller

Operator Interfaces Available: MotionNET: • EGA Color or Monochrome • RS-485 Communications Port Industrial Monitor with Keypad • 1.5 M bits per sec synchronous • Serial Industrial Terminal 8x40 LCD, alphanumeric 30 key pad • Multi-drop Industrial Terminals 1x16 LCD, numeric 24 key pad • Multi-drop Displays MotionDATA: Vacuum Fluorescent • Electronic gearing - • IBM-PC compatible keyboard linear or cascaded control • VGA, EGA, or Mono Monitor • 612.5 KHz DSP to DSP pipeline

Expansion Bus: AC Brushless Servomotors: • RS-232 and/or RS-422 serial • Peak torques from 2 to 930 lb-in communications • Speeds to 4,500 RPM • Up to 64 serial devices • Encoder resolutions up to • Interface to computers or PLCs 24,000 counts/rev • Accelerations to 57,000 rad/sec²

Inputs/Outputs: Industrially Hardened • 16 discrete I/O points • Switching Power Supply • Option: Extended I/O Bd. for: • Incoming Line Filter • an I/O expansion: may add 24 • Watchdog Timer Circuitry additional digital I/O • Integrated Emergency Stop OR • No Fault Relay • an I/O expansion: may add 512 • Extensive diagnostics analog or digital I/O with Opto-22’s Pamux

Indicators: • 16 Digital I/O LEDs •20System Status LEDs • E-STOP OK LED • NO FAULT LED • No Fault Relay output

-13- Model 20 Motion Controller

General Specifications: Programming: • 19.2"hx6"wx10.5" d • Programs with MotionBASIC • Operating Temperature 0-50C • Powerful yet easy-to-use • Humidity, 90%, non-condensing English-like motion statements • 115/230 VAC, 50/60 Hz • Pre-defined motion and I/O variables Motion Control: • Exact user units conversion • Intel 80C186 (12 MHz) with rational numbers • Option: 80C187 math coprocessor • Multi-tasking, multi-processor • controls up to 4 axes operating system • TMS320C25 DSP Axis Modules • Programs and data stored in one with shared memory interface megabit of non-volatile memory • All digital control algorithms • Option: Two Memory Card slots • Modulo Position capability • 32-bit integer & floating • Electronic Limit Switches point capability • Watchdog Timers & Integral • Program development via IBM-PC Fail-safe operation or compatible • Drive Fault Protection • Context-sensitive on-line help

Operator Interfaces Available: MotionNET: • EGA Color or Monochrome • RS-485 Communications Port Industrial Monitor with Keypad • 1.5 M bits per sec synchronous • Serial Industrial Terminal 8x40 LCD, alphanumeric 30 key pad • Multi-drop Industrial Terminals 1x16 LCD, numeric 24 key pad • Multi-drop Displays MotionDATA: Vacuum Fluorescent • Electronic gearing - • Option: IBM-PC compatible keyboard linear or cascaded control • VGA, EGA, or Mono Monitor • 612.5 KHz DSP to DSP pipeline

Expansion Bus: AC Brushless Servomotors: • RS-232 and/or RS-422 serial • Peak torques from 2 to 930 lb-in communications • Speeds to 4,500 RPM • Up to 64 serial devices • Encoder resolutions up to • Interface to computers or PLCs 24,000 counts/rev • Accelerations to 57,000 rad/sec²

Inputs/Outputs: Industrially Hardened • 16 discrete I/O points • Switching Power Supply • Option: Extended I/O Bd. for: • Incoming Line Filter • an I/O expansion: may add 24 • Watchdog Timer Circuitry additional digital I/O • Integrated Emergency Stop OR • No Fault Relay • an I/O expansion: may add 512 • Extensive diagnostics analog or digital I/O with Opto-22’s Pamux

Indicators: • 16 Digital I/O LEDs •20System Status LEDs • E-STOP OK LED • NO FAULT LED • No Fault Relay output

-14- ORMEC Operator Interface Devices

In an ORMEC Generation III control system, there are three types of operator interface devices supported in MotionBASIC, as standard.

The OIT, Operator Interface Terminal, is a rugged industrial video monitor w/ keyboard. Available as a color or monochrome monitor. The OIT Display has a 25 line by 80 column screen. It has a membrane style keypad for numeric data entry. OIT Function Keys, F1 thru F10, are standard and fully supported by MotionBASIC.

The MMI-840, Man-Machine Interface, is a rugged industrial terminal that is a serial device. The MMI Display is an 8 line by 40 column backlit LCD screen. A rubberized keypad provides for alphanumeric data entry as standard, and the MMI Function Keys, F1 thru F8, which are fully supported by MotionBASIC.

The ITM-270, Industrial Terminal, is a rugged serial device with a numeric keypad with a 1 line by 16 character display (buffered to 80 characters). It has 6 Function Keys, see ITM Display & Function Keys.

OIT Display & Function Keys DISPLAY: The OIT Display has 25 display lines (rows) and 80 display columns.

• line (row) 25 is "off-limits" while function key text is displayed, (prohibits LOCATE, PRINT,&INPUT @ on row 25)

FUNCTION KEYS: The OIT has 10 function keys, F1 thru F10. The following statements apply to their use:

KEY Syntax 1, Assign function key text labels KEY Syntax 2, Turn ON/OFF the function key label display KEY Syntax 3, Assign additional keys for special uses ON KEY...GOSUB Establish subroutines for individual keys KEY (n) Enable trapping of these keys, and thus the ability to perform the established subroutine.

• Each OIT function KEY’s text label is displayed to 6 characters.

-15- MMI Display & Function Keys DISPLAY: The MMI Display has 8 display lines (rows) and 40 display columns.

• Row 8 is "off-limits" while MMI function key text is displayed. • Row 7 is "off-limits" when long label text is defined and displayed. LOCATE, PRINT,&INPUT @ cannot be used on rows made "off-limits".

NOTE: Position ROW 8, COLUMN 40 cannot be used, it will cause a scroll.

FUNCTION KEYS: The MMI keypad has 8 function keys. F1 thru F6 can have text labels, F7 & F8 cannot. The following statements apply to their use:

KEY Syntax 1, Assign function key text labels KEY Syntax 2, Turn ON/OFF the function key label display KEY Syntax 3, Assign additional keys for special uses ON KEY...GOSUB Establish subroutines for individual keys KEY (n) Enable trapping of these keys, and thus the ability to perform the established subroutine.

ITM Display & Function Keys

The ITM-270 has a 16 character, 1 line display, buffered to 80 characters, so that long messages can be sent, but only viewed by using the left/right arrow keys. It has 6 back-lit Function Keys.

< > 1234567890123456

Spc123 F1 F2

Del456 F3 F4

Clr789 F5 F6

- 0 . Enter

See Also: ITM Driver Support

-16- MMI Keypad Layout

The MMI has rubberized keys that provide tactile feedback for alpha-numeric data entry. The keypad layout is as follows:

Shift+Key → ABCDEF F1 F2 F3 F4 F5 F6

GHIJKL 789-F7F8

MNOPQR 4 5 6 BKSP ↑ ESC

STUVWX 123←DEL →

YZ SP← SHIFT 0 . ENTER ↓ TAB

Function Key Text & Extended Function Key Text

With operator interface devices it is often desirable to use function keys to select menu options. MotionBASIC supports function key labels that automatically prompt the operator. See: KEY statement.

Function key label text is truncated to 15 characters. Thus KEY LIST will report current function key text only up to 15 characters.

The OIT Display provides only the bottom row of the display for function key labels. It displays only the first 6 of the 15 characters defined per label.

The MMI Display can provide the bottom two rows for function key labels. When the length of any one key’s text label exceeds that key’s base label width, the text string is divided and the bottom two rows are used for function key label display.

See Also: MMI Function Key Text

-17- MMI Function Key Text

Example 1 ROW 6 If all use extended text this row is usable. ROW 7 1234567 1234567 123456 1234567 1234567 123456 ROW 8 8901234 8901234 789012 8901234 8901234 78901

Example 2 ROW 6 If no keys use extended text for their labels ROW 7 these rows are useable for screen functions!! ROW 8 1234567 123456 1234567 12345

Example 3 ROW 6 If 1 key has ext text, row 7 is not useable ! ROW 7 123456 ROW 8 1234567 789012 1234567 12345

F1 F2 F3 F4 F5 F6

KEY OFF turns off the label display, and all rows become useable. NOTE: Position ROW 8, COLUMN 40 is not used for text label display.

Non-volatile Memory

Generation III Controllers have one megabit of non-volatile memory with 5-10 yrs of battery backup with the approximate memory map below.

RAM Memory 1 RAM Memory 2

User Program User Comments Program & Variables (20K bytes) and User String Space ORMEC pre-defined Variables (60K bytes) (10K bytes)

System Parameters System Overhead & Variables (5K bytes) (35K bytes)

The FRE function reports Bytes Free in the User Program / String Space.

-18- Memory Conservation Techniques

When writing very large programs in MotionBASIC, the user may encounter the error statement, #1801 Out of Memory. This error occurs when a program, and its variables, becomes too large to fit into the available memory space. See: Non-Volatile Memory. Using the following techniques will reduce the amount of memory that a program requires.

• Eliminate leading spaces. Internally, memory conservation is accomplished whenever spaces are consecutively repeated more than three times. However, even with this feature, two bytes of memory are consumed for each set of repeated spaces.

• Use multiple statements per line. There is a five byte overhead for each numbered line in a program.

• Use subroutines. This avoids repeating sections of code that need only be written once.

• Eliminate downloaded program comments. This will provide additional

memory. Upto 20 Kbytes of comment text, is stored in a dedicated and separate section of memory, See: Memory Map. User program space is slightly reduced since only three bytes of memory per comment is consumed, regardless of the comment length. If the total comment text exceeds the 20K capacity, the "overflow" will reside entirely in user program space. Disk Comments, are an excellent alternative to downloaded comments, since they do not consume any controller memory (or Memory Disk space if the file has a ".BAS" extension).

• Use a variable rather than repeat a numeric literal constant within a program. For example, using the constant 3.14159265 ten times in a program consumes much more memory than defining PI# = 3.14159265, and then using the variable PI# repeatedly in a program.

• Wherever possible, use integers instead of single precision reals. And where possible use single precision instead of double precision reals. See: Memory Usage for Variables

• Avoid defining lengthy variable names. Each character in the name of user defined variables consumes one byte of memory.

• Reuse variables. For example, variables which hold temporary results in one part of a program can be used again for the same purpose in other parts of a program. Also, if a program has many separate FOR...NEXT loops, the same index may be used in each loop.

• ERASE unused variables. Memory that was allocated to a particular variable can be reused if that old variable is erased.

• A program does not need to have an END statement. This will save seven bytes.

• Remember to use the zero elements of array variables. If you need ten elements in an array, then only dimension it for a maximum index of 9, DIM A(9).

-19- Memory Cards

Memory Cards are credit card sized memory modules which plug into Generation III motion controllers. Support is standard for the Model 40 and optional with the Model 20 for two types of Memory Cards:

• Memory Disks plug into the external card slot on the front of the Generation III motion controller and use either SRAM or FLASH PROM read/write memory for storing user program files & data files.

• MotionCARDs plug into the internal card slot of a Generation III motion controller and are programmed by ORMEC to extend the functionality of MotionBASIC.

Memory Cards are removable. They can be used to transfer programs and data between controllers in the field without additional hardware such as laptop computers, programming terminals, or data cartridge recorders.

Memory Cards should ALWAYS be inserted and removed with POWER OFF!

Memory Disks

Memory Disks plug into the external slot on the front of Generation III motion controllers. They provide installation and maintenance of program files, see powerup, and they support the use of data files. They are used with the CHAIN statement to support large user programs.

There are two types of Memory Disks:

• Flash PROM Memory Disks provide Read/Write memory that is inherently non-volatile. No batteries are required. Write speeds are similar to traditional disk drives; Read speeds are similar to RAM drives. Available in sizes from 512K to 4M bytes.

• SRAM Memory Disks provide Read/Write memory with internal lithium battery backup. Read/Write speeds comparable to RAM drives provide ideal dynamic data storage including random access files. Available in sizes from 512K to 2M bytes.

Memory Disks must be formatted with the FORMAT command prior to use.

-20- MotionCARDs

MotionCARDs plug into the internal card slot of a Generation III motion controller and are programmed at ORMEC to extend the functionality of MotionBASIC. Standard MotionCARDs currently support:

Modbus Statements are provided which allow the user to "map" program variables to register numbers. A background task automatically transfers register data serially using this factory communications network protocol.

Data Highway/Plus "Mapped" register data is transferred by a co-processor adapter at 57.6K baud using this peer-to-peer factory network protocol.

S908/Modbus This MotionCARD allows a Generation III motion controller to be configured as an "S908 remote I/O drop" and also transfers 16 or more integer variables in one PLC scan.

Delay Counters This MotionCARD provides MotionBASIC support for the optional DSP delay counters.

In addition, custom MotionCARDs can be developed at ORMEC to accomplish specific application objectives by adding functionality to MotionBASIC.

Important: Please note that the program buffer must be completely empty when the MotionCARD is installed. To make sure that this is the case set PW@=3 and type NEW. Be sure to save your program first!

Important: The power to the Gen III must be off when installing or removing a MotionCARD.

DSP Axis Modules

Generation III DSP Axis Modules utilize the latest Digital Signal Processor technology to implement all digital high performance motion control. Each DSP communicates with the main processor through an on-board shared memory interface. It implements one or two servo control loops utilizing discrete signal processing algorithms which update the loops at up to 5,000 times per second eliminating the need for analog circuitry.

In addition to a wide variety of advanced motion control software features, DSP Axis Modules also provide: • individual interfaces to each servodrive and/or axis encoder; • electronic gearing via the MotionDATA communications link; • an optional delay counter (DELAY@) per axis; and • Inputs & Outputs interfaced via a DSP I/O Terminal Block: two optional 12-bit analog inputs (AIN1@ & AIN2@) per axis. two hardware overtravel limit inputs per axis three electronic limit switch outputs per axis (TTL compatible) four high speed inputs (ASEN@, BSEN@ & two ZREF@s),

-21- DSP I/O Terminal Block REV 2.0 DSP I/O header & optional terminal block have the following pinout.

1 ASEN’in 2 BSEN’in 3 ASEN in 4 BSEN in 5 ELS1’ out 6 ELS1’ out 7 ELS2’ out 8 ELS2’ out 9 ELS3’ out 10 ELS3’ out A 11 AIN1 in 12 AIN1 in A X 13 DGND 14 DGND X I 15 ZREF mot 16 ZREF mot I S 17 ZREF dsp 18 ZREF dsp S 19 ZREF’ mot 20 ZREF’ mot A 21 ZREF’ dsp 22 ZREF’ dsp B 23 Shld 24 +5 VDC 25 V+ 26 V+ Default 27 N/C 28 N/C Header 29 HLR in 30 HLR in Jumpers 31 HLF in 32 HLF in are shown 33 V- 34 V- REV 3.0 DSP I/O header & optional terminal block have the following pinout.

1 V+SEN 2 V-SEN 3 ASEN in 4 BSEN in 5 ELS1’ out 6 ELS1’ out 7 ELS2’ out 8 ELS2’ out 9 ELS3’ out 10 ELS3’ out A 11 AIN1 in 12 AIN1 in A X 13 DGND 14 DGND X I 15 ZREF mot 16 ZREF mot I S 17 ZREF dsp 18 ZREF dsp S 19 ZREF’ mot 20 ZREF’ mot A 21 ZREF’ dsp 22 ZREF’ dsp B 23 Shld 24 +5 VDC 25 V+ 26 V+ Default 27 AHTL-PWR 28 BHTL-PWR Header 29 HLR in 30 HLR in Jumpers 31 HLF in 32 HLF in are shown 33 V- 34 V-

-22- DSP Axis Module Memory

Generation III DSP Axis Modules have two on-board memory resources:

• The 2K byte dual-port shared memory is used for real-time communications between the main processor and the axis module. The main processor accesses this memory via the its IBM-PC/AT style bus and the DSP accesses it through its other port.

The pre-defined ORMEC variables for the axes controlled by a particular DSP Axis Module are maintained in this memory. It also contains a motion queue which is a FIFO Register used by MotionBASIC to transmit motion command information to the DSP Axis Module.

• The 64K byte local memory is used for the DSP’s local code and data requirements.

Motion Queue

Motion statements transfer motion command information to individual DSP Axis Modules via the Motion Queue which is a "First In, First Out" (FIFO) register located in the shared memory interface.

Several motions may be sent to the DSP, providing the following: • MotionBASIC can pre-process motion command information, for later execution by the DSP; • the DSP can execute queued motion independently and quickly, responding to high-speed sensors or a continuous stream of pacer information; and • MotionBASIC can continue to execute and handle other tasks while the individual DSPs handle their motion queues. • The queued motions can repetitively execute at the DSP. See: REPEAT

MOVE AT, GEAR AT and HALT commands generally clear the Motion Queue of other pending motion commands. Multiple MOVE FOR, MOVE TO and GEAR FOR commands can be stacked in the queue, and will also be superimposed on any currently executing GEAR AT command.

-23- Torque Mode Servo Loop Architecture

ACL.CMD@

VEL.CMD@ Kvf Kaf

++DRV.MAX@ + ⌠ + ⌠ + POS.CMD@ Kp+Kpi dt Kv+Kvi dt Ka DRV.CMD@ ⌡ - ⌡ -

Kvh Kvha Optional "Distributed Feedback" VEL.ACT@ AIN2@ (Intended for Load Tachometer) Velocity Observer

POS.ACT@ See also: Torque Mode Servos Velocity Mode Servos

Kvf - Velocity Feedforward Gain

Kvf is set by the motion controller to be proportional to the gain factor KVF@, which for most applications would be set to 100%.

Velocity feedforward allows the DSP to directly command velocity as well as position in response to a motion command from the main processor. This enhances servo response and accuracy because the velocity loop has significantly greater bandwidth than the position loop.

The use of velocity feedforward is a major factor in the elimination of position following error while the axis is moving.

Kaf - Acceleration Feedforward Gain

Kaf is set by the motion controller to be proportional to the gain factor KAF@.

Acceleration feedforward allows the DSP to directly command acceleration (and therefore torque) as well as position in response to a motion command from the main processor. This can enhance servo response and accuracy because the torque (current) loop has significantly greater bandwidth than the position and velocity loops.

Acceleration feedforward has limited application, and should generally not be used in electronic gearing applications.

Acceleration feedforward cannot be used with velocity mode servos.

-24- Kp - Position Loop Proportional Gain

When using torque mode servos Kp is set by the motion controller as a function of the velocity loop time constant and the gain factor variable KP@. With KP@ = 100%, the position loop is adjusted for a critically damped position response. Adjusting this factor higher results in an underdamped response and adjusting it lower results in an overdamped response. The standard setting of 100% meets the requirements of most applications.

When using velocity mode servos Kp is set by the user in units of in/min/mil. The position loop response for any particular setting is dependent on the velocity loop tuning in the servodrive.

Kpi - Position Loop Integral Gain

Kpi is set by the motion controller as a function of the position loop characteristics and the gain factor variable KPI@.

With KPI@ = 100% and Kp properly adjusted, the servo axis is adjusted for critically damped position response. Adjusting this factor higher results in an underdamped response and adjusting it lower results in no improvement in response. Standard settings of either 0 or 100% meet the requirements of most applications.

Position loop integral gain (KPI@) is normally required only in applications where position error during motion is critical, such as electronic gearing or in the control of continuous web systems. It may also be required to eliminate static position errors in applications with analog velocity loops, such as axes using distributed feedback or velocity mode servodrives.

Kv - Velocity Loop Proportional Gain

When using torque mode servos the velocity loop proportional gain is set by the motion controller to achieve the velocity loop time constant objective established by the VLTC@ variable.

The performance characteristics of servo motion control systems are highly dependent on velocity loop time constant, and so VLTC@ should be set as small as the system dynamics allow. A realistic goal is 0.7 to 3 msec for loads which are tightly coupled to the motor.

When using velocity mode servos the velocity loop gain and response is controlled by the servodrive and changes to VLTC@ have no affect.

-25- Kvi - Velocity Loop Integral Gain

When using torque mode servos, Kvi is set by the motion controller as a function of the velocity loop characteristics and the gain factor variable KVI@.

With KVI@ = 100%, the servo axis is adjusted for a critically damped velocity response. Adjusting this factor higher results in an underdamped response and adjusting it lower results in no improvement in response. The standard setting of 100% meets the requirements of most applications.

When using velocity mode servos velocity loop integral gain is adjusted in the servodrive and this parameter has no affect.

Ka - Acceleration Gain

Ka translates standard acceleration units used in the DSP to the proper drive command from the DSP’s digital to analog converter.

This gain is proportional to the INERTIA@ variable and inversely proportional to the TRQ.GAIN@ variable. It is critical to set both of these variables properly for correct loop calibration and operation. MotionPRO initializes these variables from a file of motor data and the specified load inertia.

-26- Kvh - Velocity Observer Feedback Gain

The velocity observer feedback gain (Kvh) is normally set to 100%, fully connecting the output of the velocity observer to the velocity loop summing junction.

To allow the use of analog velocity feedback or velocity mode servos,it is possible to adjust Kvh using the KVH@ variable. This proportionally reduces the velocity feedback from the velocity observer, which derives its velocity information from the axis encoder.

See also: Distributed Feedback Systems

Kvha - Analog Velocity Feedback Gain

The analog velocity feedback gain (Kvha) is provided primarily to accommodate systems using distributed feedback. Generation III DSP Axis Modules can close an analog velocity loop using the optional AIN2 12-bit analog input. To use analog velocity feedback instead of the velocity observer, install a DSP Axis Module with the A/D converter option, and adjust Kvha using the KVHA@ variable. To disable velocity observer feedback, set KVH@ to 0.

ORMEC’s servodrives provide analog velocity monitor signals derived from the encoder integral to the servomotor which can be used for this purpose. The standard axis interface cables connect this signal to the DSP Axis Module’s AIN2 input for convenience.

If desired, it is possible to provide velocity loop control using a combination of analog and the velocity observer feedback. Simply reduce the setting for KVHA@ and proportionately set KVH@. e.g. Multiply a KVHA@ setting by 0.6 and set KVH@ to 40 to obtain 60% of the velocity loop feedback from the analog input and 40% from the velocity observer.

-27- Distributed Feedback Systems

Most Generation III position control systems derive both velocity and position feedback from an encoder which is integral to the servomotor. This encoder is also used by the servodrive to commutate the motor. The fact that the encoder is integral to the motor and shared by the servodrive and motion controller makes this approach straightforward and cost effective, as well as easy to and maintain.

In some servo applications, e.g. high precision linear applications using leadscrews, it is advantageous to attach an additional encoder directly to the load for more precise measurement and control of load position. Because of the "loose mechanical coupling" of the load to the motor, better system performance is usually obtained when some or all of the velocity loop feedback is derived from the motor shaft. Systems using this approach are called Distributed Feedback Systems because the velocity feedback and position feedback are derived from different points in the mechanical system.

Velocity Observer

The velocity observer is software running on the DSP Axis Module which derives velocity information from the axis encoder signals.

Since the velocity observer develops its information from the axis encoder, distributed feedback systems which require velocity information from the motor shaft normally utilize analog velocity feedback or velocity mode servos.

See also: Loop Architecture

-28- Torque Mode Servos

Torque mode servos provide motor torque proportional to the servodrive’s input voltage. Motor torque is proportional to armature current, and so torque mode servodrives are also called "current mode servodrives" because they actually control armature current.

Torque mode servodrives usually close current loops in the motor armature circuitry for accuracy and response, but it is important to note that adjustments to the current loops are totally load independent. There is therefore no reason for any user adjustments in a torque mode servodrive.

With torque mode servos, all load dependent loop adjustments are made in MotionBASIC. Since the DSP Axis Module’s drive command output commands torque, it is also easy to both limit and monitor axis torque.

Torque mode servos are preferred in most applications.

See also: Torque Mode Servo Loop Architecture Velocity Mode Servos

Velocity Mode Servos

Velocity mode servodrives provide motor velocity proportional to the servodrive’s input voltage. In addition to closing current loops in the motor armature circuitry for accuracy and response, velocity mode servodrives close a velocity loop around the motor and load. Since the velocity loop is load dependent, velocity mode servodrives require user adjustments for this loop gain and compensation.

Since the DSP Axis Module’s drive output commands velocity, axis torque is not easily limited or monitored. Torque Mode Servos are preferred for most applications, however, MotionBASIC provides compatibility with velocity mode servos for specialty applications, such as axes using distributed feedback or certain motor-drive combinations with unusual velocity loops.

Setting the Velocity Mode Servo Gain to the appropriate (non-zero) value automatically reconfigures the standard loop architecture to a velocity mode architecture compatible with velocity mode servodrives. Units used for KP@ are also changed from % to in/min/mil.

-29- Velocity Mode Servo Loop Architecture

VEL.CMD@ Kvf

+ DRV.MAX@ + ⌠ + POS.CMD@ Kp+Kpi dt Kvl DRV.CMD@ ⌡ - -

Kvh Kvha

VEL.ACT@ AIN2@

Velocity Observer

POS.ACT@ See also: Velocity Mode Servos VEL.GAIN@ Loop Architecture

Velocity Loop Output Gain

The velocity loop output gain (Kvl) translates standard velocity units used in the DSP to the proper drive command output from the DSP’s digital to analog converter. It is automatically calculated from the specified velocity mode servo gain.

VEL.GAIN@ Velocity Mode Servo Gain ORMEC Variable

Purpose: Configure an axis as a velocity mode servo and define the gain of the velocity mode servodrive used with that axis.

Syntax: VEL.GAIN@[(axes)] = factor

usage: var% = VEL.GAIN@[(axes)]

factor An integer expression which represents a velocity mode servo gain in RPM/volt from MTR.SPD.LIM@/10 to 1500. The default of 0 configures the axis as a torque mode servo.

When configuring an axis as a velocity mode servo, VEL.GAIN@ must be set first, followed by the other parameters in the velocity mode servo loop architecture.

-30- Axis Encoder

The term axis encoder refers to the position encoder attached to a particular DSP Axis Interface Connector. This encoder is commonly the feedback encoder of a servo axis under control. Alternatively, it can be simply a pacer encoder mounted to a machine to which one of more follower servos are to be "electronically geared" using MotionDATA.

When a DSP axis is used only to interface to an encoder, its axis control mode should designate it as a "pacer encoder". The MotionDATA Operating Mode variable is used to cause the actual position of the encoder to be transmitted at each loop update. Any encoder with A and B channel quadrature outputs and TTL level differential line drivers is suitable for this purpose.

A special DSP Axis Module which provides "one axis for pacer encoder input only and one axis of servo control" is available at a reduced price, but any DSP Axis Module interface can be used.

Electronic Gearing

In traditional mechanical machines, operational motions are linked to a common source of power with various mechanisms such as gears, timing belts, cams, crank-drives, etc. The motions are "programmed" into the mechanical devices by the selection of gear ratios, cam profiles and other physical parameters.

Flexible automation requirements usually dictate that these parameters be changed quickly and automatically. In addition to providing this capability, modern servo and electronic gearing technology often provide performance, reliability and/or price and delivery advantages over traditional mechanical technology.

ORMEC Generation III Motion Controllers provide the ability to electronically GEAR multiple servomotors together, or GEAR multiple servomotors to a common source of position information such as an axis encoder mounted to a machine. This is accomplished with the unique MotionDATA communications link which transmits real-time motion information directly between DSPs at each position loop update.

-31- Encoder Backup Compensation

Encoder Backup Compensation is used to precisely track reverse pacer travel when GEAR statements are executed. This is done because profiled geared motions are ONLY relevant to forward pacer travel, see: CW.FWD@. If the pacer "backs up", the follower must keep track of the total backup distance so that it can perform the profiled geared motion on forward pacer travel from the "initial gearing point".

A GEAR AT command may be treated differently. If a GEAR AT has zero Fa and Pa distance parameters, it is essentially a request for an immediate ratio change. Pacer motion, forward or reverse, is not needed to establish the new follower ratio.

When Fa or Pa are non-zero ( Pa > MIN Pa ), then the GEAR AT statement in this case defines a "profiled gear motion". The follower will ramp to the new ratio on forward pacer travel ONLY. Therefore the EBC would be active to track any reverse pacer motion at the starting point of the ratio ramp.

The EBC can accumulate as many as 2^31 pacer counts. (2,147,483,647 cnts)

Example: A Profiled Gear Motion: GEAR FOR a distance. Assume that the statement is issued when a follower is at point A, below:

GEAR follower FOR distance AT target.ratio

Forward pacer motion gears the follower into the segments AB, BC, . Reverse pacer motion, before the GEAR FOR is complete at point D, would gear the follower back through the profile, segments DC, CB, BA. Continued reverse pacer motion would be EBCed, segment AA’. With forward travel, at point D, DSP.DONE@ would be TRUE, and the GEAR FOR complete. Then pacer travel would cause motion at the base ratio, DE, ’ BC target.ratio ------/ \ /\ Base Ratio ______/ _____\______A’ A D’ D E < EBC Zone GEAR.RATIO@ shows current ratio

Example: A Profiled Gear Motion: GEAR AT a ratio IN (or BY) some distance Assume that the statement is issued when a follower is at point A, below:

GEAR follower AT target.ratio IN some.distance BY Forward pacer motion gears the follower into the segment AB. Reverse pacer motion, before the GEAR AT is complete at point B, would gear the follower back through the profile, segment BA. Continued reverse pacer motion would be EBCed, segment AA’. At point B, DSP.DONE@ would be TRUE, and the GEAR AT complete. Now with pacer forward and reverse motion, target.ratio is maintained, BC & BB’. B’ B C target.ratio ------/ / Base Ratio ______/ A’ A < EBC Zone GEAR.RATIO@ shows current ratio

-32- Encoder Backup Compensation

Example: A non-profiled GEAR motion: GEAR AT a ratio. No EBCing. Assume that the statement is issued when a follower is at point A, below:

GEAR follower AT target.ratio

Forward pacer motion gears the follower on segment BC. Reverse pacer motion gears the follower on segment BB’.

B’ B C target.ratio | Base Ratio ______|______A

GEAR.RATIO@ shows current ratio

MotionDATA

MotionDATA is a communications link directly between DSPs, allowing them to share real-time motion information. It is a daisy-chained, one-way, error-correcting communications link, normally starting with the lowest numbered axis in the system and proceeding to the highest as shown:

AXIS 1 AXIS 2 AXIS N MotionDATA MotionDATA MotionDATA In Out In Out In Out

...

The source of MotionDATA pacer information received by any axis depends on the physical configuration of the chain as well as the value of the MotionDATA Operating Mode variable for axes before it. This variable allows an axis to monitor its pacer input and/or pass-thru or transmit its commanded position or actual position at each loop update. Alternatively a DSP Axis Module can simply gate MotionDATA input info directly to its output through a hardware multiplexer (default).

-33- MotionDATA

When MotionDATA input is transferred directly by a DSP Axis Module from its input to its output by the hardware multiplexer there is no DSP computation overhead and essentially no delay in the information being transferred. This allows a large number of follower axes to receive simultaneous MotionDATA pacer information.

For example, if "Axis 1" is configured to transmit pacer information from the actual position of its axis encoder, and all the other axes in the system have their MotionDATA Operating Mode variable set to "pass-thru", then the actual position of Axis 1 is propagated to all other axes in the system simultaneously. They may all then operate as follower axes of Axis 1 using the GEAR statement.

Since any axis in the system can be reconfigured to provide real-time pacer information from its own commanded or actual position, this architecture allows cascaded control with a single position update time delay between cascaded sections of the MotionDATA communications link.

MotionDATA Interface

Multiplexer

Pacer Pass-thru 0 Input o Select GEAR AT IN o •---→o Commanded 1 ON GEAR FOR Σ Position o←---•---o o OUT o Sum | OFF Actual 2 | MOVE Position o | Crystal | Clock DSP Output Select

Axis Encoder

The second axis on a Dual DSP Axis Module can monitor MotionDATA only if MD.MODE@ for the first axis is 10, 11, or 12 (monitoring is ON).

-34- Pacer

Each axis in a Generation III motion control system can transmit and/or receive real-time position information for electronic gearing applications via its MotionDATA communications link. When an axis is chosen to transmit its own actual or commanded movement over the MotionDATA communications link, it is considered a Pacer axis.

Subsequent axes may then monitor the information and operate as follower axes of the pacer by commanding their servo control loops to "move" using the GEAR statement. The term pacer is derived from the fact that the GEAR statement commands axis motion at a "pace" determined by the movement of the pacer axis as received over the MotionDATA link.

When generating MotionDATA, a DSP Axis Module transmits information at each loop update equivalent to either the position command or the actual position of its axis encoder. MotionDATA information is always transmitted in actual counts of the position transducer. This pacer information is translated to user units by the individual follower axes, using their specified pacer position units and gear ratio multipliers.

Follower

Each axis in a Generation III motion control system can transmit and/or receive real-time position information for electronic gearing applications via its MotionDATA communications link. Any axis currently monitoring pacer information becomes a follower axis when its servo control loops are commanded to "move" by the GEAR statement.

The term follower is used because the movement resulting from a GEAR statement "follows" either the commanded or actual movement of the pacer axis.

Any axis (or axis module) can "pass-thru" MotionDATA totally independent of any motion being commanded by it. In addition, Generation III allows cascaded control, which occurs when an servo axis operating as a follower axis also generates pacer information for other axes.

-35- Cascaded Control

The figure at the right illus- trates cascaded control of an electronically geared system. Axis 1

In this case, Axis 1 could be attached to a servo axis, or Axis 2 simply an axis encoder, as long as it is configured to generate MotionDATA pacer information. Axis 4 Axis 3 Axis 2 can operate as a follower of Axis 1, and also generate MotionDATA on the basis of either its commanded position its actual position. Axis3&4canthen operate as follower axes using the pacer information provided by Axis 2. The term cascaded control is used because follower motions of Axis 3 and 4 depend on the motion of Axis 2, which in turn depends on the motion of Axis 1.

Overtravel Limits

Generation III provides the safety feature of Hardware Overtravel Limits and Software Overtravel Limits. The intent of these features is to cease motion when one of these limits is encountered during the operation of a machine axis. There is a Forward and Reverse Software Limit available for each axis in the system. There may be a Forward and Reverse Hardware Limit available for each axis in the system.

This limit checking is only performed when an axis is in a torque-producing mode. Then an occurrence of any travel limit is latched in MotionBASIC.

When a servo’s Hardware Overtravel Limit input is asserted or its position violates a Software Overtravel Limit, then:

• Commanded motion of the axis is stopped using USR.ACL.LIM@, • OTL.FWD@ or OTL.REV@ Boolean variable for that axis is set TRUE •AMotion Error will be generated which is user trappable.

See Also: AXIS.OTL@

-36- Software Overtravel Limits

Generation III DSP Axis Modules provide two software settable overtravel limit switch trippoints for each axis. These software position trippoints are established with the Ormec variables, STL.REV@ and STL.FWD@.

Should the actual position of an axis, POS.ACT@, be less than the Reverse Limit or greater than the Forward Limit, an overtravel condition will be generated.

This limit checking is only performed when an axis is in a torque-producing mode, when an occurrence of any travel limit is latched in MotionBASIC.

The state of the latched limit is accessible with MotionBASIC via the OTL.FWD@ and OTL.REV@ variables. Once a software overtravel limit condition has occurred, these OTL latches can be cleared and the axis can be moved ONLY IN THE CORRECTIVE DIRECTION such that the axis position will return to its valid position range.

See Also: Overtravel Limits Hardware Overtravel Limits AXIS.OTL@

Hardware Overtravel Limits

Some Generation III DSP Axis Modules, ver 1.1 and later, provide optically isolated hardware overtravel limit switch inputs for each axis. Should these inputs be asserted when the axis is in a torque-producing mode,a hardware latch is set causing a forward or reverse limit condition.

These Hardware Overtravel Limits are wired to the connections of the optional DSP I/O Terminal Block.

The state of the latches is accessible from MotionBASIC via the HTL.FWD@ and HTL.REV@ variables, and once an overtravel limit condition has occurred, it must be electrically overridden before these latches can be cleared and the axis can be moved again. The software latches are cleared with the Ormec Variables OTL.FWD@ and OTL.REV@

"Hardware overtravel limit switches" may instead be wired in series with the E-Stop input at the user’s preference.

See Also: Overtravel Limits Software Overtravel Limits AXIS.OTL@

-37- Electronic Limit Switches

Generation III provides three programmable electronic limit switches for each axis encoder in the system. They turn ON and OFF automatically when an axis encoder’s actual position goes "into" or "out of" a specified range.

Each electronic limit switch has a corresponding Boolean variable (ELS1@ ELS2@ or ELS3@) as well as an inverted TTL-level output (74LS04) at the DSP I/O Header connector of the DSP Axis Module. Each TTL-level output is switched "ON" or "low" (less than 1 volt) when its corresponding Boolean variable is TRUE, and "OFF" or "high" (greater than 4 volts) when it is FALSE.

Electronic limit switches can be used as gating signals for ASEN@ and BSEN@. This is done by selecting the proper SENS.MODE@ for an axis.

Electronic limit switches may be used any time, but are particularly useful in conjunction with the modulo position feature.

Modulo Position

The modulo position feature allows the configuration of any axis so that its position will automatically "repeat" over a specified distance cycle. This is especially useful in rotating machines where you would like "position" for one or more of the axes to indicate the output position of the rotating tooling. e.g. 0-359 degrees

Both commanded position and actual position are affected, with the cycle distance specified by the position modulus variable. Enhancing this feature are three programmable electronic limit switches per axis, which turn ON and OFF automatically when the axis encoder’s actual position is goes "into" or "out of" a specified range.

To setup a modulo position for an axis, set POS.MOD@ for that axis to a non-zero positive number. Setting POS.MOD@ to zero disables modulo position reporting for that axis.

-38- Discrete & Analog I/O

Generation III controllers provide access to Discrete & Analog I/O points by referencing pre-defined arrayed variables in MotionBASIC. • Discrete I/O points DIO@(1) to DIO@(16) are integral to the motion controller, and compatible with Opto-22 style plug-in modules. • The optional Extended I/O Connector can be used to access either: • Discrete I/O points DIO@(17) to DIO@(40), which are compatible with standard Opto-22 style racks and modules, or alternatively • Discrete I/O points DIO@(17) to DIO@(528) and/or Analog I/O points AIO@(17) to AIO@(528) using Opto-22’s Pamux I/O system. • Each axis of a DSP Axis Module provides 4 high speed inputs, ASEN@, BSEN@, ZREF@(a), ZREF@(b), and optionally provides two 12-bit analog inputs (AIN1@ & AIN2@).

Note that the 16 integral discrete inputs can be automatically latched in software, and can be used to interrupt MotionBASIC using ON EVENT.

Note also that timers are provided to allow timed or delayed operation of any of the DIO@ discrete outputs with a single MotionBASIC statement.

Extended I/O Connector

The extended I/O connector provides 24 Opto-22 compatible I/O points as shown below. The use of these I/O points is determined by the IO.MODE@ variable and they are accessed as an arrayed DIO@ variable. Alternatively, the EIO.MODE@ variable may be used to software configure this connector for use with Pamux, providing access to 512 fully isolated analog or digital I/O points, which are configured by IO.MODE@.

DIO(#) Opto# Pin# DIO(#) Opto# Pin# DIO(#) Opto# Pin#

17 0 47 25 8 31 33 16 15 18 1 45 26 9 29 34 17 13 19243271027351811 2034128112536199 2143929122337207 2253730132138215 2363531141939223 2473332151740231 +5 VDC is provided on pin 49 and all even numbered pins are grounded.

-39- Pamux

Pamux is a parallel multiplexed I/O sub-system which can be used to provide a total of up to 512 discrete or analog I/O points. Pamux I/O points are added in multiples of 4, 8, or 16, with either a Digital or Analog "brain board" controlling each group. Because Pamux is a "parallel multiplexed" I/O sub-system, I/O access times are virtually the same as local discrete I/O points.

Pamux utilizes an eight line parallel bus, and supports 32 groups of up to sixteen I/O. "Brain boards" are available which provide either analog or digital I/O and their addresses are set with jumpers as described in the installation instructions. Both analog (AIO@) and digital (DIO@) I/O provided by Pamux are optically isolated.

To use Pamux I/O, the EIO.MODE@ variable must be set to configure the Extended I/O Connector as "Pamux compatible". The IO.MODE@ variable is then used to configure the individual Pamux I/O points consistent with the "brain boards", their addresses, and the installed analog and/or digital I/O modules.

MotionPRO

MotionPRO software provides a complete Motion Programming environment on any IBM-PC or true compatible. It provides user-friendly "pull-down menus" and "pop-up windows" and includes the following capabilities:

• This hypertext MotionBASIC reference manual on-line at all times;

• Interactive serial communications to the motion controller: • extensive interactive program debug tools, • automatic screen-oriented configuration (See MP.CONFIG), • context sensitive help • MotionBASIC File Management • MotionPRO directives

•Atext editor with pull-down menus and file management system.

• An extensive library of MotionBASIC programming tools

-40- MotionBASIC Event Processing

One of the more powerful features of MotionBASIC is its ability to process interrupts, which are called EVENTS in MotionBASIC.

An Event can be generated by an Integral Discrete I/O point,anOperator Key press,orachange to Register data via Factory Network Communications, (note: Network Communications are available via the use of MotionCARDs). The event would then be serviced by the execution of a routine that was specifically dedicated to that event.

In general, events are only serviced between MotionBASIC statements, three exceptions being the INPUT, INPUT @, and statements which can be interrupted during their execution.

IMPLEMENTATION OF EVENT PROCESSING

There are two steps involved in the implementation of events. The first step is the definition process. A statement must be executed which associates a particular event to a specific subroutine.

For example, the input point, DIO@(2), can be assigned an event handler routine labeled, INPUT.2.HANDLER, by executing the statement:

ON EVENT DIO@(2) GOSUB INPUT.2.HANDLER

The second step is to enable the "trapping" of the event occurrence. When trapping is turned ON for an event, MotionBASIC begins to continually evaluate the event to determine if it has occurred. If it occurs, it is serviced by transfer of program execution to the defined event routine.

Event Trapping can be set to three states, ON, OFF, and STOPPED: When trapping is ON for events, they are evaluated and serviced. When trapping is OFF for an event, it is neither evaluated, nor serviced. When trapping is STOPPED for one or more events, they are evaluated and latched, but only serviced when their trapping is set to the ON state.

Trapping can be set to these three states for individual events or can be set globally for all events. See the following diagram:

DISCRETE I/O EVENT KEY EVENT STATEMENTS STATEMENTS Event Define/ ON EVENT DIO@(n) GOSUB label ON KEY(n) GOSUB label Un-define ON EVENT DIO@(n) GOSUB 0 ON KEY(n) GOSUB 0

Individual EVENT DIO@(n) ON KEY(n) ON Event Trapping EVENT DIO@(n) OFF KEY(n) OFF Control EVENT DIO@(n) STOP KEY(n) STOP

Global EVENT ON Event Trapping EVENT OFF Control EVENT STOP

-41- MotionBASIC Event Processing

Example: The following example establishes events. One event will be Discrete Input #7 and the other will be an MMI Function Key, F2.

INIT: IO.MODE@(7)="R" ’Event Inputs should be latched ON EVENT DIO@(7) GOSUB IO.HANDLER ’Definition Step for Input #7 ON KEY(2) GOSUB KEY.HANDLER ’Definition Step for Function Key F2 OPEN "R",0,"SRL2:MMI" ’Opening the MMI device MAIN: EVENT DIO@(7) ON ’Enable the trapping of Input #7 KEY (2) ON ’Enable the trapping of Function Key F2 EVENT ON ’Enable Event Processing * WHILE TRUE ’Start of an endless loop * PRINT @ 4,4;USING;"###";J; ’Print a count to the MMI screen * J=J+1 ’increment the count * WAIT 250 ’delay 1/4 sec * WEND * Represents statements where trapping is ON, END and the event routines could be serviced.

When event routines ( & error handler routines) are called, implicit commands are issued by MotionBASIC to prevent another event from interrupting these routines while they are processing.

The implicit actions taken by MotionBASIC are: Global Event Trapping is placed in the STOPPED state. In this way events that occur during the execution of an event handler are latched, but not serviced during the execution of an event handler routine.

The event being serviced is placed into the STOPPED trapping state. This is done so a user can easily enable global trapping of "all other events" within the event handler, but the event being serviced will not be able to interrupt itself.

Global Event Trapping and the serviced event’s trapping state are reset to ON after a RETURN is executed at the end of the handler routine.

See the following diagram: Event Occurs: DIO@(n) LATCHED ON! MAIN.PROGRAM: . Event Occurs: . KEY(n) WAS PRESSED! . . END | EVENT STOP | | EVENT STOP | | EVENT DIO@(n) STOP| | KEY (n) STOP | | DIO@(n)=OFF |||

DIO.HANDLER: KEY.HANDLER: ’This is user code ’This is user code RETURN RETURN

| EVENT ON | Bold Statements are | EVENT ON | | EVENT DIO@(n) ON | implicitly executed in | KEY(n) ON | MotionBASIC background

-42- MotionBASIC Event Processing

Error Handler Ramifications: In the execution of an Error Handler routine (established via an ON ERROR statement) an implicit global EVENT STOP is executed. This inhibit to Event processing is lifted when the Error Handler executes a RESUME statement. If a RESUME is not used to exit an Error Handler, then restoring Event Handler execution must be done with a global EVENT ON statement and individual "EVENT DIO@(n) ON" and "KEY(n) ON" statements for any I/O points or Operator Keys that could have been "individually stopped" via a possible call to their Event Handler routines.

Direct Mode Ramifications: Events are normally "OFF" in direct mode. If a program enters direct mode from a STOP statement or Ctrl-C, the events are "stopped". A subsequent CONT, GOTO,orGOSUB (implied or explicit) command restores event handling to its previous (program execution) state. An END statement turns off events.

MotionBASIC Files There are two types of files in the MotionBASIC environment:

Program Files contain statements, functions, directives,&comments. These files, or modules, make up the user’s control software for a Generation III Motion Control System. These files should have a "BAS" filename extension.

Data Files contain data that is used, or created, by programs running in a Generation III Motion Controller.

Both types can be stored on PC Disks & Memory Disks. MotionBASIC commands are provided for file transfer & Memory Disk file management.

Development Computer File Transfers via Gen III Memory Disk FILES File management via CHDIR RMDIR MS-DOS Commands & MotionPRO Utilities NAME KILL FORMAT

-43- MotionBASIC Program Files

Program files typically contain statements, functions, directives, comments & disk comments. They can be stored on disk & Memory Disks.

Program files should have the filename extension, ".BAS". Files with a BAS extension are handled in a special manner during a transfer from disk to Memory Disk. MotionPRO Directives and line numbering tasks are obeyed during a .BAS file transfer. Files with .BAS extensions are stored on Memory Disk with line numbers, but without disk comments.

To RUN a program, the program first needs to be "loaded" into the motion controller. The source for a LOAD could be a disk or on Memory Disk. During the load, the source program code is tokenized and placed into controller non-volatile memory. After the load the program can be RUN.

The commands and statements that are specifically used with program files are: LOAD SAVE RUN MERGE CHAIN

See Also: Data Files Program Encryption

MotionBASIC Program Encryption

MotionBASIC provides the user with the ability to "encrypt" program code. The purpose of encrypting program code is to protect one’s intellectual property. There are two levels of encryption protection:

1) The user program cannot be altered, viewing IS possible (from Gen III). 2) The user program cannot be altered, viewing IS NOT possible.

The SAVE command options allow the user to encrypt code.

WARNING!!! DO NOT SAVE ENCRYPTION ONTO YOUR ORIGINAL SOURCE FILE NAME!! YOU WILL LOSE YOUR WORK AND NOT BE ABLE TO RECOVER IT!!

A program that has been LOADed into a controller, may be SAVEed to a file. The destination of this save process is a file either on a disk of the development computer, or on a Memory Disk plugged into the controller.

IN A NORMAL SAVE PROCESS, the result is an ASCII text file which CAN be read & edited with a text editor. The default file extension is .BAS.

-44- MotionBASIC Program Encryption

IN AN ENCRYPTED SAVE PROCESS, the result is a coded file. To do this: A program is loaded into a controller from an ASCII text file containing MotionBASIC user code. When a SAVE, with an encryption option is performed, the newly saved file is very different from the original. This encrypted file, which should have been given a new & unique name, now contains an unrecognizable stream of characters. Although this coded file appears to be a garbled mess of characters to users, the Gen III will be able to decode it. The default file extension is .BPS.

Encrypted files can be loaded and run in a Generation III Controller from either a Development Computer disk file or from a Memory Disk file.

With the first level of encryption, ONLY WHEN LOADED into the Gen III Controller, can a user view the program. It cannot be changed.

With the second level of encryption, EVEN WHEN LOADED in the Gen III Controller, the user cannot view the program. It cannot be changed.

MotionBASIC Data Files

Data Files provide a location for information storage and/or retrieval. Data files typically contain information that is intended for use with a MotionBASIC program, or are files that are created by a MotionBASIC program for data storage and subsequent retrieval.

MotionBASIC can work with two types of Data Files:

Sequential Files

Random Access Files

The following statements and functions are used with Data Files:

OPEN File CLOSE EOF LOC LOF

Data Files are created on, and accessed from, Gen III Memory Disks.

See Also: Program Files

-45- MotionBASIC Sequential Files

A Sequential File is one of the two types of MotionBASIC Data Files. In a sequential file, data is written as a series of ASCII characters. Data is stored, one item after another (sequentially), in the order sent. Data is read back in the same way.

Sequential files are easier to create than are Random Access Files, but are somewhat limited in flexibility and speed when accessing data. A Sequential file will require more room on the Memory Disk than would a Random Access File which is stored in a compressed format.

The following statements and functions are used with sequential files:

OPEN File PRINT # INPUT # LOC EOF CLOSE PRINT # USING LOF

See Also: Creating Sequential Files Accessing Sequential Files Adding Data to Sequential Files

Creating Sequential Files

The following program steps are required to create a sequential file:

1) Open file in Output mode. This will create the file if it does not exist, or will destroy its current contents if it does exist.

example: OPEN "O",#1,"1:\REPORT\BATCH.REP"

2) Write string data to the file using the PRINT # statement. Example:

A=1 : B=2 : C=3 : D=4 PRINT #1, USING "###.##,";A,B,C; PRINT #1, USING "###.##" ;D ’the resulting data file CLOSE 1 1.00, 2.00, 3.00, 4.00 EOF 3) CLOSE the file. Note: is carriage return

See Also: LOC Accessing Sequential Files Adding Data to Sequential Files

-46- Accessing Sequential Files

The following program steps are required to access a sequential file:

1) Open file in Input mode.

example: OPEN "I",#1,"1:\REPORT\BATCH.REP"

2) Read string data from the file using the INPUT # statement. Example:

WHILE NOT EOF(1) ’the source data file: INPUT #1,W$,X$,Y$,Z$ PRINT W$;X$;Y$;Z$ 1.00, 2.00, 3.00, 4.00 WEND EOF CLOSE 1 Resulting Printout: 1.00 2.00 3.00 4.00

3) Check for EOF and CLOSE. This avoids Error #1303 Input past end

See Also: LOC Creating Sequential Files Adding Data to Sequential Files

Adding Data to Sequential Files

The following program steps are required to add to a sequential file:

1) Open file in Append mode.

example: OPEN "A",#1,"1:\REPORT\BATCH.REP"

2) Write string data to the file using the PRINT # statement. Example:

A=9 : B=8 : C=7 : D=6 PRINT #1, USING "###.##,";A,B,C; PRINT #1, USING "###.##" ;D ’the resulting data file: CLOSE 1 1.00, 2.00, 3.00, 4.00 9.00, 8.00, 7.00, 6.00 EOF 3) CLOSE the file. Note: is carriage return

See Also: LOC Accessing Sequential Files Creating Sequential Files

-47- MotionBASIC Random Access Files

A Random Access File is one of the two types of MotionBASIC Data Files. In a random access file, data is stored and retrieved in distinct, numbered units called records.

Since records are referenced by number, specific data can be read from a record location; the program need not read the entire file, as it must with a Sequential File.

Creating and accessing random access files requires more program steps than sequential files, but they consume less Memory Disk space.

The following statements and functions are used with random access files:

OPEN File LSET GET EOF FIELD RSET LOC CLOSE PUT LOF

See Also: Creating Random Access Files Accessing Random Access Files

Creating Random Access Files

The following program steps are required to create a random access file:

1) Open file in random access mode. This will create the file if it does not exist. The example specifies a record length of 32 bytes.

example: OPEN "R",#1,"1:\REPORT\BATCH.REP",32

2) Use the FIELD statement to allocate space in the random buffer.

3) Use LSET or RSET to move data into the random buffer fields.

4) Write the data from the random buffer to the Memory Disk using the PUT statement.

The LOC function when used with a random access file, returns the current record number.

See Also: Accessing Random Access Files

-48- Accessing Random Access Files

The following program steps are required to access a random file:

1) Open file in random access mode.

example: OPEN "R",#1,"1:\REPORT\BATCH.REP",32

2) Use the FIELD statement to allocate space in the random buffer for the variables that will be read from the file.

3) Use the GET statement to move the desired record into the random buffer fields.

4) The data in the buffer fields can now be accessed by the program.

The LOC function when used with a random access file, returns the current record number.

See Also: Creating Random Access Files

MotionPRO Directives

MotionPRO uses directives to support modular program files. Directives look like comments in a MotionBASIC program file, but are instructions obeyed by MotionPRO when loading a file from a PC to the Motion Controller and when transferring a .BAS file to Memory Disk.

Directives supported are:

’!AUTO Line numbering directive ’!INCLUDE File retrieval directive ’’ Disk comment directive.

’!DEFINE Define a symbol used for conditional loading ’!UNDEF Delete a symbol used for conditional loading

’!IFDEF Conditionally load code based on an existing symbol ’!IFNDEF Conditionally load code based on a non-existent symbol ’!ELSE Used in a conditional load ’!ENDIF Used in a conditional load

-49- MotionPRO Text Editor

The text editor provided with MotionPRO is integrated through the pull-down menu structure and provides powerful yet easy-to-use editing of MotionBASIC programs stored on disk, as well as other text files. It is menu-driven, provides context sensitive on-line help and has special macros provided for editing MotionBASIC programs. In conjunction with the MotionPRO directives, it allows the user to edit MotionBASIC programs without line numbers, and include programs in multiple files.

It is not to be confused with the line editor, which is used to edit MotionBASIC programs in the non-volatile memory of the Motion Controller.

Disk

The term disk refers to the disk drive(s) of an IBM-PC or compatible computer running the MotionPRO development software.

This computer running MotionPRO, is also called the Development System. It is connected to a Generation III controller through a RS-232 serial communications link. The RS-232 port is called the "Development Port" on the motion controller.

The disk drive(s) of the Development System will typically have letters identifying its drives: (e.g. C: & D: are typically Hard Drive designators while A: & B: are typically diskette drive designators).

MotionBASIC Files can be stored in any of these disk locations through file management utilities and commands executed at this system.

-50- Hypertext Function Keys

F1=INDEX Display the Index.

F2=MENU Display the menu of hypertext manuals.

F3=SEARCH Search hypertext cross references.

F4=AGAIN Continue a search of hypertext cross references.

PAGE UP Move up one page of a multi-page chapter. PAGE DOWN Move down one page of a multi-page chapter.

BACKSPACE=PREV Return to the hypertext chapter you accessed last.

Ctrl-BACKSPACE Go to the next higher level in the manual outline.

ESC EXIT from the manual at any time.

F10 EXIT from the manual, but stay on the current page.

Hypertext Search Function

The F3 Function Key provides a useful feature in the Hypertext system, a Text Search.

An entry window allows the user to type in a search string.

Two types of searches can be initiated. An Exact Match Search or a Partial Match Search.

A Partial Match Search is initiated by pressing the key. Hypertext tests links to ascertain if they begin with the search string. When the first link is found that begins with the search string, that chapter is displayed on the screen. Partial match searches can be continued by using the F4 Key, AGAIN, a "next match" request.

An Exact Match Search is initiated by pressing the key combination. Hypertext then tests links to ascertain if they exactly match the search string. If found, that chapter is displayed on the screen.

-51- Syntax & Usage Notation Table

Symbols Description Meaning

[] Square Brackets Optional clause or parameter

{|} "Curly" Braces Choices are available

... Three Dots Preceding clause is repeatable

This is a "quick-reference" of syntax notation symbols. For more detailed descriptions and examples, see: MotionBASIC Syntax Notation

See Also: Typical Usage

MotionBASIC Syntax Notation

MotionBASIC expects commands, statements, and functions to conform to a specific structure, or syntax. In this manual, each keyword is presented with syntax notation to indicate just how a statement using that keyword can be properly written. If a legal syntax is not used, a Syntax Error is generated by MotionBASIC.

[] SQUARE BRACKETS [optional] In syntax notation, items within square brackets are optional. A legal statement can be composed with optional items completely omitted. If the optional clause is used, the brackets should not be typed. The brackets are not part of the statement, but merely syntax notation marks.

{|}BRACES { choice1 | choice2 } In syntax notation, "curly" braces indicate a choice is available. The choices, inside the braces, are separated by the | character. The braces should not be typed. The braces are not part of the statement, but merely syntax notation marks.

... ELLIPSES [,repeatable] ... In syntax notation this indicates

-52- MotionBASIC Syntax Notation that the preceding clause may be repeated, again and again.

EXAMPLE Syntax: INPUT[;] ["prompt"{;|,}]variable [,variable] ...

; With the semi-colon option (INPUT;), no carriage return/line feed is issued after receiving input.

prompt A string constant supplying a prompt to guide the user. A semi-colon after the prompt causes ? to be printed.

variable The name of the variable that will receive the input.

The following examples each use a legal syntax for the INPUT keyword: INPUT A INPUT; AGE% , HEIGHT%,WEIGHT% INPUT "Please enter a value: ",TEMP% INPUT; "What is your full name"; NAME$ INPUT "Please enter 6 values:",A,B,C,D,E,F

Typical Usage

Some statements have an extensive syntax structure.

Many times a short version of that syntax is all that is needed for the most common usage of that statement.

When this is the case, a Typical implementation is cited for the user’s convenience.

MotionBASIC Commands

Commands are executable instructions in MotionBASIC which are primarily used for writing, editing, or running programs. Most commands are intended to be used in direct mode.

AUTO Enter a MotionBASIC program with automatic line numbering BREAK Set or reset a breakpoint at the specified line number CHDIR Change current Memory Disk directory CONT Resume execution of an interrupted program DELETE Erase a specified range of program lines DUMP List the symbol table to MotionPRO screen EDIT Edit a MotionBASIC program with the line editor FILES Display files in Memory Disk FORMAT Format a Memory Disk KILL Delete a file from Memory Disk LIST Display all or part of the current program at the console LOAD Place a program file into controller memory MERGE Merge a program file with the current program MKDIR Makes a new directory on the Memory Disk

-53- MotionBASIC Commands

NAME Change the name of a Memory Disk file NEW Delete the program currently in non-volatile memory NEW RESTORE Restore non-volatile memory RENUM Renumber all or part of a program RMDIR Delete a directory on the Memory Disk RUN Execute the current program SAVE Write the current program to a program file

MotionBASIC Statements

Statements are executable instructions in MotionBASIC which cause it to perform a desired action such as "perform a computation" or "move a servomotor". Statements can be executed in direct mode, but they are primarily put together in a logical sequence to create programs to be executed later in indirect mode. MotionBASIC statements fall into one of the categories below:

Motion Statements Control Structures Display/Keyboard Statements External I/O Statements Program Initialization Statements Miscellaneous Statements Line Format for Statements

All Statements (alphabetical list)

Motion Statements

MOVE The MOVE statement can be used to: • move for a relative distance from the current position, • move to an absolute position, or • move at a specified speed.

GEAR The GEAR statement can be used to: • gear for a relative distance from the current position, • gear at a specified ratio to the pacer encoder.

HALT The HALT statement can be used to: • stop motion on the designated motors.

Motion statements transfer actual command information to the DSP Axis Modules through the Motion Queue.

USE EXTREME CAUTION WHEN INTERACTIVELY EXECUTING MOTION STATEMENTS, especially if ACL.MAX@, DCL.MAX@ or SPD.MAX@ are set to high values!

-54- Motion Statement Modifiers

MotionBASIC allows motion statements to be modified with special clauses using the following keywords. The operation of the PRINT statement can also be modified by REPEAT.

AFTER Define a start condition.

UNTIL Define a stop condition.

REPEAT Repeat a MOVE, GEAR or PRINT Statement

Control Structures

MotionBASIC provides an enhanced list of control structures to support structured programming and real-time control.

Block Control Structures IF, THEN, ELSEIF, Conditional execution, with ELSE, ENDIF multi-line block clauses WHILE, WEND Loop on condition FOR, NEXT Loop a number of times, or through a set of elements GOSUB, RETURN Call a subroutine ON...GOSUB Call subroutine in list

Event and Error Handling ON EVENT...GOSUB Call subroutine when an event occurs EVENT Enable/Disable hardware event trapping ON ERROR, RESUME Enable/Disable error trapping & continue STACK CLEAR Clear control stack ERROR Force a MotionBASIC error

Other GOTO Branch unconditionally ON...GOTO Branch to label or line number in list

-55- Display/Keyboard Statements

Display Statements: PRINT Display on screen CLS Clear screen CLREOL Clear to end of line COLOR Set foreground, background colors LOCATE Position the cursor WIDTH Sets the output width

Keyboard Statements: INPUT Get input from keyboard INPUT @ Get input from keyboard at specified location KEY Set or display soft keys KEY (n) Enable/disable key trapping ON KEY Trap for keypress

See also: Input/Output Functions

External I/O Statements

Character Device and File I/O Statements: OPEN Allow device or file I/O CLOSE Close a device or file PRINT # Output to a device or file INPUT # Get input from a device or file WIDTH Set output width Console talk mode CHAIN Load and execute a program or overlay FIELD Define a Random Access File field GET Read from a Random Access File PUT Write to a Random Access File IOCTL Send device "control data" string

See also: Input/Output Functions

-56- Program Initialization Statements

Variable Definition: CLEAR Reset variables / Set maximum string space ERASE Remove variable from memory DEFDBL Define variable(s) as double precision DEFINT Define variable(s) as integer DEFLNG Define variable(s) as long integer DEFSET Define variable(s) as set DEFSNG Define variable(s) as single precision DEFSTR Define variable(s) as string DIM Dimension array(s) Function Definition: DEF FN Define function Variable Initialization: READ Assign DATA items to variables DATA Store constants for retrieval via READ RESTORE Reset DATA item pointer

See also: Program Initialization

Miscellaneous Statements

Timer Statements: WAIT Wait for condition or time

Debug Statements: STOP Halt program, leave devices open TRACE Program trace control TRACE VAL Variable trace control

Miscellaneous Statements: LET Assignment RANDOMIZE Reseed random number generator REM Comment END Terminate program

String Statements: LSET Left justify string data into buffer/variable RSET Right justify string data into buffer/variable

System Access Statements: DEF SEG Define segment PEEK Read byte from memory POKE Write byte to memory PEEKW Read word from memory POKEW Write word to memory OUT Send byte to output port OUTW Send word to output port

-57- MotionBASIC Statements

CHAIN Load and execute program or overlay CLEAR Reset variables / set maximum string space CLOSE Close a device CLREOL Clear to end of line CLS Clear screen COLOR Set foreground, background, and border colors DATA Store constants for retrieval via READ DEF FN Define function DEF SEG Define segment DEFDBL Define variable(s) as double precision DEFINT Define variable(s) as integer DEFLNG Define variable(s) as long integer DEFSET Define variable(s) as set DEFSNG Define variable(s) as single precision DEFSTR Define variable(s) as string DIM Dimension array(s) END Terminate program ERASE Remove array from memory

ERROR Force a MotionBASIC error EVENT Enable/Disable Hardware Event Trapping FIELD Define Random Access File field format FOR Begin definition of FOR / NEXT loop GEAR Gear one or more servo motors to the electronic lineshaft GET Read from a random access file GOSUB Execute subroutine GOTO Unconditional branch HALT Halt a motion in progress IF Conditional branch INPUT Get input from keyboard INPUT # Get input from a device INPUT @ Get input from keyboard at specified location IOCTL Send control data to a device driver KEY Set or display soft keys KEY (n) Enable/disable key trapping LET Assignment LOCATE Position the cursor

LSET Left-justify string data MOVE Move one or more servomotors NEXT End definition of FOR/NEXT loop ON ERROR Enable/Disable error trapping ON EVENT Trap for specified Event ON KEY Trap for keypress ON...GOSUB Branch to item in subroutine list ON...GOTO Branch to item in line number list OPEN Allow device I/O OUT Send byte to output port OUTW Send word to output port POKE Write byte to memory POKEW Write word to memory PRINT Display on screen PRINT # Output to a device PUT Write to a random access file RANDOMIZE Reseed random number generator READ Assign DATA items to variables

-58- MotionBASIC Statements

REM Comment RESTORE Reset DATA item pointer RESUME Continue after error trap RETURN Return from subroutine RSET Right-justify string data STACK Control stack STOP Halt program, leave devices open TALK Console talk mode TRACE Program trace control TRACE VAL Variable trace control WAIT Wait for I/O point or time WEND End definition of a WHILE / WEND loop WHILE Begin definition of WHILE / WEND loop WIDTH Set output width

MotionBASIC Functions

Functions are MotionBASIC keywords that can be used inside numeric or string expressions to return a result. They may take one or more parameters, but always return a single result. There are several types of MotionBASIC functions:

Arithmetic Functions

String Functions

Conversion Functions

Input/Output Functions

System Functions

All Functions (alphabetical list)

Arithmetic Functions

ABS Absolute value ATN Arctangent CLG Common logarithm COS Cosine EXP Exponent (natural) FIX Truncate to whole number INT Next lower whole number LOG Natural logarithm SGN Sign of number SIN Sine SQR Square root TAN Tangent

-59- String Functions

INSTR substring LCASE$ Convert upper cases to lower cases LEFT$ Substring at left LEN Length of string MID$ Substring in middle RIGHT$ Substring at right SPACE$ String of N spaces STRING$ String of specified length and character UCASE$ Convert lower cases to upper cases

See Also: Garbage Collection

Conversion Functions

ASC ASCII value of first character BIN$ Binary value, as string CHR$ Convert ASCII code to character HEX$ Hexadecimal value, as string OCT$ Octal value as string STR$ String representation of numeric expression VAL Numeric value of string

Input/Output Functions

Display Functions: CSRLIN Row position of cursor POS Current cursor column position SPC Skip N spaces in a PRINT statement TAB Tab to specified position in a PRINT statement

Keyboard Functions: INKEY$ Most recent character at keyboard

Character Device I/O Functions: EOF End-of-file status INPUT$ Read specified number of characters SPC Skip N spaces in a PRINT # statement TAB Tab to specified position in a PRINT # statement LOC Last accessed record LOF Length of file

See also: Display/Keyboard Statements External I/O Statements

-60- System Functions

DATE$ Set system date or return it as a string ERL Line number of most recent error ERR Error number ERR$ Error message EXITKEY INPUT @ Exit Key Code FRE Available memory INP Read from an I/O port INPW Read from an I/O port MBVER$ MotionBASIC Version Code PEEK Value at specified address PEEKW Value at specified address RND Random number TIME$ Set system time or return it as a string TIMER Return elapsed time in user units

MotionBASIC Functions

ABS Absolute value ASC ASCII value of first character ATN Arctangent BIN$ Binary value, as string CHR$ Convert ASCII code to character CLG Common logarithm COS Cosine CSRLIN Row position of cursor DATE$ Get or set system date EOF End-of-file status ERL Line number of most recent error ERR Error number ERR$ Error message EXITKEY Exit key code for INPUT @ statement EXP Exponent (natural) FIX Truncate to integer FRE Available memory HEX$ Hexadecimal value, as string

-61- MotionBASIC Functions

INKEY$ Most recent character at keyboard INP Read from an I/O port INPUT$ Read specified number of characters INPW Read from an I/O port INSTR Find substring INT Next lower integer LCASE$ Convert upper cases to lower cases LEFT$ Substring at left LEN Length of string LOC Last accessed record LOF Length of file LOG Natural logarithm MBVER$ MotionBASIC version MID$ Substring in middle OCT$ Octal value as string PEEK Value at specified address PEEKW Value at specified address POS Current cursor column position

RIGHT$ Substring at right RND Random number SGN Sign of number SIN Sine SPACE$ String of N spaces SPC Skip N spaces in a PRINT statement SQR Square root STR$ String representation of numeric expression STRING$ String of specified length and character TAB Tab to specified position TAN Tangent TIME$ Set system time or return it as a string TIMER Return elapsed time in user units UCASE$ Convert lower cases to upper cases VAL Numeric value of string

-62- Function & ORMEC Variable Usage

When the usage of a function or an ORMEC variable is shown, it is shown as the right side of an assignment. The variable shown on the left side is used to indicate the "type" of the result returned by the function or ORMEC variable. All functions and ORMEC variables can be used anywhere in an expression where the appropriate type variable may be used.

The following variable types may be specified: var A numeric variable (type may vary). var# A double precision floating-point variable. var! A single precision floating-point variable. var% A 16-bit integer variable. var& A 32-bit long integer variable. var~ A set variable. var$ A string variable.

Remember that type conversion among the various numeric types is performed automatically. This means, for example, that a double precision floating-point variable may be assigned an integer result.

MotionBASIC Operators

Operators work with numerical, string and set variables as appropriate.

Arithmetic Relational

- Negation < Less than ^ Exponentiation <= Less than or equal to * Multiplication, Intersection <> Not equal / Division = Equal \ Integer division > Greater than MOD Modulo arithmetic >= Greater than or equal to + Addition, Concatenation, Union WITHIN Set membership - Subtraction, Difference Logical Note that arithmetic and logical operators are shown in order of NOT Logical NOT, Complement precedence. Note also that AND Logical AND all logical operators perform OR Logical OR bitwise operations. XOR Logical exclusive OR

-63- Precedence Operator Precedence in MotionBASIC

Highest: - (unary negation) ^ (exponentiation) */\MOD +- = <> < > <= >= WITHIN NOT AND Lowest: OR XOR

Operators in MotionBASIC have an inherent precedence. In the absence of explicit grouping (with parentheses), an expression is evaluated in the order dictated by this inherent precedence. Operators of the same precedence level are evaluated in left-to-right order.

All function calls in an expression are evaluated before any operators.

See also: Differences

Bitwise Operations

The four logical operators NOT, AND, OR, XOR perform "bitwise" operations on integer expressions. The term bitwise means that the operator performs its operation on each bit (or pair of bits) of the integer (or integers) being operated upon. The truth tables for these operators show the result for each bit after the operation is complete.

Example: 10 LOGICAL1% = &B0000000011111111 : LOGICAL2% = &B1100110011001100 30 RES.NOT% = NOT LOGICAL1% : RES.AND% = LOGICAL1% AND LOGICAL2% 50 RES.OR% = LOGICAL1% OR LOGICAL2% : RES.XOR% = LOGICAL1% XOR LOGICAL2% 70 PRINT BIN$(RES.NOT%) ;BIN$(RES.AND%) ;BIN$(RES.OR%) ;BIN$(RES.XOR%) 80 PRINT NOT {2,10,11,15,19,28,29,30,31} 90 END RUN 1111111100000000 11001100 1100110011111111 1100110000110011 1,3,4,5,6,7,8,9,12,13,14,16,17,18,20,21,22,23,24,25,26,27,32

Note the leading zero suppression when RES.AND% is printed.

-64- Truth Tables for Logical Operators

Bitwise truth table for NOT Bitwise truth table for AND

exp1 NOT exp1 exp1 exp2 exp1 AND exp2

10 11 1 01 10 0 01 0 00 0

Bitwise truth table for OR Bitwise truth table for XOR

exp1 exp2 exp1 OR exp2 exp1 exp2 exp1 XOR exp2

11 1 11 0 10 1 10 1 01 1 01 1 00 0 00 0

MotionBASIC Constants

Constants (or literals) are static values which MotionBASIC uses during the execution of a program. They may be numbers, strings of characters, or sets of bits.

There are several different types of numeric constants. The type of a numeric constant depends on its magnitude and the use of an optional suffix. The table below lists the constant types that are available:

Data Type Suffix Range Accuracy Storage

Integer default % -32768 to 32767 Perfect 3 bytes Long Integer & -2147483648 to 2147483647 Perfect 5 bytes Single Precision ! ± 3.4E-38 to 3.4E38 6 digits 5 bytes Double Precision # ± 1.07E-308# to 1.07E308# 16 digits 9 bytes String $ 0 to 255 characters 2+bytes Set ~ 0 to 32 elements Perfect 5 bytes

See also: Variables Type conversion Boolean Expressions

Constants may have type integer, long or set. Floating-point constants are always double precision. There is no such thing as a single precision constant.

Integral constants beginning with &H are interpreted as having a hexadecimal base. Those beginning with &O or just & are treated as having octal base. Finally, constants beginning with &B are treating as a string of bits (binary base).

If an integer constant has the suffix &, it has type long. If it does not have this suffix, its type depends on its magnitude. If the value will fit in an integer, it has type integer. If the value fits within a long integer, it will have type long, otherwise it ends up being a double.

-65- MotionBASIC Constants

Examples: 1234, &O033, &Hab, &B0111100 type integer 1234&, 123456, &H123&, -23& type long integer 1234#, 1.234, -3456. 2.3e35 type double {}, {1,15},{14,17,32} type set "This is a string" type string

MotionBASIC Variables and Data Types

Variables are names used to represent values used in a MotionBASIC program, and they may be any of the data types listed below. The value of a variable may be assigned explicitly by the programmer, or it may be assigned as the result of calculations in the program. Non-initialized numeric variables have a value of zero. Variable Names Memory Usage Constants Boolean Set Array Variables Type Conversion Differences from GWBASIC

Data type Suffix Range Accuracy Storage

Integer(default) % -32768 to 32767 Perfect 2 bytes Long Integer & -2147483648 to 2147483647 Perfect 4 bytes Single Precision ! ± 3.4E-38 to 3.4E38 6 digits 4 bytes Double Precision # ± 1.07E-308# to 1.07E308# 16 digits 8 bytes Set ~ 0 to 32 elements Perfect 4 bytes String $ 0 to 255 characters 5+bytes Empty String $ 0 characters 2 bytes ORMEC Variables @

Variable Names and Type Declaration Characters

MotionBASIC variable names may be any length and all characters are significant. Variable names can contain letters, numbers, and the decimal point. However, the first character must be a letter. Special type declaration characters are also allowed (see below).

A variable name may not be a reserved word, but embedded reserved words are allowed. Reserved words include all MotionBASIC commands, statements, function names, and operator names. If a variable begins with FN, it is assumed to be a user-defined function. Variables may represent either a numeric value or a string.

String variable names are written with a dollar sign ($) as the last character. For example:

A$ = "SALES REPORT"

The dollar sign is a variable type declaration character; that is, it "declares" that the variable will represent a string.

-66- Variable Names and Type Declaration Characters

Numeric variable names may declare integer, long, single precision, double precision,orset values. The type declaration characters for these variable names are as follows:

% (default) Integer variable

& Long Integer variable

! Single precision variable

# Double precision variable

~ Set variable

@ Ormec Variables (any type including string)

The default type for numeric variables is integer. See the individual ORMEC Variable description to determine the type of any particular variable.

Examples of MotionBASIC variable names:

PI# Declares a double precision value.

MINIMUM! Declares a single precision value.

LIMIT% Declares an integer value.

N$ Declares a string value.

ABC Represents an integer value, because of the implicit integer declaration in MotionBASIC.

There is a second method by which variable types may be declared. The MotionBASIC statements DEFINT, DEFLNG, DEFSET, DEFSTR, DEFSNG, and DEFDBL may be included in a program to declare the types for certain variable names.

-67- TRUE, FALSE, ON, OFF Boolean

Boolean variables are actually integer variables which have only two states: TRUE (ON) and FALSE (OFF). They are declared just like any other integer variable.

TRUE is represented by the value -1, and FALSE by 0, because the values -1 and 0 represent integers with all bits set to one, or cleared to zero respectively. MotionBASIC provides special keywords, TRUE, FALSE, ON and OFF to represent Boolean constants. The two Boolean values are equivalent to the numeric constants below:

Base TRUE, ON FALSE, OFF

Decimal -1 0 Hexadecimal &HFFFF &H0000 Binary &B1111111111111111 &B0000000000000000 Octal &O177777 &O000000

Since the values -1 and 0 represent integers with either all bits set to one or cleared to zero, only these values ensure the proper operation of the bitwise logical operators AND, OR, XOR, and NOT, with Boolean expressions.

The boolean value of a set is FALSE if the set is empty, otherwise, it is TRUE.

Example: 10 RESULT% = TRUE OR FALSE 20 PRINT TRUE; FALSE; RESULT%; ON; OFF 30 END

RUN -10-1-10

-68- MotionBASIC Array Variables

An array is a group or table of values referenced by the same variable name. Each element in an array is referenced by the variable name, and is subscripted with integers or integer expressions.

An array variable name has as many subscripts as there are dimensions in the array. For example V(10) would reference a value in a one-dimension array, T(1,4) would reference a value in a two-dimension array, and so on.

The maximum number of dimensions for an array is 255. The maximum number of elements per dimension is 32,767. These values are realistically limited by the controller memory size.

Wherever a variable name can be entered in a MotionBASIC program line, an array element can also be entered. From now on, when speaking of a variable we shall mean either a simple variable or an array element.

See also: Differences from GWBASIC DIM Memory Usage for Variables

Type Conversion

MotionBASIC performs automatic conversion between the various numeric data types when necessary. The following rules are used to perform automatic type conversions:

1. If a variable of one type is assigned to a variable of another, the data takes on the precision of the target variable.

2. When a higher-precision value (constant or variable) is assigned to a variable of lower precision, if the value is within the range of the lower precision variable then the value is rounded, rather than truncated. (See note below.) An attempted transfer of a value that is out of range for the lower precision variable will cause Error #1202 Numeric overflow.

3. When a lower-precision value (constant or variable) is assigned to a higher-precision variable, its accuracy is limited to that of the lower-precision value.

-69- Type Conversion

4. When expressions are evaluated, all operands are normally converted to the same level of precision--that of the highest-precision operand in the expression. For expressions which require integer or long integer operands, integer type conversion is performed.

Note: When an integer variable is assigned a floating point value, the value is rounded to the nearest whole number. If the fractional part of the floating-point number is exactly 0.5, the value is rounded to the nearest even integer.

Example 1 Example 2 Example 3 Example 4 A%=2.5 A%=2.51 A%=3.5 A%=3.49 PRINT A% PRINT A% PRINT A% PRINT A% 2343

5. Sets may only be assigned to a set, integer,orlong integer variable. If a set is assigned to an integer, or long integer variable, the variable takes the value of the set’s smallest element.

6. If an integer or long integer is to be assigned to a set variable, the value is treated as an element for the set and thus the value must be between 0 and 32. Assigning an integer value of 0 to a set variable results in the "empty" set. i.e. the set with no elements, as designated by "{}"

7. A "type mismatch" error will be generated whenever a floating point value is assigned to a set variable or when a set value is assigned to a floating point variable.

Integer Type Conversion

Integers are converted to long integers by a process called "sign extension". Sign extension preserves the value of two’s complement negative numbers through the conversion.

The 16-bit integer value is copied directly into the low 16 bits of the long integer. The sign bit (most significant bit) of the two’s complement integer is copied into the 16 most significant bits of the long integer.

Integer = &HA5A5 = -23131 sign extension 1010010110100101LSB ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

MSB11111111111111111010010110100101LSB

Long Integer = &HFFFFA5A5& = -23131&

-70- Two’s Complement Storage

Integers and long integers are stored in "two’s complement" notation. Two’s complement notation is a way of internally representing signed (positive and negative) integers so that they can be added or subtracted without any special sign considerations. The sign of a number can be changed by inverting all of the bits and adding one.

An understanding of two’s complement notation is necessary when combining arithmetic operations (such as +, -, > and <) with logical operations (such as AND, OR, and NOT). It is also necessary when switching between signed decimal and unsigned hexadecimal, octal, or binary constants. Some examples of equivalent values are shown below:

Decimal Hex Int Hex Long Int Decimal Hex Int Hex Long Int

0 &H0000 &H00000000& -32768 &80000 &HFFFF8000& 1 &H0001 &H00000001& -32767 &H8001 &HFFFF8001& 32767 &H7FFF &H00007FFF& -1 &HFFFF &HFFFFFFFF&

Because all relational comparisons on integers assume that the values are two’s complement signed numbers, unexpected results can sometimes occur. For example, the relational expression "&H8001 > 0" is FALSE because &H8001 is actually a negative number (see the table above).

Memory Usage for Variables

User Variables each consume 5 bytes of memory for overhead plus 1 byte per character in their variable name plus x number of data bytes, x depending upon the variable type. The table below summarizes:

Variable General Name Non-Array Array Array Type Overhead Overhead Data Data Overhead

Integer 5 1 per char 2 2 * E 2 * N Long Integer 5 1 per char 4 4 * E 2 * N Set 5 1 per char 4 4 * E 2 * N Single Precision 5 1 per char 4 4 * E 2 * N Double Precision 5 1 per char 8 8 * E 2 * N String 5 1 per char 2 + S 2E + S 2 * N

N = The number of dimensions of the array see: DIM E = The number of elements in the array "" S= The number of characters in the string(s) (for empty strings, S=0)

-71- Set

A set is a collection of elements. Each element is represented by a bit in memory. Since each set in MotionBASIC takes 4 bytes of storage, a set can have up to 32 elements, numbered from 1 to 32.

Set constants are defined by including a set value string within "braces". e.g. The expression {1,2,3} defines a set with three elements. Only constants between 1 and 32 are allowed to be elements within the "braces". Set variables are defaulted to the "empty" set as designated by {}.

Sets are most commonly used in MotionBASIC to define groups of servo axes. These groups can then receive a common command or have a common value assigned to any pre-defined variable indexed by axes. The pre-defined variable AXIS.LIST@ defines the set of all servos in the system. AXIS.SET@ defines a default group of servos for use in MotionBASIC statements indexed on axes. AXIS.FAULT@ defines a group of servos which currently have a "fault". AXIS.OTL@ defines a group of servos which currently have an over travel limit.

Example: 10 PRINT AXIS.LIST@ 20 AXIS.SET@ = {1} 30 PRINT AXIS.SET@ 40 END RUN {1,2,3,4} {1}

See also: Type Conversion VAL STR$ Example under AXIS.SET@ Impact of Set Variables on MotionBASIC

Integer

Integer variables are 16-bit binary values which may contain any whole number from -32768 to 32767. Integer variable name may end with a percent sign (%). Storage space for integer values is 2 bytes (16-bits).

Because it is designed for real-time control, MotionBASIC defaults all variables to integer unless declared otherwise!

Integer constants can denote several different radixes. They may be written in one of the following forms: Decimal: [-]ddddd[%] Hexadecimal: [-]&Hdddd[%] Octal: [-]&[O]dddddd[%] Binary: [-]&Bdddddddddddddddd[%]

where d represents a digit in the appropriate radix.

Any integral constant followed by a percent sign (%) is considered to be an integer, as is any integral constant with a value small enough to be an integer.

-72- Integer

Examples: VALUE% = 6 BIT.PATTERN% = &H0AB VALUE% = 123%

See also: Long Integer Constants Boolean DEFINT

Long Integer

Long integer variables are 32-bit binary values which may contain any whole number from -2147483648 to 2147483647. If not declared with the DEFLNG statement, an integer variable name must end with an ampersand (&). Storage space for long integer values is 4 bytes (32-bits).

Long Integer constants can denote several different radixes. They may written in one of the following forms:

Decimal: [-]dddddddddd[&] Hexadecimal: [-]&Hddddddd[&] Octal: [-]&[O]ddddddddddd[&] Binary: [-]&Bdddddd...ddddddd[&] where d represents a digit in the appropriate radix.

Any integral constant followed by an ampersand (&) is considered to be a long integer, as is any integral constant with a value too large to be an integer.

Example: VALUE& = 6 BIT_PATTERN& = &H0AB VALUE& = 123& VALUE& = 1234567 VALUE& = 1234567&

See also: Integer Constants Set

-73- Single Precision

Single Precision floating-point variables may contain any positive or negative number from 3.4E-38 to 3.4E+38. Up to six significant digits may be included in the mantissa before rounding will occur. They may be explicitly declared as single precision with the DEFSNG statement, or by ending the variable name with a exclamation point (!). Storage space for single precision values is 4 bytes (32-bits).

Single Precision floating-point constants may be written in one of the following forms:

[-]ddd.ddd[E[-]ee] [-]ddd.ddd[E[+]ee] [-]ddd[.ddd][E[-]ee]! [-]ddd[.ddd][E[+]ee]! where ddd.ddd represents the mantissa with up to six significant decimal digits (the decimal point may be located anywhere in the mantissa), and ee represents the exponent with one or two digits.

All floating-point constants are internally represented as double precision. There is no way to explicitly specify a single precision constant. Any decimal number followed by an exclamation point (!) or a number sign (#) is considered to be a double precision floating-point number.

Since all floating-point arithmetic is performed in double precision, and all floating-point expressions used as function arguments are promoted to double precision, it might appear you would have little use for single precision. Single precision variables however, require only four storage bytes, whereas double precision requires eight. The decision between single and double is one of space versus run-time conversion cost.

The IEEE representation consisting of a sign bit, a 7-bit excess 127 binary exponent, and a 24-bit mantissa is used. The mantissa represents a number between 1.0 and 2.0; since the high-order bit of the mantissa is always 1, it is not stored in the number.

Examples: VALUE! = 1.234 F1! = 1.234E-24 VALUE = 123!

See also: Double Precision Long Integer

-74- Double Precision

Double Precision floating-point variables may contain any positive or negative number from 1.07E-308# to 1.07E+308#. Up to sixteen significant digits may be included in the mantissa. If not declared with the DEFDBL statement, a double precision variable name must end with a number sign (#). Storage space for double precision values is 8 bytes (64-bits).

Double Precision floating-point constants may be written in one of the following forms:

[-]ddd.ddd[E[-]ee] [-]ddd.ddd[E[+]ee] [-]ddd[.ddd][E[-]ee]! [-]ddd[.ddd][E[+]ee]! where ddd.ddd represents the mantissa with up to sixteen significant decimal digits (the decimal point may be located anywhere in the mantissa), and ee represents the exponent with up to three digits.

All floating-point constants are internally represented as double precision. There is no way to explicitly specify a single precision constant. Any decimal number followed by an exclamation point (!) or a number sign (#) is considered to be a double precision floating-point number.

The IEEE representation consisting of a sign bit, an 11-bit excess 1023 binary exponent, and a 52-bit mantissa is used. The mantissa represents a number between 1.0 and 2.0, and since the high-order bit of the mantissa is always 1, it is not stored in the number. The range of values is approximately 1.7E-308# to 1.7E+308#.

Examples: VALUE# = 1.234 D1# = 1.234E-24# VALUE = 123#

See also: Single Precision Long Integer

-75- String Variables

String variables contain variable length groups of ASCII characters. These character strings may be from 0 to 255 characters in length, and may contain any combination of characters. If not declared with the DEFSTR statement, a string variable name must end with a dollar sign ($). The size of a string variable is 5 bytes for the descriptor plus one byte per character in the string. Non-initialized string variables contain an "empty" or "null" string, which is a string with no ASCII characters in it. String variables are volatile and will be reset to the "null" string on powerup.

String constants may be written as a string of characters enclosed in double quotes, e.g. "string", where string represents a string of between 0 and 255 ASCII characters.

Example: VALUE$ = "abcd"

See also: Garbage Collection

String Garbage Collection

The speed at which a MotionBASIC program executes is normally very predictable. When using strings, however, the programmer should be aware of a process called "string garbage collection", which can sometimes cause a string operation to take longer to execute. e.g. String garbage collection for a 4,000 byte string space would typically take 10 to 20 msec. For the default string space size, 1024 bytes, 9.6 ms worst case.

Since garbage collection occurs only during string operations, and only when insufficient string space exists, following the rules below will prevent unexpected delays in a program: 1. Do not perform string operations in critical (fast) code sections. 2. To reduce the time needed for each string garbage collection, reduce the number of string variables used in the program (i.e. no large string arrays). 3. To reduce the frequency of string garbage collections, increase the amount of available string space by using the CLEAR statement. 4. Use the FRE function to force garbage collection in non-critical sections of code.

-76- String Garbage Collection

Note: A string enclosed in quotes in a PRINT statement is not considered a string expression, and will not cause a garbage collection unless a string operation (such as +) is performed on it.

Examples where Garbage Collection may occur: 1010 PRINT TIME$ ’ TIME$ is a string expression 5320 PRINT "One"+"Two" ’ "One"+"Two" is a string expression 6230 A$=B$+C$ ’ B$+C$ is a string expression 3220 DIR$="Forward" ’ Assignment to a string variable 2000 READ A$ ’ Assignment to a string variable 2110 PRINT "Direction=";DIR$ ’ DIR$ is a string expression

Examples where Garbage Collection will not occur: 1010 PRINT TIMER ’ TIMER is a numeric expression 5320 PRINT "One";"Two" ’ "One";"Two" are string constants 6230 A=B+C ’ B+C is a numeric expression 3220 DIR=1 : READ A ’ Assignments to a numeric variable 2110 PRINT "Direction=";DIR ’ DIR is a numeric expression

ORMEC Pre-defined MotionBASIC Variables

MotionBASIC simplifies motion control and I/O by the implementation of a number of ORMEC pre-defined variables. All ORMEC variables end with an @ character, and fall into one of the categories below.

Unit Parameters and I/O Variables

Axis Setup Parameters User Units Axis Range Variables Axis Operating Parameters Servo Loop Tuning Parameters

Numeric Axis Status Parameters

Boolean Axis Status Parameters

All ORMEC Variables

-77- Unit Parameters and I/O Variables

Unit I/O Setup Parameters: IO.MODE@ Discrete I/O Config EIO.MODE@ Extended I/O Config

Unit I/O Variables DIO@ Discrete I/O Point AIO@ Analog I/O Point

Unit Status Parameters: LOOP.RATE@ Servo Loop Update Rate AXIS.LIST@ Set of all axes AXIS.SET@ Default set of axes UNIT.ID@ Unit ID Code FAULT@ Unit Fault Status AXIS.FLT1@ First axis to fault AXIS.FAULT@ All axes with a fault PG.LEN@ Page Length AXIS.OTL@ All axes with an OTL BAUD@ Serial Port Baud Rate PW@ Program Write Enable PB1@ Pushbutton PB1 pressed ESTOP.OK@ Emergency Stop Input OK USER2.LED@ User 2 LED ON USER1.LED@ User 1 LED ON

User Units

MotionBASIC provides built-in conversion factors so that time, position, speed and acceleration can be expressed in units of the user’s choice. e.g. msec, inches, inches/sec, & g’s. Sections on axis position units, speed units, acceleration units, pacer position units and gear ratio multipliers describe the conversion factors below:

CNT.REV@ Axis Position Transducer counts/rev MTR.SPD.LIM@ USR.SPD.LIM@ Motor/Machine Speed Limits MTR.ACL.LIM@ USR.ACL.LIM@ Motor/Machine Acceleration Limits PCT.REV@ PCR.SPD.LIM@ Pacer-counts/rev and Speed Limit

After setting LOOP.RATE@, set the parameters above in the order listed. All servo loop tuning parameters must then be initialized.

POS.MUL@ PPS.MUL@ Axis/Pacer Position Units Multiplier POS.DIV@ PPS.DIV@ Axis/Pacer Position Units Divider OUTSPD.MUL@ INSPD.MUL@ Gear Ratio Output/Input Speed Multipliers TIME.MUL@ Time Conversion Factor

-78- Axis Position Units

Position information for each axis is measured by its axis encoder and is stored in its DSP Axis Module in counts of the axis encoder, with a 32-bit range. However, MotionBASIC allows the programmer to refer to position and distance for each "machine" axis in units of his choice.

User specified positions and distances are automatically converted to counts of the axis encoder using POS.DIV@ and POS.MUL@. These variables respectively define some exact number of the user’s desired machine position units, (POS.DIV@), that equates EXACTLY to some number of axis encoder counts, (POS.MUL@).

The actual position of an axis is available via the Ormec Variable, POS.ACT@. The integer value stored in POS.ACT@, is in the chosen user units and is limited to a Long Integer (a 32-bit range number, the same as the DSP’s storage counter.)

Note: When implied resolution of user units is greater than actual resolution of the encoder, numeric overflow can occur.

For example, if two (2) user units are equated to one (1) encoder count by setting POS.DIV@=2 and POS.MUL@=1, then the possibility exists that the value of POS.ACT@ could go "out of range" if the DSP encoder counter were to reach one count more than half of the 32 bit maximum value.

Establishing Axis Position Units

Example 1: To express user axis position in degrees (360 in a revolution) when a 6,000 count per rev axis encoder is installed, set POS.DIV@=360 (deg) & POS.MUL@=6000 (cts). Alternatively, set POS.DIV@=36 & POS.MUL@=600, or POS.DIV@=3 & POS.MUL@=50, or any other exact combination which results in the same relationship.

Example 2: Express user unit distance in mils (thousandths of an inch) for a ballscrew having 5 revs/inch-travel when a 6000 cnt/rev axis encoder is attached. The combination of 5 revs/inch and 6000 cts/rev provides 30,000 cts/inch or 30 cts/mil. Therefore set POS.DIV@=1 (mil) & POS.MUL@=30 (cts).

Example 3: You have a web system drive roll circumference of 9 inches, and would like to express web position in mils. The motor attached has 6,000 counts/rev. Since for 9000 mils of web, one rev of roll, there are 6000 axis encoder counts, set POS.DIV@=9000 (mils) & POS.MUL@=6000 (cts). Alternatively, set POS.DIV@=9 & POS.MUL@=6, POS.DIV@=3 & POS.MUL@=2 or any other exact combination resulting in the same relationship.

Caution: The above user units will have a greater implied resolution than does the axis encoder feedback hardware!! See the Note above.

Axis position units conversion is "turned off" when POS.MUL@=1 and POS.DIV@=1, resulting in somewhat faster program operation.

When Pi is required in the calculation of position units, use the following fraction as an approximation of Pi: π≈355/113

-79- User Speed Units

MotionBASIC automatically calculates the conversion factor for user speed units when the user establishes the "absolute machine speed limit" both in terms of "user speed units" (USR.SPD.LIM@) and the corresponding "absolute motor speed limit" (MTR.SPD.LIM@) in RPM of the axis encoder.

Example 1: You want speed and velocity units to be expressed in the MotionBASIC program in RPM, and the fastest you ever want the machine to go is 4000 RPM. The motor is coupled directly to the machine and so it also goes 4000 RPM. Set USR.SPD.LIM@ = 4000 & MTR.SPD.LIM@ = 4000. These values are the defaults.

Example 2: You want speed and velocity units to be expressed in the MotionBASIC program in inches/min, and the fastest you ever want the machine to go is 500 in/min. The motor is driving a 5 pitch ballscrew (5 revs/inch), and so it runs at a corresponding speed of 2500 RPM. Set USR.SPD.LIM@ = 500 & MTR.SPD.LIM@ = 2500.

Note that the process of setting the "user speed units conversion factor" utilizes the CNT.REV@ parameter because the internal units for speed are "counts per second" of the position transducer. This process also determines the speed resolution of the system and affects the servo loop tuning parameters. User speed units are generally set only once during program initialization. There is another parameter, SPD.MAX@, for changing the maximum speed during the applications program.

User Acceleration Units

MotionBASIC automatically calculates the conversion factor for user acceleration units when the user establishes the "absolute maximum machine acceleration limit" both in terms of "user acceleration units" (USR.ACL.LIM@) and the corresponding "motor acceleration rate" (MTR.ACL.LIM@) in rev/sec² of the axis encoder.

Example 1: You want acceleration units to be expressed in the MotionBASIC program in rad/sec², and the fastest you ever want the machine to accelerate is 20,000 rad/sec². The motor is coupled directly to the machine and so it also accelerates at 20,000 rad/sec², which is equivalently expressed as 20000/2π = 3183 revs/sec². Set USR.ACL.LIM@ = 20000 & MTR.ACL.LIM@ = 3183.

Example 2: You want user acceleration units to be in inches/second², and the maximum acceleration you want to allow is 500 in/sec². The motor is driving a 5 pitch ballscrew (5 revs/inch), and so the motor acceleration when the axis is at 500 in/sec² is 2500 revs/sec². Set USR.ACL.LIM@ = 500 & MTR.ACL.LIM@ = 2500.

-80- User Acceleration Units

Example 3: You want user acceleration units are to be in hundredths of a "g" (the acceleration due to gravity), and the maximum allowable acceleration you want to allow is 1.25 g. The acceleration due to gravity is 386.4 in/sec² and so at 1.25 g, the maximum allowable acceleration is 483 in/sec². The motor is driving a 5 pitch ballscrew (5 revs/inch), and so the corresponding motor acceleration rate is 2415 revs/sec². Set USR.ACL.LIM@ = 125 & MTR.ACL.LIM@ = 2415.

Note that the process of setting the "user acceleration units conversion factor" utilizes the CNT.REV@ parameter because the internal units for acceleration is "counts per second²" of the axis position transducer. User acceleration units are generally set only once during program initialization. The ACL.MAX@ and DCL.MAX@ parameters should be used for changing the maximum acceleration or deceleration during the applications program.

Pacer Position Units

Pacer position is transmitted over the MotionDATA communications link in actual counts of the axis encoder for the axis originating the pacer information. However, MotionBASIC allows the programmer to refer to pacer distance for each follower axis in units of his choice.

Program references to pacer distance are automatically converted to counts of the pacer encoder using the PPS.MUL@ and PPS.DIV@ variables, which define the ratio of pacer encoder counts to pacer position units.

Example 1: To express pacer distance in degrees with a 6,000 cnt/rev axis encoder, set PPS.MUL@=6000 & PPS.DIV@=360. Alternatively, set POS.MUL@=600 & POS.DIV@=36, POS.MUL@=50 & POS.DIV@=3, or any other combination resulting in the same ratio.

Example 2: Express pacer distance in mils (thousandths of an inch) with a 6000 cnt/rev pacer encoder and a ballscrew having 5 revs/inch. The combination of 6000 counts/rev and 5 revs/inch provides 30,000 cts/inch or 30 cts/mil. Therefore set PPS.MUL@=30 & PPS.DIV@=1.

Example 3: You have 6,000 counts/rev and a pulley on the motor with a circumference of 9 inches, resulting in 6000/9000 counts per mil. For pacer position units of mils, PPS.MUL@=2 & PPS.DIV@=3.

Pacer position units conversion is "turned off" whenever PPS.MUL@ =1 and PPS.DIV@ = 1, resulting in somewhat faster program operation.

-81- Gear Ratio Multipliers

The MotionBASIC statement GEAR AT 1 TO 1 specifies a user gear ratio. The user ratio "1 to 1" would have an application specific meaning. For actual control by the DSP these "user ratios" are converted to encoder count ratios; the "ratio of axis encoder counts to pacer encoder counts". To perform the conversion, MotionBASIC internally multiplies the outspeed and inspeed parameters of the GEAR statement by OUTSPD.MUL@ and INSPD.MUL@, respectively.

Example 1: A pacer encoder has 24,000 cts/rev and the follower has 6000 cts/rev, then GEAR AT 1 TO 1 without gear ratio multipliers would result in the follower moving 4 times faster than the pacer. To have "1TO1" result in the same speed, set OUTSPD.MUL@ =1 & INSPD.MUL@ =4. The follower then moves 1 count for every 4 pacer counts.

Example 2: With the encoders above, for user ratios that specify speed percentages, set OUTSPD.MUL@ = 1 and INSPD.MUL@ = 400. Then the statement GEAR AT 50 will move follower to pacer encoders at 50 counts to 400 counts, (1 count for every 8 pacer counts), a 50% speed ratio.

When GEAR AT 1 TO 1 is required to match machine rotary speeds, giving 1 cycle of the follower axis for 1 cycle of the pacer axis, then the gear speed multipliers are as follows:

INSPD.MUL@ COUNTS for 1 Machine pacer axis cycle = OUTSPD.MUL@ COUNTS for 1 Machine follower axis cycle

When the application requires GEAR AT 1 TO 1 to match machine linear speeds, meaning move X distance of the follower axis for X distance of the pacer axis, then the gear speed multipliers are as follows:

INSPD.MUL@ PPS.MUL@ * POS.DIV@ = (all referenced to follower) OUTSPD.MUL@ PPS.DIV@ * POS.MUL@

NOTE: Reduce these fractions to a numerator and denominator that are integers. DO NOT perform floating point divisions or rounding.

Axis Range Variables

SPD.MAX@ Maximum Speed ACL.MAX@ Maximum Acceleration Rate DCL.MAX@ Maximum Deceleration Rate DRV.MAX@ Maximum Drive Command STL.FWD@ Forward Software Travel Limit STL.REV@ Reverse Software Travel Limit PERR.MAX@ Maximum Position Error PERR.INPOS@ In-Position Error

All Axis Range Variables are indexed by axes.

-82- Axis Operating Parameters

MODE@ Axis control mode CW.FWD@ Direction of Forward Rotation POS.MOD@ Position Modulus Conversion Factor MD.MODE@ MotionDATA Operating Mode SENS.MODE@ Sensor Mode DELAY.DIST@ Sensor Delay Distance SCURVE@ S-Curve Velocity Profile DCL.ERR@ Error Deceleration Rate AXIS.VAR@ Axis-Indexed, Long Integer Array

ELS1.LOW@ Electronic Limit Switch 1 Low Range ELS1.HIGH@ Electronic Limit Switch 1 High Range ELS2.LOW@ Electronic Limit Switch 2 Low Range ELS2.HIGH@ Electronic Limit Switch 2 High Range ELS3.LOW@ Electronic Limit Switch 3 Low Range ELS3.HIGH@ Electronic Limit Switch 3 High Range

All Axis Operating Parameters are indexed by axes.

Servo Loop Tuning Parameters

TRQ.GAIN@ Torque Gain of Motor and Drive INERTIA@ Servo Axis Inertia VLTC@ Velocity Loop Time Constant KVH@ Velocity Loop Feedback Gain Factor KVI@ Velocity Loop Integral Gain Factor KP@ Position Loop Gain Factor KPI@ Position Loop Integral Gain Factor KAF@ Acceleration Feedforward Factor KVF@ Velocity Feedforward Factor

All Servo Loop Tuning Parameters are indexed by axes.

See Also: Loop Architecture

-83- Numeric Axis Status Parameters

Read-Write Parameters: Read-Only Parameters, cont’d: AFAULT@ Axis Fault Code AIN1@ Axis Analog Input One DRV.CMD@ Drive Command AIN2@ Axis Analog Input Two VEL.CMD@ Velocity Command ALARM@ Servodrive Alarm Code POS.ACT@ Actual Position GEAR.RATIO@ Current Gear Ratio DIST.BIAS@ Distance Bias POS.ABS@ Absolute Encoder Poll DSP.CTR@ DSP Motion Counter POS.ASEN@ Position at A-Sensor Read-Only Parameters: POS.BSEN@ Position at B-Sensor ACL.CMD@ Accel Command POS.DELAY@ Position at Delay Input VEL.ACT@ Actual Velocity POS.ZREF@ Position at Encoder Ref POS.CMD@ Position Command ACL.LAST@ Last Specified Accel DIST.MOVE@ MOVE distance DCL.LAST@ Last Specified Decel DIST.GEAR@ GEAR distance VEL.LAST@ Last Specified Top Vel DIST.GRAT@ GEAR AT distance POS.ERR@ Position Error PERR.NORM@ Normalization Error

All Numeric Axis Status Parameters are indexed by axes.

Boolean Axis Status Parameters

Motion Status Parameters: IN.MOT@ Servo(s) In Motion IN.ACL@ Servo(s) Accelerating AT.SPD@ Servo(s) at Constant Speed IN.DCL@ Servo(s) Decelerating AT.REST@ Servo(s) at Rest IN.POS@ Servo(s) In Position DSP.DONE@ No DSP motion changes in process or pending OTL.FWD@ OTL.REV@ Forward / Reverse Overtravel Limit Status

DSP Inputs: DSP Outputs: ZREF@ Zero Reference On ELS1@ Limit Switch 1 ASEN@ Sensor A On ELS2@ Limit Switch 2 BSEN@ Sensor B On ELS3@ Limit Switch 3 HTL.FWD@ Forward Limit Status HTL.REV@ Reverse Limit Status DELAY@ Internal Delay On

All Boolean Axis Status Parameters are indexed by axes.

-84- ORMEC Variables

ACL.CMD@ Acceleration command ACL.LAST@ Last specified acceleration rate ACL.MAX@ Maximum acceleration rate AFAULT@ Axis fault AIN1@ Axis Analog Input 1 AIN2@ Axis Analog Input 2 AIO@ Analog I/O point ALARM@ Axis servodrive alarm code ASEN@ A-Sensor on AT.REST@ Servo(s) at rest AT.SPD@ Servo(s) at constant speed AXIS.FAULT@ Set of servos with a fault AXIS.FLT1@ First servo axis to develop a fault AXIS.LIST@ List of all servos in the system AXIS.OTL@ Set of servos with an overtravel limit AXIS.SET@ Default set of servos AXIS.VAR@ Axis indexed, long integer array BAUD@ Serial port baud rate

BSEN@ B-Sensor on CNT.REV@ Axis position counts/revolution of servomotor CW.FWD@ Direction of forward rotation DCL.ERR@ Error deceleration rate DCL.LAST@ Last Specified deceleration rate DCL.MAX@ Maximum deceleration rate DELAY.DIST@ Sensor Delay Distance DELAY@ Delayed sensor on DIO@ Discrete I/O point DIST.BIAS@ Position command bias distance DIST.GEAR@ Gear distance command DIST.GRAT@ Constant gear ratio distance command DIST.MOVE@ Move distance command DSP.CTR@ DSP Motion Counter DSP.DONE@ No DSP motion changes in process or pending DRV.CMD@ Output command to the servodrive DRV.MAX@ Maximum output command to the servodrive EIO.MODE@ Extended I/O Configuration

ELS1@ Electronic limit switch 1 status ELS1.HIGH@ Electronic limit switch 1 range, high ELS1.LOW@ Electronic limit switch 1 range, low ELS2@ Electronic limit switch 2 status ELS2.HIGH@ Electronic limit switch 2 range, high ELS2.LOW@ Electronic limit switch 2 range, low ELS3@ Electronic limit switch 3 status ELS3.HIGH@ Electronic limit switch 3 range, high ELS3.LOW@ Electronic limit switch 3 range, low ESTOP.OK@ Emergency Stop Input OK FAULT@ Unit fault GEAR.RATIO@ Current electronic gear ratio HTL.FWD@ Forward hardware overtravel limit status HTL.REV@ Reverse hardware overtravel limit status IN.ACL@ Servo(s) accelerating IN.DCL@ Servo(s) decelerating IN.MOT@ Servo(s) in motion IN.POS@ Servo(s) in position

-85- ORMEC Variables

INERTIA@ Servo Axis Inertia INSPD.MUL@ Gear ratio input speed multiplier IO.MODE@ Machine I/O configuration KAF@ Acceleration Feedforward Factor KP@ Position loop gain factor KPI@ Position loop integral gain factor KVF@ Velocity feedforward factor KVH@ Velocity loop feedback gain factor KVHA@ Analog velocity loop feedback gain factor KVI@ Velocity loop integral gain factor LOOP.RATE@ Servo loop update rate MD.MODE@ MotionDATA mode MODE@ Axis control mode MTR.ACL.LIM@ Motor acceleration limit in rev/sec² MTR.SPD.LIM@ Axis speed limit in RPM OTL.FWD@ Forward overtravel limit status OTL.REV@ Reverse overtravel limit status OUTSPD.MUL@ Gear ratio output speed multiplier

PB1@ Pushbutton PB1 pressed PCR.SPD.LIM@ Pacer encoder speed limit in RPM PCT.REV@ Pacer position counts/revolution PERR.INPOS@ In-position error PERR.MAX@ Maximum position error PERR.NORM@ Normalization error PG.LEN@ Page length used for the LIST command POS.ABS@ Absolute encoder poll POS.ACT@ Actual position POS.ASEN@ Position at A-Sensor POS.BSEN@ Position at B-Sensor POS.CMD@ Position command POS.DELAY@ Position at Delayed Sensor Input POS.DIV@ Axis position units conversion divider POS.ERR@ Current position error POS.MOD@ Position modulus POS.MUL@ Axis position units conversion multiplier POS.ZREF@ Position at Encoder Reference

PPS.DIV@ Pacer position units divider PPS.MUL@ Pacer position units multiplier PW@ Program write enable SCURVE@ S-Curve velocity profile SENS.MODE@ Sensor Mode SPD.MAX@ Maximum speed STL.FWD@ Forward software travel limit STL.REV@ Reverse software travel limit TIME.MUL@ Time conversion factor TRQ.GAIN@ Torque Gain of Motor and Drive UNIT.ID@ Unit identification code USER1.LED@ User 1 LED ON USER2.LED@ User 2 LED ON USR.ACL.LIM@ Acceleration limit in user units USR.SPD.LIM@ Speed limit in user units VEL.ACT@ Actual Velocity VEL.CMD@ Velocity command VEL.GAIN@ Velocity mode servo gain

-86- ORMEC Variables

VEL.LAST@ Last specified top velocity VLTC@ Velocity Loop Time Constant ZREF@ Zero reference on

-87- MotionBASIC Error Codes

MotionBASIC divides errors into several categories by error number, which can be accessed using the ERR function: 1- 999: User Defined Errors 1400-1599: (reserved) 1000-1099: Syntax Errors 1600-1699: Motion Errors 1100-1199: Program Structure Errors 1700-1799: (reserved) 1200-1299: Expression Errors 1800-1899: System Errors 1300-1399: I/O Errors 1900-1999: Controller Fault Errors

Action taken when an error occurs is as follows: 1. If the error is a controller fault error, "fault action" is taken and a user trappable error is generated. 2. Other errors generate a user trappable error immediately. 3. Un-trapped syntax and expression errors will invoke the line editor with the cursor positioned at the point where the error was found. 4. For errors which occur asynchronous to program operation, such as Axis Faults and Overtravel Limits or E-Stop, only the first occurrence will report a user trappable error. The reporting of these errors must be re-enabled with a FAULT@=0 statement.

-88- User Trappable Errors

MotionBASIC errors are "user trappable" during indirect mode operation, which allows them to be intercepted by an error handler in the user program.

With "error trapping" enabled by an ON ERROR statement, no further action is automatically taken by MotionBASIC once the user trappable error is generated. This provides flexibility to take the appropriate action in the user configurable error handler.

In addition to being "user trappable": 1) Controller fault errors always disable the No Fault Relay. 2) During indirect mode operation, other errors generate the appropriate error code and stop motion related to the error using the DCL.ERR@ deceleration rate. 3) During direct mode operation, other errors generate the appropriate error code but do not stop motion. Pressing Ctrl-C at the MotionPRO development terminal does stop motion.

User Defined Errors

User defined errors are errors generated by the user with an ERROR statement. These errors may have any number (as defined by the user) but if the number corresponds to one of the standard ORMEC error codes, that error will be generated by MotionBASIC, and the appropriate action taken.

It is recommended that unique user generated errors use error numbers from 1 to 999 to prevent possible overlap with future releases of MotionBASIC.

User Defined Faults The block of numbers from 1900-1909 have been reserved to allow unique user generated controller fault errors. These controller faults are uniquely identified by the FAULT@ unit fault code variable.

-89- Syntax Errors

Code Error Message Code Error Message

#1000 Syntax error #1018 Expected comma or semicolon #1001 Invalid line number #1019 Expected semicolon #1002 Missing subscript #1020 Expected left paren #1003 Read-only variable #1021 Expected right paren #1004 MOVE syntax error #1022 Expected equal sign #1005 Error in data #1023 Expected GOTO #1006 Expected command #1024 Expected THEN #1007 Garbage after statement #1025 Expected TO #1008 Too many parameters #1026 Expected ON, OFF or STOP #1009 Not enough parameters #1027 Expected a numeric variable #1010 Expected expression #1028 Expected an EVENT input signal #1011 Expected user variable name #1029 GEAR syntax error #1012 Expected variable name #1031 Expected IN or AT to #1014 Expected a number specify gear ratio #1015 Expected line number or label #1032 Expected a string variable #1017 Expected comma

Syntax errors are caused by an incorrect, unexpected, or missing keyword, parameter, or delimiter. They are not caused by a value out of range or an incorrect variable type in an expression (see Expression Errors).

They can be fixed by modifying the line where the error occurred.

Note that non-trapped syntax errors will invoke the line editor with the cursor positioned at the point where the error was found.

Program Structure Errors

Code Error Message Code Error Message

#1101 Missing equal sign or #1116 Missing FIELD statement undefined line number/label #1117 Statement cannot be nested #1102 FOR without NEXT #1118 Statement not allowed inside a #1103 NEXT without FOR FOR loop #1104 GOSUB without RETURN #1105 RETURN without GOSUB #1106 WHILE without WEND #1107 WEND without WHILE #1108 ELSE/ELSEIF without IF-THEN block #1109 Missing ENDIF #1110 RESUME without error #1111 Out of data #1112 Excess data #1113 Function not found #1114 Duplicate definition #1115 Block structure must be the first statement

-90- Program Structure Errors

Program structure errors are caused by an unexpected or missing statement. They can be fixed by adding, deleting, or changing a line in the program other than where the error occurred, or by modifying or deleting the line where the error occurred.

Error #1114: Duplicate Definition

Description: Two DIM statements are given for the same array.

An array may not be redimensioned, unless it has first been deleted by means of an ERASE or CLEAR statement.

User Variables and array dimensions survive power cycles and hardware resets.

See: Program Initialization.

Expression Errors

Code Error Message Code Error Message

#1201 Illegal function call #1217 Function evaluation Error #1202 Numeric overflow #1218 Range error from INPUT @ high limit #1203 Subscript out of range #1219 Range error from INPUT @ low limit #1204 Division by zero #1220 Expected a positive number #1205 Type mismatch #1221 No such Ormec variable #1206 String too long #1222 Array not dimensioned #1207 String formula too complex #1224 Expected set #1208 Numeric underflow #1225 Invalid set element #1209 Invalid numeric operation #1226 Record length exceeded #1210 Precision error #1227 Invalid FIELD variable #1211 Integer division by zero #1212 Parameter out of range #1213 Expected string #1214 Expected integer #1215 Expected long #1216 Empty string

Expression errors are caused by a numeric or string value out of range, or an incorrect variable type. They can be fixed by changing the value or type of a variable or constant.

Note that non-trapped expression errors will invoke the line editor with the cursor positioned at the point where the error was found.

-91- I/O Errors Code Error Message

#1301 File not found #1302 Cannot create file #1303 Input past end #1304 Bad filename #1305 Direct statement in file #1306 Invalid baud rate #1307 Cannot open device/file #1308 Device/File already open #1309 Device not open #1310 Device write failed #1311 Cannot close device #1312 Device read failed #1313 Illegal Discrete I/O Statement #1314 Device not opened for writing #1315 Device not opened for reading #1316 EIO.MODE@ not set for PAMUX Code Error Message #1317 Timeout during AIO@ access #1318 Illegal analog I/O statement #1319 Invalid IO.MODE@ configuration #1320 IO.MODE@ for PAMUX is write only #1321 Too many timed DIO@ points active #1322 No Memory Disk installed #1324 Memory Disk is write protected #1325 Invalid path #1326 Disk full #1327 Memory Disk is not formatted properly #1328 File transfer aborted by MotionPRO #1329 File save failed #1330 Memory disk may contain data or MotionCARD in wrong slot #1331 Unable to FORMAT Memory Disk #1332 Memory Disk option is not supported #1333 MotionPRO/MotionBASIC failure #1334 Bad file mode Code Error Message #1335 Device seek failed #1336 ITM-270 Communications Failure #1337 Path/File Access Error #1338 Cannot open protected file #1339 Disk is full

I/O errors are caused by an error during an attempted I/O operation. They are not caused by a syntax error in an I/O statement (see Syntax Errors).

-92- Error #1305: Direct Statement in File

Description: A direct statement is encountered while loading an ASCII-format program file. The load is terminated.

If file line number support in MotionPRO is turned on, a program file that is to be loaded must contain line numbers. Otherwise this error will be generated.

Motion Errors

Code Error Message Reference

#1601 Velocity out of range SPD.MAX@ #1602 Accel or Decel out of range ACL.MAX@ DCL.MAX@ #1604 Illegal motion sequence #1606 Invalid axis ID axes #1607 Axis mode is incorrect MODE@ #1608 Fwd software travel limit OTL.FWD@ #1609 Rev software travel limit OTL.REV@ #1610 Illegal while DSP busy #1612 Specified Gear ratio is out of range #1614 Fwd hardware travel limit OTL.FWD@ #1615 Rev hardware travel limit OTL.REV@ #1616 DSP queue too full for REPEAT

Motion errors are caused by an error in a motion command.

Error #1601: Velocity Out of Range

Description: An attempt was made to perform a motion in which the specified velocity cannot be achieved.

Possible causes are:

• A velocity specified in a MOVE statement exceeds the current value of SPD.MAX@.

• The distance parameter in a MOVE FOR statement would be satisfied before the specified velocity is reached. Lower the velocity, use a different syntax, or do not specify velocity, to remedy this situation.

-93- Error #1602: Accel or Decel out of range

Description: An attempt was made to perform a motion in which the specified acceleration or deceleration cannot be achieved.

Possible causes are:

• An acceleration or deceleration specified in a motion statement exceeds the values for ACL.MAX@,orDCL.MAX@, respectively.

• An acceleration or deceleration specified in a motion statement is not appropriate with the other specified parameters of that motion statement.

Error #1610: Illegal While DSP Busy

Description: An attempt was made to set the actual position, POS.ACT@ while the DSP was busy. The DSP is busy when an accel or decel is being commanded, a GEAR is in effect, or there are motions waiting to execute in the motion queue.

System Errors

Code Error Message Reference

#1801 Out of memory #1802 Illegal direct #1803 Out of string space CLEAR #1804 Cannot continue #1805 Ctrl-C break detected #1806 Input buffer overflow EDIT #1807 Too many levels of nesting #1808 Illegal Indirect #1810 Program buffer write protected PW@ #1811 Token buffer overflow #1812 Illegal while FAULT@ is non-zero #1813 Illegal while ESTOP.OK@ is FALSE #1814 Illegal while AFAULT@ is non-zero #1815 MotionDATA not available #1816 Program buffer read protected

System errors are caused by a system limitation (i.e. memory), incorrect mode, etc.

-94- Error #1801: Out of Memory

Description: The user memory has been filled with no space remaining. Possible causes are:

• The program is simply too large to fit in the controller memory. This would occur during download of the program to the controller. See: Memory Conservation Techniques

• Too many variables and/or arrays are defined in the program and have consumed available memory. See: Memory Conservation Techniques

• The control stack has accumulated so much information that available memory has been filled. Usually due to repeated branching out of: a subroutine,aFOR...NEXT loop, or a WHILE...WEND loop. See: Structured Programming

• The control stack has overflowed due to an error handler routine’s failure to perform a STACK CLEAR when the program is designed to not RESUME at the location of the error occurrence.

Error #1802: Illegal Direct

Description: An attempt was made to execute a statement that is only legal in indirect mode.

Error #1804: Cannot Continue

Description: An attempt was made to continue a program that:

• has halted because of an error

• has been modified during a break in execution

• does not exist

See Also: CONT

-95- Error #1805: Ctrl-C Detected

Description: This error occurs when a Ctrl-C keystroke is read from the MotionPRO Development port.

MotionBASIC reacts differently to a Ctrl-C, depending on whether a program is running or not. If a CTRL-C is encountered when the controller is in Direct Mode, the following 4 steps are executed:

1. Clear the keyboard buffer 2. Bring motors to a controlled stop but leave them enabled 3. Clear all timed DIO@ Points. 4. Reset the screen COLOR to white on black

If a CTRL-C is encountered when the Model 40 is running a program, the following steps will be executed:

1. Clear the keyboard buffer 2. Do normal Non-Fault Error processing which consists of:

A) When an Error Handler routine IS NOT defined:

- Set the ERR value to the error code number - Bring motors to controlled stop but leave them enabled. - Clear all timed DIO@ Points - Turn on the Program Error LED - Reset the screen COLOR to White on Black - Print the error message - Return to Direct Mode

B) When an Error Handler routine IS defined:

- Set the ERR value to the error number - inhibit EVENT processing so the error handler runs "uninterrupted" - Start execution of the ON ERROR GOTO error handler. - (Note: When the RESUME is executed in the error handler routine, the EVENT processing will be re-enabled)

Error #1808: Illegal Indirect

Description: An attempt was made to execute a direct-only command, indirectly.

Error #1811: Token Buffer Overflow

Description: An attempt was made to download or enter a program line that when tokenized, overflows the 128 byte Token Buffer.

A line may be less than 128 characters, but is converted to tokens in MotionBASIC Storage. To remedy this error, shorten the program line.

-96- Error #1815: MotionDATA Not Available

Description: An attempt was made to turn on pacer input monitoring for an axis when pacer information was not available.

This could be due to cabling problems, configuration problems (MD.MODE@), or transmission problems with "up-stream" axes on the MotionDATA bus.

Example: Dual axis DSP Axis Modules control two axes, "Axis-A" and "Axis-B", which occupy two consecutive ascending axis numbers, e.g. axis 3 and 4.

Attempting to set up Axis-B to monitor the MotionDATA input when Axis-A is neither monitoring nor sourcing information, then a MotionDATA not available error will be generated on Axis-B.

Controller Fault Errors

Controller fault errors always result in the following fault action:

1. The green "NO FAULT" LED is turned OFF and the No Fault Relay is "dropped out"; if the fault is an Axis Fault, that axis is disabled; 2. the FAULT@ variable is set to the appropriate non-zero value; and 3. a user trappable error is generated as follows:

Code Error Message Code Error Message

#1900-09 User Defined Errors #1915 Incompatible MotionCARD Software #1910 E-Stop OK input open #1916 Not enough memory for MotionCARD #1911 Axis fault #1917 MotionCARD changed #1912 Internal error #1918 Missing MotionCARD #1913 DSP axis module failure #1919 Checksum Error #1914 String space corrupted #1998 * Watchdog timeout #1999 * Temporary power loss

* These controller faults suspend MotionBASIC processing with the fault

displayed on the System Status LEDs. The error code may be accessed with the ERR function ONLY after the unit is reset or has its power removed and restored.

-97- Status, Faults & Error Codes

MotionBASIC provides very complete status and fault information and fail safe operation for a wide variety of possible problems, which include:

Controller Fault Errors Problems with overall system operation

Error Codes Description of all MotionBASIC error codes

Axis Modes Modes of operation of individual axes

Axis Faults Faults of individual axes in the system

Servodrive Alarms Servodrive alarm codes for individual axes

System Status LEDs Description of System Status LEDs & Diagnostics Axis Module Failure

-98- System Status LEDs

There are 20 System Status LEDs on the front of Gen III controllers:

Status Indicator Color Status Indicator Color

Memory Fault Flashing Red MotionNET Alarm In Red Program Error Red MotionNET Alarm Out Red Power Fault Orange Sending MotionDATA Orange Servo Fault Orange Receiving MotionDATA Orange User 1 Green MotionDATA Active Green User 2 Green System Watchdog OK Flashing Green OK to Transmit Orange Loss of Feedback Orange Ready to Receive Orange MotionNET Talker Orange Sending Serial Red Sending MotionNET Red Receiving Serial Red Receiving MotionNET Red

Two other diagnostic status lights are found on the front of the controller, E-STOP OK and No Fault. See also: Controller Faults

Memory Fault - System Status LED

When the Memory Fault LED is flashing red it indicates one of the following faults:

Battery Failure if the Power Fault LED also lit,

RAM Checksum Error or String Space Corrupted if the Power Fault LED is NOT lit.

Program Error - System Status LED

When the Program Error LED is lit it indicates that MotionBASIC has issued a program error code which was not trapped by an error handler in the user program.

The error code that was issued can be determined from the MotionPRO serial port by accessing the ERR function.

-99- Power Fault - System Status LED

When the Power Fault LED is lit it indicates one of the following faults:

Battery Failure if the Memory Fault LED is flashing and the System Watchdog OK LED is flashing

Temporary Power Loss if the Memory Fault LED is NOT lit and the System Watchdog OK LED is NOT flashing

Servo Fault - System Status LED

When the Servo Fault LED is lit it indicates one of the following faults:

Axis Module Failure

Axis Fault

You can determine which of these faults occurred by checking the value of the FAULT@ variable.

User 1 & User 2 - System Status LEDs

These two green LEDs are provided for user indications. They are turned off and on under program control by writing values to USER1.LED@ and USER2.LED@.

User 1 LED also provides an important indication. It will flash during a powerup program load from a Memory Disk.

-100- Serial Port Status LEDs

The OK to Transmit, Ready to Receive, Sending Serial and Receiving Serial System Status LEDs are provided for to assist the customer in trouble- shooting any problems with the MotionPRO Serial Port.

OK to Transmit When lit, this serial port "handshake" line indicates that it is okay for the controller to transmit to the IBM-PC running MotionPRO. This LED will not be lit if the cable is disconnected!

Ready to Receive When lit, this serial port "handshake" line indicates that it is okay for the IBM-PC or compatible to transmit to the controller.

Sending Serial When lit, indicates that the controller is transmitting serial communications.

Receiving Serial When lit, indicates that the controller is receiving serial communications.

MotionNET Alarm System Status LED

These two red LEDs are unused in MotionBASIC version 2.1a and later.

In previous versions, they both were on when the RS-485, MotionNet port (SRL2), was OPENed.

-101- MotionDATA Communications Status LEDs

MotionDATA is a communications link for DSPs to share real-time motion information directly. It is a "non-bussed" RS-485 communications system which is connected in a "daisy chain" with modular 8-pin connectors and "line driver repeaters" on each unit.

The MotionDATA Active, Sending MotionDATA and Receiving MotionDATA System Status LEDs are provided for to assist the customer in troubleshooting any problems with MotionDATA communications.

MotionDATA Active When lit, this LED indicates that MotionDATA is "active". i.e. The controller is receiving input on its MotionDATA clock line input.

Sending MotionDATA When lit, indicates that the controller is transmitting MotionDATA communications.

Receiving MotionDATA When lit, indicates that the controller is receiving MotionDATA communications.

Watchdog Timer - System Watchdog OK Status LED

Generation III controllers contain a "Watchdog Timer" which is located on the motherboard. This hardware circuitry consists of a timer which is directly connected to the No Fault Relay and will de-energize it unless it is reset by the multi-tasking operating system every 20 milliseconds.

For normal system operation, the System Watchdog OK status LED will be flashing at a rate of about once per second.

If controller software fails to respond within the 20 milliseconds, a Watchdog Timeout fault occurs, the System Watchdog OK LED will not be flashing as usual, and all the local DIO@ outputs will be turned OFF.

If the normally-open contact of the No Fault Relay is interlocked with the servodrive Main Power as recommended in the "Installation & Operation Manual", then electromotive power will be removed from the servomotors if there is a firmware failure in the Generation III - Controller CPU.

-102- Loss of Feedback System Status LED

The "loss of feedback" LED indicates that an "open wire" exists in one of the quadrature channels of an axis encoder, or one of these feedback signals is out of specification. It will cause an Axis Fault which identifies the encoder channel with the "open wire" and disables operation if the axis is in axis control mode 1-5.

This valuable feature prevents loss of feedback from causing the servomotor to "run away" if one of the feedback wires breaks or is intermittent. It also guarantees overall system integrity and provides troubleshooting assistance for all pacer encoders attached to the motion control system.

MotionNET Communications Status LEDs

MotionNET is simply an RS-485 serial communications link used primarily for Operator Interface devices such as the MMI-840. Another popular use of this port is to connect multiple Gen III’s in a "daisy chain" using cables with modular 8-pin connectors, and establish information transfers using a serial factory communication network, such as that provided with Modbus MotionCARDs.

The MotionNET Talker, Sending MotionNET and Receiving MotionNET System Status LEDs are provided for to assist the customer in troubleshooting any problems with MotionNET communications.

MotionNET Talker When lit, this LED indicates that the Model 40 is operating as a MotionNET "talker". Sending MotionNET When lit, indicates that the Model 40 is transmitting MotionNET communications. Receiving MotionNET When lit, indicates that the Model 40 is receiving MotionNET communications.

Controller Faults

Controller faults occur when the controller diagnostics determine that there is a problem with: 1) the controller itself, 2) any of the DSP Axis Modules in it, 3) any of the servodrives or axis encoders attached, 4) the E-Stop OK input, or 5) the incoming power.

When a controller fault occurs, a MotionBASIC generates a controller fault error. With the exception of Watchdog Timeout and Power Fault, which suspend MotionBASIC processing, all other controller faults can be determined from the value of the FAULT@ variable.

-103- RAM Checksum Error

Each time the unit is "powered up" or "reset", the battery-backed non-volatile memory is tested by computing a checksum of the memory contents and comparing it with the former checksum.

If they are not equal, the red Memory Fault LED on the front of the controller will be flashing, a bit in the FAULT@ variable will be set and automatic powerup program execution will be inhibited.

The red reset button on the front of the unit will NOT clear this fault, since the program or data in battery-backed RAM is corrupted and is only corrected by re-loading the program or editing the corrupted version in the RAM. Therefore, to clear a "RAM Checksum Error", change the contents of the program buffer using LOAD, EDIT or NEW. All MotionBASIC variable values in battery-backed RAM will be lost.

To clear the fault condition and reset the No Fault Relay you must explicitly clear the FAULT@ variable.

Power Fault - Battery Failure

Each time the power is applied to the unit, there is a test of the lithium battery used to maintain information in the battery-backed RAM. If its voltage tests too low, • the Power Fault LED on the front of the unit will be lit; • the Memory Fault LED on the front of the unit will be flashing; • the System Watchdog OK LED will be blinking; • the FAULT@ variable will be non-zero and the No Fault Relay off, and • automatic powerup program execution will be inhibited.

As long as there is no RAM Checksum Error, pressing the red reset pushbutton on the front of the unit will clear this fault. This allows operation after powerup between time when the battery voltage tests low and the battery-backed RAM actually loses information during power-down.

If data is lost in the battery-backed RAM during power-down, the resulting RAM Checksum Error cannot be cleared by pressing the red reset pushbutton. Replace the battery promptly after the first battery failure error to prevent this loss of data during power-down.

-104- Invalid Unit Identification Code

The controllers unit identification code (UNIT ID) is set by rotary DIP switches under the right side of the front cover. This code is valid for values of 1 to 32, which establishes the controller’s unit number.

The Unit ID is also used to determine the axis numbers of servos interfaced to the controller via DSP Axis Modules. The sum of the Controller’s Unit ID, and the DSP Module’s Rotary Switch, determines the Axis number of the first axis on a module. These hardware switch settings are used on powerup to determine AXIS.LIST@.

If UNIT.ID@ is outside the range of 1-32, a fault will be generated and a bit in the FAULT@ variable will be set.

To correct the fault, you must set a valid unit identification code using the rotary switches near the Serial Port and either press the red reset button on the front of the unit or cycle the power.

Error #1910: E-STOP OK Input Open

Gen III controllers include a 24 VDC E-STOP input which is annunciated with a green E-STOP OK LED on the front panel. The ESTOP.OK@ variable contains the real-time status of the input and is true when the LED is ON. For normal operation, this Emergency Stop input must be shorted to the internal +24 VDC supply, allowing 5 mA of current to flow in the E-STOP input’s optically coupled isolator. Should that current be interrupted, the E-STOP OK LED on the front panel will go off and the ESTOP.OK@ variable will be false causing a controller fault error.

After an E-Stop has occurred, the FAULT@ variable can be cleared independent of the state of the E-STOP OK input. However, the No Fault Relay will not be enabled until both FAULT@=0 AND the E-Stop OK input is asserted.

Please note that for errors which occur asynchronous to program operation, such as Axis Faults and Overtravel Limits or E-Stop, only the first occurrence will report a user trappable error. Additional reporting of these errors must be re-enabled with a FAULT@=0 statement.

-105- Error #1911: Axis Fault

An axis (servo) fault is one of several fault conditions detected by a DSP Servo Axis Module, and reported by the AFAULT@ variable. When an axis fault occurs, MotionBASIC issues a controller fault error, which disables the problem axis by setting its MODE@ to zero. The AFAULT@ and/or ALARM@ variables are latched to indicate the cause of the fault. The Servo Fault LED on the front of the unit will be lit and the No Fault Relay will be "dropped out". The AFAULT@, ALARM@, AXIS.FAULT@, AXIS.FLT1@ and FAULT@ variables are set appropriately.

The statement AFAULT@ = 0 will attempt to clear the fault, but if the fault condition persists, AFAULT@ will remain non-zero. To enable the No Fault Relay after an axis fault condition is cleared, FAULT@ must be explicitly cleared to 0 and ESTOP.OK@ must be TRUE.

Please note that for errors which occur asynchronous to program operation, such as Axis Faults and Overtravel Limits or E-Stop, only the first occurrence will report a user trappable error. Additional reporting of these errors must be re-enabled with a FAULT@=0 statement.

Servodrive Alarm - Servo Fault

A servodrive alarm condition is detected when an axis is in Mode 2-5 and current is interrupted in the NO-ALARM’ optically coupled input circuit at the DSP Axis Interface Connector (pin 23).

Unless NO-ALARM’ is asserted, the ALARM@ variable will have a value of 10 or more. The lower digit of the ALARM@ variable indicates the state of the three alarm code inputs AL03’-AL01’ (pins 24-26).

ALARM@ AL03’ AL02’ AL01’ 0or10 ---value with no Axis Connector attached 1or11--I 2or12-I-TheI’sindicate current present in 3or13-IItheinput circuit, which will be true 4or14I--when the voltage at these connectors 5or15I-Iis4-25 volts lower than the V+ voltage 6or16II-supplied at pin 22 of the Axis 7or17IIIInterface Connector. Codes 0-7 are informational only and do not indicate an alarm condition.

-106- Position Command Overspeed - Servo Fault

This fault occurs when the position command at any servo loop update exceeds the maximum allowed speed for the axis as defined by MTR.SPD.LIM@ and CNT.REV@.

It can be caused in a number of ways, including:

•aGEAR motion on a follower axis which is at too high a ratio for the received MotionDATA pacer information.

•aGEAR FOR or MOVE statement superimposing too fast a motion on a "constant ratio" GEAR AT command

• making large instantaneous position changes using the DIST.BIAS@ variable.

Pacer Overspeed - Servo Fault

This fault occurs when the MotionDATA pacer information for a servo axis exceeds the maximum speed defined by the combination of the PCR.SPD.LIM@ and the PCT.REV@ variables.

Axis Encoder Overspeed - Servo Fault

This fault occurs when the axis encoder information for a servo axis exceeds the maximum speed defined by the combination of the MTR.SPD.LIM@ and the CNT.REV@ variables.

MotionDATA Error - Axis Fault

This fault occurs when the error-correction scheme for MotionDATA Communications fails to resolve a communications error.

MotionDATA communications error correction is done using a "voting" method, which compares three sets of received data. As long as two of the sets of data are identical, the system continues to operate. If all three sets of data are unique, then a MotionDATA communications axis fault is generated.

-107- Missing MotionDATA Communications - Servo Fault

This fault occurs when an axis performs a motion synchronized to MotionDATA and a packet of MotionDATA communications is not received at the DSP Axis Module MotionDATA Interface.

It can be generated by a broken wire or a missing MotionDATA communications cable.

See also: MotionDATA not available pacer follower Electronic Gearing

DSP Software Faults - Servo Fault

These faults occur when there is a software fault detected in the DSP software. If a DSP Software Fault occurs, please note its number and call ORMEC Service to report it.

Error #1912: Internal Error

An internal error is generated if at any time the software has found an internal malfunction of the Gen III Unit. The System Status LED, System Watchdog OK will not flash and the system will be "locked up".

If your controller develops an internal error, it is imperative that you call ORMEC Service to report this occurrence.

It is also advised that a "snapshot" of system memory be extracted from the unit while it is in this failure state. The "snapshot" of the failed state of the controller AT THIS TIME is important for problem analysis, especially if this occurrence is not easily repeatable.

This "snapshot" is called a memory dump during which the contents of the controller’s memory is transmitted out of the RS-232 Serial Port to a file on the PC running MotionPRO.

See Also: Memory Dump

-108- Memory Dump

A memory dump is the process by which the contents of a failed Gen III Controller’s memory is transmitted out of the RS-232 Serial Port to a file on a PC running MotionPRO. The file, MBDUMP.BIN, can be copied to diskette and sent to Ormec Service for evaluation. To perform a memory dump:

1) Turn Controller Power OFF.

2) Connect the controller to a computer running MotionPRO and use to set the communication baud rate of MotionPRO to 9600 baud. Press to clear any error messages and put MotionPRO in "Talk mode".

3) Press and hold both the Red Reset and the Black PB1 Pushbuttons. While holding them both, turn Controller Power ON.

4) The memory dump should commence and its progress shown on the PC screen. The buttons may be released once the dump has begun.

5) After completion, turn power OFF then back ON to reset the Gen III unit.

Error #1913: DSP Axis Module Failure

An axis module failure controller fault is generated if the powerup diagnostics of the DSP board fail or MotionBASIC detects a failure in the shared memory.

When this error is detected, the Servo Fault LED on the front of the unit will be lit. The fault will be reported in the "sign on message" when communications is established at the MotionPRO serial port. Also, the axis identification codes for that DSP Axis Module will not appear in the AXIS.LIST@ variable.

This failure is distinguished from an Axis Fault because axis faults are diagnosed by the DSP Axis Module and the fault identification code for them (AFAULT@) is stored in its shared memory.

Call ORMEC Service to return the DSP Axis Module for repair.

Error #1914: String Space Corrupted

A string space corrupted error is generated if at any time the software discovers an error in the memory used to store and retrieve strings.

If your controller develops a string space corrupted error, call ORMEC Service.

You can clear this fault by pressing the red reset button or cycling the power.

-109- Error #1915: Incompatible MotionCARD Software

A MotionCARD Fault that indicates that the MotionCARD installed in the controller will not operate with the version of MotionBASIC installed in the controller.

One or the other must be changed to a compatible version.

A power cycle will be required to clear the error.

Error #1916: Not Enough Memory for MotionCARD

A MotionCARD Fault that indicates that the MotionCARD installed in the controller cannot operate with the current utilization of non-volatile memory.

There must be a minimum amount of space available in the User Comment space bank. The amount required will vary for different MotionCARD types. This error indicates that the user needs to change some program comments to be disk comments to free up more of this memory.

To clear this fault, you must:

1) Enable writing to the program buffer (PW@) 2) Execute the NEW command 3) Reset the controller fault variable. FAULT@=OFF

MotionCARD Fault

A MotionCARD fault is generated if at any time the software discovers a problem with the MotionCARD. Which particular problem exists with the MotionCARD would be detailed in the reported Controller Fault Error.

To clear these faults, you must:

1) Enable writing to the program buffer (PW@) 2) Execute the NEW command 3) Reset the controller fault variable. FAULT@=OFF

-110- Error #1919: Checksum Error

This controller fault error is generated when the user attempts to SAVE or LIST to a disk file, the contents of the controllers program buffer while a RAM Checksum Error exists.

To copy the contents of a program buffer with a checksum error into a disk file, use MotionPRO’s "Capture" facility, as follows.

1) From the File Menu of MotionPRO, select the option "Capture".

2) Create a unique filename for the capture file. Do not use the same name as the source file. The source should be preserved, and not overwritten by a copy that has a checksum error associated with it.

3) With capture active, all text displayed to the screen is also placed into the capture file. Therefore, LIST to the screen, those portions of the program buffer that you wish to save to a disk file.

4) From the File Menu of MotionPRO, close the capture file.

Error #1998: Watchdog Timeout

A Generation III controller’s watchdog timer circuit must be reset every 20 milliseconds by the multi-tasking operating system software for the unit to continue normal operation. In addition, the multi-tasker requires that MotionBASIC respond to it every 100 milliseconds. If either of these events are ever missed, a Watchdog Timeout Controller Fault error will occur.

When this error occurs, the flashing green System Watchdog OK LED on the front of the controller will NOT flash every second as it normally does. Controller operation is completely suspended and local DIO@ outputs are turned OFF.

A watchdog timeout is cleared by either pressing the red reset pushbutton on the front of the controller or cycling power. After this is done, operation should proceed normally, with the exception that the ERR variable will be initially set to 1998 instead of 0.

If the problem recurs or does not clear, call ORMEC Service.

-111- Error #1999: Temporary Power Loss

Generation III controllers have circuitry which senses loss of incoming AC power before the +5 VDC computer power goes below specification. When incoming AC power loss is detected: • the Power Fault LED is turned on; • the System Watchdog OK light is not blinking; and • all processing by the main CPU is suspended.

If the +5 VDC computer power supply goes below specification or power is cycled off and back on, then the CPU will be reset normally when +5 VDC power is restored and ERR will be set to 0.

If AC power is restored before the +5 VDC computer power supply goes out of specification, the unit will be inoperative with the Power Fault light on, the System Watchdog OK light off and ERR=1999.

This Temporary Power Loss fault may be cleared by pressing the red reset pushbutton on the front of the unit. Operation should proceed normally, with the exception that the ERR variable will be initially set to 1999.

No Fault Relay - No Fault LED

Generation III controllers have a "No Fault Relay" which is located on the I/O board on the front of the unit. This electro-mechanical relay has a 24 VDC coil which is powered by the internal 24 VDC power supply, and an isolated "normally-open" output contact.

As long as there is no fault condition in the unit, as defined by the bits in the FAULT@ variable and ESTOP.OK@ is TRUE, the No Fault Relay coil will be energized, holding the "normally-open" output contact closed. The green NO FAULT LED will be lit when and only when the relay coil is energized. The power to the No Fault Relay coil is also hardware interlocked with both the E-STOP input as well as the Watchdog Timer circuitry.

The fully isolated contact output is available to the user, and it is recommended that it be interlocked with the servodrive Main Power, which provides electromotive power to the servomotors. To re-energize this relay after a fault, ESTOP.OK@ must be TRUE and the FAULT@ variable must be explicitly cleared. These two conditions may be met in either order.

-112- Troubleshooting and ORMEC Service

The System Status LEDs are designed to provide overview troubleshooting capabilities without the necessity for instrumentation.

MotionBASIC also provides the ability to easily build extensive error handling capabilities into your motion control application program with the ON ERROR statement and Error Codes, as well as the pre-defined Unit Fault and Axis Fault variables.

The Error Codes, along with the Unit Fault and Axis Fault variables can also assist you in troubleshooting your motion control system interactively from the Serial Port using MotionPRO on an IBM-PC or compatible.

If you are having trouble communicating with your motion controller from MotionPRO, consult the Development Communications section.

If you can’t resolve your problem, or need to return equipment for repair, please call our Service Department at 716-385-3520.

Development Communications

Generation III controllers provide development communications through an RS-232 serial port. To communicate, an IBM-PC or clone must run MotionPRO development software. Four Serial Port Status LEDs are provided to simplify troubleshooting these communications. Communications with a PC are full-duplex and use hardware handshaking.

Fast PC clones running MotionPRO can communicate with a Gen III controller at up to 38,400 baud. Slower PCs, or PCs running certain TSRs, will not be able to communicate reliably as fast. This will be detected by an excessive number of "retrys" during a LOAD, SAVE or MERGE, or the receipt of "error characters" ( ) during commands such as LIST or EDIT.

In this case, lower the communications baud rate using the F7 Function Key in MotionPRO. If communications are not established automatically, either press the red reset button on the front of the unit or cycle the power, and then press the Enter key a few times.

Serial Port Hardware Handshaking

"Hardware handshaking" is a method for the controller or the PC running MotionPRO to temporarily suspend incoming serial communications from the other device. The hardware signals used are OK to Transmit from the IBM-PC and Ready to Receive from the controller, which have their status indicated by the System Status LEDs.

These status LEDs should generally be lit for communications to take place, and should be off only temporarily during active communications.

-113- Full-Duplex Serial Communications

When using MotionPRO in "talk mode", pressing a key on the PC keyboard causes the PC to transmit a character to the controller, which in turn "echoes" that character to the screen of the PC. This communications can be observed as flashes on the Receiving Serial and Sending Serial System Status LEDs.

-114- ASCII TABLE Page 1

Dec Hex Char Code Dec Hex Char Code Dec Hex Char Dec Hex Char

0 00h NUL 16 10h DLE 32 20h 48 30h 0 1 01h SOH 17 11h DC1 33 21h ! 49 31h 1 2 02h STX 18 12h DC2 34 22h " 50 32h 2 3 03h ♥ ETX 19 13h DC3 35 23h # 51 33h 3 4 04h ♦ EOT 20 14h ¶ DC4 36 24h $ 52 34h 4 5 05h ♣ ENQ 21 15h § NAK 37 25h % 53 35h 5 6 06h ♠ ACK 22 16h SYN 38 26h & 54 36h 6 7 07h • BEL 23 17h ETB 39 27h ’ 55 37h 7 8 08h BS 24 18h ↑ CAN 40 28h ( 56 38h 8 9 09h HT 25 19h ↓ EM 41 29h ) 57 39h 9 10 0Ah LF 26 1Ah → SUB 42 2Ah * 58 3Ah : 11 0Bh VT 27 1Bh ← ESC 43 2Bh + 59 3Bh ; 12 0Ch FF 28 1Ch FS 44 2Ch , 60 3Ch < 13 0Dh CR 29 1Dh ↔ GS 45 2Dh - 61 3Dh = 14 0Eh SO 30 1Eh RS 46 2Eh . 62 3Eh > 15 0Fh SI 31 1Fh US 47 2Fh / 63 3Fh ?

Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char

64 40h @ 80 50h P 96 60h ‘ 112 70h p 65 41h A 81 51h Q 97 61h a 113 71h q 66 42h B 82 52h R 98 62h b 114 72h r 67 43h C 83 53h S 99 63h c 115 73h s 68 44h D 84 54h T 100 64h d 116 74h t 69 45h E 85 55h U 101 65h e 117 75h u 70 46h F 86 56h V 102 66h f 118 76h v 71 47h G 87 57h W 103 67h g 119 77h w 72 48h H 88 58h X 104 68h h 120 78h x 73 49h I 89 59h Y 105 69h i 121 79h y 74 4Ah J 90 5Ah Z 106 6Ah j 122 7Ah z 75 4Bh K 91 5Bh [ 107 6Bh k 123 7Bh { 76 4Ch L 92 5Ch \ 108 6Ch l 124 7Ch | 77 4Dh M 93 5Dh ] 109 6Dh m 125 7Dh } 78 4Eh N 94 5Eh ^ 110 6Eh n 126 7Eh ~ 79 4Fh O 95 5Fh _ 111 6Fh o 127 7Fh

-115- ASCII TABLE Page 1

Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char

128 80h Ç 144 90h É 160 A0h á 176 B0h 129 81h ü 145 91h æ 161 A1h í 177 B1h 130 82h é 146 92h Æ 162 A2h ó 178 B2h 131 83h â 147 93h ô 163 A3h ú 179 B3h 132 84h ä 148 94h ö 164 A4h ñ 180 B4h 133 85h à 149 95h ò 165 A5h Ñ 181 B5h 134 86h å 150 96h û 166 A6h ª 182 B6h 135 87h ç 151 97h ù 167 A7h º 183 B7h 136 88h ú 152 98h 168 A8h ¿ 184 B8h 137 89h ë 153 99h Ö 169 A9h 185 B9h 138 8Ah è 154 9Ah Ü 170 AAh ¬ 186 BAh 139 8Bh ï 155 9Bh ¢ 171 ABh ½ 187 BBh 140 8Ch î 156 9Ch £ 172 ACh ¼ 188 BCh 141 8Dh ì 157 9Dh ¥ 173 ADh ¡ 189 BDh 142 8Eh Ä 158 9Eh 174 AEh « 190 BEh 143 8Fh Å 159 9Fh ƒ 175 AFh » 191 BFh

Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char

192 C0h 208 D0h 224 E0h α 240 F0h ≡ 193 C1h 209 D1h 225 E1h ß 241 F1h ± 194 C2h 210 D2h 226 E2h Γ 242 F2h ≥ 195 C3h 211 D3h 227 E3h π 243 F3h ≤ 196 C4h 212 D4h 228 E4h Σ 244 F4h ⌠ 197 C5h 213 D5h 229 E5h σ 245 F5h ⌡ 198 C6h 214 D6h 230 E6h µ 246 F6h ÷ 199 C7h 215 D7h 231 E7h τ 247 F7h ≈ 200 C8h 216 D8h 232 E8h Φ 248 F8h ° 201 C9h 217 D9h 233 E9h Θ 249 F9h 202 CAh 218 DAh 234 EAh Ω 250 FAh 203 CBh 219 DBh 235 EBh δ 251 FBh √ 204 CCh 220 DCh 236 ECh ∞ 252 FCh 205 CDh 221 DDh 237 EDh φ 253 FDh ² 206 CEh 222 DEh 238 EEh ε 254 FEh 207 CFh 223 DFh 239 EFh ∩ 255 FFh

-116- Non-printing ASCII Codes

The BEL, BS, LF & CR ASCII codes will not print to either an Operator Interface Terminal (OIT) or the MotionPRO screen because they are used to perform the screen functions shown below.

Code Screen Function Description

BEL Bell Ring the "bell" of the device BS Backspace Move the cursor one space to the left LF Linefeed Move the cursor down one line CR Carriage Return Move the cursor to the beginning of a line

The (HT) will print to the OIT but not to the MotionPRO screen because it performs the screen function below.

Code MotionPRO Function Description

HT Horizontal Tab Move the cursor to next tab column (8-space)

The ← (Esc) Escape Character will initiate an "ANSI standard Escape sequence" only if it is followed by one of the following characters:

[ Control Sequence Introducer _ Applications Program Command Introducer \ String Terminator

Otherwise it will print out as a left arrow, "←".

-117- MotionBASIC Key Table Keys with several MotionBASIC uses.

Key INKEY$ Fncode KEY (n) EXITKEY INPUT @ Effect

ESC CHR$(27) 32 Unchanged ENTER CHR$(13) 0 Changed F1 CHR$(0)+CHR$(59) 59 1 1 " F2 CHR$(0)+CHR$(60) 60 2 2 " F3 CHR$(0)+CHR$(61) 61 3 3 " F4 CHR$(0)+CHR$(62) 62 4 4 " F5 CHR$(0)+CHR$(63) 63 5 5 " F6 CHR$(0)+CHR$(64) 64 6 6 " F7 CHR$(0)+CHR$(65) 65 7 7 " F8 CHR$(0)+CHR$(66) 66 8 8 " F9 CHR$(0)+CHR$(67) 67 9 9 " F10 CHR$(0)+CHR$(68) 68 10 10 " ↑ CHR$(0)+CHR$(72) 11 11 " ← CHR$(0)+CHR$(75) 12 12 " → CHR$(0)+CHR$(77) 13 13 " ↓ CHR$(0)+CHR$(80) 14 14 "

Keyboard Scan Codes See: INKEY$

Key Scancode Key Scancode Key Scancode

F1 59 ↓ 80 Ctrl F3 96 F2 60 PgDn 81 Ctrl F4 97 F3 61 Ins 82 Ctrl F5 98 F4 62 Del 83 Ctrl F6 99 F5 63 Shift F1 84 Ctrl F7 100 F6 64 Shift F2 85 Ctrl F8 101 F7 65 Shift F3 86 Ctrl F9 102 F8 66 Shift F4 87 Ctrl F10 103 F9 67 Shift F5 88 Ctrl Home 119 F10 68 Shift F6 89 Ctrl PgUp 132 Home 71 Shift F7 90 Ctrl ← 115 ↑ 72 Shift F8 91 Ctrl → 116 PgUp 73 Shift F9 92 Ctrl End 117 ← 75 Shift F10 93 Ctrl PgDn 118 → 77 Ctrl F1 94 Ctrl 2 3 End 79 Ctrl F2 95 Alt 1 120

-118- Keyboard Scan Codes See: INKEY$

Key Scancode Key Scancode Key Scancode

Alt 2 121 Alt y 21 Alt c 46 Alt 3 122 Alt u 22 Alt v 47 Alt 4 123 Alt i 23 Alt b 48 Alt 5 124 Alt o 24 Alt n 49 Alt 6 125 Alt p 25 Alt m 50 Alt 7 126 Alt a 30 Alt F1 104 Alt 8 127 Alt s 31 Alt F2 105 Alt 9 128 Alt d 32 Alt F3 106 Alt 0 129 Alt f 33 Alt F4 107 Alt - 130 Alt g 34 Alt F5 108 Alt = 131 Alt h 35 Alt F6 109 Alt q 16 Alt j 36 Alt F7 110 Alt w 17 Alt k 37 Alt F8 111 Alt e 18 Alt l 38 Alt F9 112 Alt r 19 Alt z 44 Alt F10 113 Alt t 20 Alt x 45

MotionBASIC Keywords & Statements

+ AIN1@ AXIS.SET@ CONT - AIN2@ AXIS.VAR@ COS * AIO@ BAUD@ CSRLIN / ALARM@ BIN$ CW.FWD@ \ AND BREAK DATA ^ AS BSEN@ DATE$ < ASC BY DCL.ERR@ <= ASEN@ BYE DCL.LAST@ <> AT CHAIN DCL.MAX@ = AT.REST@ CHDIR DEF > AT.SPD@ CHR$ DEF FN >= ATN CLEAR DEF SEG ABS AUTO CLG DEFDBL ACL.CMD@ AUTOLOAD.BAS CLOSE DEFINT ACL.LAST@ AXIS.FAULT@ CLREOL DEFLNG ACL.MAX@ AXIS.FLT1@ CLS DEFSET AFAULT@ AXIS.LIST@ CNT.REV@ DEFSNG AFTER AXIS.OTL@ COLOR DEFSTR

-119- MotionBASIC Keywords & Statements

DELAY.DIST@ ELS1.LOW@ EVENT HEX$ DELAY@ ELS2@ EXITKEY HTL.FWD@ DELETE ELS2.HIGH@ EXP HTL.REV@ DIM ELS2.LOW@ FALSE IF DIO@ ELS3@ FAULT@ IN DIST.BIAS@ ELS3.HIGH@ FIELD IN.ACL@ DIST.GEAR@ ELS3.LOW@ FILES IN.DCL@ DIST.GRAT@ ELSE FIX IN.MOT@ DIST.MOVE@ ELSEIF FN IN.POS@ DSP.CTR@ END FOR INERTIA@ DSP.DONE@ ENDIF FORMAT INKEY$ DRV.CMD@ EOF FRE INP DRV.MAX@ ERASE GEAR INPUT DUMP ERL GEAR.RATIO@ INPUT # EDIT ERR GET INPUT @ EIO.MODE@ ERR$ GOSUB INPUT$ ELS1@ ERROR GOTO INPW ELS1.HIGH@ ESTOP.OK@ HALT INSPD.MUL@

INSTR LIST MTR.SPD.LIM@ OUT INT LOAD NAME OUTSPD.MUL@ IOCTL LOC NEW OUTW IO.MODE@ LOCATE NEW RESTORE PB1@ KAF@ LOF NEXT PB1LOAD.BAS KEY LOG NOT PCR.SPD.LIM@ KEY (n) LOOP.RATE@ OCT$ PCT.REV@ KILL LSET OFF PEEK KP@ MBVER$ ON PEEKW KPI@ MD.MODE@ ON ERROR PERR.INPOS@ KVF@ MERGE ON EVENT PERR.MAX@ KVH@ MID$ ON KEY PERR.NORM@ KVHA@ MKDIR ON...GOSUB PG.LEN@ KVI@ MOD ON...GOTO POKE LCASE$ MODE@ OPEN POKEW LEFT$ MOVE OR POS LEN MP.CONFIG OTL.FWD@ POS.ABS@ LET MTR.ACL.LIM@ OTL.REV@ POS.ACT@

POS.ASEN@ RENUM SPD.MAX@ TRACE POS.BSEN@ REPEAT SQR TRACE VAL POS.CMD@ RESTORE STACK TRQ.GAIN@ POS.DELAY@ RESUME STEP TRUE POS.DIV@ RETURN STL.FWD@ UCASE$ POS.ERR@ RIGHT$ STL.REV@ UNIT.ID@ POS.MOD@ RMDIR STOP UNTIL POS.MUL@ RND STR$ USER1.LED@ POS.ZREF@ RSET STRING$ USER2.LED@ PPS.DIV@ RUN SYSTEM USING PPS.MUL@ SAVE TAB USR.ACL.LIM@ PRINT SCURVE@ TALK USR.SPD.LIM@ PRINT # SEG TAN VAL PUT SENS.MODE@ THEN VEL.ACT@ PW@ SGN TIME$ VEL.CMD@ RANDOMIZE SIN TIME.MUL@ VEL.GAIN@ READ SPACE$ TIMER VEL.LAST@ REM SPC TO VLTC@

-120- MotionBASIC Keywords & Statements

WAIT WEND WHILE WITHIN WIDTH XOR ZREF@

-121- ’ Comment Statement

Purpose: Adds explanatory text to a program listing. See also ’’.

Syntax:’[remark]

remark Commentary text, ignored by MotionBASIC.

MotionBASIC does not execute comments, but a program may branch to a statement beginning with ’. Program operation continues with the first executable statement thereafter.

An ’ can also be used to add a comment at the end of any program line, which REM cannot. MotionBASIC will ignore everything from the ’ character to the end of the line.

Note that the first 20K bytes of comments are stored in a separate section of the memory map, so that they reduce the 60K bytes used for program and variable storage by only three characters per comment. Note also that characters which appear consecutively more than three times

are stored in compressed format to minimize storage requirements. e.g. ’------will take only six bytes of comment space.

Example: 10 A=100 ’Set the initial acceleration 20 V=48 ’Set the initial velocity 30 PRINT "A=";A;" V=";V ’Display the acceleration & velocity 40 END RUN A=100 V=48

See Also: ’’, Disk Comment, REM

-122- ’’ Disk Comment Directive

Purpose: Add explanatory text to a program listing in a program file that will not be downloaded by MotionPRO.

Syntax: ’’[remark]

remark Commentary text, eliminated by MotionPRO during LOAD.

This MotionPRO directive allows the user to edit program files with the text editor which contain block comments which will be stored on disk but not downloaded to the Motion Controller. This allows lengthy block comments in source code that will not require Motion Controller memory.

Note that these comments are "lost" during download, and so a programming discipline must be followed if changes are made directly to the Motion Controller’s non-volatile memory with the line editor.

See also: ’

’!AUTO Automatic Line Numbering Directive Directive

Purpose: Activate a specific line numbering sequence when downloading a program file without line numbers.

Syntax: ’!AUTO [startline][,[increment][,maxline]]

startline The starting line number or a label defining the starting line number. See PW@ for the default values.

increment The interval between line numbers. Defaults to 10.

maxline The maximum line number allowed. See PW@.

This directive allows the user to have program files without line numbers which will be automatically located in a specific set of line numbers when LOADed to the controller or transferred to Memory Disk.

See also: AUTO

-123- ’!DEFINE Conditional Loading Symbol Definition Directive

Purpose: Define a symbol used for conditional loading in a program file.

Syntax: ’!DEFINE symbol

symbol The symbol name to define. Symbol names may contain the same characters as variable names, and may be 32 characters long.

Symbols defined in the loading program file are also defined for all included files. See: ’!INCLUDE

See Also: ’!UNDEF ’!IFDEF ’!IFNDEF

’!IFDEF / ’!IFNDEF Conditional Loading Block Construct Directive

Purpose: Conditionally load a section of the program file if a symbol is previously defined (or not defined).

Syntax: ’!IFDEF symbol ’!IFNDEF symbol [statements] [statements] [’!ELSE] [’!ELSE] [statements] [statements] ’!ENDIF ’!ENDIF

symbol The symbol name to check for its definition state. statements One or more code lines (may contain MotionPRO directives).

IFDEF is TRUE if the symbol is defined. IFNDEF is TRUE if the symbol is not defined.

IF[N]DEF...ELSE...ENDIF structures can be nested any number of times.

See also: ’!DEFINE ’!UNDEF

-124- ’!INCLUDE Include File Directive Directive

Purpose: Include a specific program file when downloading with MotionPRO. This allows a program file to "retrieve" other program files.

Syntax 1: ’!INCLUDE "[path]filename"[,startline [,increment [,maxline]]] Syntax 2: ’!INCLUDE "[path]filename",AUTO OFF

path The DOS path to the file to be included.

filename Name of the program file to be retrieved

startline Number defining the starting line number. See PW@ Disables ’!AUTO directives in the included file.

increment Interval between line numbers. Default:10 or last increment.

maxline The maximum line number allowed. See PW@.

AUTO OFF Disable ’!AUTO directives in the included file

’!UNDEF Conditional Loading Symbol Delete Directive

Purpose: Undefine a symbol that was previously defined by ’!DEFINE.

Syntax: ’!UNDEF symbol

symbol The symbol name to undefine.

See Also: ’!DEFINE ’!IFDEF ’!IFNDEF

* Multiplication or Set Intersection Operator

Purpose: Perform multiplication, or set intersection.

Usage1: exp1 * exp2 Multiplication

Usage2: set1 * set2 Set Intersection

exp1, exp2 Numeric expressions which represent the two values to multiply.

set1, set2 Set expressions. The result of the intersection is the set composed of elements which are in both set1 and set2.

If the expression involves operands of more than one precision, all operands are converted to the level of the highest precision operand in the expression before the expression is evaluated.

See also: +-/\MOD^Precedence

-125- + Addition, Concatenation, or Set Union Operator

Purpose: Perform addition, string concatenation, or set union.

Usage1: exp1 + exp2 Addition

Usage2: str1 + str2 String Concatenation

Usage3: set1 + set2 Set Union

exp1, exp2 Numeric expressions which represent the two values to add.

str1, str2 String expressions. The result of the concatenation is a string composed of str1 followed by str2.

set1, set2 Set expressions. The result of the union is the set of all elements which are in either set1 and set2.

If the expression involves numeric operands of more than one precision, all operands are converted to level of the highest-precision operand in the expression before the expression is evaluated.

See also: -*/\MOD^Precedence Garbage Collection

- Subtraction, Negation, or Set Difference Operator

Purpose: Perform subtraction, negation, or set difference.

Usage1: exp1 - exp2 Subtraction

Usage2: - exp Negation (unary)

Usage3: set1 - set2 Set Difference

exp1, exp2 Numeric expressions which represent the two values to subtract.

exp A numeric expression which represents the number to negate (reverse the sign of).

set1, set2 Set expressions. The result is the set of all elements in set1 that are not elements in set2.

If the expression involves operands of more than one precision, all operands are converted to the level of the highest-precision operand in the expression before the expression is evaluated.

See also: +*/\MOD^Precedence Differences

-126- < Less than or Set Membership Operator

Purpose: Perform a "less than" relational comparison, or a set membership.

Usage1: exp1 < exp2 Less Than

Usage2: set1 < set2 Set Membership

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is less than that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expressions. If set2 has all the elements in set1 and set1 is not equal to set2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

In IF statements, BASIC regards 0 as equivalent to FALSE and all non-zero values as equivalent to TRUE.

If the operands are string expressions, BASIC compares the ASCII values of the first character in each expression. If the first characters have the same ASCII value, BASIC then compares the second characters, and so on. If one string terminates before the other, and the characters in each string are identical to that point, the shorter string is considered "less" than the longer one.

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

See also: = <> > <= >= WITHIN Precedence

Example: 10 A=20: B=21 30 IF A < B THEN PRINT "A is less than B" 40 END RUN A is less than B

-127- <= Less than or Equal to, or Set Membership Operator

Purpose: Perform a "less than or equal to" relational comparison, or set membership.

Usage1: exp1 <= exp2 Less Than or Equal

Usage2: set1 <= set2 Set Membership

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is less than or equal to that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expressions. If set2 has all the elements in set1, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

In IF statements, BASIC regards 0 as equivalent to FALSE and all non-zero values as equivalent to TRUE.

If the operands are string expressions, BASIC compares the ASCII values of the first character in each expression. If the first characters have the same ASCII value, BASIC then compares the second characters, and so on. If one string terminates before the other, and the characters in each string are identical to that point, the shorter string is considered "less" than the longer one.

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

See also: =<><>>=WITHIN Precedence

Example: 10 IF A <= B THEN PRINT "A is less than or equal to B"

<> Not Equal to Operator

Purpose: Perform a "not equal to" relational comparison.

Usage1: exp1 <> exp2 Not Equal To

Usage2: set1 <> set2 Set Membership

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is not equal to that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expressions. If set1 is not identical to set2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

In IF statements, BASIC regards 0 as equivalent to FALSE and all non-zero values as equivalent to TRUE.

-128- <> Not Equal to Operator

If the operands are string expressions, BASIC compares the ASCII values of the first character in each expression. If the first characters have the same ASCII value, BASIC then compares the second characters, and so on. If one string terminates before the other, and the characters in each string are identical to that point, the shorter string is considered "less" than the longer one.

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

It is not good programming style to use single or double precision floating point variables with the <> operator. A comparison may fail because of the inexactness of the numeric representation.

See also: =<><=>=WITHIN Precedence

Example: 10 IF A <> B THEN PRINT "A is not equal to B"

= Assignment or Equal Operator

Purpose: Assign the result of an expression to a variable, or perform an "equal to" relational comparison.

Syntax:[LET] var = exp Assignment Statement

Usage1: exp1 = exp2 Equal to Operator

Usage2: set1 = set2 Set Membership

var Any numeric or string variable. In an assignment statement, the = stores the value of exp in variable var.Ifvar is numeric, then exp must be numeric. If var is a string, exp must be a string.

exp A numeric or string expression.

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is equal to that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expressions. If set1 is identical to set2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

The keyword LET is optional and is usually omitted.

If var and exp are not both numeric or both string, a Type Mismatch error will occur.

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

-129- = Assignment or Equal Operator

It is not good programming style to use single or double precision floating point variables with the = operator. A comparison may fail because of the inexactness of the numeric representation.

See also: <><><=>=WITHIN Precedence Garbage Collection

Example 1: Assignment 10A=C+1 ’Assign the value of "C + 1" to variable A

Example 2: Equal to Operator 1020 IFA=BTHEN PRINT "A is equal to B"

> Greater than, or Set Membership Operator

Purpose: Perform a "greater than" relational comparison, or set membership.

Usage1: exp1 > exp2 Greater Than

Usage2: set1 > set2 Set Membership

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is greater than that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expression. If set1 has all the elements in set2 and set1 is not equal to set2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

In IF statements, BASIC regards 0 as equivalent to FALSE and all non-zero values as equivalent to TRUE.

If the operands are string expressions, BASIC compares the ASCII values of the first character in each expression. If the first characters have the same ASCII value, BASIC then compares the second characters, and so on. If one string terminates before the other, and the characters in each string are identical to that point, the longer string is considered "greater" than the shorter one.

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

See also: = <> < <= >= WITHIN Precedence

Example: 10IFA>BTHEN PRINT "A is greater than B"

-130- >= Greater than or Equal to, or Set Membership Operator

Purpose: Perform a "greater than or equal to" relational comparison, or set membership.

Usage1: exp1 >= exp2 Greater Than or Equal

Usage2: set1 >= set2 Set Membership

exp1, exp2 Numeric or string expressions. Both exp1 and exp2 must be either numeric or string. If the value of exp1 is greater than or equal to that of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

set1, set2 Set expressions. If set1 has all the elements in set2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

In IF statements, BASIC regards 0 as equivalent to FALSE and all non-zero values as equivalent to TRUE.

If the operands are string expressions, BASIC compares the ASCII values of the first character in each expression. If the first characters have the same ASCII value, BASIC then compares the second characters, and so on. If one string terminates before the other, and the characters in each string are identical to that point, the longer string is considered "greater" than the shorter one.

If the operands are set expressions and exp1 is a subset of exp2, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

If exp1 and exp2 are not both numeric or both strings, a Type Mismatch error will occur.

See also: =<><><=WITHIN Precedence

Example: 10 IF A >= B THEN PRINT "A is greater than or equal to B"

/ Division Operator

Purpose: Perform floating-point division.

Usage: exp1 / exp2

exp1 A numeric expression which represents the dividend.

exp2 A numeric expression which represents the divisor. The divisor must not be zero.

Both operands are converted to double precision floating-point values before the operation takes place, and the result is always double precision floating-point.

See also: +-*\MOD^Precedence

-131- \ Integer Division Operator

Purpose: Perform integer division.

Usage: exp1 \ exp2

exp1 An integer expression which represents the dividend.

exp2 An integer expression which represents the divisor. The divisor must not be zero.

The operands must be either integer or long integer. Any other operand types will cause a Type Mismatch error to occur. The result is the same type as the largest operand. If the two operands are different sizes, integer type conversion is performed.

See also: +-*/MOD^Precedence

^ Exponentiation Operator

Purpose: Perform exponentiation.

Usage: exp1 ^ exp2

exp1 A numeric expression which represents the value to be raised to a power. This may be negative if and only if exp2 is an integer.

exp2 A numeric expression which represents the power to raise exp1 to. This may be fractional or negative. It must be an integer if exp1 is negative.

Both operands are converted to double precision floating-point before the operation takes place, and the result is always double precision floating-point.

See also: +-*/\MODPrecedence Differences

ABS Absolute Value Function

Purpose: Return the absolute value of an expression.

Usage: var = ABS(numexpr)

ACL.CMD@ Acceleration Command ORMEC Variable

Purpose: Return the current real-time value for commanded acceleration (or deceleration) rate of a servo axis in user units.

Usage: var& = ACL.CMD@[(axes)]

-132- ACL.LAST@ Last Specified Acceleration Rate ORMEC Variable

Purpose: This read-only variable is the acceleration rate last specified in a MOVE command, either directly or indirectly.

Usage: var% = ACL.LAST@[(axes)]

Specifying an acceleration in any MOVE command, either directly or indirectly, will change this parameter.

ACL.MAX@ Maximum Acceleration ORMEC Variable

Purpose: Define the maximum allowable acceleration rate command in user units. This is also the default acceleration rate used by motion statements.

Syntax: ACL.MAX@[(axes)] = accel

Usage: var& = ACL.MAX@[(axes)] accel A numeric expression representing the maximum allowable commanded axis acceleration rate in user units from 1 to USR.ACL.LIM@. A value of 0 disables maximum acceleration checking, allowing instant accelerations to be commanded. Default = USR.ACL.LIM@, and changing USR.ACL.LIM@ will always reset ACL.MAX@ equal to USR.ACL.LIM@.

Any motion statement that does not have an acceleration rate specified in some way will use this rate. If a motion statement specifies an acceleration rate greater than this parameter, an error will be generated and the motion will not occur.

AFAULT@ Axis Fault Code ORMEC Variable

Purpose: Identify a servo axis fault, or clear this fault variable.

Usage: var% = AFAULT@[(axes)]

Syntax: AFAULT@[(axes)]=0

var An integer indicating the first axis fault condition to occur since this variable was last cleared.

Code Axis Fault Condition Code Axis Fault Condition

0 = None 7 = Encoder Overspeed 1=Position Error>Max 8=MotionDATA Error 2=Servodrive Alarm - See ALARM@ 9=Hi Axis Loop Rate 3=Encoder Ch-A Open 10 = Hi Pacer Loop Rate 4=Encoder Ch-B Open 11 = No MotionDATA 5=Command Overspeed 6=Pacer Overspeed 901-999 are DSP Software Faults

-133- AFAULT@ Axis Fault Code ORMEC Variable

AXIS.FAULT@ identifies the set of all servo axes in the system that currently have a fault condition (other than zero).

AXIS.FLT1@ indicates the first axis to detect a fault.

When an axis fault occurs, MotionBASIC will automatically set MODE@ to 0 for the problem axis and issue a controller fault error. The AFAULT@ variable will be latched to a non-zero value which indicates the cause of the fault. The statement AFAULT@ = 0 will attempt to clear the fault, but if the fault condition persists, AFAULT@ will remain non-zero.

To enable the No Fault Relay after an axis fault condition is cleared, FAULT@ must be explicitly cleared to 0 and ESTOP.OK@ must be TRUE.

AFTER Define a Start Condition Modifier

Purpose: Define a start condition for a motion specified by a MOVE, GEAR or HALT statement; define a start condition for a WAIT statement.

Usage 1: [REPEAT] MOVE parameters AFTER condition [UNTIL condition]

Usage 2: [REPEAT] GEAR parameters AFTER condition [UNTIL condition]

Usage 3: HALT parameters AFTER condition [UNTIL condition]

Usage 4: WAIT time [AFTER expression]

condition ZREF@, ASEN@, BSEN@ or DELAY@

expression Any Boolean expression.

When MotionBASIC executes a MOVE, GEAR or HALT statement, it processes the parameters and places high level information in the shared memory of the DSP Axis Module(s). When AFTER, UNTIL and/or REPEAT modifiers are

-134- AFTER Define a Start Condition Modifier

included in the statement, the DSP uses this information as it executes or "repeats" the motion, allowing "fast" decision making by the next servo loop update. Note that motions modified by AFTER and UNTIL clauses can be "repeated" independently by the DSP, freeing up MotionBASIC execution for other tasks.

DSP.DONE@ will be FALSE if a motion is initiated but waiting for an AFTER condition to become TRUE.

MOVE, GEAR and HALT statements implicitly clear latched variables when executed, causing the AFTER clause to be satisfied on the next event.

When an AFTER clause is used with a WAIT statement, then MotionBASIC repeatedly executes the WAIT statement suspending program execution, except for ON EVENT processing, until the WAIT condition becomes TRUE.

Examples: 10 MOVE AT 500 AFTER ASEN@ 20 HALT IN 30 AFTER ZREF@

AIN1@ Axis Analog Input One ORMEC Variable

Purpose: Read a 12-bit analog input at the DSP I/O Header for an axis.

Usage: var% = AIN1@[(axes)] Read Analog Input/Output

var% Returns an integer value in the range -32768 to +32767, which corresponds to an analog input voltage from -10 to +10 VDC at the optional AIN1 analog input. This variable will return unpredictable values if the 12-bit analog input option is not present on the DSP Axis Module!

Example: 10 X% = AIN1@({3}) ’read a 12-bit analog input for axis 3 20 PRINT X% ’print the value read 30 END RUN -32768 ’printed if the value read was -10 VDC

See also: AIN2@

-135- AIN2@ Axis Analog Input Two ORMEC Variable

Purpose: Read a 12-bit analog input at the Axis Interface Connector of the DSP Axis Module.

Usage: var% = AIN2@[(axes)] Read Analog Input/Output

var% Returns an integer value in the range -32768 to +32767, which corresponds to an analog input voltage from -10 to +10 VDC at the optional AIN2 analog input. This variable will return unpredictable values if the 12-bit analog input option is not present on the DSP Axis Module!

Example: 10 X% = AIN2@({3}) ’read a 12-bit analog input for axis 3 20 PRINT X% ’print the value read 30 END RUN -32768 ’printed if the value read was -10 VDC See also: AIN1@ Loop Architecture

AIO@ Analog I/O Point ORMEC Variable

Purpose: Allow MotionBASIC to read or set Analog I/O points using the Pamux Interface.

Syntax: AIO@(point)=value Write Analog Output

Usage: var% = AIO@(point) Read Analog Input/Output

point An integer expression in the range from 17 to 528 inclusive.

value An integer expression in the range from 0 to 4096 when writing to a single-ended analog output and in the range from -2048 to 2047 when writing to a bipolar output.

var% An integer value will be returned in the range from 0 to 4096 when reading a single-ended analog I/O point, and in the range from -2048 to 2047 when reading a bipolar analog I/O point. When an analog output is read, the value

returned will be the value last written to it. The default value for analog outputs is 0.

The AIO@ array variable is only accessible when EIO.MODE@ is configured for Pamux and the type and direction of each AIO point has been configured using IO.MODE@.

Example: 10 AIO@(33) = 512 20 X = AIO@(34)

The program lines above set the level of Analog Output point 33 to 512 and assign the value of Analog I/O point 34 to a variable named ’X’.

-136- ALARM@ Servodrive Alarm Code ORMEC Variable

Purpose: Identify the current servodrive alarm code for a servo axis.

Usage: var% = ALARM@[(axes)]

var An integer indicating the servodrive alarm condition:

ALARM@ E-SERIES SERVODRIVES

0--7 → No Drive Alarms 10 → Drive Unplugged 11 → Drive Overcurrent 12 → Drive CB Tripped 13 → Regeneration Fault 14 → Hi Main DC Voltage 15 → Motor Overspeed 16 → Lo Main DC Voltage 17 → Motor Overload

ALARM@ S-SERIES SERVODRIVES

0--7 → Normal operation 10 → Drive Unplugged or Uncoded Alarm 11 → Drive Overcurrent 12 → Drive CB Tripped 13 → Drive Overcurrent & CB Tripped 14 → Uncoded Alarm with Motor Moving 15 → Drive Overcurrent & Motor Moving 16 → CB Tripped & Motor Moving 17 → Overcurrent & CB Tripped & Moving

ALARM@ F-SERIES SERVODRIVES

0--7 → Normal operation 10 → Drive Unplugged or Uncoded Alarm 11 → Uncoded Alarm 12 → Drive Current Output Fault 13 → High Bus Voltage Fault 14 → Drive Over Temperature Fault → or RMS Current Limit Fault 15 → Uncoded Alarm 16 → Alarms 12 and 14 17 → Alarms 13 and 14

-137- ALARM@ Servodrive Alarm Code ORMEC Variable

Note that when the AFAULT@ variable is cleared after a servodrive ALARM condition, the controller asserts the Alarm Reset Output (ALM-RESET’) at the DSP Axis Module’s Axis Interface Connector for up to 50 msec in an attempt to clear the servodrive ALARM condition.

S-Series servodrives do not support an external reset signal and must be reset by pressing the pushbutton on the front of the drive near the "Drive Fault Indicator". If S-Series servodrives must be reset automatically, then you must cycle the servodrive control power using a discrete digital output. See DIO@.

F-Series servodrives require a power cycle to clear: High Bus Voltage Fault (ALARM@ = 12 or 16) Drive Current Output Fault (ALARM@ = 13 or 17) All other faults can be cleared by either a power cycle, or by clearing the AFAULT@ variable.

See also: FAULT@ AFAULT@ AXIS.FAULT@ AXIS.FLT1@

AND Logical AND Operator

Purpose: Perform a bitwise logical AND on two binary integers or long integers.

Usage: exp1 AND exp2

exp1, exp2 Any expressions, including boolean expressions, that produce an integer or long integer result.

The operands must be either integer or long integer. Any other operand types will cause a Type Mismatch error to occur. The result is the same type as the largest operand. If the two operands are different sizes, integer type conversion is performed.

MotionBASIC performs a bitwise AND, according to the AND truth table. See the chapter on bitwise operations for an example.

See also: NOT OR XOR Precedence

ASC ASCII Value of First Character Function

Purpose: Return the ASCII value of the first character of a string expression.

Usage: var% = ASC(stringexpr)

stringexpr A string expression.

Note: If the argument is a null string, ASC generates an Empty String error.

See also: CHR$ VAL

-138- ASEN@ A-Sensor On ORMEC Variable

Purpose: Allow MotionBASIC to determine if the high speed A-Sensor on the DSP Axis Module is asserted; or has been asserted since last cleared. Clear and arm an edge sensitive latch.

Usage: var% = ASEN@[(axes)] ’w/ multiple axes reference, ASEN@s are ORed Syntax: ASEN@[(axes)]=0

var A Boolean value which will be TRUE (-1) if A-Sensor either is asserted, or has been asserted since last cleared, depending on SENS.MODE@. Otherwise it will be FALSE (0).

This input signal is used to capture axis position POS.ASEN@. ASEN@ can initiate a motion AFTER it occurs, terminate a motion waiting UNTIL it occurs, and it can be used in any boolean expression.

Setting ASEN@ to 0 always clears it if it was configured by SENS.MODE@ as Rising or Falling edge sensitive. If configured level sensitive, it may be immediately re-asserted depending on the state of the input.

AT.REST@ At Rest ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the specified servo(s) is (are all) at rest.

i.e. VEL.CMD@=0

Usage: var% = AT.REST@[(axes)]

NOTE: GEAR commanded motion does not affect this variable’s status, it could be gearing but report AT.REST@ is TRUE. Only MOVE commanded motion will set AT.REST@ to FALSE.

AT.SPD@ At Constant Speed ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the specified servo(s) is (are all) being commanded to operate at a steady state speed by a MOVE.

Usage: var% = AT.SPD@[(axes)]

NOTE: GEAR commanded motion does not affect this variable’s status.

-139- ATN Arctangent Function

Purpose: Return, in radians, the angle whose tangent is numexpr. The return value is in the range -PI/2 to +PI/2.

Usage: var# = ATN(numexpr)

Note: PI radians = 180 degrees, and so to convert from radians to degrees, multiply the returned value by 180/PI or 57.296.

See also: COS SIN TAN

AUTO Automatic Line Numbering Command

Purpose: Activate automatic line numbering for keying in a program with the MotionBASIC line editor, starting at a specified line number and incrementing by a specified amount. See also ’!AUTO.

Syntax: AUTO [startline [,increment]]

startline The starting line number or a label defining the starting line number. See PW@ for the default values.

increment The interval between line numbers. Defaults to 10.

If AUTO is about to write a line number that already exists, an asterisk (*) is displayed next to the number. To avoid overwriting the existing line, and return to direct mode, press the Enter key immediately after the asterisk.

Since AUTO calls the line editor for input, the line edit keys may be used during line entry. If the "up-arrow" key is pressed, you may

also EDIT previous lines. When the cursor is on the last program line entered, pressing the Enter key will resume AUTO numbering at the next appropriate line number.

To terminate automatic line numbering, press Enter on an empty line or "break" the command by pressing Ctrl-C.

Automatic Load Program File

AUTOLOAD.BAS is included in the list of keywords, but it is not a keyword in the strictest sense. It is the required filename for the program file which is designated to automatically load into the controller from the Memory Disk on powerup.

This file must be stored in the root directory of the Memory Disk to provide this functionality.

See Also: PB1LOAD.BAS

-140- Motion Statements and Variables Indexed by Axes

An optional axes parameter is used to index Motion Statements and many of the pre-defined ORMEC variables. This parameter is a set variable, allowing more than one axis at a time to be referenced; e.g. {1,2} defines the set of axis 1 and 2. The pre-defined variable AXIS.SET@ is used whenever the axes parameter is not explicitly specified.

If more than one axis is specified by either AXIS.SET@ or the axes parameter in a motion statement or when setting an axis parameter, then all the specified axes will be affected.

If more than one axis is specified when using a pre-defined variable to return a numeric value, the value returned will be for the first (lowest numbered) axis included in the set.

If more than one axis is specified when returning one of the Boolean Axis Status Parameters, the value returned will be either "ANDed" or "ORed" for the servos in the set depending on that particular variable.

AXIS.FAULT@ Set of Servos in the System with a Fault ORMEC Variable

Purpose: Identify the set of servo axes which currently have faults.

Usage: var~ = AXIS.FAULT@

var~ A set variable which is to receive the set of all servos in the system with a fault.

The actual fault(s) for the servo(s) identified by this variable are indicated by the AFAULT@ variable. If the fault is a servodrive alarm, then the ALARM@ variable will return the alarm code.

AXIS.FLT1@ First Servo in the System with a Fault ORMEC Variable

Purpose: Identify the first servo axis to have a fault.

Usage 1: var~ = AXIS.FLT1@

var~ A set variable which is to receive the axes of the first servo axis in the system to develop a fault.

Usage 2: var% = AFAULT@(AXIS.FLT1@)

var% An integer variable which is to receive the fault code of the first servo axis in the system to develop a fault.

The actual fault(s) for the servo(s) identified by this variable are indicated by the AFAULT@ variable. If the fault is a servodrive alarm, then the ALARM@ variable will return the type of alarm.

-141- AXIS.LIST@ Set of all servos in the system ORMEC Variable

Purpose: Identify all of the servo axes in the system. Remove one or more axes from the system.

Syntax: AXIS.LIST@ = set

Usage: var~ = AXIS.LIST@

set The set of all servos in the system. All servo axes specified in this expression must be included in the current AXIS.LIST@. In other words, axes may be removed from AXIS.LIST@ but may never be added. Default AXIS.LIST@ = all servo axes found at powerup.

var~ A set variable which is to receive the set of all servo axis found.

Example: 100 AXIS.LIST@ = AXIS.LIST@ - {2} ’Remove axis 2 from system

AXIS.OTL@ Set of Servos in the System with an OTL ORMEC Variable

Purpose: Identify the set of servo axes which currently have an overtravel limit condition. i.e. either OTL.FWD@ or OTL.REV@ TRUE

Usage: var~ = AXIS.OTL@

var~ A set variable which is to receive the set of all servos in the system with an overtravel limit condition.

AXIS.SET@ Default Set of Servos ORMEC Variable

Purpose: Define a default set of servos to MotionBASIC. This default set of servos will be used if no axes parameter is specified in statements or variables where it is optional.

Syntax: AXIS.SET@ = set Define the Default Axis Set

Usage: var~ = AXIS.SET@ Get the Default Axis Set

set The set of servos to be used by default. All servo axes specified in this expression must be included in AXIS.LIST@. Default AXIS.SET@ = AXIS.LIST@.

var~ A set variable which is to receive the current default axis set.

See the Example below.

-142- AXIS.SET@ Default Set of Servos ORMEC Variable Example: 10 X~ ={1} ’assign logical names to the servo 20 Y~ = {2} ’axes 30 Z~ = {3} 40 AXIS.SET@=X~+Z~ ’select the "X & Z Axes" 50 SPD.MAX@=2000 ’sets the maximum speed ofX&Zto2,000 60 SPD.MAX@(Y~)=2400 ’set the maximum speed of the Y Axis 70 PRINT SPD.MAX@(X~); ’print the maximum speed for the X Axis 80 AXIS.SET@=Y~+Z~ ’select the "Y & Z Axes" 90 PRINT SPD.MAX@; ’print the maximum speed for the first ’member of the set which is the Y Axis 100 PRINT SPD.MAX@(Z~) ’print the maximum speed for the Z Axis 110 PRINT AXIS.SET@ ’print axis numbers included in AXIS.SET@ 120 END RUN 2000 2400 2000 {2,3}

See also: VAL STR$ Example under set.

AXIS.VAR@ Axis-Indexed Long Integer Array ORMEC Variable

Purpose: Provide the ability to execute a single motion statement that will command multiple axes yet permit each axis to reference a distinct axis-indexed value for its motion parameter(s).

Syntax: AXIS.VAR@[(axes)] = numexpr

Usage: var = AXIS.VAR@[(axes)]

var A numeric variable to receive the value of the AXIS.VAR@ element corresponding to the lowest numbered axis in [(axes)]. Example: Assume a controller has an AXIS.LIST@={1,2,3,4,6,7}. An AXIS.VAR@ variable is established with 6 long integer elements. Values are written to the elements, as follows:

AXIS.VAR@(2)=100 : AXIS.VAR@({3,6,7})=20 : AXIS.VAR@(4)=-40

The following diagram conceptually illustrates the result:

-143- AXIS.VAR@ Axis-Indexed Long Integer Array ORMEC Variable

123467

AXIS.VAR@ 0 100 20 -40 20 20

Now consider the operation of the following statements:

AXIS.SET@ = {2,3} MOVE FOR AXIS.VAR@ IN AXIS.VAR@ ’command two axes to "index" ’Axis 2 moves an incremental 100 position units during 100 time units ’Axis 3 moves an incremental 20 position units during 20 time units

MOVE AT -AXIS.VAR@ ’Axis 2 ramps to the speed -100 ’Axis 3 ramps to the speed -100 ’The indexing feature does not apply because the - changed AXIS.VAR@ to ’an expression. -AXIS.VAR@ was evaluated as -AXIS.VAR@({2,3}) or -100.

The specific motion parameters that can be indexed to AXIS.VAR@ elements are indicated (with a "♦") in the MOVE, GEAR,&HALT Syntax Charts.

BAUD@ Serial Port Baud Rate ORMEC Variable

Purpose: Return the baud rate of the RS-232 serial port, SRL1, which is dedicated to motion program development and troubleshooting.

Syntax: BAUD@ = 0 ’Initiate autobaud sequence Usage: var& = BAUD@ ’return the current Serial Port baud rate

var An integer variable which will have one of the following values (2400, 4800, 9600, 19200, 38400) indicating the current baud rate of the Serial Port used for MotionPRO development.

The statement "BAUD@ = 0" initiates an autobaud sequence which requires that the next two characters be ASCII "carriage returns" (Code CR) which are sent a minimum of 10 msec apart. When the first one is received, the baud rate is selected from the possible values above. The second one is used to verify that the proper baud rate was selected. This sequence is automatically executed by MotionPRO when a baud rate is selected from the menu.

BIN$ Binary Value, as String Function

Purpose: Return, as a string, the binary representation of a number.

Usage: var$ = BIN$(lngexpr)

If lngexpr is negative, BIN$ returns the twos complement value in binary.

The returned string contains no leading zeros.

See also: HEX$ STR$ OCT$

-144- BREAK Program Break Control Command

Purpose: Set or reset a breakpoint at the specified line number.

Syntax 1: BREAK [ON] {linenum|label}[,count] [[PRINT varlist] [CONT|STOP]] Syntax 2: BREAK OFF [linenum|label] Syntax 3: BREAK LIST

ON an optional keyword to indicate that a breakpoint should be enabled at the specified line number.

OFF disables the specified breakpoint, or all breakpoints if none is specified

linenum the line which, when executed, will cause MotionBASIC to process the breakpoint.

label a symbolic label at the beginning of an existing program line which, when executed, will cause MotionBASIC to process the breakpoint.

count the number of times that a breakpoint must be encountered before MotionBASIC processes it. The default is 1.

PRINT (Syntax 1) when the breakpoint is processed, MotionBASIC will print out the list of variables in varlist. This syntax is not comparable to the PRINT statement in that only variables (separated by commas) can be listed.

CONT (Syntax 1) when MotionBASIC processes the breakpoint, any variables are first printed and then program execution continues. Without this option, program execution is halted and brought back to direct mode. Execution can be continued with the CONT command.

STOP (Syntax 1) when MotionBASIC processes the breakpoint, any variables are first printed and then program execution is halted and brought back to direct mode. Execution can be continued with the CONT command.

LIST (Syntax 3) causes MotionBASIC to list all breakpoints currently enabled.

Any number of BREAK statements can be invoked.

BREAK can be entered in direct mode for a line break, however the PRINT varlist cannot be specified.

Breakpoints are cleared by BREAK OFF & CLEAR.

All breakpoints will lose PRINT and count information whenever the program buffer is changed.

MotionBASIC processes a line breakpoint by waiting until count times the line has been executed and then printing out the line within square brackets followed by any variables specified.

See also: CONT TRACE TRACE VAL Program Initialization

-145- BSEN@ B-Sensor On ORMEC Variable

Purpose: Allow MotionBASIC to determine if one of the high speed sensors on the DSP Axis Module (B-Sensor) is asserted; or has been asserted since last cleared. Clear and arm an edge sensitive latch.

Usage: var% = BSEN@[(axes)] ’w/ multiple axes reference, BSEN@s are ORed Syntax: BSEN@[(axes)]=0

var%ABoolean value which will be TRUE (-1) if B-Sensor either is asserted, or has been asserted since last cleared, depending on SENS.MODE@. Otherwise it will be FALSE (0).

This input signal is used to capture axis position POS.BSEN@. BSEN@ can initiate a motion AFTER it occurs, terminate a motion waiting UNTIL it occurs, and it can be used in any boolean expression.

Setting BSEN@ to 0 always clears it if it was configured by SENS.MODE@ as Rising or Falling edge sensitive. If configured level sensitive, it may be immediately re-asserted depending on the state of the input.

BYE Return to Operating System (BASIC) Command

Purpose: None. This keyword is currently reserved for future use.

CHAIN Load and Execute Program or Overlay Statement

Purpose: The CHAIN Command is used to transfer control to the specified program from a Memory Disk or from a PC running MotionPRO without affecting the variable values.

Syntax: CHAIN [MERGE] filespec [,{linum | label}] [,DELETE start][[-]end]]]

filespec "[drive:][path\]filename[.ext]"

drive Development Computer drive letter or 1 for Memory Disk. path A string expression that follows DOS file-naming filename conventions. ext Default extension is .BAS.

linum The numeric literal that specifies the line number at which program execution should resume after the file has been loaded. If no line number is specified, execution will begin at the first line in the program buffer.

-146- CHAIN Load and Execute Program or Overlay Statement

label The same idea as linenum, except that this is a symbolic label that designates the "chain-on" starting spot.

start The numeric literals or symbolic labels that specify the end line or range of lines to be deleted before the merge.

MERGE Specifies the new program should be merged into the existing program. Note, if the merge option is not specified, all unprotected program areas will be deleted before the chained program is loaded, and all variables will be cleared.

DELETE Specifies that a line or range of lines in the existing program should be deleted before the chained program is loaded into memory.

If variables need to be ERASEdorCLEARed before the CHAIN command is executed, it will be up to the currently running program to "clean up" before executing the CHAIN command. The command line provides options for deleting lines in the existing program, merging the new program into an "overlay" area, and specifying the start line of the new program.

The file will normally be loaded through the serial link from an IBM PC or compatible running MotionPRO. If the drive number "1:" is specified at the beginning of filespec, the file will be loaded directly from the Memory Disk. The file will not be able to be loaded into areas of the controller memory protected by PW@.

See also: LOAD MERGE SAVE Differences from GWBASIC

CHDIR Change Current Memory Disk Directory Command

Purpose: Changes the current working directory on the Memory Disk.

Syntax: CHDIR "[1:]path"

path A string expression that follows DOS path specification conventions which specifies the name of the directory which is to become the current working directory.

See also: MKDIR RMDIR FILES

-147- CHR$ Convert ASCII Code to Character Function

Purpose: Return the character whose ASCII value is specified.

Usage: var$ = CHR$(code)

code An integer expression in the range 0 to 255 which corresponds to the decimal value in the ASCII chart.

See also: ASC STR$

CLEAR Reset Variables; Set Maximum String Space Statement

Purpose: Erase all user variables and set all predefined axis variables to their powerup defaults; or specify the maximum size of MotionBASIC’s string space.

Usage: CLEAR [strsize]

strsize Maximum size, in bytes, of MotionBASIC’s string space. Defaults to 1024.

CLEAR erases all variable data, including any information set via DEF FN, DEF SEG, DEFINT, DEFLNG, DEFDBL, DEFSNG, DEFSTR and DEFSET. Unlike NEW, however, it leaves the current program intact.

See also: ERASE NEW Program Initialization Garbage Collection

CLG Common Logarithm Function

Purpose: Return the common (base 10) logarithm of a number.

Usage: var# = CLG(numexpr)

numexpr A numeric expression greater than 0.

See also: LOG EXP

-148- CLOSE Close a Device or File Statement

Purpose: Close one or more devices or files and terminate the association between a device or file and its number.

Usage: CLOSE [[#] devnum [,[#] devnum]...]

devnum The number under which a device was OPENed.

If the device was OPENed for sequential output, CLOSE writes the final buffer to the device. Any Input task or Output task that is in process will be terminated without error.

END, NEW & RUN, also automatically close all open devices & data files.

STOP and RETURN, however, close no devices.

See also: OPEN ITM Driver Support

CLREOL Clear to End of Line Statement

Purpose: Clear the line from the current cursor location using the background color.

Syntax: CLREOL

See also: CLS

CLS Clear Screen Statement

Purpose: Clear the screen to the background color and return the cursor to the Home position (row 1, column 1).

Syntax: CLS

See also: CLREOL

-149- CNT.REV@ Axis Counts/Rev ORMEC Variable

Purpose: Define the number of counts per revolution of the servo axis position transducer.

Syntax: CNT.REV@[(axes)] = counts

Usage: var% = CNT.REV@[(axes)]

counts A numeric expression in the range 1 to 32767, which represents the number of counts per revolution of the axis encoder. Default CNT.REV@ = 6000.

var% A numeric variable to receive the current number of counts per revolution of the servomotor as defined by CNT.REV@.

This parameter should be set prior to setting any other user units. MAC-E Series Servomotors: 6,000 counts per rev MAC-A Series Servomotors: 6,000 counts per rev MAC-B Series Servomotors: 24,000 counts per rev MAC-C Series Servomotors: 24,000 counts per rev MAC-F Series Servomotors with F-Series "/A" drives: 16,384 counts per rev with F-Series "/B" drives: 4,096 counts per rev

COLOR Set Foreground and Background Colors Statement

Purpose: Specify foreground and background colors for the video display.

Usage: COLOR [foreground] [,[background]

foreground An integer expression from 0 to 31 which selects the foreground color from the table below.

background An integer expression from 0 to 7 which selects the background color from the table below.

At least one of the optional parameters above must be included. Omitted parameters retain former values. The default is white foreground (7) and black background (0).

See also: Differences

-150- COLOR Set Foreground and Background Colors Statement

Value Color Monochrome Notes

0 Black Black Add 16 to a value 1 Blue Underline to produce its 2 Green blinking equival- 3 Cyan ent. 4 Red 5 Magenta Background values 6 Brown in the range 0 to 7 White White 6 produce a black 8 Gray background, while 9 Bright Blue Bright Underline a value of 7 pro- 10 Bright Green duces a white 11 Bright Cyan background. 12 Bright Red 13 Bright Magenta 14 Yellow 15 Bright White Bright White

CONT Resume Program Execution Command

Purpose: Resume execution of a program that has been interrupted via STOP, BREAK, or Ctrl-C.

Syntax: CONT

Execution continues at the program line where the break occurred.

CONT produces a "Can’t Continue" message if the program has been edited since it was interrupted.

See also: GOTO

COS Cosine Function

Purpose: Return the cosine of the angle whose value, in radians, is expressed in numexpr.

Usage: var# = COS(numexpr)

numexpr A numeric expression which represents the angle, in radians. If numexpr is large (greater than 1.0E8), a partial loss of significance in the result may occur. If numexpr is so large that a total loss of significance occurs (greater than 2.0E9), an Overflow Error will occur.

Note: PI radians = 180 degrees, and so before executing the cosine function, convert numexpr from degrees to radians by dividing by 180/PI or 57.296.

See also: ATN SIN TAN

-151- CSRLIN Row Position of Cursor Function

Purpose: Return the row number of the current cursor location on the current screen page.

Usage: var% = CSRLIN

To get the current column position, use POS. To set the cursor position, use LOCATE.

CW.FWD@ Clockwise Forward ORMEC Variable

Purpose: Cause the servomotor’s direction of "forward" travel to be "clockwise", as viewed from the motor shaft end of the motor.

Syntax: CW.FWD@[(axes)] = mode

Usage: var% = CW.FWD@[(axes)]

mode A Boolean expression that, when non-zero, causes the motor to rotate clockwise when commanded to move in a positive direction.

var% A numeric variable to receive the current "forward" direction as defined by CW.FWD@.

Default forward rotation of the motor is counter-clockwise (CW.FWD@=0).

See also: DRV.CMD@ DRV.MAX@

DATA Store Constant(s) for Retrieval via READ Statement

Purpose: Store one or more constants, of any type, for subsequent access via READ statements.

Syntax: DATA constant1 [,constant2]...

DATA statements are nonexecutable statements that supply a stream of constants for use by READ statements. All the items supplied by all the DATA statements in a program make up one continuous string of information that is accessed in order by your program’s READ statements. Use RESTORE to reset the pointer to the first item in a specified DATA statement.

You may put as many constants (expressions are not allowed) in a single DATA statement as will fit on one line, and your program may have any number of DATA statements, positioned anywhere in the program.

String constants in DATA statements do not need to be surrounded by quote marks, unless they contain quote marks themselves, colons, commas, single-quotes, or significant leading or trailing blanks.

See also: Differences from GWBASIC Program Initialization

-152- DATE$ Get or Set System Date Function

Purpose: Get or Set the current system date.

Syntax: DATE$ = stringexpr Set the system date

Usage: var$ = DATE$ Retrieve the system date

stringexpr A string expression in one of the following forms: "mm-dd-yy", "mm/dd/yy", "mm-dd-yyyy", "mm/dd/yyyy".

The system date retrieved is formatted as follows: "mm-dd-yy".

If the year is expressed in two digits, instead of four, the twentieth century is assumed. If the month or day is expressed as a single digit, a leading zero is assumed.

The year portion of the date must be in the range 1980 to 2099.

See also: TIME$

DCL.ERR@ Error Deceleration ORMEC Variable

Purpose: Define the deceleration rate to be used when an error occurs (including Ctrl-C).

Syntax: DCL.ERR@[(axes)] = decel

Usage: var& = DCL.ERR@[(axes)]

decel A numeric expression representing the deceleration rate in user units from 1 to USR.ACL.LIM@. Default = 1/10 of USR.ACL.LIM@.

See also: Error Codes.

DCL.LAST@ Last Specified Deceleration Rate ORMEC Variable

Purpose: This read-only variable is the deceleration rate last specified in a MOVE command, either directly or indirectly.

Usage: var% = DCL.LAST@[(axes)]

Specifying a deceleration in any MOVE command, either directly or indirectly, will change this parameter.

-153- DCL.MAX@ Maximum Deceleration ORMEC Variable

Purpose: Define the maximum allowable commanded deceleration rate in user units. This is also the default deceleration rate used by motion statements.

Syntax: DCL.MAX@[(axes)] = decel

Usage: var& = DCL.MAX@[(axes)] decel A numeric expression representing the maximum allowable commanded axis deceleration rate in user units from 1 to USR.ACL.LIM@. A value of 0 disables maximum deceleration checking, allowing instant decelerations to be commanded. Default = USR.ACL.LIM@, and changing USR.ACL.LIM@ will always reset DCL.MAX@ equal to USR.ACL.LIM@.

Any motion statement that does not have an deceleration rate specified in some way will use this rate. If a motion statement specifies an deceleration rate greater than this parameter, an error will be generated and the motion will not occur.

DEF FN Define Function Statement

Purpose: Define a user function.

Syntax: DEF FNname[(parmlist)] = expression

name A valid variable name (with type suffix). The suffix establishes the data type of the value returned. Defaults to integer type (%) when suffix is omitted.

parmlist One or more parameters for the function. Each must be a valid variable name. Parameters are passed by value.

expression An expression, of the same type as name, that defines the value returned by the function.

Function definitions may include any number of arguments as dummy parameters. The arguments serve as definition placeholders only; even if they happen to be the same as variable names currently in use within the program, they do not affect the values of those variables.

A function definition is limited to a single MotionBASIC statement and it must be executed before the function is called.

Functions may not call themselves.

To call a function, use the syntax

v = FNname [(parameter [,parameter]...)]

DEF FN may not be used in direct mode.

See also: Program Initialization

-154- DEF SEG Define Segment Statement

Purpose: Specify the segment address from which arguments to PEEK, PEEKW, POKE and POKEW will be offset.

Syntax: DEF SEG [=segment]

segment A numeric expression in the range 0 to &HFFFF. If no segment is specified, then DEF SEG defaults to MotionBASIC’s data segment (DS). Default=&HD000.

Segmented Memory

Intel 8086 family CPUs have "segmented memories", which means that locations in memory are addressed using a combination of a "segment address" as defined by the DEF SEG statement, and a "memory offset" as defined by the PEEK, POKE, PEEKW or POKEW statements.

DEFDBL Define Variable(s) as Double Precision Statement

Purpose: Declare one or more variables to be double precision.

Syntax: DEFDBL letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be double precision, unless a type-identifier character (%, &, !, $, ~, or @) is used to override the DEFDBL declaration.

The DEFDBL declaration must be processed before any of the declared variables are used.

See also: DEFINT DEFLNG DEFSET DEFSNG DEFSTR

DEFINT Define Variable(s) as Integer Statement

Purpose: Declare one or more variables to be of type integer.

Syntax: DEFINT letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be integer, unless a type identifier character (&, #, !, $, ~, or @) is used to override the DEFINT declaration.

The DEFINT declaration must be processed before any of the declared variables are used.

See also: DEFLNG DEFDBL DEFSET DEFSNG DEFSTR

-155- DEFLNG Define Variable(s) as Long Integer Statement

Purpose: Declare one or more variables to be of type Long Integer.

Syntax: DEFLNG letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be Long Integer, unless a type identifier character (%, #, !, $, ~, or @) is used to override the DEFLNG declaration.

The DEFLNG declaration must be processed before any of the declared variables are used.

See also: DEFINT DEFDBL DEFSET DEFSNG DEFSTR

DEFSET Define Variable(s) as Set Statement

Purpose: Declare one or more variables to be of type set.

Syntax: DEFSET letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be Set, unless a type identifier character (%, &, #, !, $, ~, or @) is used to override the DEFSET declaration.

The DEFSET declaration must be processed before any of the declared variables are used.

See also: DEFINT DEFLNG DEFDBL DEFSNG DEFSTR

DEFSNG Define Variable(s) as Single Precision Statement

Purpose: Declare one or more variables to be single precision.

Syntax: DEFSNG letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be single precision, unless a type-identifier character (%, &, #, $, ~, or @) is used to override the DEFSNG declaration.

The DEFSNG declaration must be processed before any of the declared variables are used.

See also: DEFDBL DEFINT DEFLNG DEFSET DEFSTR

-156- DEFSTR Define Variable(s) as String Statement

Purpose: Declare one or more variables to be of type string.

Syntax: DEFSTR letter[-letter]

All variable names beginning with any of the specified letters (case-insensitive) will be strings, unless a type identifier character (%, &, !, #, ~, or @) is used to override the DEFSTR declaration.

The DEFSTR declaration must be processed before any of the declared variables are used.

See also: DEFINT DEFLNG DEFSET DEFSNG DEFDBL

DELAY@ Delayed Sensor On ORMEC Variable

Purpose: Allow MotionBASIC to determine if the delayed sensor input (DELAY) signal is asserted; or has been asserted since last cleared.

Usage: var% = DELAY@[(axes)] ’w/ multiple axes reference, DELAY@s are ORed Syntax: DELAY@[(axes)]=0

var A Boolean value which will be TRUE (-1) if only if the DELAY input has been asserted since last cleared.

The delayed sensor input signal can also be used to capture encoder position (POS.DELAY@), initiate a MOVE AFTER it occurs or continue a MOVE UNTIL it occurs.

The sensor delay counter is an extra cost hardware option for the DSP Axis Module. For MotionBASIC software, a MotionCARD is needed to support delay counter functions. References to DELAY@ without the MotionCARD installed are invalid.

DELAY.DIST@ Sensor Delay Distance ORMEC Variable

Purpose: Set an axis encoder distance to load into a DSP Axis Module delay counter.

The sensor delay counter is an extra cost option of the DSP Axis Module, and is described in detail in its own hypertext manual.

-157- DELETE Delete Program Lines Command

Purpose: Erase a specified range of program lines.

Syntax: DELETE [start] [-[end]]

start Line number or label of the first line to delete. If start is the only parameter on the line, then only start is deleted.

end Line number or label of the last line to delete.

If a single line number is specified, the line must exist or an error will be generated. If a range is specified, no error is generated if the lines do not exist.

See PW@ for the default start and end values.

DIM Dimension Array(s) Statement

Purpose: Declare one or more user array variables, and for each, allocate memory space for its specified number of elements.

Syntax: DIM variable(subscripts)[,variable(subscripts)] ...

subscripts a list of numbers separated by commas, where each number establishes a dimension for the array. There could legally be as many as 255 numbers separated by commas (255 legal dimensions).

The value of each number, limits the maximum subscript for that dimension. (32,767 maximum limit)

e.g. DIM A(2,3) establishes a two dimensional array. Analogous is a "row-column" matrix, with three "rows" 0,1,2 and four "columns" 0,1,2,3. This array would have twelve elements, (3 rows * 4 columns = 12 elements), each addressed by its unique combination of subscripts.

The DIM statement must be processed before the array is used.

An array may not be redimensioned, unless it has first been deleted by means of an ERASE or CLEAR statement.

The first element of a 1 dimensional array is element(0). The first element of a 2 dimensional array is element(0,0). The first element of a 3 dimensional array is element(0,0,0). etc.

See also: Differences from GWBASIC Program Initialization

-158- DIO@ Discrete I/O Point ORMEC Variable

Purpose: Allow MotionBASIC to read and/or write Discrete I/O. See also ON EVENT.

Usage: var% = DIO@(point) Read Input or Output Point

Syntax: DIO@(point)=value Write Output or Clear Latched Input

point This integer expression specifies the number of the DIO point. When EIO.MODE@ = 0, the range is 1 to 40, otherwise the range is 1 to 528. IO.MODE@ is used to configure I/O point as an input, output, or a "latched" input.

var% DIO@ array variables return Boolean values of ON or OFF as follow, depending on the configuration set by IO.MODE@. • Discrete Inputs return an ON value when voltage is applied to the input module and the LED is lit. • Discrete Outputs return an ON value when the output module is outputing a voltage and the LED is lit.

• Rising-edge Latched Inputs return an ON value from the time voltage is applied to the input module until they are explicitly "cleared" by the MotionBASIC program. e.g. DIO@(1) = OFF

• Falling-edge Latched Inputs return an ON value from the time voltage is removed from the input module until they are explicitly "cleared" by the MotionBASIC program. e.g. DIO@(1) = OFF

"Rising-edge" or "Falling-edge" latched inputs are always cleared by assigning the OFF value to them (e.g. DIO@(1) = OFF) independent of the value of the input voltage) and will be latched ON again only after the input voltage either "rises" or "falls" again. To read the current state of the input voltage, simply re-configure the DIO point as an "input" using IO.MODE@.

value When writing to output points, the value used in the expression DIO@(point) = value has the effects below:

value Action taken

OFF (or 0) TURN OFF immediately, and indefinitely. (time scheduled ON/OFFs cleared)

ON (or -1) TURN ON immediately, and indefinitely. (time scheduled ON/OFFs cleared)

Timed Output (Momentary OFF) -32,768≤ -time ≤-2 TURN OFF now TURN ON is scheduled for (now + time)

Timed Output (Momentary ON) 1≤ time ≤32,767 TURN ON now TURN OFF is scheduled for (now + time)

-159- DIO@ Discrete I/O Point ORMEC Variable Example 1: DIO@(6) =ON ’turn discrete output point 6 ON.

Example 2: DIO@(6) = 50 ’turn discrete output point 6 ON ’schedule point 6 OFF at (time now + 50 ms) Example 3: DIO@(6) = -50 ’turn discrete output point 6 OFF ’schedule point 6 ON at (time now + 50 ms)

Example 4: DIO@(6) = 5000 ’turn point 6 ON now (ref: time 0) ’schedule point 6 OFF at time (0+5) or 5 secs WAIT 2000 ’wait for 2 secs (ref: time 0) DIO@(6) = -1000 ’turn point 6 OFF now (ref: time 2) ’schedule point 6 ON at time (2+1) or 3 secs

Super-Imposed ON Timed Outputs This transition was scheduled by DIO@(6) = 5000 OFF RefTime012345secs

Example 5: IF DIO@(START) THEN GOSUB START Call a subroutine named START if the Discrete I/O point referenced by the integer variable, START, is ON. Note that while this statement normally would be used to make a decision based on an input point, an output point can also be used.

Note that output points 1 to 40 of the controller are turned OFF by pressing the red RESET pushbutton on the front of the unit or by a Watchdog Timer timeout. Pamux output points are unaffected.

Note that timed output points will be automatically turned OFF by errors which are not user trapped. With error trapping enabled, the error handler routine should turn OFF timed outputs as appropriate using DIO@(point)=OFF.

-160- DIST.BIAS@ Position Command Bias Distance ORMEC Variable

Purpose: Make a direct "step" change in the position command for a servo axis. Return the cumulative real-time value of position command bias.

Syntax: DIST.BIAS@[(axes)] = distance

Usage: var& = DIST.BIAS@[(axes)]

distance A numeric expression which represents the desired distance value to offset the overall position command in user units. Valid range is set by axis position units conversion factors.

var A long integer cumulative value of currently commanded distance resulting from direct changes in distance command. DIST.BIAS@ is a read-write variable whose range is determined by the axis position units conversion factor. Default = 0.

Assigning a value to POS.ACT@ sets DIST.BIAS@ to zero. POS.CMD@ is the sum of DIST.MOVE@, DIST.GEAR@, DIST.GRAT@,&DIST.BIAS@.

Assigning a value to MODE@ automatically takes the current position value stored in DIST.BIAS@ and adds it to DIST.MOVE@. DIST.BIAS@ is then set equal to zero.

DIST.GEAR@ Gear Distance Command ORMEC Variable

Purpose: Return the current real-time cumulative value of commanded distance resulting from GEAR FOR and ramped portions of GEAR AT statements for a servo axis.

Usage: var& = DIST.GEAR@[(axes)]

var A long integer cumulative value of commanded distance resulting from GEAR FOR, and ramped portions of GEAR AT commands. DIST.GEAR@ is a read-only variable whose range is determined by the axis position units conversion factor.

Assigning a value to POS.ACT@ sets DIST.GEAR@ equal to zero.

Assigning a value to MODE@ automatically takes the current position value stored in DIST.GEAR@ and adds it to DIST.MOVE@. DIST.GEAR@ is then set equal to zero.

POS.CMD@ is the sum of DIST.MOVE@, DIST.GEAR@, DIST.GRAT@,&DIST.BIAS@.

-161- DIST.GRAT@ Constant Gear Ratio Distance Command ORMEC Variable

Purpose: Return the current real-time cumulative value of commanded distance resulting from constant ratio portions of GEAR AT statements for a servo axis. (for ramped distance portions, see DIST.GEAR@)

Usage: var& = DIST.GRAT@[(axes)]

var A long integer cumulative value which is the currently commanded distance resulting from constant ratio GEAR AT statements. DIST.GRAT@ is a read-only variable whose range is determined by the axis position units conversion factor.

Assigning a value to POS.ACT@ sets DIST.GRAT@ equal to zero.

Assigning a value to MODE@ automatically takes the current position value stored in DIST.GRAT@ and adds it to DIST.MOVE@. DIST.GRAT@ is then set equal to zero.

POS.CMD@ is the sum of DIST.MOVE@, DIST.GEAR@, DIST.GRAT@,&DIST.BIAS@.

DIST.MOVE@ Move Distance Command ORMEC Variable

Purpose: Return the current real-time value of cumulative commanded distance resulting from MOVE commands for a servo axis.

Usage: var& = DIST.MOVE@[(axes)]

var&Along integer cumulative value of the currently commanded distance resulting from MOVE commands. DIST.MOVE@ is a read-only variable whose range is determined by the axis position units conversion factor.

Assigning a value to MODE@ automatically takes the current position values stored in DIST.GEAR@, DIST.GRAT@, and DIST.BIAS@ and adds their sum to the current value of DIST.MOVE@. They are then cleared to zero.

Assigning a value to POS.ACT@ automatically assigns the same value to DIST.MOVE@ and clears the other three distance variables to zero.

POS.CMD@ is the sum of DIST.MOVE@, DIST.GEAR@, DIST.GRAT@,&DIST.BIAS@.

-162- DSP.CTR@ DSP Motion Counter ORMEC Variable

Purpose: Returns or presets a counter which counts the number of motion statements that have been completed by the DSP.

Syntax: DSP.CTR@(axes)=preset

Usage: var% = DSP.CTR@(axes)

preset An integer expression, in the range 0 to 32767, providing the value to which DSP.CTR@(axes) is to be preset.

var% An integer variable in which the current value of DSP.CTR@(axes) will be placed.

Each time a DSP axis completes execution of a motion statement,it increments the value of DSP.CTR@(axis) by one. When the value reaches 32767, it will be reset to 0 on completion of the next motion statement. This can be used to track queued and REPEAT moves as follows:

REPEAT Move Tracking Example - This example repeats a set of three moves 4 times then stops. Monitoring DSP.CTR@ allows the program to determine which of the three moves has just been executed, and how many times the sequence has been repeated.

DSP.CTR@(1) = 0 :LAST.MOVE = 0 REPEAT MOVE 1 FOR 1000 AT 2000 ’move 1 REPEAT MOVE 1 FOR -500 AT 2000 ’move 2 REPEAT MOVE 1 FOR -500 AT 100 ’move 3 WHILE PASS<3ORMOVE.NUM < 2 IF DSP.CTR@(1) <> LAST.MOVE THEN LAST.MOVE = LAST.MOVE + 1 MOVE.NUM = ((DSP.CTR@(1) - 1) MOD 3) + 1 PASS = ((DSP.CTR@(1) - 1) \ 3) + 1 PRINT USING "Completed move # pass #";MOVE.NUM,PASS ENDIF WEND MOVE 1 FOR 0 IN 0 ’stop after completing current move

Queued Move Tracking Example - This example executes 100 moves keeping one move in the DSP motion queue at all times. Monitoring DSP.CTR@ prevents the motion queue from filling up, and allows the program to determine which move has just been completed.

DSP.CTR@(1) = 0 LAST.MOVE = 0 MOVE 1 FOR 1000 MOVE 1 FOR 1000 MOVES = 2 WHILE MOVES < 100 IF DSP.CTR@(1) <> LAST.MOVE THEN LAST.MOVE = LAST.MOVE + 1 MOVE 1 FOR 1000 PRINT USING "Move ### completed";DSP.CTR@(1) ENDIF WEND

-163- DSP.DONE@ No DSP Motion in Process or Pending ORMEC Variable

Purpose: Return a read-only Boolean variable as TRUE if all the specified servos do not have a motion acceleration or deceleration pending and do not have a motion pending an AFTER or UNTIL clause.

Usage: var% = DSP.DONE@[(axes)]

DUMP List Symbol Table Command

Purpose: List to the MotionPRO Development Port, the current state of the symbol table.

Syntax: DUMP

EDIT Display a Program Line for Editing Command

Purpose: Enter the line editor, display the specified program line. The edit keys are then used for editing the line. See also Text Editor.

Syntax: EDIT [line]

line The line number or label of the line to edit. If line is missing, then the most recently added line or the line where the last error occurred is used.

An "undefined line number" error occurs if the line number to edit is not in the current program.

The program write enable variable, PW@, must be set properly to allow a line to be edited.

-164- EIO.MODE@ Extended I/O Configuration ORMEC Variable

Purpose: Define the configuration mode of the Extended I/O Connector.

Syntax: EIO.MODE@ = mode Set Discrete I/O Mode

Usage: var% = EIO.MODE@ Get Extended I/O Mode

mode An integer expression representing the Extended I/O Mode.

0 - Digital In this (default) mode, the 24 I/O points at the Extended I/O Connector are compatible with 4, 8, 16 or 24-slot Opto-22 racks with the I/O point assignments as shown below. 1 - Pamux In this mode, the Extended I/O connector is used to interface up to 512 digital or analog I/O points using the Opto-22 Pamux standard.

var% An integer variable to receive the current value of EIO.MODE@

ELS1@ Electronic Limit Switch One ORMEC Variable

Purpose: Return a read-only Boolean variable which indicates whether or not the actual position for an axis is within a specified range. Serve as a gating signal for ASEN@ of its own axis. (See: SENS.MODE@)

Usage: var% = ELS1@[(axes)] ’w/ multiple axes reference, ELS1@s are ORed

var A Boolean value which will be turned ON or OFF at any servo loop update for which the value of POS.ACT@ for an axis moves "into" or "out of" the range specified by ELS1.LOW@ and ELS1.HIGH@.

All three electronic limit switches have corresponding TTL-level outputs at the "DSP I/O Header" on the DSP Axis Module.

Example: If ELS1.LOW@ = 90 and ELS1.HIGH@ = 180, then ELS1@ will be ON whenever 90 <= POS.ACT@ < 180. Otherwise it will be OFF.

-165- ELS1.LOW@,ELS1.HIGH@ Electronic Limit Switch Range ORMEC Variable

Purpose: Define the range for which an electronic limit switch will be ON.

Syntax: ELS1.LOW@[(axes)] = position1 ELS1.HIGH@[(axes)] = position2

Usage: var1& = ELS1.LOW@[(axes)] var2& = ELS1.HIGH@[(axes)]

position1 A long integer expression which represents the "lower" of two values which define the range for which a corresponding electronic limit switch ELS1@ will be ON.

position2 A long integer expression which represents the "higher" of two values which define the range for which a corresponding electronic limit switch ELS1@ will be ON.

Setting position1 & position2 to the same non-zero value sets the ELS ON. Setting position1 & position2 to zero sets the ELS OFF.

ELS2@ Electronic Limit Switch Two ORMEC Variable

Purpose: Return a read-only Boolean variable which indicates whether or not the actual position for an axis is within a specified range. Serve as a gating signal for BSEN@ of companion axis. (See: SENS.MODE@)

Usage: var% = ELS2@[(axes)] ’w/ multiple axes reference, ELS2@s are ORed

var A Boolean value which will be turned ON or OFF at any servo loop update for which the value of POS.ACT@ for an axis moves "into" or "out of" the range specified by ELS2.LOW@ and ELS2.HIGH@.

All three electronic limit switches have corresponding TTL-level outputs at the "DSP I/O Header" on the DSP Axis Module.

Example: If ELS2.LOW@ = 90 and ELS2.HIGH@ = 180, then ELS2@ will be ON whenever 90 <= POS.ACT@ < 180. Otherwise it will be OFF.

-166- ELS2.LOW@,ELS2.HIGH@ Electronic Limit Switch Range ORMEC Variable

Purpose: Define the range for which an electronic limit switch will be ON.

Syntax: ELS2.LOW@[(axes)] = position1 ELS2.HIGH@[(axes)] = position2

Usage: var1& = ELS2.LOW@[(axes)] var2& = ELS2.HIGH@[(axes)]

position1 A long integer expression which represents the "lower" of two values which define the range for which a corresponding electronic limit switch ELS2@ will be ON.

position2 A long integer expression which represents the "higher" of two values which define the range for which a corresponding electronic limit switch ELS2@ will be ON.

Setting position1 & position2 to the same non-zero value sets the ELS ON. Setting position1 & position2 to zero sets the ELS OFF.

ELS3@ Electronic Limit Switch Three ORMEC Variable

Purpose: Return a read-only Boolean variable which indicates whether or not the actual position for an axis is within a specified range.

Usage: var% = ELS3@[(axes)] ’w/ multiple axes reference, ELS3@s are ORed

var A Boolean value which will be turned ON or OFF at any servo loop update for which the value of POS.ACT@ for an axis moves "into" or "out of" the range specified by ELS3.LOW@ and ELS3.HIGH@.

All three electronic limit switches have corresponding TTL-level outputs at the "DSP I/O Header" on the DSP Axis Module.

Example: If ELS3.LOW@ = 90 and ELS3.HIGH@ = 180, then ELS3@ will be ON whenever 90 <= POS.ACT@ < 180. Otherwise it will be OFF.

-167- ELS3.LOW@,ELS3.HIGH@ Electronic Limit Switch Range ORMEC Variable

Purpose: Define the range for which an electronic limit switch will be ON.

Syntax: ELS3.LOW@[(axes)] = position1 ELS3.HIGH@[(axes)] = position2

Usage: var1& = ELS3.LOW@[(axes)] var2& = ELS3.HIGH@[(axes)]

position1 A long integer expression which represents the "lower" of two values which define the range for which a corresponding electronic limit switch ELS3@ will be ON.

position2 A long integer expression which represents the "higher" of two values which define the range for which a corresponding electronic limit switch ELS3@ will be ON.

Setting position1 & position2 to the same non-zero value sets the ELS ON. Setting position1 & position2 to zero sets the ELS OFF.

END Terminate Program Statement

Purpose: Terminate a program and CLOSE all OPEN devices & files.

Syntax: END

The END statement turns off all error and event trapping, and event checking completely.

Any Input task or Output task that is in process will be terminated without error.

See Also: STOP ON ERROR EVENT

-168- EOF End-of-File Status Function

Purpose: Check for end-of-file status on a file or device.

Usage: var% = EOF({ filenum | devnum })

filenum The number under which the file was OPENed.

devnum The number under which the device was OPENed.

With a file, if an end-of-file has been reached, EOF returns -1 (TRUE); otherwise, it returns 0 (FALSE).

With a communications device, an EOF of -1 (TRUE) means the input buffer is empty.

See Also: ITM Driver Support Sequential Files

ERASE Remove Variable from Memory Statement

Purpose: Delete one or more variables and make available the memory allocated to those variables.

Syntax: ERASE variable[,variable] ...

variable The name(s) of the variable(s) to be erased from memory.

Note that:

• Arrays must be erased with an ERASE or CLEAR statement before they can be re-dimensioned with a DIM statement.

• Note that ERASE statements cannot be used inside a FOR...NEXT loop.

See also: CLEAR

-169- ERL Line Number of Most Recent Error Function

Purpose: Return the program line number at which the most recent error occurred.

Usage: var& = ERL

ERL returns 65535 if a direct-mode statement produced the most recent error.

When RENUM is used, it will interpret all numbers on a line after an ERL token as line numbers, and renumber them appropriately.

See also: ERR ERR$ ERROR ON ERROR RESUME Program Initialization

ERR Error Number Function

Purpose: Return the error code number of the most recent error.

Usage: var& = ERR

If no error has occurred, ERR returns 0.

ERR is non-volatile and will return the number of the most recent error code even if the unit’s power is lost and restored.

See also: ERL ERR$ ERROR ON ERROR RESUME Program Initialization

ERR$ Error Message Function

Purpose: Return the error message string for a MotionBASIC error.

Usage: var$ = ERR$(error number)

error number An integer expression indicating the number of the error code of the error whose "error message" is to be returned. This function returns the same string that MotionBASIC prints to the console when an error occurs.

ERR$(ERR) returns the error message for the most recent error to occur.

See also: ERL ERROR ON ERROR RESUME

-170- ERROR Force Error Statement

Purpose: Produce error number n.

Syntax: ERROR n

n An integer expression from 1 to 65535.

If n is not one of MotionBASIC’s standard error codes, and no ON ERROR routine is in use, ERROR n stops program execution and produces an "User Defined Error" error message.

If an ON ERROR routine is in effect, an ERROR n statement is trapped in the normal way, whether or not the number is one of MotionBASIC’s error codes.

See also: ERL ERR ERR$ ON ERROR RESUME

ESTOP.OK@ Emergency Stop Input OK ORMEC Variable

Purpose: Return the status of the Emergency Stop Input.

Usage: var% = ESTOP.OK@

var% A Boolean integer variable which will be TRUE (-1) if +24 VDC is applied to the E-Stop input. Otherwise it will be FALSE (0).

EVENT Enable/Disable Hardware Event Trapping Statement

Purpose: Enable & disable trapping for individual events defined with the ON EVENT...GOSUB statement. Also, globally enable & disable all events.

Syntax 1: EVENT var@ {ON | OFF | STOP} ’individual Event syntax

var@ DIO@(n) Specifies a discrete I/O point. n An integer expression, range 1 to 16.

ON EVENT var@ ON enables "trapping" for an event already defined in an ON EVENT...GOSUB statement. With "trapping" ON, MotionBASIC always checks for an event occurrence, before executing each program statement. If the event is trapped asserted ( & not in the "stopped" state), program execution branches to that event’s handler routine. Always clear a latched input before enabling its trapping, if the next transition is the one which should be trapped.

OFF EVENT var@ OFF turns off trapping for the specified event.

-171- EVENT Enable/Disable Hardware Event Trapping Statement

STOP EVENT var@ STOP inhibits the event handler execution for a specified point until a subsequent EVENT var@ ON is executed. Its Event trapping does continue. If the point is "trapped asserted" during the "inhibit period", the event will be serviced immediately after an EVENT var@ ON is executed. A global EVENT ON does not restore event handler execution of individually "stopped" events.

NOTE: I/O Events have a priority. Events defined in a particular order with ON EVENT...GOSUB statements, will be evaluated in that very same order. Events defined first will have priority.

Before each program statement is executed, MotionBASIC checks I/O. It only checks for assertion of those points that have trapping enabled (via the EVENT DIO@(n) ON). This check always begins with the first defined I/O EVENT. When it finds an event asserted, it checks no further, and that Event is serviced. On the next check, it again begins with the first event defined.

Syntax 2: EVENT {ON | OFF | STOP} ’global Event syntax

ON EVENT ON will lift an inhibit to Event Handler routine execution imposed by a global EVENT STOP or EVENT OFF.

OFF EVENT OFF suspends event trapping and execution of event handler routines.

STOP EVENT STOP only inhibits execution of event handler routines. The event trapping continues in the "stopped" state.

When an Event is serviced, MotionBASIC performs a GOSUB to the event’s handler routine. MotionBASIC also temporarily inhibits all events. This is done with two "implicit", or background, commands: EVENT DIO@(n) STOP for the event in progress, and EVENT STOP for all other events. This inhibit remains in effect until a RETURN is executed. At that time, implicit EVENT DIO@(n) ON and EVENT ON are executed. In this way, "nesting" of event routines is avoided.

Allowing "nesting" of Event Handlers: As explained above, nesting of event handler routines is avoided with implicit MotionBASIC instructions. For those users want to circumvent this "standard" approach, this discussion is included:

Within an event routine, to permit the execution of other event routines, execute a global EVENT ON statement. All other events that were viable, could now be serviced. Remember, only one additional handler routine will be serviced at a time, since along with each GOSUB to an event handler routine, another implicit EVENT STOP is executed.

Note: If an event is to be permitted to either interrupt itself, or some nested event handler that is being executed, then the statement EVENT DIO@(n) ON will need to be strategically placed in order to remove the individual "stopped status" that was implicitly commanded. Remember, an individual event "stop status" is implicitly imposed on an event, whenever its event handler routine is called.

-172- EVENT Enable/Disable Hardware Event Trapping Statement

Error Handler Ramifications: In the execution of an Error Handler routine (established via an ON ERROR statement) an implicit global EVENT STOP is executed. This inhibit to all Event Handler routines is lifted when the Error Handler executes a RESUME statement. If a RESUME is not used to exit an Error Handler, then restoring Event Handler execution must be done with a global EVENT ON statement and individual "EVENT DIO@(n) ON statements for any points that could have been caught "individually stopped" within their own Event Handler routines.

Direct Mode Ramifications: Events are normally "OFF" in direct mode. If a program enters direct mode from a STOP statement or Ctrl-C, the events are "stopped". A subsequent CONT, GOTO,orGOSUB (implied or explicit) command restores event handling to its previous (program execution) state. An END statement turns off events.

See Also: Stack Clear MotionBASIC Event Processing

EXITKEY The INPUT @ Exit Key Code Function

Purpose: Return a value indicating which key which terminated an INPUT @ statement, allowing programming decisions to be based on that key.

Usage: var% = EXITKEY Store a value indicating the key pressed See: Key Table

Syntax: EXITKEY = value Initialize or reset an EXITKEY value.

EXITKEY values: Key that terminated edit EXITKEY value INPUT @ Action ENTER 0 value updated Function key F1-F10 1-10 value updated UP Arrow 11 value updated LEFT Arrow 12 value updated RIGHT Arrow 13 value updated DOWN Arrow 14 value updated ESCAPE 32 value unchanged

-173- EXITKEY The INPUT @ Exit Key Code Function

Example: EXITKEY is used as the argument for an ON...GOSUB to direct program flow based on the key that terminated the field edit.

10 INPUT @12,12; "Enter a Value: "; USING " ##.## "; val1 20 ON EXITKEY-10 GOSUB UPKEY, LEFTKEY, RIGHTKEY, DOWNKEY 30 RETURN

100 UPKEY: ... program statements to handle up arrow

210 LEFTKEY: ... program statements to handle left arrow

350 RIGHTKEY: ... program statements to handle right arrow

385 DOWNKEY: ... program statements to handle down arrow

EXP Exponent (Natural) Function

Purpose: Return e (the base of natural logarithms) to the power of numexpr.

Usage: var# = EXP(numexpr)

numexpr A numeric expression. An overflow error will occur if numexpr is greater than 7.0E2.

Note: The value of e is approximately 2.718282.

See also: LOG CLG

-174- FAULT@ Unit Fault Code ORMEC Variable

Purpose: Identify the set of current fault(s) with a motion controller; Clear (or set) this variable, and reset (or trip) the No Fault Relay.

Usage: var~ = FAULT@ ’FAULT@ is returned as a Set Syntax: FAULT@={ON|OFF} ’FAULT@ is written as a Boolean

var~ A set variable to receive the set of current fault condition(s).

OFF Clear FAULT@ and energize the No Fault Relay. ON Set FAULT@ ( 8 Machine Fault) and trip the No Fault Relay.

Code Fault Condition Code Fault Condition

1 RAM Checksum Error 6 E-Stop Input Open 2 Battery Failure 7 Axis Fault 3 Invalid Unit ID 8 Machine Fault 4 Internal Error 9 String Space Fault 5 Axis Module Failure 10 MotionCARD Fault

The FAULT@ variable is "latched", in that when one or more of the fault conditions listed above has occurred, the appropriate elements in FAULT@ are asserted and when the condition "goes away" the fault condition(s) is(are) NOT automatically cleared. To clear FAULT@, you must explicitly clear it using one of the syntaxes above.

Whenever any elements of FAULT@ are non-zero, the green "NO FAULT" indicator on the front of the unit will be OFF, and the No Fault Relay will be "dropped out" opening its isolated, normally-open contact output. When FAULT@ is cleared, AND ESTOP.OK@ is TRUE, the coil of the No Fault Relay will be energized.

Example: If we assume that both Battery Failure and Invalid Unit ID were detected at powerup, then the program below would print as shown. 10 PRINT FAULT@ 20 END RUN {2,3}

-175- FIELD Define File Field Format Statement

Purpose: Define random access file field format(s) via file variables

Syntax: FIELD [#]filenum, fieldelem [,fieldelem]...

filenum An integer expression; Specifies an OPEN file, from 1 to 15.

fieldelem { fieldwidth AS strvar |[fieldwidth AS] numvar }

fieldwidth The number of characters positions to be allotted for strvar or the number of bytes to be allotted for the binary representation for the value of numvar.

strvar A string variable to be used for random access.

numvar A numeric variable to be used for random access. All numeric representations are left justified.

Once the random access file has been FIELDed, data may be extracted from the random access file buffer through file variables after a GET statement or placed into the buffer through file variables in preparation for a PUT statement.

The value of numeric variables are always stored in binary format. If field width of a numeric variable is not specified, it will be equal to the binary storage size of that variable. If the field width of a numeric variable is less than the binary storage size of that variable, only the least significant portion of that binary format will be stored. However, an error will occur if the specified field width of a floating point variable is less than the binary storage size of that floating point variable.

ONLY ONE FIELD STATEMENT IS ALLOWED PER DEVICE.

Elimination of a field variable with an ERASE command will cause subsequent PUT or GET statements to generate an error.

A device must be OPENed for random access before the corresponding FIELD statement may be executed.

Examples: 10 OPEN "R", #1, "myrec.bin", 14 20 FIELD #1, 1 AS BYTE%, 2 AS SMALL.SET~, 3 AS MNTH$, PCENT# 30 BYTE% = &HA55A : SMALL.SET~ = {1,16,17} 40 LSET MNTH$ = "JUN" : PCENT# = 38.45# 50 PUT #1,3:GET #1, 3 60 PRINT HEX$(BYTE%); SMALL SET~; MNTH$; PCENT#

This example will print: 5A{1,16}JUN 38.45

And the 14, (1+2+3+8), byte record in hex will look like: 5A 01 80 4A 55 4E 9A 99 99 99 99 39 43 40

See Also: PUT, GET, OPEN file

-176- FILES Display Files in Memory Disk Command

Purpose: Display the names of files currently stored on a Memory Disk. Or, transfer files between the Memory Disk and the Development Computer disks directly.

Syntax 1: FILES ["filemask"] List files on Memory Disk Syntax 2: FILES LOAD "pcfile" [TO "mdfile"] Load file into Memory Disk Syntax 3: FILES SAVE "mdfile" [TO "pcfile"] Save file to PC

filemask A string expression that follows DOS file-naming conventions. This string can be used to selectively display the names of files stored in the Memory Disk. The "*" and "?" characters may be used as wild cards. If the filemask is not specified, the default value is "*.*" which will cause the names of all the files to be listed.

pcfile The file specification for a file on the Host PC. Disk drive and path information may be included in the specification. If the Disk Drive and path specification

is not specified, the Host PC’s current drive and working directory will be assumed.

mdfile The file specification for a file on the Memory Disk. The drive specification and path information is optional. If the drive and path information is omitted, the current Memory Disk directory will be assumed.

See also: CHDIR MKDIR RMDIR KILL NAME FORMAT

FIX Truncate to Whole Number Function

Purpose: Truncate, without rounding, any numeric expression to a whole number.

Usage: var = FIX(numexpr)

Note: FIX eliminates everything to the right of the decimal point. FIX returns either an Integer or a Long Integer depending on numexpr.

Example:

PRINT FIX(35756.998) 35756

PRINT FIX(-234.678) -234

See also: INT

-177- FOR, NEXT FOR...NEXT Loop Statement

Purpose: Define a loop to take an action a certain number of times, or for a specified set of elements.

Syntax 1: FOR counter = start TO end [STEP increment] . . [statements] . NEXT [counter]

Syntax 2: FOR setvar WITHIN setexpr . . [statements] . NEXT [setvar]

counter A numeric (non-set) variable to be used as the loop counter (integer and long integer variables execute faster). start A numeric expression; the starting value of counter.

end A numeric expression; the ending value of counter. increment A numeric expression; the value by which counter is incremented with each iteration of the loop. May be negative to decrement counter. Defaults to 1. setvar A set variable to be used as the loop counter. setexpr A set expression, whose individual elements are to be sequencially assigned to setvar, starting with the lowest.

Syntax 1: MotionBASIC begins processing the FOR...NEXT loop by setting counter equal to start. Then, if increment is positive and counter is not greater than end, the statements between the FOR statement and the NEXT statement are executed. When the NEXT statement is encountered, counter is increased by increment, and the process is repeated. Execution passes to the statement following the NEXT statement if counter is greater than end.

If increment is negative, execution of the FOR...NEXT loop is terminated whenever counter becomes less than end.

If increment is 0, the FOR...NEXT loop executes until Ctrl-C is pressed (unless one of the instructions in the loop increments counter).

Note that changes made within the FOR...NEXT loop to counter affect the number of times the loop instructions are executed; changes made to start, end, and increment, however, do not have this effect.

Inclusion of counter in a NEXT statement is optional as long as it is only used to close one FOR statement; if counter is omitted, its value is assumed to be that of counter in the most recent FOR statement.

FOR...NEXT loops may be nested within one another. Each FOR must be given a unique counter specification and each nested FOR must have its NEXT statement appear within the enclosing FOR/NEXT block.

Nested loops that have a common termination point may use a single NEXT statement as long as they specify multiple counters matching the counters in the FOR statements.

-178- FOR, NEXT FOR...NEXT Loop Statement

The loop is skipped if start is greater than end and increment is positive, or start is less than end and increment is negative.

Syntax 2: When taking an action for a set of elements, processing of the FOR...NEXT block begins by assigning the lowest numbered element in setexpr to setvar. The statements between the FOR statement and the NEXT statement are then executed. When the NEXT statement is executed, setvar is assigned the next lowest numbered element in setexpr. The process repeats until the highest numbered element in setexpr is used. Execution then passes to the statement following the NEXT statement.

Note that changes made within the FOR...NEXT loop to setvar or setexpr have no affect on the sequence of elements assigned to setvar.

Inclusion of setvar in a NEXT statement is optional as long as it is only used to close one FOR statement; if setvar is omitted, its value is assumed to be that of setvar in the most recent FOR statement.

FOR...NEXT loops may be nested within one another. Each nested FOR must be given a unique setvar specification and its corresponding NEXT statement must appear within the enclosing FOR...NEXT block.

Nested loops that have a common termination point may use a single NEXT statement as long as it specifies multiple setvars matching the setvars in the FOR statements.

The loop is not executed if setexpr is an empty set.

MotionBASIC programs should not include GOTO statements which branch out of a FOR...NEXT loop. See structured programming for details.

See also: WHILE...WEND IF...THEN...ELSE Differences from GWBASIC

FORMAT Format a Memory Disk Command

Purpose: Format the Memory Disk so that it may be used.

Syntax: FORMAT [DELETE]

The command will format a Memory Disk. If a recognized format exists on the Memory Disk, an error message will be generated to warn the User that a potential exists that data will be lost. To override the error message, the optional DELETE parameter must be specified.

See also: FILES KILL

-179- FRE Available Memory Function

Purpose: Return the number of bytes available in MotionBASIC’s data space; optionally force a defragmentation of MotionBASIC’s string space.

Usage: var& = FRE({stringexpr | numexpr})

stringexpr A dummy argument; the actual value is inconsequential. FRE(stringexpr) causes MotionBASIC to clean house on its string data space by performing a "garbage collection", then report the amount of string space that is available.

numexpr A dummy argument; the actual value is inconsequential. FRE(numexpr) returns the available data memory (no housecleaning is performed).

GEAR Gear Follower Axis to Pacer Axis Statement

A single GEAR statement can be used to command motion for one or more servomotors which will be executed relative to the movement of another motor or encoder. It has two major variations:

Variation Purpose

GEAR FOR move the follower a relative distance from its current position as a function of the pacer movement. GEAR AT move the follower at a specified ratio with respect to the pacer movement

Motion statements transfer actual command information to the DSP Axis Modules through the motion queue.

Electronic gearing parameters define acceleration, top speed and deceleration in a variety of ways. In addition, all parameters for GEAR statements are specified in user units, and are limited by the axis range variables.

-180- GEAR Statement SYNTAX CHART For Instructions See: Syntax Chart Rules

IN ♦Pdist ,Pa ,Pd FOR IN Pa A[REPEAT] modifier may [-] AT TO precede any GEAR FOR. ♦Fdist ♦outspeed ♦inspeed GEAR The following modifiers [axes] BY ♦Fa ,Fd may be appended to any GEAR statement: AT TO [AFTER cond] [-] ♦outspeed ♦inspeed [UNTIL cond] IN ♦Pa ,Pd [AFTER cond UNTIL cond]

♦ indicates that A GEAR AT with an AXIS.VAR@ can be used [UNTIL cond] or both for that parameter. [AFTER cond UNTIL cond] modifiers is REPEATable See Also: GEAR FOR, GEAR AT , EBC

GEAR FOR Gear Follower Axis a Specified Distance Statement

Purpose: Move a follower motor a relative distance from its current position in synchronism with a pacer motor or encoder; move multiple follower motors a relative distance from their current positions.

Syntax:

[REPEAT] GEAR [axes] FOR Fdist IN Pdist [,Pa[,Pd]] [AFTER cond] [UNTIL cond]

[REPEAT] GEAR [axes] FOR Fdist AT outspeed [TO inspeed] [IN Pa[,Pd]] [AFTER cond] [UNTIL cond]

[REPEAT] GEAR [axes] FOR Fdist AT outspeed [TO inspeed] [BY Fa[,Fd]] [AFTER cond] [UNTIL cond]

NOTE: GEAR FOR movements can be "superimposed on a moving frame of reference" created by a constant ratio GEAR AT statement.

See Also: GEAR Syntax Chart Encoder Backup Compensation

-181- GEAR FOR Gear Follower Axis a Specified Distance Statement Examples: (assume user units of "thousandths of an inch" for axis & pacer)

REPEAT GEAR FOR 1000 IN 5000 AFTER ASEN@ Cause the servos defined in AXIS.SET@ to repeat a follower motion of 1 inch in 5 inches of pacer travel each time the "A-Sensor" is asserted, without intervention of the main processor.

GEAR {3} FOR -20000 AT 4 TO 3 BY 1000,2000 Cause axis 3 to move in the reverse direction 20 inches at a ratio of 4:3 of the pacer input, reaching the specified ratio after 1 inch of travel and decelerating 2 inches before the stop position.

GEAR {2} FOR 5000 AT 4 TO 1 BY 100 Cause axis 2 to move 5" at 4x pacer speed, accelerating and decelerating in 0.1" travel of its own travel.

GEAR {1,4} FOR -1000 IN 5000 Cause axes1&4tomove in the negative direction 1 inch in 5 inches travel of the pacer.

GEAR FOR 2000 IN 10000,500,650 Cause the servos defined in AXIS.SET@ to move forward 2 inches during 10 inches travel of the pacer, accelerating in 0.500 inches of the pacer and decelerating in 0.650 inches its travel.

GEAR AT Gear Follower Axis at a Specified Ratio Statement

Purpose: Move a follower motor at a specified ratio with respect to pacer motor or encoder; move multiple follower motors at a specified ratio.

Syntax: GEAR [axes]AT[-]outspeed [TO inspeed] [IN Pa[,Pd]][AFTER cond][UNTIL cond] GEAR [axes]AT[-]outspeed [TO inspeed] [BY Fa[,Fd]][AFTER cond][UNTIL cond]

A GEAR AT can be REPEATed when an UNTIL modifier is used. A GEAR AT can be REPEATed when both AFTER & UNTIL modifiers are used.

Note that motions created by GEAR FOR and MOVE may be "superimposed on a moving frame of reference" created by a GEAR AT statement, with the restriction that the additional GEAR or MOVE statements will not be executed during accelerations of the GEAR AT. GEAR AT statements will replace GEAR AT and/or GEAR FOR statements in the motion queue.

See Also: GEAR Syntax Chart Encoder Backup Compensation

-182- GEAR AT Gear Follower Axis at a Specified Ratio Statement

Examples: (assume user units of "thousandths of an inch" for axis & pacer) GEAR {2} AT 11 TO 23 ’move axis 2 at 11/23 of the pacer rate

GEAR {2} AT 1 TO 1 BY 200,300 AFTER ASEN@ UNTIL BSEN@ Cause axis 2 to accelerate to a 1:1 ratio with the pacer within 0.2 inches of its own travel after the A-Sensor is asserted; also begin deceleration when the B-Sensor is asserted and come to rest in 0.3 inches of travel.

REPEAT GEAR {2} AT 1 TO 1 BY 200,300 AFTER ASEN@ UNTIL BSEN@ Cause axis 2 to start the motion described above each time the A-Sensor is asserted. (B-Sensor also needs to occur to stop the geared motion.)

Parameters for the GEAR statement

Parameter Description Default

axes a set of one or more servos to be geared AXIS.SET@ Fdist total distance & relative direction to gear for Pdist total pacer input distance in which to gear for outspeed *(OUTSPD.MUL@)= the numerator of the ratio of axis encoder counts to pacer counts inspeed *(INSPD.MUL@)= the denominator of the ratio of 1 axis encoder counts to pacer counts ,Pa pacer input distance in which to accelerate Pdist/3 IN Pa pacer input distance in which to accelerate 0 Pd pacer input distance in which to decelerate Pa Fa follower output distance in which to accelerate Fd follower output distance in which to decelerate Fa

GEAR Statement parameters are specified in User Units.

See Also: GEAR Syntax Chart Encoder Backup Compensation

Pdist is the total pacer input distance in a GEAR FOR statement. Along with total pacer distance, the user may specify acceleration distances.

Even when specifying pacer acceleration distance parameters (Pa, Pd) the resultant motion may actually use a Pa=0 and Pd=0 if Pdist is less than a minimum value. That minimum value, in user units, is given by:

PCR.SPD.LIM@ * PCT.REV@ PPS.DIV@ MIN Pdist = * 0.14 * LOOP.RATE@ PPS.MUL@

With the minimum Pdist requirement is satisfied, then a non-zero Pa and non-zero Pd can be performed. Pa & Pd also have minimum usable values. These minimum values are:

MIN Pdist (from above) MIN Pa = MIN Pd = Pa & Pd minimums also apply 4inaGEAR AT statement.

-183- Parameters for the GEAR statement

Outspeed and Inspeed are parameters which are used in GEAR statements to determine the constant ratio portion of GEAR AT and GEAR FOR motions.

Example: GEAR AT outspeed to inspeed

The two rules on these parameters are as follows:

1) The product of the parameter and its gear speed multiplier must be in the range of a long integer. Symbolically stated:

-2,147,483,648 ≤ (outspeed * OUTSPD.MUL@) ≤ 2,147,483,647

1 ≤ ( inspeed * INSPD.MUL@ ) ≤ 2,147,483,647

2) The specified values for outspeed and inspeed must result in a ratio that is within range for proper handling by the DSP Module. The error message, #1612 Specified Gear Ratio is Out of Range, is issued if the parameters do not satisfy this requirement.

The following formulas may be used to obtain the minimum and maximum ratios achievable with outspeed and inspeed parameters for an axis.

First Calculate the PCR.SPD.LIM@ * PCT.REV@ minimum segment: MIN Seg = * 0.035 LOOP.RATE@

Minimum Ratio Maximum Ratio

INSPD.MUL@ 1 outspeed 32767 INSPD.MUL@ * ≤≤ * OUTSPD.MUL@ 32767 - MIN Seg inspeed MIN Seg +1 OUTSPD.MUL@

2

Values for outspeed and inspeed that fail the test will be Out of Range. (NOTE: Some values will pass the test and thus appear to be in range, but will actually be Out of Range due to internal scaling.)

GEAR.RATIO@ Current Electronic Gear Ratio ORMEC Variable

Purpose: Return the electronic gear ratio currently in use by an axis.

Usage: var# = GEAR.RATIO@[(axes)]

var A read-only double precision floating-point value which contains the actual GEAR ratio currently in effect for an axis. The value returned is consistent with the outspeed and inspeed as specified in the GEAR statement.

-184- GET Read from a Random Access File Statement

Purpose: Transfer a specified record from a specified random access file on a Memory Disk into the associated random access file buffer.

Syntax: GET [#]devnum [,recnumber]

devnum An integer expression specifying a device from 1 to 15.

recnumber A positive, non-zero long expression specifying the record number to be transferred. Defaults to the next record, or record 1 (if no record has been GET/PUT).

A FIELD statement must be declared before execution of a PUT statement.

See Also: PUT, FIELD

GOSUB Execute Subroutine Statement

Purpose: Call a MotionBASIC subroutine.

Syntax: GOSUB {linenum | label}

linenum A numeric constant representing an existing program line.

label A symbolic label at the beginning of an existing program line.

Causes program execution to branch to the specified line number or label; when the RETURN statement is encountered, execution branches to the statement immediately following the most recent GOSUB statement or the specified one.

Subroutines may be called any number of times, from any number of different points in a program. They may be nested, and they may have multiple RETURN statements.

MotionBASIC programs should not include GOTO statements which branch out of a subroutine. See the structured programming chapter for details.

See also: GOTO ON...GOTO ON...GOSUB

-185- GOTO Unconditional Branch Statement

Purpose: Branch unconditionally to a specified MotionBASIC line.

Syntax: GOTO {linenum | label}

linenum A numeric constant representing an existing program line.

label A symbolic label at the beginning of an existing program line.

Causes program execution to branch to a specified line number or label.

Example: 10 START: PRINT "HELLO" 20 INPUT BYE$ 30 GOTO START

See also: GOSUB ON...GOTO ON...GOSUB

HALT Halt a Motion in Process Statement

Purpose: Stop all motion in progress, or pending, on one or more axes.

Syntax 1: HALT [axes] USING Ah [AFTER cond] [UNTIL cond] Syntax 2: HALT [axes]BYDh [AFTER cond] [UNTIL cond] Syntax 3: HALT [axes]INTh [AFTER cond] [UNTIL cond] Syntax 4: HALT [axes][AFTER cond] [UNTIL cond]

Ah A numeric expression representing the Rate to halt (decel). Dh A numeric expression representing the Distance to halt. Th A numeric expression representing the Time to halt.

If the HALT statement is used with no parameters, the system will decelerate using the rate specified by DCL.MAX@. Also, whenever HALT is used for more than one axis, deceleration starts as soon as possible for each axis. This will cause axes running in synchronism with each other to stop at different positions after a multi-axis HALT statement.

See Also: HALT Syntax Chart

-186- HALT Statement SYNTAX CHART For Instructions See: Syntax Chart Rules

USING ♦Ah

HALT BY ♦Dh The following modifiers [axes] may be appended to a IN ♦Th HALT statement:

[AFTER cond] [UNTIL cond] Parameter Description Default [AFTER cond UNTIL cond]

axes servos to halt AXIS.SET@ ♦ indicates that Ah halt rate DCL.MAX@ AXIS.VAR@ can be used Dh halt distance for that parameter Th halt time

HALT Statement parameters are specified in User Units

HEX$ Hexadecimal Value, as String Function

Purpose: Return, as a string, the hexadecimal representation of a number.

Usage: var$ = HEX$(lngexpr)

If lngexpr is negative, HEX$ returns the twos complement value in hex.

The returned string contains no leading zeros.

See also: STR$ OCT$ BIN$

HTL.FWD@ Forward Hardware Travel Limit ORMEC Variable

Purpose: Read the state of the forward hardware travel limit input latch for a servo or set of servos.

Usage: var& = HTL.FWD@[(axes)] ’w/ multiple axes, HTL.FWD@s are ORed

var A read-only Boolean which is latched ON when the forward hardware travel limit input on a DSP Axis Module goes "high" (more than 4 volts). If, and only if, the hardware travel limit input is "low" (less than 0.8 volts), HTL.FWD@ may be cleared to the OFF state by the statement OTL.FWD@ = OFF.

If a servo is in position, velocity or output mode and it’s forward hardware travel limit is asserted, then: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.FWD@ Boolean variable for that axis will be asserted, and •amotion error will be generated.

See OTL.FWD@ for a detailed explanation of overtravel limit operation.

-187- HTL.REV@ Reverse Hardware Travel Limit ORMEC Variable

Purpose: Read the state of the reverse hardware travel limit input latch for a servo or set of servos.

Usage: var& = HTL.REV@[(axes)] ’w/ multiple axes, HTL.REV@s are ORed

var A read-only Boolean which is latched ON when the reverse hardware travel limit input on a DSP Axis Module goes "high" (more than 4 volts). If, and only if, the hardware travel limit input is "low" (less than 0.8 volts), HTL.REV@ may be cleared to the OFF state by the statement OTL.REV@ = OFF.

If a servo is in position, velocity, or output mode and it’s reverse hardware travel limit is asserted, then: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.REV@ Boolean variable for that axis will be asserted, and •amotion error will be generated.

See OTL.REV@ for a detailed explanation of overtravel limit operation.

IF, THEN, ELSEIF, ELSE Conditional Branch Statement

Purpose: Conditionally execute statement(s), based on expression(s).

Syntax 1: BLOCK STRUCTURED IF: The recommended syntax, see structured programming

IF expression THEN ’each IF block needs an ENDIF statement [:statement]... ’THEN "action" statements must start [statement][:statement]... ’on the next line, many lines OK. [statement][:statement]... [ELSEIF expression THEN] ’zero or multiple ELSEIF blocks OK. [statement][:statement]... ’THEN "actions" must start on [statement][:statement]... ’the next line, many lines OK. [statement][:statement]... [ELSE] ’one ELSE block is optional. [statement][:statement]... ’ELSE "actions" must start on [statement][:statement]... ’the next line, many lines OK. [statement][:statement]... ENDIF

-188- IF, THEN, ELSEIF, ELSE Conditional Branch Statement

Syntax 2:IFexpression THEN clause [ELSE clause] Syntax 3:IFexpression GOTO {linenum | label} ’not recommended Syntax 4:IFexpression THEN linenum ’not recommended Syntax 5:IFexpression THEN label ’not recommended

expression A numeric or boolean expression.

clause A MotionBASIC statement or sequence of statements (on the same logical program line, separated by colons).

For syntax 1, if expression is non-zero (TRUE), MotionBASIC transfers control to the next program line. It executes the THEN block until the optional matching ELSEIF or ELSE is encountered. The block following the ELSEIF and/or ELSE is skipped. If expression is zero (FALSE), MotionBASIC transfers control to the following ELSEIF or ELSE clause at the same level of nesting, if it exists. Unconditional execution continues on the line following the ENDIF. Block IF, THEN, ELSE nesting is allowed.

For syntax 2, if expression is non-zero (TRUE), MotionBASIC executes the THEN clause. Otherwise it executes the ELSE clause, if one exists. Unconditional execution continues on the next line.

For syntax3&4,ifexpression is non-zero (TRUE), MotionBASIC branches to (performs a GOTO) the line specified by linenum or label. Otherwise it continues unconditional execution on the following line. These syntaxes are NOT recommended, but included for compatibility reasons.

Note that syntax 5 does an implied GOSUB to the label! This syntax may cause confusion and is NOT recommended. Instead, use an explicit GOSUB within a block syntax to perform this function.

The THEN and ELSE clauses may also be a line number (with no keyword before it). MotionBASIC treats

IF expression THEN {linenum}

as if it were

IF expression THEN GOTO {linenum}

Expression may be a Boolean expression (e.g., IF today$ = "Monday" ...) or a numeric expression (e.g. IF A(4) ...). In the latter case, MotionBASIC considers a value of 0 to be FALSE and all other values to be TRUE.

IF statements may be nested to any depth. In nested IFs, all ELSEIFs and ELSEs are associated with their nearest preceding THEN and all ENDIFs are associated with their nearest preceding ELSEIF or ELSE block if there is one otherwise the nearest preceding THEN block.

-189- IF, THEN, ELSEIF, ELSE Conditional Branch Statement

Note: There are other variations of the IF-THEN-ELSE construct that combine the syntaxes described above, but these variations are not recommended.

See also: ON...GOSUB ON...GOTO Operators

IN.ACL@ In Acceleration ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the specified servo(s) is (are all) being commanded by a MOVE to accelerate.

Usage: var% = IN.ACL@[(axes)]

IN.DCL@ In Deceleration ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the specified servo(s) is (are all) being commanded by a MOVE to decelerate.

Usage: var% = IN.DCL@[(axes)]

IN.MOT@ In Motion ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the specified servo(s) is (are all) being commanded by a MOVE to move.

Usage: var% = IN.MOT@[(axes)]

IN.POS@ In Position ORMEC Variable

Purpose: Return a read-only Boolean variable as true if the motor(s) is (are all) positioned within the specified "in position" band, as defined by PERR.INPOS@.

Usage: var% = IN.POS@[(axes)]

-190- INERTIA@ Total Inertia at Motor Shaft ORMEC Variable

Purpose: Define the total inertia of a servo axis.

Syntax: INERTIA@[(axes)] = inertia

Usage: var! = INERTIA@[(axes)]

inertia A single precision floating point expression which represents the total system inertia as seen at the motor shaft from 0.000001 to 99 lb-in-sec². Default = 0.0001

Note that when an assignment is made to INERTIA@, an additional range check is made to insure that the ratio of TRQ.GAIN@ to INERTIA@ is greater than or equal to 12.8. If it is less than 12.8, an error will be generated, and the parameters will not be changed in the DSP.

See Also: Loop Architecture Ka Kaf

INKEY$ Return a Character from Keyboard Function

Purpose: Return character(s) from the keyboard buffer (First In/First Out)

Usage: var$ = INKEY$

If no key-press is queued in the keyboard buffer a null string ("")is returned. If many keys are pressed, the first in the queue is returned. The string returned will be either one or two characters in length:

One-Character: ASCII character Two-Characters: CHR$(0)+CHR$(scancode) See Also: Key Table

Example: 10 TYPICAL.USES: 20 WHILE INKEY$ <> "" ’this small loop flushes out the keyboard buffer 30 WEND ’by extracting characters from INKEY$ until empty 40 PRINT "Press a key" 50 WHILE INKEY$ = "" ’this small loop will act as a pause in the code 60 WEND ’since it will continue until a key is pressed

-191- INKEY$ Return a Character from Keyboard Function

Example: 10 MORE.USES: ’How to capture a Key Press & use it 15 OPEN "R",0,"SRL2:MMI" ’OPEN MMI as Input/Output Device 0 20 F1KEY$ = CHR$(0) + CHR$(59) ’define an F1 string using its scancode 30 PRINT "Press a key" 40 LOOP: 50 A$=INKEY$ ’update the variable A$ with INKEY$ 60 IF A$="" GOTO LOOP ’do it again if there was no key pressed 70 ’ 80 IF A$ = F1KEY$ THEN PRINT "F1 Pressed!" ’Use the A$ information

INKEY$ is a function dedicated to the currently OPENed Input Device 0. Device 0 is the RS-232 Development Port until changed by an OPEN statement.

Event Keys are not found in the keyboard buffer. For MB v2.1i and later: Any Event Key whose trapping state is OFF is processed as normal input and is found in the keyboard buffer. However, if an Event Key’s trapping is ON or in the STOP state, the key is intercepted and is not found in INKEY$.

INP Read from an I/O Port Function

Purpose: Return a byte from a specified I/O port.

Usage: var% = INP(port)

port An integer expression in the range &H100 to &H3FF specifies the port to read.

See also: OUT INPW OUTW

INPUT Get Input from Keyboard Statement

Purpose: Assign input from the keyboard to one or more string or numeric variables.

Syntax: INPUT[;] ["prompt"{;|,}]variable [,variable] ...

; If a semicolon is included directly after the INPUT keyword, MotionBASIC does not issue a carriage return/line feed after receiving the user’s input

prompt A string constant supplying a prompt to guide the user.

variable The name of a variable (string or numeric) that will receive input.

See also: INPUT @ INPUT #

-192- INPUT Get Input from Keyboard Statement

If a prompt is included, it must be followed by either a semicolon or a comma (outside the quotes, before the first variable name). If it’s followed by a semicolon, MotionBASIC displays a question mark after the prompt string. If it’s followed by a comma, MotionBASIC suppresses the question mark

If no prompt is included, MotionBASIC displays a question mark.

If more than one variable is included in the INPUT statement, the user must enter values for all variables, separated by commas.

If only one variable is included in the INPUT statement, the user must enter a value for the number and press the Enter key.

If the user enters too few or too many values in response to an INPUT statement, MotionBASIC displays a message telling the user to retry from the start of the input; no values are assigned to variables until satisfactory input is received.

If the user enters a comma in response to an INPUT statement, MotionBASIC displays a "?Redo from Start" error message.

Input for a string variable need not be enclosed in quote marks. String input that is enclosed within quotes is handled as though it were not (that is, MotionBASIC ignores the quotes).

Input to a numeric variable must be numeric.

See also: INPUT @ INPUT #

INPUT # Get Input from a Device or File Statement

Purpose: Receive input from a device or data file and assign it to one or more numeric or string variables.

Syntax: INPUT #devnum, variable [,variable] ...

devnum The number under which the device was OPENed. It may refer to a communications device or data file.

variable The name of a variable (string or numeric) that will receive input.

The input data type must match the variable(s) in the INPUT # statement.

String input need not be enclosed within quote marks, unless it contains one or more line feeds or carriage returns or a significant quote mark or comma.

-193- INPUT # Get Input from a Device or File Statement

When receiving string input, MotionBASIC looks for the first non-space character. If that character is a quote mark, MotionBASIC considers the string to be everything from the character that follows the quote mark up to the next quote mark. If the first character is not a quote mark, MotionBASIC terminates the string when it encounters a line feed, a carriage return, or a comma -- or when it has received 255 characters.

When receiving numeric input, MotionBASIC ignores leading spaces, and terminates the input when it encounters a carriage return, a line feed, or a comma.

See also: INKEY$ INPUT ITM Driver Support

INPUT @ INPUT AT Screen Location Statement

Purpose: A screen device statement for numeric operator input; This single statement combines the functionality of LOCATE, PRINT,&INPUT.

Typical: INPUT @row[,col[,cursor]];[prompt;][FOR range;][USING format;][var]

row A numeric expression which sets the row position of the cursor. Range is 1 to the screen maximum less any rows used for function key text. May be omitted if column is specified.

col A numeric expression which sets the column position of the cursor. Range is 1 to the value set by the WIDTH statement. May be omitted if a cursor appearance is specified.

cursor A numeric expression for setting the cursor appearance. 0 for an invisible cursor 1 for a visible cursor

prompt A literal string to be printed in the current COLOR. Prompt output begins at specified row and column positions.

range Specify a range check on operator input values. If the check on the input fails, then an error #1218 or #1219 will result.

{ lo TO hi | < hi | > lo }

lo A numeric expression. The lowest value allowed. hi A numeric expression. The highest value allowed.

format A string expression that defines the field size and display format. Refer to the USING documentation for a detailed description. All text that appears on the screen as a result of the format string will be displayed in "reverse video".

var The name of a numeric variable to be edited.

If var is not used, this usage only serves to obtain an EXITKEY value as a completion result of the statement; ( This is convenient for "scrollable" selection fields).

-194- INPUT @ INPUT AT Screen Location Statement When an INPUT @ statement is executed:

1) The cursor is positioned at the specified row and column. If it was specified, the prompt is printed in standard video.

2) The format field is printed in reverse video, with the current value of var. If a variable was specified, it can be edited.

3) The statement is completed when one of the following keys is pressed:

Enter Exit statement & update variable. F1 - F10 Exit statement & update variable. ↑ Exit statement & update variable. ← *Exit statement & update variable. * These keys first → *Exit statement & update variable. move the internal ↓ Exit statement & update variable. field cursor to the Esc Exit statement. far left or right.

At completion, EXITKEY contains a value for the key used, see Key Table.

If the statement was used for a menu selection type field (var was omitted), the formatted field is simply re-displayed in standard video, and the only information changed is the value stored in EXITKEY.

If the statement changed a variable, the following takes place:

1) If the Escape key was pressed, then the variable is not updated, and the variable’s last value is displayed in standard video.

2) Otherwise, if no range checking was specified, the variable is updated with the new value and printed in standard video.

3) If a range check was specified, then the variable will be updated with the new value only if it passes the range check. If it fails the range check, a user trappable error is generated.

4) A new value in EXITKEY indicates the key that terminated the edit.

Example: 10X=15 20 INPUT @12,10; "Enter Value: "; FOR 10 to 20; USING " ## "; X

The program above will display the following row 12, column 10 on the screen:

Enter Value: 15

The cursor will be positioned in the left most column of the reverse video field and editing will begin. Editing of the field will continue until one of the Exit Keys is entered. After it is entered, a corresponding value will be stored in the EXITKEY function, the edited value will be put into the variable X (unless it was the Escape key or the value failed the range check), the reverse video field will be changed to standard, and MotionBASIC execution will continue at the next statement.

-195- INPUT @ INPUT AT Screen Location Statement

The formal syntax notation for the INPUT @ statement is shown below:

Syntax:

INPUT @{row|[row],{col|[col],crsr}};[prmpt;][FOR range;][USING format;][var]

This allows for some of the more uncommon cursor positioning techniques that are legal in MotionBASIC, such as:

INPUT @1,,0; ’at row 1, but current col, input with an invisible cursor INPUT @,10; ’at current row, but column 10 input with a visible cursor INPUT @,,0; ’at current cursor location input with an invisible cursor

INPUT$ Read Specified Number of Characters Function

Purpose: Return a specified number of characters from a specified device, or from the keyboard.

Usage: var$ = INPUT$(n [,devnum])

n An integer expression from 1 to 255 specifying the number of characters to be read.

devnum The number under which the input device was OPENed. If omitted, the characters are read from the standard input device (the keyboard, by default). Characters input from the keyboard are not echoed to the screen.

The INPUT$ function terminates when the specified number of characters have been received. It is not necessary to press Enter.

See also: INPUT INPUT #

INPW Read from an I/O Port Function

Purpose: Return a word from a specified I/O port.

Usage: var% = INPW(port)

port An integer expression in the range &H100 to &H3FF specifies the port to read.

See also: OUTW INP OUT

-196- INSTR Find Substring Function

Purpose: Return the character position within a string at which a substring is found.

Usage: var% = INSTR([start,] stringexp1, stringexp2)

start An integer expression in the range 1 to 255 specifying an optional offset from which to start searching. Default=1.

stringexp1 The string to be scanned.

stringexp2 The substring to be searched for.

INSTR returns 0 if: start > LEN(stringexpr2) stringexpr1 is null stringexpr2 cannot be found

INT Next Lower Whole Number Function

Purpose: Return the largest whole number "less than or equal to" numexpr.

Usage: var = INT(numexpr)

Note: INT rounds to the next lowest whole number. INT returns either an Integer or a Long Integer depending on numexpr. Compare this with FIX, which simply eliminates everything to the right of the decimal point.

Examples:

PRINT INT(33123.89) 33123

PRINT INT(-12.11) -13

-197- IOCTL Send Device "Control Data" String Statement

Purpose: Send a "control data" string to an open device driver to access "special" embedded capabilities.

Syntax: IOCTL [#]devnum, ctrl$

devnum An integer expression that specifies a device from 1 to 15.

ctrl$ A string expression to be passed to the device driver used to control some embedded function.

See Also: ITM Driver Support

IO.MODE@ Machine I/O Configuration ORMEC Variable

Purpose: Define or return the configuration of the machine I/O points.

Syntax: IO.MODE@(point)=mode Set Configuration

Usage: var$ = IO.MODE@(point) Get Configuration

point An integer expression which specifies the I/O point where configuration will begin. When EIO.MODE@ = 0, the range is from 1 to 40, otherwise the range is 1 to 528.

mode A string expression made up exclusively of the characters "I, O, R, F, B, C, S, T" and " " . Each non-space character defines a subsequent I/O point as described below.

I - Discrete Input O - Discrete Output R - Rising-edge Latched Input F - Falling-edge Latched Input B - Bipolar Analog Input C - Bipolar Analog Output S - Single-ended Analog Input T - Single-ended Analog Output

-198- IO.MODE@ Machine I/O Configuration ORMEC Variable

var$ When read, the IO.MODE@ array returns a one character string corresponding to the mode of the specified I/O point. Invalid information will cause a "?" to be returned.

The 16 Integral I/O each default to I, yet can be set to I, O, R or F.

Example: IO.MODE@(1) = "IIOO ioio FROI RRFF" results in the following:

Point # I/O Mode Point # I/O Mode

1 Input 9 Falling-edge Latch 2 Input 10 Rising-edge Latch 3 Output 11 Output 4 Output 12 Input 5 Input 13 Rising-edge Latch 6 Output 14 Rising-edge Latch 7 Input 15 Falling-edge Latch 8 Output 16 Falling-edge Latch

When EIO.MODE@ =0(digital) then I/O points 17 to 40 provided at the Extended I/O Connector can be configured as follow: Points 17-24 are individually configurable as I or O Points 25-32 are bank configurable as either all I or O Points 33-40 are bank configurable as either all I or O Note that setting the IO.MODE@ of any point within a "bank" will change the mode of all the other points in that bank to that setting.

When EIO.MODE@ =1(Pamux) then I/O points 17 to 528 are configured to align with the addresses of the selected Pamux "Brain-Boards". To calculate the AIO@ or DIO@ point number for the first point associated with a brain-board, multiply its Pamux address by 8 and add 17. e.g. The base I/O point on the Pamux brain-board with address 0 maps to I/O point 17, 2 maps to 33, etc. Subsequent points associated with that particular brain-board occupy subsequent point numbers in the array.

Pamux I/O points may be individually configured as I, O, B, C, S or T as long as they are consistent with the Pamux brain-board and I/O module

installed in the system. Pamux I/O is unaffected by a Watchdog Timeout or the red reset pushbutton on the front of the controller.

Note also that IO.MODE@ is "write only" for Pamux and the configuration cannot be "read back" using the IO.MODE@ variable.

-199- KAF@ Acceleration Feedforward Factor ORMEC Variable

Purpose: Define the acceleration feedforward gain factor for a servo axis.

Syntax: KAF@[(axes)] = factor

Usage: var% = KAF@[(axes)]

factor An integer expression which represents the acceleration feedforward gain factor as a percentage from 0 to 200%. Default = 0

Acceleration feedforward should generally not be used in electronic gearing applications.

See Also: Loop Architecture Kaf Ka Kvf

KEY Establish & Display Key Text, & Assign User Keys Statement

Purpose: Establish, and automatically display, function key text. Also, Syntax 3, assign a "shift state" of a function key to be trappable.

Syntax 1: KEY fkey, strexp Function key text definition Syntax 2: KEY { ON | OFF | LIST } Turn the label display On/Off

fkey A numeric expression for the function key number. Range1-10.

strexp The string expression for the function key text.Itis truncated to 15 characters. A null string turns off the label

KEY ON Enables the display of function key text. The bottom screen row(s) are off-limits to LOCATE, PRINT, INPUT @.

KEY OFF Removes function key text display, & screen restrictions.

KEY LIST Displays for F1 - F10, the function key text labels.

-200- KEY Establish & Display Key Text, & Assign User Keys Statement

Syntax 3: KEY ukey, CHR$(KBflag) + CHR$(Fn code) Assign User Key

ukey User Key Number: a numeric expression in the range 15 to 20.

Key numbers1-14arealways assigned to the "non-shifted" Function Keys: F1 - F10, & Arrow Keys: ↑←→↓ See: Key Table & KEY (n)

KBflag A numeric expression which chooses either the Shift, Ctrl or Alt "state" for a function key: KBflag Shift 1 Ctrl 4 Alt 8

Fn code A numeric expression for a Function Key code. Range: 59 - 68

Trapped Keys do not enter the keyboard buffer. (INKEY$)

KEY (n) Enable/Disable Key Event Trapping Statement

Purpose: Enable or disable the trapping of individual key events, previously assigned a routine with the ON KEY...GOSUB statement.

Syntax: KEY (n) { ON | OFF | STOP }

n A numeric expression in the range 1 to 20, specifying the key to trap, as follows: Key numbers1-14arealways assigned to the "non-shifted" Function Keys: F1 - F10, & Arrow Keys: ↑←→↓ See: Key Table

Key numbers 15 - 20 are user defined keys. See: KEY

ON KEY (n) ON activates trapping. Between each statement MotionBASIC checks to see if the specified key was pressed. If it was, MotionBASIC executes the defined GOSUB.

OFF KEY (n) OFF disables Key event trapping.

-201- KEY (n) Enable/Disable Key Event Trapping Statement

STOP KEY(n) STOP suspends the execution of GOSUB to the key handler routine, but "trapping" continues (the checking to see if the specified key has been pressed). If a key has been pressed while in this "stop state", the execution of a subsequent KEY (n) ON statement causes an immediate GOSUB to the defined key handler routine.

Event Keys do not enter the keyboard buffer (INKEY$)

However in MotionBASIC version 2.1i and later, Event Keys will enter the Keyboard buffer if the Trapping of the key is in the OFF state. At that time the key-press is treated as normal input.

See Also: MotionBASIC Event Processing

KILL Delete a file from Memory Disk Command

Purpose: Delete a file that had previously been saved on a Memory Disk.

Syntax: KILL cardfile

cardfile "[1:][path\]filename.ext"

path A string expression that follows DOS file-naming filename conventions. ext A filename extension is required for this statement

No error is generated for a cardfile that is non-existant.

See also: FILES NAME

-202- KP@ Position Loop Gain Factor ORMEC Variable

Purpose: Define the position loop gain factor for a servo axis.

Syntax: KP@[(axes)] = factor

Usage: var% = KP@[(axes)]

factor An integer expression which represents position loop gain from 1 to 500% for torque mode servos (VEL.GAIN@ = 0), and from 0.1 to 30 in/min/mil for velocity mode servos (VEL.GAIN@ > 0).

Defaults are 100 for torque mode servos, and 5 for velocity mode servos, respectively.

See Also: Loop Architecture Kp

KPI@ Position Loop Integral Gain Factor ORMEC Variable

Purpose: Define the position loop integral gain factor for a servo axis.

Syntax: KPI@[(axes)] = factor

Usage: var% = KPI@[(axes)]

factor An integer expression which represents the position loop integral gain factor as a percentage from 0 to 500%. Default = 0

KPI@ would normally be changed from the default of 0 to 100% for applications where position error during motion is critical, such as electronic gearing or in the control of continuous web systems.

See Also: Loop Architecture Kpi

KVF@ Velocity Feedforward Factor ORMEC Variable

Purpose: Define the velocity feedforward gain factor for a servo axis.

Syntax: KVF@[(axes)] = factor

Usage: var% = KVF@[(axes)]

factor An integer expression which represents the velocity feedforward gain factor as a percentage from 0 to 200%. Default = 100

See Also: Loop Architecture Kvf

-203- KVH@ Velocity Observer Feedback Gain Factor ORMEC Variable

Purpose: Define the velocity observer feedback gain factor for a servo axis.

Syntax: KVH@[(axes)] = factor

usage: var% = KVH@[(axes)]

factor An integer expression which represents the velocity loop feedback gain factor from 0 to 200%. Default values are: 100 for torque mode servos (VEL.GAIN@ = 0), and 0 for velocity mode servos (VEL.GAIN@ > 0).

See Also: Loop Architecture Kvh

KVHA@ Analog Velocity Loop Feedback Gain Factor ORMEC Variable

Purpose: Define the gain of AIN2 analog input for analog velocity loop feedback on a servo axis.

Syntax: KVHA@[(axes)] = factor

usage: var% = KVHA@[(axes)]

factor An integer expression which represents the analog input gain in RPM/volt from 0 to 1500. Default = 0

For velocity mode servos this parameter has a range from 0toMTR.SPD.LIM@/5.

See Also: Loop Architecture Kvha KVH@

KVI@ Velocity Loop Integral Gain Factor ORMEC Variable

Purpose: Define the velocity loop integral gain factor for a servo axis.

Syntax: KVI@[(axes)] = factor

Usage: var% = KVI@[(axes)]

factor An integer expression which represents the velocity loop integral gain factor as a percentage from 0 to 500%. Default = 100

See Also: Loop Architecture Kvi

-204- LCASE$ Convert Upper Cases to Lower Cases Function

Purpose: Return a string with all upper case characters of its argument being converted into lower case characters.

Usage: var$ = LCASE$(stringexpr)

stringexpr A string expression.

See also: UCASE$

LEFT$ Substring at Left Function

Purpose: Return a specified number of characters from the left side of a string.

Usage: var$ = LEFT$(stringexpr,length)

stringexpr A string expression.

length An integer expression in the range 0 to 255 which determines the number of characters to be returned. If length is larger than LEN(stringexpr), LEFT$ returns the entire string. If length is 0, LEFT$ returns a null string.

See also: MID$ RIGHT$

LEN Length of String Function

Purpose: Return the number of characters in a string, including blanks and nonprinting characters.

Usage: var% = LEN(stringexpr)

stringexpr A string expression.

LET Assignment Statement

Purpose: Assign the value of an expression to a variable.

Syntax: [LET] variable = expression

variable A valid variable name.

expression The value assigned to variable.Ifvariable is numeric, then expression must be numeric. If variable is a string, then expression must be a string.

Note: The keyword LET is optional and is rarely used.

See also: =

-205- LIST Display Program Listing Command

Purpose: Display all or part of the current program on the screen.

Syntax: LIST [start] [-[end]] [,pcfile]

start Line number or label of the first line to list. If start is the only parameter on the line, then only start will be listed. If start is missing, the first line of the program is used.

end Line number or label of the last line to list. If end is missing, the last line of the program is used.

pcfile A valid disk file specification to be used by MotionPRO to save the lines in the program from start to end.

See PW@ for the default start and end values.

LOAD Install a Program File Command

Purpose: Install a program file into the controller’s non-volatile memory.

Syntax: LOAD filespec

filespec "[drive:][path\]filename[.ext]"

drive Development Computer drive letter or 1 for Memory Disk. path A string expression that follows DOS file-naming filename conventions. ext Default extension is BAS.

The file will be loaded via the development port from an IBM PC or compatible running MotionPRO OR If the drive "1" is specified the file will be loaded from the Memory Disk.

The file will not load into program memory areas protected by PW@.

See Also: SAVE MERGE CHAIN

-206- LOC Last Accessed Record Function

Purpose: Return the current position in a data file OR Return the status of serial communications devices.

Usage: var# = LOC({ filenum | devnum })

filenum is the file number used when the file was OPENed.

devnum is the device number used when the device was OPENed.

With Random Access Files, LOC returns the record number last accessed with a GET or PUT statement.

With Sequential Files, LOC returns the number of 128-byte blocks accessed. For Input files, the first sector is read automatically when the file is opened. LOC will start at 1.

For communication devices, LOC returns the number of characters in the input queue waiting to be read.

LOCATE Position the Cursor Statement

Purpose: Set the position and appearance of the cursor.

Syntax: LOCATE {row|[row],{col|[col],cursor}}

Typical: LOCATE row [,col [,cursor]]

row A numeric expression to set a row position of the cursor. Range is 1 to the screen maximum less any rows used for function key text. Defaults to the current row position.

col A numeric expression in the range 1 to WIDTH. Sets the column position of the cursor. Defaults to current col.

cursor A numeric expression. If 1, the cursor is visible; if 0, the cursor is invisible. Defaults to a visible cursor.

See also: CSRLIN POS

-207- LOF Length of a File Function

Purpose: Return the length (number of bytes) allocated to a file, OR Return the amount of free space in communication input buffer.

Usage 1: var# = LOF(filenum)

Usage 2: var# = LOF(devnum)

filenum is the file number used when the file was OPENed.

devnum is the device number used when the device was OPENed.

LOG Natural Logarithm Function

Purpose: Return the natural (base e) logarithm of a number.

Usage: var# = LOG(numexpr)

numexpr A numeric expression greater than 0.

Note: The value of e is approximately 2.718282.

See also: EXP CLG

LOOP.RATE@ Servo Loop Update Rate ORMEC Variable

Purpose: Define the number of times per second (Hz) that the servo loops will be updated.

Syntax: LOOP.RATE@ = frequency

Usage: var% = LOOP.RATE@

frequency An integer expression which defines the number of times per second the servo loops will be updated. Range 1000 to 5000. Default = 3000 (Hz)

Servo loop update rate is a unit parameter which must be set the same for all Gen III units which are sharing MotionDATA for the purpose of multi-axis synchronized "MOVEs" and for coordinated "GEARed" motions.

-208- LSET Left-Justify String Data Statement

Purpose: Left-justifies string data in a specified field of the random buffer, in preparation for a PUT statement or left-justifies string data in ordinary string variables.

Syntax: LSET strvar = stringexpr

strvar A valid string variable name; specifies the variable into which stringexpr is to be left justified.

stringexpr A string expression.

If LEN(stringexpr) is less than LEN(strvar), strvar is padded on the right with space characters.

See Also: RSET, PUT

MBVER$ MotionBASIC Version Function

Purpose: Return the version code for MotionBASIC.

Usage: var$ = MBVER$

var This read-only string variable returns a string representing the version of MotionBASIC. e.g. For MotionBASIC version 1.1a, then the string returned will be "1.1a".

Note that in MotionBASIC version code, the number before the decimal point refers to a "major" release which adds significant new features. The second number refers to a "minor" release which adds new features, and possibly introduces some incompatibilities. The alphabetic character refers to a change which adds "compatible new features and fixes" to a minor release.

-209- MD.MODE@ MotionDATA Operating Mode ORMEC Variable

Purpose: Determine whether an axis monitors MotionDATA and select the source of its MotionDATA output information.

Syntax: MD.MODE@[(axes)] = mode Usage: var% = MD.MODE@[(axes)]

mode An integer which sets up the MotionDATA Interface of an axis. The ten’s digit selects input; the one’s digit selects output.

default 0 = Turn off pacer input but pass-thru incoming MotionDATA 1 = Turn off pacer input but transmit commanded position 2 = Turn off pacer input but transmit actual position 10 = Turn on pacer input and pass-thru incoming MotionDATA 11 = Turn on pacer input and transmit commanded position 12 = Turn on pacer input and transmit actual position

With pacer input monitoring turned ON, an axis will synchronize its loop update with received MotionDATA at the next MODE@ change.

MERGE Merge Program File with Current Program Command

Purpose: Merge a program file with the program resident in memory.

Syntax: MERGE filespec

filespec "[drive:][path\]filename[.ext]"

drive Development Computer drive letter or 1 for Memory Disk. path A string expression that follows DOS file-naming filename conventions. ext Default extension is .BAS.

The file can be merged into controller memory from an IBM PC or compatible running MotionPRO OR the file can be merged directly from the Memory Disk.

The file will not be able to be merged into areas of the program memory protected by PW@.

MERGE is similar to LOAD except the program in memory is not erased before the disk program is loaded. Program lines in the disk program are inserted into the resident program as if they were typed on the keyboard. New lines are added and old lines are updated. This command allows you to include common subroutines in multiple programs.

See also: CHAIN

-210- MID$ Substring in Middle Function

Purpose: Return a specified number of characters from a string, beginning at a specified character position.

Usage: var$ = MID$(stringexpr, position [,length])

stringexpr A string expression.

position An integer expression in the range 1 to 255; specifies the character position from which the substring is to be extracted. If position is greater than LEN(stringexpr), a null string is returned.

the number of characters to return. If length is omitted, MID$ returns all the characters in the string beginning at character position.

See also: LEFT$ RIGHT$

MKDIR Makes a new directory on the Memory Disk Command

Purpose: Makes a new directory on the Memory Disk.

Syntax: MKDIR "[1:]path"

path A string expression that follows DOS path specification conventions which specifies the name of the directory to be created.

See also: CHDIR RMDIR FILES

-211- MOD Modulo Arithmetic Operator

Purpose: Perform modulo arithmetic. That is, perform an integer division on the two operands (see \) and return the remainder.

Usage: exp1 MOD exp2

exp1 An integer expression which represents the dividend.

exp2 An integer expression which represents the divisor. The divisor must not be zero.

The operands must be either integer or long integer. Any other operand types will cause a Type Mismatch error to occur. The result will be a long integer if either operand is a long. Also if only one operand is a long, the other will undergo an integer type conversion.

See also: +-*/\^Precedence

MODE@ Axis Control Mode ORMEC Variable

Purpose: Define the mode of operation for one or more servo axes. Required to enable servo drives and turn on the controls.

Syntax: MODE@[(axes)] = mode

Usage: var% = MODE@[(axes)]

mode An integer expression representing the axis control mode:

0 = Unused or Off (default) 3 = Output (13) 1=Pacer Encoder 4 = Velocity (14) 2 = Standby 5 = Position (15)

Note that after entering Modes 2-5, time will probably be required for the servodrive power to stabilize, with the amount depending on the particular servodrive in use. After entering one of these modes, it is therefore advisable to wait a minimum of 50 msec (and possibly more) before initiating any motion.

-212- MODE@ Axis Control Mode ORMEC Variable

OPERATING MODES DEBUG MODES Feature Provided 012345 131415

Position Feedback Signal Loss Detection Alarm Detection Overtravel Limit Detection Torque Output Enabled Velocity Control Loop On Position Control Loop On

• In Mode 0, all axis fault and overtravel limit checking is disabled. • In Mode 1, the encoder interface is checked for signal loss, but servodrive alarm detection and overtravel limit checks are disabled. • In Mode 2, the encoder interface is checked for signal loss, AND servodrive alarm detection. Overtravel limit checks are disabled. • In Mode 3-5, all axis fault and overtravel limit checking is operational. • Servo operation in modes 13-15 MAY BE UNSAFE and should NOT be attempted.

Modes 13-15 are similar to modes 3-5, but with alarm detection, encoder signal loss detection, and hardware overtravel limits disabled. These modes are provided for uses such as program debug with no servodrive connected to the axis module. Servo operation in modes 13-15 MAY BE UNSAFE and should NOT be attempted with a servodrive and motor connected to the axis controller.

Mode 15 can also be useful to create a virtual axis, or ideal motor, when a perfect motion generator is desired for sourcing commanded position information onto MotionDATA for electronic gearing of real servo axes.

When MD.MODE@ is set at 10 or more, the next change to MODE@ will cause the axis to begin monitoring MotionDATA. This is also when the individual DSP Axis Modules’ cycle is synchronized to the Axis sending MotionDATA.

Assigning a value to MODE@ automatically takes the current position values stored in DIST.GEAR@, DIST.GRAT@, and DIST.BIAS@ and adds their sum to the current value of DIST.MOVE@. They are then cleared to zero.

-213- MOVE Move One or More Servomotors Statement

A single MOVE statement can be used to command motion for one or more servomotors, and has three major variations:

Variation Purpose

MOVE FOR move for a relative distance from the current position (called INDEX by some motion controllers).

MOVE TO move to a specified absolute position.

MOVE AT move at a specified speed.

Motion statements transfer actual command information to the DSP Axis Modules through the motion queue.

Move time, speed, acceleration, and deceleration can be specified in a variety of ways. In addition, all parameters for MOVE statements are specified in user units, and are limited by the axis range variables.

Syntax Chart Rules

1) Read the chart from left to right.

2) Do not cross horizontal lines.

3) Vertical lines may be crossed.

4) Clauses surrounded by square brackets [] are optional.

5) Your statement may legally end when you reach a double vertical line.

6) Defaults will be invoked if you use an abbreviated syntax, (Rule 5). The shaded areas, with the symbol , on the chart indicate the default parameters that will be used after legal endpoints.

Charts: MOVE, GEAR, HALT, RENUM

-214- MOVE Statement SYNTAX CHART For Instructions See: Syntax Chart Rules

TO IN ♦time ,Ta [-] ,Td ♦position IN Ta AT A[REPEAT] modifier may FOR ♦speed BY Da ,Dd precede a MOVE FOR. [-] MOVE ♦distance The following modifiers [axes] may be appended to a USING Aa ,Ad MOVE statement:

AT [AFTER cond] [-] BY ♦Da ,Dd [UNTIL cond] ♦velocity [AFTER cond UNTIL cond] IN ♦Ta ,Td ♦ indicates that AXIS.VAR@ can be used See Also: MOVE FOR, MOVE TO, MOVE AT for that parameter

MOVE FOR Move Servomotor(s) for a Relative Distance Statement

Purpose: Move a motor a relative distance from its current position. Move multiple motors a relative distance from their current positions.

Syntax: [REPEAT] MOVE [axes] FOR dist IN time [,Ta[,Td]][AFTER cond] [UNTIL cond] [REPEAT] MOVE [axes] FOR dist AT speed BY Da[,Dd][AFTER cond] [UNTIL cond] [REPEAT] MOVE [axes] FOR dist AT speed IN Ta[,Td][AFTER cond] [UNTIL cond] [REPEAT] MOVE [axes] FOR dist [AT speed] [USING Aa[,Ad]] [AFTER cond] [UNTIL cond]

Note that MOVE FOR statements may be "superimposed on a moving frame of reference" created by a GEAR AT statement.

When the [UNTIL cond] clause is used, the condition is not checked until the commanded motion is within the decel distance (Dd)to completion. The minimum move in this case is the dist specified.

See Also: MOVE Syntax Chart

-215- MOVE FOR Move Servomotor(s) for a Relative Distance Statement

Examples: (assume user units of degrees, RPM & msec)

MOVE FOR 360 IN 100 ’move 360 degrees in 100 msec

MOVE FOR 2*360 ’move 2 revs at max accel speed & decel

MOVE FOR 3600 AT 455 BY 90,720 ’move for 10 revs at 455 RPM, with 90 & ’720 degree accel & decel distances

Examples: (assume user units of "thousandths of an inch", "inches per second", acceleration in "g’s", and msec)

MOVE FOR 10000 IN 500,10,150 Causes the servos defined in AXIS.SET@ to move forward 10 inches in 500 msec with an accel time of 10 and a decel time of 150 msec.

REPEAT MOVE FOR 10000 IN 500,10,150 AFTER ASEN@ Cause the move above to be repeated on each occurrence of ASEN@.

MOVE {1,4} FOR -1000 IN 50 Causes axes1&4tomove in the negative direction 1 inch in 50 msec with the default timed move profile of 1/3 accel, 1/3 top speed and 1/3 decel.

MOVE {3,4} FOR 30000 AT 3 USING 1,2 Causes axes3&4tomove forward 30 inches at 3 in/sec using a 1 g acceleration rate anda2gdeceleration rate

MOVE {1} FOR -20000 AT 4 BY 1000,2000 Causes axis 1 to move in the reverse direction 20 inches at 4 inches/sec, reaching top speed after 1 inch of travel and beginning to decelerate 2 inches before the stop

MOVE {1} FOR -20000 AT 4 IN 10,20 Causes axis 1 to move in the reverse direction 20 inches at 4 inches/sec, reaching top speed in 10 msec and decelerating in 20 msec.

-216- MOVE TO Move Servomotor(s) to an Absolute Position Statement

Purpose: Move one or more motor(s) to a specified absolute position.

Syntax: MOVE [axes]TOposition IN time [,Ta[,Td]] [AFTER cond] [UNTIL cond] MOVE [axes]TOposition [AT speed] [USING Aa[,Ad]] [AFTER cond] [UNTIL cond] MOVE [axes]TOposition AT speed BY Da[,Dd][AFTER cond] [UNTIL cond] MOVE [axes]TOposition AT speed IN Ta[,Td][AFTER cond] [UNTIL cond]

MOVE TO statements may be "superimposed on a moving frame of reference" created by a GEAR AT statement. Only position commanded by MOVE statements is accumulated as absolute position. See DIST.MOVE@.

When the [UNTIL cond] clause is used, the condition is not checked until the commanded motion is within the decel distance (Dd)to completion. The minimum move in this case is to position specified.

See Also: MOVE Syntax Chart

Examples: (assume user units of degrees, RPM & msec)

MOVE TO -90 IN 100 ’move to the -90 degree position in 100 msec

MOVE TO 90 ’move to 90 degrees at max speed, accel & decel

Examples: (assume user units of "thousandths of an inch", "inches per second", acceleration in "g’s", and msec)

MOVE TO 0 Causes the servos defined in AXIS.SET@ to move to their respective "zero" positions.

Note that these statements will cause the servos to move to the specified positions as defined by the DIST.MOVE@ variable, which only includes position accumulated from MOVE statements.

-217- MOVE AT Move Servomotor(s) at a Specified Velocity Statement

Purpose: Move one or more motor(s) at a specified velocity.

Syntax: MOVE [axes]ATvelocity [USING Aa[,Ad]] [AFTER cond] [UNTIL cond] MOVE [axes]ATvelocity BY Da[,Dd][AFTER cond] [UNTIL cond] MOVE [axes]ATvelocity IN Ta[,Td][AFTER cond] [UNTIL cond]

Examples: (These examples assume user units of degrees, RPM & msec.) MOVE AT 500 BY 180 ’move at 500 RPM by 180 degrees of servomotor travel MOVE AT 500 IN 100 ’move at 500 RPM within 100 msec

The resultant motion is a ramp from any current velocity to the stated velocity (0 included).

When the [UNTIL cond] clause is used, condition is not checked until the commanded motion reaches the specified velocity. Therefore, the mininum move is the accel distance, Da, plus the decel distance, Dd.

A MOVE AT command will clear any existing Motion Queue of currently executing and queued motions which were yet to be executed.

When a MOVE AT statement that includes an AFTER clause is executed, any currently executing motion profile is suspended and the current running velocity is maintained until the AFTER clause is satisfied. This AFTER clause specifies the trigger which will cause the DSP to begin the specified acceleration ramp to the target velocity, as specified in the MOVE AT statement.

See Also: MOVE Syntax Chart

-218- Parameters for the MOVE statement

Parameter Description Default

axes a set of one or more servos to move. AXIS.SET@ position the end position to reach in a MOVE TO. distance the distance & direction in a MOVE FOR. velocity the speed and direction in a MOVE AT. speed the top speed of a MOVE FOR or MOVE TO. SPD.MAX@ time the total time to complete the motion. ,Ta time to accelerate. time/3 ,Td time to decelerate. Ta Aa rate to use for acceleration. ACL.MAX@ Aa,Ad rates to use for both accel & decel ACL.MAX@,DCL.MAX@ ,Ad rate to use for deceleration. Aa Da distance to move during acceleration. ,Dd distance to move during deceleration. Da

MOVE Statement parameters are specified in User Units. See Also: MOVE Chart

Generation III Configuration Subroutine

MP.CONFIG is included in the list of keywords, but it’s not a keyword in the strictest sense. It is the label of the configuration subroutine that is automatically generated & downloaded by MotionPRO.

The purpose of this subroutine is to setup the motion controller for a particular machine configuration. This is done by initializing ORMEC variables which are dependent on: the axis motor selection, the user units selected, operating ranges chosen for the machine, specific servo tuning parameters, operating variables and I/O configuration. It must be executed each time that: 1) power is applied to the unit, 2) a RUN command is executed, 3) a CLEAR statement is executed. It initializes a number of variables stored in the volatile memory of all the DSP Axis Module(s) in the system.

MP.CONFIG also supports the polling & enabling of absolute encoders.

Use of this subroutine name as a label elsewhere in a user program is not recommended as it will disable this valuable feature!

-219- MTR.ACL.LIM@ Acceleration Limit in Motor Units ORMEC Variable

Purpose: Define the absolute maximum acceleration of the servo axis position transducer in rev/sec².

Syntax: MTR.ACL.LIM@[(axes)] = accel

Usage: var% = MTR.ACL.LIM@[(axes)]

accel An integer expression representing the absolute maximum acceleration rate of the servo axis position transducer in rev/sec². Default MTR.ACL.LIM@ = 5000 / 2π = 796 rev/sec².

This variable is used in conjunction with USR.ACL.LIM@ and CNT.REV@ to define the user acceleration units.

This setup parameter should generally be set only once during program initialization.

MTR.SPD.LIM@ Axis Encoder Speed Limit in RPM ORMEC Variable

Purpose: Define the absolute machine speed limit for a servo axis encoder in RPM of the motor-encoder.

Syntax: MTR.SPD.LIM@[(axes)] = speed

Usage: var% = MTR.SPD.LIM@[(axes)]

speed An integer expression representing the absolute maximum machine speed limit for a servo axis encoder in RPM of the motor-encoder. Default = 4000 RPM; minimum = 600 RPM.

Note that the process of setting MTR.SPD.LIM@ calibrates the equations used in the DSP to allow resolution of speed to 15-bit precision (one part in 32,768) independent of the maximum motor speed selected. In order to provide an integer number of position transducer counts per loop update, MotionBASIC may raise the value of MTR.SPD.LIM@ to a value somewhat higher than the value you enter. To perform the right speed units conversion, you may need to raise USR.SPD.LIM@ appropriately.

-220- NAME Change the Name of a Memory Disk File Command

Purpose: Change the name of a file or directory that had previously been saved or created on the Memory Disk.

Syntax: NAME cardfile AS "filename[.ext]"

cardfile "[1:][path\]filename[.ext]"

path A string expression that follows DOS file-naming filename conventions. ext

filename A string expression that follows DOS file-naming ext conventions.

See also: FILES KILL

NEW Delete Current Program Command

Purpose: Delete the program currently in memory, clear all variables, and set trace mode off.

Syntax: NEW

The extent of influence of the NEW command is dependent on the value of the program write enable variable PW@. Attempting a NEW command with PW@ = 0 will cause an error.

NEW RESTORE Restore Non-Volatile Memory Command

Purpose: Restore all non-volatile memory to factory default values and save the current state of the Gen-III unit.

Syntax: NEW RESTORE

This command will restore all non-volatile memory to factory default values, save the current state of the Gen-III unit to a disk file through the serial link to MotionPRO, and reset the Gen-III unit. It should be used only when non-volatile memory is suspected of being corrupted. Please call ORMEC Service to report its use.

-221- NOT Logical NOT, Set Complement Operator

Purpose: Perform a bitwise inversion on an integer or long integer, or perform a set complement.

Usage1: NOT exp Logical

Usage2: NOT set Set Complement

exp Any expression, including boolean expressions, that produces an integer or long integer result.

set A set expression. The result is the set with all the elements that are not in the specified set.

The operand must be either integer, long integer,orset. Any other operand type will cause a Type Mismatch error to occur. The result is the same type as the operand.

MotionBASIC performs a bitwise complement according to the NOT truth table. See the chapter on bitwise operations for an example.

Example: 10 PRINT NOT {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16} 20 END RUN {17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}

See also: AND OR XOR Precedence

OCT$ Octal Value as String Function

Purpose: Return, as a string, the octal representation of a number.

Usage: var$ = OCT$(lngexpr)

If lngexpr is negative, OCT$ returns the twos complement value in octal.

The returned string contains no leading zeros.

See also: HEX$ STR$ BIN$

-222- ON ERROR Enable Error Trapping Statement

Purpose: Enable the trapping of error conditions and specify the first line of an error-trapping routine. Also, disable error trapping.

Syntax 1: ON ERROR GOTO {linenum | label} Enable error trapping Syntax 2: ON ERROR GOTO 0 Disable error trapping

linenum The first line of the error-handling routine. Setting linenum to 0 disables error trapping, but does not transfer program control to line 0.

label A symbolic label at the beginning of the error-handling routine.

To use ON ERROR to trap error conditions, the user must write an error- handler routine which performs appropriate error processing based on the error codes returned by the ERR function, the ERR$ function, and the ERL function, as well as various fault variables such as: FAULT@, AXIS.FAULT@, AXIS.FLT1@, AFAULT@ and ALARM@.

Within an Error Handler, before a RESUME statement is executed, error trapping (and all other Event processing) is disabled. If an error occurs during this time, MotionBASIC halts program execution, returns to direct mode and displays the error message. Error handlers must contain a RESUME statement.

The statement "ON ERROR GOTO 0" has special meaning. When used in a program, it disables any further error trapping. When used within an error-handler routine, it causes MotionBASIC to immediately process the trapped error as it would without an error-handler. Error-handlers should use an "ON ERROR GOTO 0" statement to process errors not to be specifically processed within the error-handler routine.

Without an error-handler enabled, MotionBASIC normally prints the error code (ERR), error message (ERR$(ERR)), and the line number where the error occurred (ERL) to the MotionPRO port, and then returns to direct mode. For some errors, such as syntax errors, it opens the line editor with the cursor at the line location where the error was found.

An example program flow for an Error Handler:

ERR.HDLR: ’Previously defined in ON ERROR statement ’ user code ’Here program is vulnerable to an error ’ user code RESUME MORE.ERROR.HDLR ’Error trapping is re-established ’and execution directed to additional MORE.ERROR.HDLR: ’code to rectify the current error ’Typically used functions & ’variables in error handlers ’include: ’ ERR ERL ERR$ ’ FAULT@ AFAULT@ ’ ALARM@ AXIS.FLT1@ ’ AXIS.FAULT@ STACK CLEAR ’performed since a restart will be done GOTO RESTART.MY.MACHINE ’send execution to a restart routine

-223- ON ERROR Enable Error Trapping Statement

Error trapping is disabled in direct mode. If a program enters direct mode from a STOP statement, error trapping is disabled only temporarily. A subsequent CONT, GOTO,orGOSUB (implied or explicit) command restores error trapping to its previous state. An END statement turns off error trapping completely.

See also: ERL ERR ERR$ ERROR RESUME Error Codes

ON EVENT...GOSUB Define an Event Handler Routine Statement

Purpose: Establish a subroutine to which MotionBASIC will branch if a specified I/O point is "trapped asserted". Event trapping must be turned on by means of an EVENT statement.

Syntax: ON EVENT var@ GOSUB {label | linenum}

var@ DIO@(n) Specifies a Discrete Input or Output point. n An integer expression, valid range 1 to 16.

label A label at the beginning of the event handling subroutine. linenum The first line of the event handling subroutine.

NOTE: The execution order of ON EVENT...GOSUB statements, sets the priority of the event; First defined has highest priority, etc.

CHAIN removes event definitions. Re-establish events after a CHAIN

See Also: MotionBASIC Event Processing ON KEY...GOSUB

ON KEY...GOSUB Define a Key Event Handler Routine Statement

Purpose: Establish a subroutine to which MotionBASIC will branch if a specified key is "trapped pressed". Key trapping is turned on by means of a KEY (n) ON statement.

Syntax: ON KEY(n) GOSUB {linenum | label}

n A numeric expression in the range 1 to 20 which represents the MotionBASIC key code to be trapped. 1-10 Function Keys F1 through F10 11 Cursor Up 12 Cursor Left 13 Cursor Right 14 Cursor Down 15-20 Keys defined via the KEY statement

linenum The first line of the key-handler subroutine.

label A label at the beginning of the key-press handler routine.

-224- ON KEY...GOSUB Define a Key Event Handler Routine Statement

NOTE: The execution order of ON KEY...GOSUB statements, sets the priority of the key event; First defined has highest priority, etc.

With trapping in effect, MotionBASIC checks for the specified keypress before executing each program statement. When the keypress is detected, MotionBASIC branches to the specified subroutine and temporarily suspends trapping (by means of an implicit KEY (n) STOP statement). Trapping automatically resumes when a RETURN from the handling subroutine is executed (unless the handler explicitly performs a KEY (n) OFF or KEY (n) STOP).

Event Keys do not enter the keyboard buffer (INKEY$)

However in MotionBASIC version 2.1i and later, Event Keys will enter the Keyboard buffer if the Trapping of the key is in the OFF state. At that time the key-press is treated as normal input.

See Also: MotionBASIC Event Processing ON EVENT...GOSUB

ON...GOSUB Branch to Item in Subroutine List Statement

Purpose: Cause MotionBASIC to execute one of a list of subroutines.

Syntax:ONyGOSUB {linenum | label} [,{linenum | label}]...

y An integer expression, valid range 0 to 255. Upon execution of the ON...GOSUB statement, MotionBASIC branches to the y’th item in the list of labels and/or line numbers that follows the keyword GOSUB. If y is 0 or > "# of list items", then execution transfers to the next statement. If y is outside the valid range, an error is generated.

linenum The first line number of a subroutine.

label A symbolic label at the beginning of a subroutine.

See also: ON...GOTO

-225- ON...GOTO Branch to Item in Line-Number List Statement

Purpose: Cause MotionBASIC to branch to one of a list of program labels or line numbers.

Syntax:ONyGOTO {linenum | label}, [,{linenum | label}]

y An integer expression. Upon execution of the ON...GOTO statement, MotionBASIC branches to the y’th item in the list of labels and/or line numbers that follows the keyword GOTO. If y is out of the range of listed line numbers, then execution resumes on the next statement.

linenum A valid line number.

label A symbolic label at the beginning of a program line.

See also: ON...GOSUB

OPEN Devices and/or Files

The OPEN statement is used to establish in a system: ORMEC devices and generic devices, and/or to establish data files used for information exchange with a MotionBASIC program. The relevant chapters are:

Chapter Description

OPEN OIT This syntax supports an Ormec OIT

OPEN MMI This syntax supports an Ormec MMI-840

OPEN ITM This syntax supports an Ormec ITM-270.

OPEN Device This syntax supports generic devices in a system. (e.g. a keyboard, monitor, simple display, or comm link)

OPEN File This syntax supports the use of data files.

See Also: CLOSE

-226- OPEN OIT Allow Operator Interface Terminal I/O Statement

Purpose: Make an Ormec OIT available for input and/or output.

Usage 1: OPEN "O",[#]0,"SCRN:" ’Redirect output to Video Adapter Usage 2: OPEN "I",[#]0,"KYBD:" ’Redirect input to Keyboard Interface

Operator I/O for MotionBASIC programs defaults to the MotionPRO Development Port (RS-232). To use an OIT, which is essentially two devices, a remote monitor & a remote keyboard, redirect the interfaces by opening KYBD: and SCRN: both as device number 0.

Assigning device #0 to an OIT allows the use of PRINT, LOCATE, INPUT, and INPUT @ statements.

No error is generated when "KYBD:" is opened in direct mode. However Device #0 is the only valid number.

See also: CLOSE

OPEN MMI Allow MMI-840 I/O Statement

Purpose: Make an Ormec MMI-840 available for input and/or output.

Syntax: OPEN "mode", [#]devnum,"device[serialspec]MMI"

Typical: OPEN "R",0,"SRL2:MMI" ’open MMI for use on the MotionNet port

mode A string expression that defines the MMI operating mode as Input and/or Output with one of the following values:

I Input Only O Output Only R Input & Output

devnum An integer expression; sets an MMI device number (0 to 15) Device #0 allows the use of PRINT, LOCATE, INPUT, and INPUT @ statements on an MMI-840.

Devices #’s 1-15 are accessed with PRINT # and INPUT #.

-227- OPEN MMI Allow MMI-840 I/O Statement

device A string expression to define the MMI-840 interface: Default Spec SRL2: MotionNET (RS-485) serial port (9600,N,8,1) COM1: IBM PC compatible serial port (9600,N,8,1) COM2: IBM PC compatible serial port (9600,N,8,1) COM3: IBM PC compatible serial port (9600,N,8,1) COM4: IBM PC compatible serial port (9600,N,8,1)

Note: MMI-840 default parameters are (9600,N,8,1)

serialspec A string expression for setting non-default serial port communication parameters. Four parameters would be specified, separated by commas:

baudrate 1200, 2400, 4800, 9600 parity N, O, E (None, Odd, or Even) databits 7or8 stopbits 1or2

Communication parameters at the MMI-840 are set with its menu screen. This menu screen can be accessed by pressing two keys, SHIFT & ENTER, when the powerup display is visible on the MMI screen.

Operator I/O for MotionBASIC programs defaults to the MotionPRO Development Port (RS-232). To conveniently use an MMI-840 as Operator I/O, OPEN it as an Input/Output Device #0.

Example: 10 OPEN "R",0,"SRL2:MMI" ’open the MMI-840 for input/output ’it is connected to the MotionNET port

A device that is already open may not be opened again until it is closed either with the CLOSE statement or with commands or statements which perform an implicit CLOSE, such as RUN, END, EDIT, etc.

See also: CLOSE

-228- OPEN ITM Allow ITM-270 I/O Statement

Purpose: Make an Ormec ITM-270 available for input and/or output.

NOTE: When a port/device is opened with ITM support, continuous polling of the ITM-270 takes place. When the port is closed, the polling is stopped. Other statements are effected, see: ITM Driver Support

Syntax: OPEN "mode",[#]devnum,"device[serialspec]ITM=addr[,time[,timeout]]"

Typical: OPEN "R",1,"SRL2:ITM=1" ’open ITM for use on the MotionNET port

mode A string expression that defines the ITM operating mode as Input and/or Output with one of the following values: I Input Only O Output Only R Input & Output

devnum An integer expression; sets an ITM device number (1 to 15) Device #’s 1-15 are accessed with PRINT # and INPUT #.

device A string expression to define the ITM-270 interface: Default Spec SRL2: MotionNET (RS-485) serial port (9600,N,8,1) COM1: IBM PC compatible serial port (9600,N,8,1) COM2: IBM PC compatible serial port (9600,N,8,1) COM3: IBM PC compatible serial port (9600,N,8,1) COM4: IBM PC compatible serial port (9600,N,8,1)

Note: ITM-270 default parameters are (9600,N,8,1)

serialspec A string expression for setting non-default serial port communication parameters. Four parameters would be specified, separated by commas:

baudrate 1200, 2400, 4800, 9600 parity N, O, E (None, Odd, or Even) databits 7or8 stopbits 1or2

addr A string constant representing the ITM-270’s hardware address setting. Range: 1-32

time A string constant setting the ITM-270’s refresh rate. Range: 100 to 5000 msecs. Default is 100 msecs.

timeout A string constant setting the number of refresh cycles that will be permitted without receiving a response from the ITM before MotionBASIC decides the device has failed. Range: 1-10. Default is 1.

Communication parameters at the ITM-270 are changed in its setup mode. This mode is entered by pressing the . key through its powerup cycle.

Examples: OPEN "R",1,"SRL2:ITM=1" ’simplest form OPEN "R",2,"COM1:4800,N,8,1,ITM=15,500,2" ’total specification

See also: CLOSE

-229- OPEN Device Allow Generic Device I/O Statement

Purpose: Make a generic type device available for input and/or output.

Syntax: OPEN "mode", [#]devnum,"device[serialspec]"

mode A string expression that defines the device operating mode as Input and/or Output with one of the following values:

I Input Device O Output Device R In/Out Device

devnum An integer expression to set a device number from 0 to 15. Devices 1-15 are accessed with PRINT # and INPUT #.

Device number 0 has special functionality allowing its use by PRINT, LOCATE, INPUT, and INPUT @ statements. This functionality can be utilized by an OIT,anMMI,ora generic monitor & keyboard.

device A string expression to define the device interface: KYBD: Keyboard Interface (wait 6 sec after powerup) SCRN: Video Display Adapter Interface Default Spec SRL2: MotionNET (RS-485) serial port (9600,N,8,1) COM1: IBM PC compatible serial port (9600,N,8,1) COM2: IBM PC compatible serial port (9600,N,8,1) COM3: IBM PC compatible serial port (9600,N,8,1) COM4: IBM PC compatible serial port (9600,N,8,1)

serialspec A string expression for setting non-default serial port communication parameters. Four parameters would be specified, separated by commas:

baudrate 1200, 2400, 4800, 9600 parity N, O, E (None, Odd, or Even) databits 7or8 stopbits 1or2

Operator I/O for MotionBASIC programs defaults to the MotionPRO Development Port (RS-232). To use a remote monitor and/or remote compatible keyboard as the operator devices, rather than the development computer, redirect the interfaces by opening KYBD: and SCRN: both as device number 0.

No error is generated when "KYBD:" is opened in direct mode. However Device #0 is the only valid number.

Examples: 10 OPEN "I",0,"KYBD:" ’open the remote keyboard interface for input 20 OPEN "O",0,"SCRN:" ’open the Video Adapter Interface for output

A device that is already open may not be opened again until it is closed either with the CLOSE statement or with commands or statements which perform an implicit CLOSE, such as RUN, END, EDIT, etc.

See also: CLOSE

-230- OPEN File Allow File I/O Statement

Purpose: Make a Data File available for input and/or output.

Syntax: OPEN "mode", [#]filenum,"cardfile"[,reclength]

mode A string expression that defines the data file I/O mode with one of the following values:

I Input from a Sequential File O Output to a Sequential File (Overwrite) A Append to a Sequential File (add data) R Random Access File Input & Output

filenum An integer expression. Specify a file from 1 to 15

cardfile A string expression. Follow DOS file-naming conventions

reclength An integer expression, range 1 to 32767. Set the record length for a Random Access File. Default is 128.

OR Logical OR Operator

Purpose: Perform a logical OR on two binary integers or long integers.

Usage: exp1 OR exp2

exp1, exp2 Any expressions, including boolean expressions, that produce an integer or long integer result.

The operands must be either integer or long integer. Any other operand types will cause a Type Mismatch error to occur. The result is the same type as the largest operand. If the two operands are different sizes, integer type conversion is performed.

MotionBASIC performs a bitwise OR, according to the OR truth table. See the chapter on bitwise operations for an example.

See also: NOT AND XOR Precedence

-231- OTL.FWD@ Forward Overtravel Limit Status ORMEC Variable

Purpose: Identify a forward overtravel limit condition, or re-enable normal operation after an overtravel condition has occurred.

Usage: var% = OTL.FWD@[(axes)] ’w/ multiple axes, OTL.FWD@s are ORed

Syntax: OTL.FWD@[(axes)]=0

var% a "latched" Boolean variable which will be ON if any of the servo axes defined in axes have exceeded their forward hardware or software overtravel limits. OTL.FWD@ must be turned OFF before any motion commands will again be allowed for that axis.

When a servo’s forward hardware travel limit input is asserted or its actual position exceeds the forward software travel limit, then: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.FWD@ Boolean variable for that axis will be asserted, and •amotion error will be generated which is user trappable.

The statement OTL.FWD@ = OFF will clear forward hardware overtravel limits only if the forward overtravel limit input on the DSP Axis Module is low (less than 0.8 volts). Therefore, to "back off" a hardware limit switch under power, the overtravel limit switch must be overridden, allowing OTL.FWD@ to be cleared and the axis to be moved.

The statement OTL.FWD@ = OFF will clear forward software overtravel limits even though the servo’s actual position is more positive than than the forward software travel limit. In this case, reverse motion commands will be allowed but attempting to move in the forward direction will set OTL.FWD@ and cause the motion error to recur. Normal operation will be fully restored once the servo is out of the overtravel zone.

This makes it possible to: • hit a software limit which stops the motor slightly into the overtravel zone, • reset OTL.FWD@ to zero, even though still in the overtravel zone, and • then MOVE the motor out of the overtravel zone under power.

Please note that for errors which occur asynchronous to program operation, such as Axis Faults and Overtravel Limits or E-Stop, only the first occurrence will report a user trappable error. Additional reporting of these errors must be re-enabled with a FAULT@=0 statement.

See Also: OTL.REV@

-232- OTL.REV@ Reverse Overtravel Limit Status ORMEC Variable

Purpose: Identify a reverse overtravel limit condition, or re-enable normal operation after an overtravel condition has occurred.

Usage: var% = OTL.REV@[(axes)] ’w/ multiple axes, OTL.REV@s are ORed

Syntax: OTL.REV@[(axes)]=0

var% a "latched" Boolean variable which will be ON if any of the servo axes defined in axes have exceeded their reverse hardware or software overtravel limits. OTL.REV@ must be turned OFF before any motion commands will again be allowed for that axis.

When a servo’s reverse hardware travel limit input is asserted or its actual position is more negative than the reverse software travel limit: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.REV@ Boolean variable for that axis will be asserted, and •amotion error will be generated which is user trappable.

The statement OTL.REV@ = OFF will clear reverse hardware overtravel limits only if the reverse overtravel limit input on the DSP Axis Module is low (less than 0.8 volts). Therefore, to "back off" a hardware limit switch under power, the overtravel limit switch must be overridden, allowing OTL.REV@ to be cleared and the axis to be moved.

The statement OTL.REV@ = OFF will clear reverse software overtravel limits even though the servo’s actual position is more negative than than the reverse software travel limit. In this case, forward motion commands will be allowed but attempting to move in the reverse direction will set OTL.REV@ and cause the motion error to recur. Normal operation will be fully restored once the servo is out of the overtravel zone.

This makes it possible to: • hit a software limit which stops the motor slightly into the overtravel zone, • reset OTL.REV@ to zero, even though still in the overtravel zone, and • then MOVE the motor out of the overtravel zone under power.

Please note that for errors which occur asynchronous to program operation, such as Axis Faults and Overtravel Limits or E-Stop, only the first occurrence will report a user trappable error. Additional reporting of these errors must be re-enabled with a FAULT@=0 statement.

See Also: OTL.FWD@

-233- OUT Send Byte to Output Port Statement

Purpose: Send one byte of data to the specified output port.

Syntax: OUT port,byte

port An integer expression in the range &H100 to &H3FF specifies the port number.

byte An integer expression in the range 0 to &HFF; specifies the data byte.

See also: INP INPW OUTW

OUTSPD.MUL@/INSPD.MUL@ Gear Ratio Conversion Multipliers ORMEC Variable

Purpose: Define gear ratio multipliers allowing GEAR statements to refer to gear ratios in user units.

Syntax: OUTSPD.MUL@[(axes)] = outmul INSPD.MUL@[(axes)] = inmul Usage: var1% = OUTSPD.MUL@[(axes)] var2% = INSPD.MUL@[(axes)]

outmul An integer expression which is multiplied by the user specified outspeed prior to executing a GEAR command. Default OUTSPD.MUL@ = 1. inmul An integer expression which is multiplied by the user specified inspeed prior to executing a GEAR command. Default INSPD.MUL@ = 1.

With the defaults of 1, "GEAR AT 1 TO 1" or "GEAR FOR 360 AT 1 TO 1" refer to the ratio of axis encoder counts to pacer encoder counts as "1 TO 1".

OUTW Send Word to Output Port Statement

Purpose: Send a data word to the specified output port.

Usage: OUTW port,word

port An integer expression in the range &H100 to &H3FF specifies the port number.

word An integer expression in the range 0 to &HFFFF; specifies the data word.

See also: INPW INP OUT

-234- PB1@ Pushbutton PB1 Pressed ORMEC Variable

Purpose: Return the status of the black pushbutton labeled "PB1" on the front of the unit.

Usage: var% = PB1@

var% A Boolean integer variable which will be ON (-1) if the black pushbutton labeled "PB1" on the front of the controller is pressed. Otherwise it will be OFF (0).

Note that this pushbutton is also used to:

1) Inhibit a MotionBASIC program from automatically executing at line number 0 on powerup.

2) To load a MotionBASIC program named PB1LOAD.BAS, stored on a Memory Disk.

Pushbutton Load Program File

PB1LOAD.BAS is included in the list of keywords, but it is not a keyword in the strictest sense. It is the required filename for the program file which is designated to load into the controller from the Memory Disk when PB1 button is held pressed during powerup.

This program file must be stored in the root directory of the Memory Disk in order to provide this functionality.

See Also: AUTOLOAD.BAS

PCR.SPD.LIM@ Pacer Encoder Speed Limit in RPM ORMEC Variable

Purpose: Define the absolute machine speed limit for a axis pacer encoder in RPM of the encoder.

Syntax: PCR.SPD.LIM@[(axes)] = speed

Usage: var% = PCR.SPD.LIM@[(axes)]

speed An integer expression representing the absolute maximum machine speed limit for an axis pacer encoder in RPM of the encoder. Default PCR.SPD.LIM@ = 4000 RPM.

-235- PCT.REV@ Pacer Counts/Rev ORMEC Variable

Purpose: Define the number of counts per revolution of the servo pacer position transducer.

Syntax: PCT.REV@[(axes)] = counts

Usage: var% = PCT.REV@[(axes)]

counts An integer expression which represents the number of counts per revolution of the pacer encoder used by a servo axis. Default PCT.REV@ = 6000. var% A numeric variable to receive the current number of counts per revolution of the pacer encoder as defined by PCT.REV@.

This parameter should be set prior to setting other pacer user units. MAC-E Series Servomotors: 6,000 counts per rev MAC-A Series Servomotors: 6,000 counts per rev MAC-B Series Servomotors: 24,000 counts per rev MAC-C Series Servomotors: 24,000 counts per rev MAC-F Series Servomotors with F-Series "/A" drives: 16,384 counts per rev with F-Series "/B" drives: 4,096 counts per rev

PEEK Value at Specified Address Function

Purpose: Return the byte at a specified memory offset within the current segment.

Usage: var% = PEEK(address)

address A numeric expression in the range 0 to &HFFFF, which specifies a memory offset within the segment specified by the most recent DEF SEG statement.

Accessible memory areas are offsets &H0000-&HFFFF within segments &HA000, &HB000, &HC000 or &HD000, except: • segment &HB000, offsets &H8000-&HFFFF if using a mono monitor, or • segment &HB000, offsets &H0000-&H7FFF if using a color monitor

See also: DEF SEG PEEKW POKE POKEW

-236- PEEKW Value at Specified Address Function

Purpose: Return the word at a specified memory offset within the current segment.

Usage: var% = PEEKW(address)

address A numeric expression in the range 0 to &HFFFF, which specifies a memory offset within the segment specified by the most recent DEF SEG statement.

Accessible memory areas are offsets &H0000-&HFFFF within segments &HA000, &HB000, &HC000 or &HD000, except: • segment &HB000, offsets &H8000-&HFFFF if using a mono monitor, or • segment &HB000, offsets &H0000-&H7FFF if using a color monitor

See also: DEF SEG PEEK POKE POKEW

PERR.INPOS@ In-Position Error ORMEC Variable

Purpose: Define the magnitude of position error allowed while the servo axis is still considered to be "in-position".

Syntax: PERR.INPOS@[(axes)] = error

Usage: var& = PERR.INPOS@[(axes)]

error An integer expression representing the magnitude of position error allowed while the servo axis is considered to be "in-position". This parameter is expressed in user units. The range is restricted so that the resulting position error is less than 32,767 counts of the axis position encoder. A value of 0 (default) prevents IN.POS@ from returning TRUE.

When the position error is less than the magnitude specified by this variable, the servo is considered to be "in-position", and the IN.POS@ Boolean variable will be true.

-237- PERR.MAX@ Maximum Position Error ORMEC Variable

Purpose: Define the maximum allowable position error for the axis servo when it is in a torque producing mode.

Syntax: PERR.MAX@[(axes)] = error

Usage: var% = PERR.MAX@[(axes)]

error An integer expression representing the maximum allowable position error for the axis servo in user units. The range of this variable is restricted so that the resulting position error in motor encoder counts is less than 32,767. A value of 0 disables maximum position error checking. Default = 360

If this error is exceeded: • the servodrive output will be disabled, • AXIS.FAULT@ will indicate the axis which has a fault, and • AFAULT@ will identify the fault.

PERR.NORM@ Normalization Error ORMEC Variable

Purpose: Return the amount of position error when the absolute position POS.ACT@ was last set by the user.

Usage: var% = PERR.NORM@[(axes)]

This variable is in user units.

PG.LEN@ Development Computer Page Length ORMEC Variable

Purpose: Cause the LIST command to pause after printing a certain number of lines.

Syntax: PG.LEN@ = lines

Usage: var% = PG.LEN@

lines An integer expression which defines the number of lines to be listed between "pauses". Default = 20. If PG.LEN@ = 0, then there will be no pauses.

Pressing any character (except Ctrl-C & Esc) during a "pause" causes list printing to resume.

Pressing Esc stops the current operation without Ctrl C processing.

-238- POKE Write Byte to Memory Statement

Purpose: Write a specified byte at a specified memory offset within the current segment.

Syntax: POKE address,byte

address A numeric expression in the range 0 to &HFFFF, which specifies a memory offset within the segment specified by the most recent DEF SEG statement.

Accessible memory areas are offsets &H0000-&HFFFF within segments &HA000, &HB000, &HC000 or &HD000, except: • segment &HB000, offsets &H8000-&HFFFF if using a mono monitor, or • segment &HB000, offsets &H0000-&H7FFF if using a color monitor

byte A numeric expression in the range 0 to &HFF, which specifies the data to be written at offset address.

See also: DEF SEG PEEK PEEKW POKEW

POKEW Write Word to Memory Statement

Purpose: Write a specified word at a specified memory offset within the current segment.

Syntax: POKEW address,word

address A numeric expression in the range 0 to &HFFFF, which specifies a memory offset within the segment specified by the most recent DEF SEG statement.

Accessible memory areas are offsets &H0000-&HFFFF within segments &HA000, &HB000, &HC000 or &HD000, except: • segment &HB000, offsets &H8000-&HFFFF if using a mono monitor, or • segment &HB000, offsets &H0000-&H7FFF if using a color monitor

word A numeric expression in the range 0 to &HFFFF, which specifies the data to be written at offset address.

See also: DEF SEG PEEK PEEKW POKE

POS Current Cursor Column Position Function

Purpose: Return the column position of the current cursor location.

Usage: var% = POS(dummy)

dummy A dummy argument. Any numeric or string expression may be used.

See also: CSRLIN LOCATE

-239- POS.ABS@ Absolute Encoder Poll ORMEC Variable

Purpose: A read-only variable that when referenced, forces a poll of an absolute encoder, and then returns the net number of encoder counts travelled since the encoder was last physically cleared to zero. It also enables encoder feedback, and turns off backup battery drain.

Usage: var& = POS.ABS@[(axes)]

var a long integer variable to receive a count value from a poll of an absolute encoder. The count value range is ± ((50000*CNT.REV@)-1), since POS.ABS@ "wraps around" at ± 50,000 revolutions. POS.ABS@ increments for counter- clockwise travel, and decrements for clockwise travel of the motor, (regardless of the CW.FWD@ setting).

The encoder polling task completely "ties-up" a DSP Axis Module and takes approximately 1/2 second per axis. All axes interfaced to a DSP Axis Module being polled, must have their operating mode disabled, MODE@=0, & MotionDATA operating mode set to default, MD.MODE@=0.

The required use of POS.ABS@ for all absolute encoders, should be restricted to the powerup and initialization routines of a program. In the execution of the configuration routine, MP.CONFIG, absolute encoders are polled, and the position data received is written to [email protected] insure the use of maximum position resolution (counts), the sequence of statements below, are executed before user units are established.

1) MODE@(AXIS.LIST@)=0 (all motors are disabled) 2) MD.MODE@(AXIS.LIST@)=0 (all pacer inputs are disabled) 3) CNT.REV@ is set to the motor count/rev specification. 4) POS.MUL@=1: POS.DIV@=1: POS.MOD@=0 ’(position units: counts) 5) POS.ACT@=POS.ABS@ (poll & enable encoder. Set position in counts) 6) POS.MUL@, POS.DIV@,&POS.MOD@ are setup to report user units so now POS.ACT@ is in user units.

Absolute encoders have capacitors that retain enough charge for 4 days of tracking. An optional battery, charges encoders while quadrature feedback is disabled. POS.ABS@ is zeroed only by a complete capacitor discharge.

-240- POS.ACT@ Actual Position ORMEC Variable

Purpose: Return the value of, or assign a value to, the actual real-time position of an axis encoder.

Syntax: POS.ACT@[(axes)] = position Usage: var& = POS.ACT@[(axes)]

position A long integer expression which represents the new, real-time position assignment for a servo axis in axis position units. The valid range for POS.ACT@ is determined by the axis position units conversion factors and the value of POS.MOD@.

var a long integer value equal to the current real-time position of the servo axis in user units

Assigning a value to POS.ACT@ automatically assigns that value to DIST.MOVE@ and zeroes out: DIST.GEAR@, DIST.GRAT@, and [email protected] also assigns the current position error, POS.ERR@,toPERR.NORM@, and then zeroes the value of POS.ERR@.

POS.ASEN@ Position at A-Sensor ORMEC Variable

Purpose: Return a value (in user units) equal to the real-time position of the axis encoder when the ASEN@ variable was last asserted.

Usage: var& = POS.ASEN@[(axes)]

var A long integer read-only variable which indicates the actual position of the axis encoder when the A-Sensor input last asserted the ASEN@ variable.

The operation of this feature requires a latched sensor configuration. ASEN@ must be configured as a Rising or Falling Latched Sensor with the SENS.MODE@ variable.

The value of POS.ASEN@ is latched within one microsecond of receipt of the sensor. If however ASEN@ is asserted within 20 microseconds of BSEN@, DELAY@ or ZREF@, the value of POS.ASEN@ will be equal to the value of POS.BSEN@, POS.DELAY@ or POS.ZREF@ respectively.

-241- POS.BSEN@ Position at B-Sensor ORMEC Variable

Purpose: Return a value (in user units) equal to the real-time position of the axis encoder when the BSEN@ variable was last asserted.

Usage: var& = POS.BSEN@[(axes)]

var A long integer read-only variable which indicates the actual position of the axis encoder when the B-Sensor input last asserted the BSEN@ variable.

The operation of this feature requires a latched sensor configuration. BSEN@ must be configured as a Rising or Falling Latched Sensor with the SENS.MODE@ variable.

The value of POS.BSEN@ is latched within one microsecond of receipt of the sensor. If however BSEN@ is asserted within 20 microseconds of ASEN@, DELAY@ or ZREF@, the value of POS.BSEN@ will be equal to the value of POS.ASEN@, POS.DELAY@ or POS.ZREF@ respectively.

POS.CMD@ Position Command ORMEC Variable

Purpose: Return the current real-time value of commanded position for a servo axis in user units.

Usage: var& = POS.CMD@[(axes)]

var A long integer value which is the currently commanded position. POS.CMD@ is a read-only variable whose range is determined by the axis position units conversion factor and the value of POS.MOD@.

Commanded position is made up of the sum of four components: DIST.MOVE@ distance commanded by MOVE FOR statements DIST.GEAR@ distance commanded by GEAR FOR statements DIST.BIAS@ distance commanded by setting this variable directly DIST.GRAT@ distance commanded by the constant ratio portion of GEAR AT statements

-242- POS.CMD@ Position Command ORMEC Variable

Assigning a value to POS.ACT@ automatically assigns the same value to DIST.MOVE@ (POS.CMD@) and clears the other position command variables.

The approach taken above allows commanded position generated by MOVE or GEAR FOR statements to be considered independent of commanded position generated by setting DIST.BIAS@ or by the execution of continuous ratio GEAR AT statements.

An example of the usefulness of this approach is an application where controlled motion is to be superimposed on a moving frame of reference such as a conveyor. If a continuous ratio GEAR AT statement is used to create the moving frame of reference, and MOVE or GEAR statements are used to create the controlled motion, then the separation of sources for the final POS.CMD@ described above allows the user to easily separate the "current position with respect to the conveyor" from the "change of position related to the change in conveyor position".

See also: POS.MOD@

POS.DELAY@ Position at Delayed Sensor ORMEC Variable

Purpose: Return a value (in user units) equal to the real-time position of the axis encoder when the DELAY@ variable was last asserted.

Usage: var& = POS.DELAY@[(axes)]

var A long integer read-only variable which indicates the actual position of the axis encoder when DELAY@ was asserted.

The value of POS.DELAY@ is latched within one microsecond of assertion of the DELAY sensor. If however DELAY@ is asserted within 20 microseconds of ASEN@, BSEN@ or ZREF@, the value of POS.DELAY@ will equal the value of POS.ASEN@, POS.BSEN@ or POS.ZREF@ respectively.

The sensor delay counter is an extra cost option of the DSP Axis Module, and also requires the use of the appropriate MotionCARD. POS.DELAY@ is always 0 without the option and the supporting MotionCARD.

See Also: SENS.MODE@

-243- POS.ERR@ Current Position Error ORMEC Variable

Purpose: Return the current real-time position error of the servo axis.

Usage: var& = POS.ERR@[(axes)]

This error is signed because it is the difference [email protected]@.

Note that if the actual position lags the commanded position during motion, POS.ERR@ will be positive for moves in the "forward" direction and negative for moves in the "reverse" direction. Conversely, if POS.ERR@ is negative during a forward move, then the actual position is actually "ahead of" the commanded position.

POS.MOD@ Position Modulus ORMEC Variable

Purpose: Define a modulo position conversion factor so that axis position variables POS.CMD@ and POS.ACT@ will automatically "repeat" over a specified distance cycle.

Syntax: POS.MOD@[(axes)] = modulus

Usage: var& = POS.MOD@[(axes)]

modulus A positive long integer expression, in the range of minimum modulus to maximum modulus, which represents the number of axis position units over which POS.CMD@ and POS.ACT@ will repeat. With the default value of 0, modulo position conversion is disabled. When POS.MOD@<>0, only positive values are valid for POS.CMD@ & POS.ACT@, in the range from 0 to POS.MOD@-1.

The minimum assignable value, minimum modulus, is the same as the "maximum change in position" per tick, and is given by the following:

max pos MTR.SPD.LIM@ * CNT.REV@ * POS.DIV@ minimum modulus == tick 60 * LOOP.RATE@ * POS.MUL@

This calculation may result in a decimal. Minimum modulus is the smallest integer greater than or equal to that number.

The maximum assignable value, maximum modulus, is the same as the axis maximum position in user units. This is given by the following:

maximum modulus = max pos = INT (2147483647 * POS.DIV@ / POS.MUL@)

Modulo position affects the operation of the MOVE command. The details of these effects is best described through the following examples:

-244- POS.MOD@ Position Modulus ORMEC Variable

Examples: If POS.ACT@=0, POS.MOD@=360, and the axis is commanded to MOVE FOR 450, it will move for a distance of 450, but the resulting position will be 90. If it was again commanded to MOVE FOR 450, the resulting position would be 180.

If it was at 0 and received a command to MOVE FOR -450, then the resulting position would be 270.

For MOVE TO statements, the sign of the specified position is used to determine the direction of motion, since there are no negative positions and the direction of motion must be defined. Special algorithms like "moving in the direction that results in the shortest move" or "moving in a direction to prevent windup" should be programmed in MotionBASIC.

Note that for positive POS.CMD@ (or POS.ACT@) values and POS.MOD@<>0 the returned value is equivalent to "POS.CMD@ (or POS.ACT@) MOD POS.MOD@"... for negative values, it’s the same as POS.MOD@+ POS.CMD@ MOD POS.MOD@.

POS.MUL@/POS.DIV@ Axis Position Units Multiplier ORMEC Variable

Purpose: Define the ratio of axis encoder counts to the desired axis position units allowing MotionBASIC statements to refer to axis positions and distances in user units.

Syntax: POS.MUL@[(axes)] = mult POS.DIV@[(axes)] = div Usage: var1% = POS.MUL@[(axes)] var2% = POS.DIV@[(axes)]

mult A numeric expression in the range 1 to 32767, which defines the numerator of the ratio of axis encoder counts to axis position units. Default POS.MUL@ = 6000. div A numeric expression in the range 1 to 32767, which defines the denominator of the ratio of axis encoder counts to axis position units. Default POS.DIV@ = 360.

If the axis encoder has 6000 cts/rev, then the default ratio of 6000/360 defines axis position units of degrees.

-245- POS.ZREF@ Position at Encoder Reference ORMEC Variable

Purpose: Return a value (in user units) equal to the real-time position of the axis encoder when the ZREF@ variable was last asserted.

Usage: var& = POS.ZREF@[(axes)]

var A long integer read-only variable which indicates the actual position of the axis encoder when the encoder reference input last asserted the ZREF@ variable.

The operation of this feature requires a latched sensor configuration. ZREF@ must be configured as a Rising or Falling Latched Sensor with the SENS.MODE@ variable.

The value of POS.ZREF@ is latched within one microsecond of receipt of the sensor. If however ZREF@ is asserted within 20 microseconds of ASEN@, BSEN@ or DELAY@, the value of POS.ZREF@ will be equal to the value of POS.ASEN@, POS.BSEN@ or POS.DELAY@ respectively.

PPS.MUL@/PPS.DIV@ Pacer Position Units Multiplier ORMEC Variable

Purpose: Define the ratio of pacer encoder counts to the desired pacer position units allowing MotionBASIC statements for follower axes to refer to pacer distances in user units.

Syntax: PPS.MUL@[(axes)] = mult PPS.DIV@[(axes)] = div Usage: var1% = PPS.MUL@[(axes)] var2% = PPS.DIV@[(axes)]

mult An integer expression which defines the numerator of the ratio of pacer encoder counts to pacer position units. Default PPS.MUL@ = 6000. div An integer expression which defines the denominator of tha ratio of pacer encoder counts to pacer position units. Default PPS.DIV@ = 360.

If the pacer encoder has 6000 cts/rev, then the default ratio of 6000/360 defines pacer position units of degrees.

-246- PRINT Display on Screen Statement

Purpose: Display one or more numeric or string expressions on screen device 0. (? is a synonym for PRINT.) See also PRINT #.

Typical:[REPEAT] PRINT [@row[,col[,cursor]];] [USING format;][exprlist][;]

row A numeric expression in the range 1 to screen max (less rows used for function key text). Sets row position of the cursor.

col A numeric expression in the range 1 to WIDTH. Sets the column position of cursor. Default is current location.

cursor A numeric expression. 0 for invisible, 1 for visible cursor.

format A string variable or constant specifying the format in which the data is to be printed. Refer to USING for details.

exprlist Numeric and/or string expressions to print. Each expression is separated from the next by a space, comma,orasemicolon.

; If a semi-colon is included at the end of the statement, it suppresses the usual carriage return and line feed.

PRINT with no exprlist and no terminating semi-colon sends only the usual carriage-return, line-feed pair.

Screen Positioning Rules: MotionBASIC divides the screen into zones of 14 character positions. If an expression is followed by a comma, MotionBASIC prints the next expression at the beginning of the next zone. If an expression is followed by a semi-colon or space character, MotionBASIC prints the next expression directly after the previous one.

If the last expression in the list to be displayed is followed by a comma, a semicolon, or either the SPC,orTAB function, MotionBASIC spaces appropriately and suppresses the carriage-return, line-feed pair. Otherwise, MotionBASIC sends a carriage-return and line-feed after the last expression in the PRINT statement.

MotionBASIC assumes a maximum line length of 80 characters, unless a different value has been specified by means of a WIDTH statement or a specific driver has been applied with an OPEN statement. MotionBASIC sends a carriage-return, line-feed pair when the maximum line length has been reached.

The formal syntax notation for the PRINT @ statement is shown below:

Syntax: [REPEAT] PRINT @{row|[row],{col|[col],cursor}}; [USING format;][exprlist][;]

This allows for some of the more uncommon cursor positioning techniques that are legal in MotionBASIC, such as:

PRINT @1,,0; ’at row 1, but current col, print with an invisible cursor PRINT @,10; ’at current row, but column 10 print with a visible cursor PRINT @,,0; ’at current cursor location print with an invisible cursor

-247- PRINT # Output to a Device or File Statement

Purpose: Write to a specified device or data file an image of what would be displayed on screen by a corresponding PRINT statement.

Syntax: PRINT #devnum,[USING format;] [exprlist][;]

devnum The number under which the device was opened for output.

format A string variable or constant specifying the format in which the data is to be printed. See USING for details.

exprlist Numeric and/or string expressions to print. Each expression must be separated from the one after it by either a comma or a semicolon.

; If included at the end of the statement, suppresses the usual carriage return and line feed.

? is a synonym for the keyword PRINT.

PRINT # outputs exactly the same characters that would appear on screen in response to a PRINT statement. Commas between expressions, for example, result in the insertion of space.

If an expression to be output contains significant quote marks or commas, you should surround it with a quote mark by means of CHR$(34); otherwise, when you input these fields, MotionBASIC will interpret the significant commas or quotes as delimiters.

See Also: ITM Driver Support

PUT Write to a Random Access File Statement

Purpose: Writes a specified record from a specified random access file buffer to a random access file on a Memory Disk.

Syntax: PUT [#]devnum [,recnumber]

devnum An integer expression specifying a device from 1 to 15.

recnumber A positive, non-zero long expression specifying the record number to be transferred. Defaults to the next record, or record 1 (if no record has been PUT/GET).

A FIELD must be declared before execution of a PUT statement.

See Also: GET, FIELD, LSET, RSET

-248- PW@ Program Write Enable ORMEC Variable

Purpose: Program memory is divided into User and Setup program areas; Allow changes to no areas, one area, or both areas.

Syntax: PW@ = mode

Usage: var% = PW@

mode An integer expression which enables part or all of the program memory to be modified. Changes are allowed to program memory lines as follows:

0 - NO lines may be changed POWERUP DEFAULT SETTING 1 - lines from 0 to 39999 (User program area) 2 - lines from 40000 to 65529 (Setup program area) 3 - lines from 0 to 65529 (Both program areas)

The effect of PW@ on the operation of AUTO, DELETE, LIST,&RENUM is described below:

Syntax: AUTO [startline [,increment]] DELETE [start] [-[end]] LIST [start] [-[end]] RENUM [newstart] [,[[oldstart][-oldend]] [,increment]]

This chart shows AREA OPEN None User Setup Both the defaults used for the above start 0 0 0 commands. 1 1 1 oldstart startline 10 10 10 newstart Defaults change with the current end 39999 39999 oldend setting of PW@. ------start 40000 oldstart shows areas startline 40010 newstart protected from changes end 65529 65529 oldend

The extent parameter defines the range of influence of EDIT, LOAD, MERGE and NEW as well as the above commands with the exception of LIST.

AREA OPEN PW@ Extent None 0 none User 1 0 - 39999 Setup 2 40000 - 65529 Both 3 0 - 65529

RUN and SAVE commands are not affected by the value of PW@.

-249- RANDOMIZE Reseed Random Number Generator Statement

Purpose: Supply a new seed for the pseudo-random number generator.

Syntax: RANDOMIZE intexpr

expression An integer expression which is a seed for the random number generator.

Each random number seed produces a unique sequence of random numbers, but the same seed always produces the same sequence.

See also: RND

READ Assign DATA Items to Variables Statement

Purpose: Assign values in DATA items to specified variables.

Syntax: READ variable [,variable] ...

variable A numeric or string variable, or an array element.

A single READ statement can assign multiple DATA items to multiple variables; or several READ statements can assign the same DATA item to several variables.

The RESTORE statement allows the rereading of DATA items.

Unless a RESTORE statement is executed, MotionBASIC moves to the next DATA item with each READ assignment. If MotionBASIC runs out of DATA items to READ, an Out of Data error occurs. If the variable and the data item do not match in type, a Syntax Error occurs.

See also: DATA RESTORE Program Initialization

-250- REM Comment Statement

Purpose: Add explanatory commentary to a program listing.

Syntax: REM [remark]

remark Commentary text, ignored by MotionBASIC.

MotionBASIC does not execute REM statements, but a program may branch to a REM statement; execution continues with the first executable statement following the REM.

A REM statement must be the last statement in a logical program line MotionBASIC ignores everything after the REM keyword.

A single-quote mark (’)isthe recommended equivalent to REM. A single quote can also be used to append a comment to the end of any program line. A REM comment cannot be written this way; it must be in a program statement by itself.

RENUM Renumber Program Lines Command

Purpose: Renumber all or part of a program, starting at a specified line number and incrementing each line by a specified amount.

Syntax: RENUM [newstart] [,[oldstart] [-[oldend]]] [,increment] newstart First line number to be used in the new number sequence. oldstart First line number or label of the old line numbers to be renumbered. oldend Last line number or label of the old line numbers to be renumbered. If oldend does not exist then MotionBASIC will generate an error. increment Interval between line numbers in the renumbered program. Defaults to 10. See PW@ for the default newstart, oldstart and oldend values. RENUM adjusts all line number references in statements using ELSE, GOSUB, GOTO, ON...GOTO, ON...GOSUB, RESTORE, RESUME, THEN & ERL.

RENUM WILL NOT RE-ORDER LINES IN THE PROGRAM; you must use the text editor for this purpose.

-251- RENUM Statement SYNTAX CHART For Instructions See: Syntax Chart Rules

i new old old n R start start end c E r N e U m M,-, e n t

newstart First line # to be used in the new number sequence. oldstart First line # or label of the old lines to be renumbered. oldend Last line # or label of the old lines to be renumbered. increment Interval between lines in renumbered program. Default 10.

RENUM CANNOT REPOSITION LINES IN A PROGRAM; For this, use a Text Editor Default Parameters used for RENUM Command

AREA OPEN User Setup Both PW@=123

oldstart 1 1 newstart 10 10

oldend 39999 ------oldstart 40000 newstart 40010

oldend 65529 65529

-252- REPEAT Repeat a MOVE, GEAR or PRINT Statement Modifier

Purpose: Cause motions specified by MOVE or GEAR statements to be placed in the DSP motion queue where they remain for repetitive execution; cause BASIC to repeat a PRINT statement in direct mode.

Usage 1: REPEAT MOVE FOR parameters [AFTER condition] [UNTIL condition] Usage 2: REPEAT GEAR FOR parameters [AFTER condition] [UNTIL condition] Usage 3: REPEAT GEAR AT parameters [AFTER condition] UNTIL condition Usage 4: REPEAT PRINT parameters

condition ZREF@, ASEN@, BSEN@ or DELAY@

When MotionBASIC executes a MOVE or GEAR statement, it processes the parameters and places high level information in the shared memory of the DSP Axis Module(s). When the REPEAT modifier precedes the statement, the information is placed in the DSP motion queue. The DSP continues to cycle through these motions locally, freeing up MotionBASIC execution for other tasks. REPEAT PRINT is a direct command only, and MotionBASIC loops on that statement until a character is received at the serial port.

Note that since user units conversion for MOVE FOR and GEAR FOR statements is done by the main processor, REPEAT motions for these statements will each cause the commanded position to change by the nearest integral number of encoder counts.

Example: REPEAT MOVE FOR 360 DSP MOTION QUEUE REPEAT MOVE FOR 0 IN 500 REPEAT MOVE FOR -360 MOVE FOR 360 REPEAT MOVE FOR 0 IN 500 MOVE FOR 0 IN 500 MOVE FOR -360 At the DSP level a 360 forward move, 1/2 MOVE FOR 0 IN 500 sec delay, 360 reverse move, and a 1/2 sec delay will continue to execute. A REPEAT queue can be immediately cleared by a HALT, MOVE AT,orGEAR AT statement. It can also be cleared at the end of the sequence by executing a MOVE FOR 0 IN 0 or a GEAR FOR 0 in 0.

See Also: DSP.CTR@

-253- RESTORE Reset DATA Item Pointer Statement

Purpose: Reset the DATA item pointer to the first item in the first DATA statement or to the first DATA item in a specified DATA statement.

Syntax: RESTORE [linenum | label]

linenum A program line number.

label A symbolic label at the beginning of an existing program line.

If the statement at linenum or label is not a DATA statement, BASIC RESTOREs to the first DATA statement following linenum or label.

See also: DATA READ Program Initialization

RESUME Continue after Error Trap Statement

Purpose: Restore error trapping and direct program execution after an error recovery procedure has been invoked.

Syntax 1: RESUME Goes back to the statement of error Syntax 2: RESUME NEXT Goes to the statement after error Syntax 3: RESUME {linenum | label} Goes to a specific program statement

RESUME to a specific label, Syntax 3, is the recommended approach! RESUME, without an argument, causes the program to try again at the statement that was executing when the error occurred.

NEXT RESUME NEXT causes program execution to continue at the statement following the statement where the error occurred. This is NOT RECOMMENDED, due to the following: An IF block conditional test could be executing when an error occurs. A RESUME NEXT from the error handler would restore execution to the next physical line, regardless to the normal program flow that the IF block’s conditional test might have directed.

-254- RESUME Continue after Error Trap Statement

linenum RESUME linenum or RESUME label causes program execution to label continue at a specified line number or program label.

All ON ERROR GOTO routines should contain a RESUME statement. After an Error Handler routine has been invoked, error trapping is suspended until a RESUME is executed. Before a RESUME is executed the program is vulnerable to a second error that would end program execution and return MotionBASIC to direct mode.

If program flow is not directed to RESUME operation at the lowest level FOR...NEXT, WHILE...WEND or subroutine where the error occurred, then the MotionBASIC control stack should be cleared. After a STACK CLEAR statement, program operation can then be restarted at any location with a GOTO statement. If a STACK CLEAR is not done, then it is likely that the MotionBASIC control stack will grow in size, continually reducing the amount of memory available. Eventually Error #1801 Out of Memory occurs.

A RESUME executed outside an error handler routine generates Error #1110.

An example program flow for an Error Handler:

ERR.HDLR: ’Previously defined in ON ERROR statement ’ user code ’Here program is vulnerable to an error ’ user code RESUME MORE.ERROR.HDLR ’Error trapping is re-established ’and execution directed to additional MORE.ERROR.HDLR: ’code to rectify the current error ’Typically used functions & ’variables in error handlers ’include: ’ ERR ERL ERR$ ’ FAULT@ AFAULT@ ’ ALARM@ AXIS.FLT1@ ’ AXIS.FAULT@ STACK CLEAR ’performed since a restart will be done GOTO RESTART.MY.MACHINE ’send execution to a restart routine

RETURN Return from Subroutine Statement

Purpose: Transfer program execution from a subroutine to the line following the GOSUB, or to a specified line.

Syntax: RETURN [linenum | label]

linenum A program line number.

label A symbolic label at the beginning of a program line.

See also: GOSUB

-255- RIGHT$ Substring at Right Function

Purpose: Return a specified number of characters from the right side of a string.

Usage: var$ = RIGHT$(stringexpr,length)

stringexpr A string expression.

length An integer expression in the range 0 to 255 which specifies the number of characters to be returned. If length is larger than LEN(stringexpr), RIGHT$ returns all of stringexpr. If length is 0, RIGHT$ returns a null string.

See also: LEFT$ MID$

RMDIR Delete a directory on the Memory Disk Command

Purpose: Deletes a directory that currently exists on the Memory Disk. The directory to be deleted must be empty of all files and sub-directories before it can be deleted.

Syntax: RMDIR "[1:]path"

path A string expression that follows DOS path specification conventions to specify the name of the directory to be deleted.

No error is generated when attempting to remove a directory that is non-existant.

See also: CHDIR MKDIR FILES

-256- RND Random Number Function

Purpose: Generate an pseudo-random number in the range of 0 to 1.

Usage: var# = RND(numexpr)

If numexpr is: positive, RND returns the next random number in the current sequence;

zero, RND returns the last (most recent) random number in the current sequence;

negative, MotionBASIC uses numexpr to reseed the random number function. The first number in the reseeded random number series is returned.

See also: RANDOMIZE

RSET Right-Justify String Data Statement

Purpose: Right-justifies string data in a specified field of the random buffer, in preparation for a PUT statement or right-justifies string data in ordinary string variables.

Syntax: RSET strvar = stringexpr

strvar A valid string variable name; specifies the variable into which stringexpr is to be right justified.

stringexpr A string expression.

If LEN(stringexpr) is less than LEN(fieldvar), fieldvar is padded on the left with space characters.

See Also: LSET, PUT

-257- RUN Execute Program Command

Purpose: Execute the current program from the beginning or from a specified line number or label.

Syntax: RUN [linenum | label]

linenum A program line number.

label A symbolic label at the beginning of a program line.

If no line argument is given, MotionBASIC begins execution at the lowest numbered line.

Note: To preserve the contents of non-volatile variables, MotionBASIC does not clear all program variables when a RUN command is executed. The CLEAR statement may be used to clear all variables.

See Also: GOTO Program Initialization Differences from GWBASIC

SAVE Write Current Program to Disk Command

Purpose: Save the controller’s entire program buffer into a specified file

Syntax 1: SAVE pcfile [,{C|P}] OnDevelopment System Disk Syntax 2: SAVE cardfile [,{C|P}] OnMemory Disk

pcfile "[drive:][path\]filename[.ext]" cardfile "1:[path\]filename[.ext]"

drive Development Computer disk drive letter. path A string expression that follows DOS file-naming filename conventions. ext Default extension is .BAS (or .BPS when encrypted)

Two program encryption options are available when saving program files.

WARNING!!! DO NOT SAVE ENCRYPTION ONTO YOUR ORIGINAL SOURCE FILE NAME!! YOU WILL LOSE YOUR WORK AND NOT BE ABLE TO RECOVER IT!!

-258- SAVE Write Current Program to Disk Command

The program encryption options available when saving program files are:

C Creates a CODED file that is unreadable with text editors. When loaded into a controller, it can be viewed and traced using the LIST and TRACE commands, however no changes can be made to the program. The controller’s program buffer is now WRITE PROTECTED.

P Creates a CODED file that is unreadable with text editors. When loaded into a controller, it cannot be viewed at all, and no changes can be made to the program. The controller’s program buffer is now WRITE and READ PROTECTED.

WARNING!!! DO NOT SAVE ENCRYPTION ONTO YOUR ORIGINAL SOURCE FILE NAME!! YOU WILL LOSE YOUR WORK AND NOT BE ABLE TO RECOVER IT!!

Example: SAVE "C:\ORMEC\BAS\TEST",C ’Puts TEST.BPS on the Hard Drive

See Also: LOAD MERGE AUTOLOAD.BAS PB1LOAD.BAS

SCURVE@ S-Curve Velocity Profile ORMEC Variable

Purpose: Provide the ability to adjust the "smoothness" of velocity ramps commanded by MOVE statements. As SCURVE@ increases, the peak value of "jerk",(instantaneous acceleration change), is reduced.

Syntax: SCURVE@[(axes)] = smoothness Usage: var% = SCURVE@[(axes)]

smoothness An integer expression in the range 0 to 100; specifies the percentage of a velocity ramp to be "smoothed"; Default= 0

In linear velocity ramps, SCURVE@=0, the required acceleration is applied, held constant over 100% of the ramp, and removed. NOTE: Ramps taking 5 seconds or more are commanded as linear, regardless of SCURVE@.

When SCURVE@ is used, the velocity ramp is portioned into three segments: a smoothed start, a linear mid-section, and a smoothed finish. The length of the segments are percentages of the total velocity ramp, respectively they are: (SCURVE@/2)%, (100-SCURVE@)%, (SCURVE@/2)%.

-259- SCURVE@ S-Curve Velocity Profile ORMEC Variable

For example, SCURVE@(1) = 50, and a MOVE 1 AT 3000 IN 4000 is commanded. This defines a velocity ramp to a speed of 3000, over 4 seconds. With SCURVE@=50, the smoothed start is 25% (1 sec), the linear mid-section is 50% (2 secs), and the smoothed end of the ramp is 25% (1 sec).

An S-Curve velocity ramp is produced as follows: Acceleration is increased from zero to the necessary peak value during the first segment, held constant over the second segment, and then decreased back to zero acceleration during the third segment. This produces a "smoothed" velocity profile with a linear mid-section.

When using the S-Curve feature, the peak acceleration, (used during the linear mid-section), is higher than the acceleration that would have been used without S-Curve. In general terms, a short period of "higher" acceleration is needed to compensate for the lower values used in the beginning, and end, of the smoothed velocity ramp.

As SCURVE@ increases, so does the peak acceleration requirement.

SENS.MODE@ Sensor Mode ORMEC Variable

Purpose: Select the mode of operation of the high speed sensors provided on the DSP Axis Module.

Syntax: SENS.MODE@[(axes)]="mode[agate[bgate]]" Set Configuration Usage: var$ = SENS.MODE@[(axes)] Get Configuration

mode A three character string expression combining the characters "H", "L", "R", and "F", which sequentially define the ZREF@, ASEN@ & BSEN@ inputs as either asserted High, Low, on a Rising edge, or on a Falling edge. Default is "RRR".

agate One character each, either an "N"or"G" which will bgate disable/enable ELS gating of ASEN@ and BSEN@ respectively. Not Gating, or Gating. Default is "NN".

var$ When read a 3, 4, or 5 character string is returned indicating the respective operating modes of ZREF@, ASEN@ & BSEN@, and any gating that has been enabled.

-260- SENS.MODE@ Sensor Mode ORMEC Variable

Sensor For Which Axis? Gated by Which ELS? ASEN@ first on DSP Axis Module ELS1@(first) BSEN@ first on DSP Axis Module ELS2@(second) ASEN@ second on DSP Axis Module ELS1@(second) BSEN@ second on DSP Axis Module ELS2@(first)

Example: For a Dual DSP module controlling Axis 3 & Axis 4 10 CONFIGURE.SENSORS: 20 SENS.MODE@({4}) = "RFHGG" 30 PRINT SENS.MODE@({4}) 40 RETURN GOSUB CONFIGURE.SENSORS RFHGG

The example above sets up Axis 4 to have the following sensor action: ZREF@ to be asserted on a rising edge. ASEN@ to be asserted on a falling edge, only when ELS1@(4) is TRUE. BSEN@ to be asserted on a high level, only when ELS2@(3) is TRUE. +V This diagram illustrates the resultant ASEN@ state ASEN 0 for each sensor mode when gating is used. ELS1@ T F

T ASEN@ w/ MODE="R"

T ASEN@ w/ MODE="F"

TF ASEN@ w/ MODE="H"

ASEN@ w/ MODE="L" FT

SGN Sign of Number Function

Purpose: Return the sign of its numeric argument.

Usage: var% = SGN(numexpr)

If numexpr is: positive, SGN(numexpr) returns 1;

zero, SGN(numexpr) returns 0;

negative, SGN(numexpr) returns -1.

-261- SIN Sine Function

Purpose: Return the sine of the angle whose value, in radians, is expressed in numexpr.

Usage: var# = SIN(numexpr)

numexpr A numeric expression which represents the angle, in radians. If numexpr is large (greater than 1.0E8), a partial loss of significance in the result may occur. If numexpr is so large that a total loss of significance occurs (greater than 2.0E9), an Overflow error will occur.

Note: PI radians = 180 degrees, and so before executing the sine function, convert numexpr from degrees to radians by dividing by 180/PI or 57.296.

See also: ATN COS TAN

SPACE$ String of n Spaces Function

Purpose: Return a string consisting of a specified number of space characters.

Usage: var$ = SPACE$(n)

n An integer expression in the range 0 to 255 specifying the number of spaces to return to var$.

See also: SPC STRING$ TAB

SPC Output n Spaces in a PRINT Statement Modifier

Purpose: Output a specified number of spaces in a PRINT or PRINT # statement.

Usage: PRINT SPC(n)

n An integer expression in the range 0 to 255.

If n is larger than the width of the output device (as defined by WIDTH), MotionBASIC skips n MOD width spaces.

If the SPC function is used at the end of a list of items to print, MotionBASIC behaves as though the PRINT statement terminated with a semicolon; it suppresses the usual carriage return and line feed.

See also: SPACE$ TAB WIDTH

-262- SPD.MAX@ Maximum Speed ORMEC Variable

Purpose: Define the maximum allowable commanded speed in user units. This is also the default speed used by motion statements.

Syntax: SPD.MAX@[(axes)] = speed

Usage: var& = SPD.MAX@[(axes)]

speed A long integer expression representing the maximum allowable commanded axis speed in user units from 1 to USR.SPD.LIM@. Default SPD.MAX@ = USR.SPD.LIM@, and changing USR.SPD.LIM@ will always reset SPD.MAX@ equal to USR.SPD.LIM@.

This speed is used by default for all motion statements. If a motion statement specifies a speed greater than this parameter, an error will be generated and the motion will not occur. This variable can be changed at any time without affecting any other variables, but must always be less than or equal to USR.SPD.LIM@.

SQR Square Root Function

Purpose: Return the square root of a number.

Usage: var# = SQR(numexpr)

numexpr A numeric expression greater than or equal to 0.

STACK Clear Control Stack Statement

Purpose: Clear the MotionBASIC control stack, aborting all loops and subroutines, and allowing the program to start over properly.

Usage: STACK CLEAR

The MotionBASIC control stack is used to keep track of nested subroutines, FOR...NEXT and WHILE...WEND loops.

The STACK CLEAR statement clears the status of the MotionBASIC control stack causing all program loop and subroutine returns to be aborted. After a STACK CLEAR statement, program operation is normally continued at the main program entry point with a GOTO statement.

See also: RESUME

-263- STL.FWD@ Forward Software Travel Limit ORMEC Variable

Purpose: Define the maximum allowed forward position for a servo.

Syntax: STL.FWD@[(axes)] = position

Usage: var& = STL.FWD@[(axes)]

position A long numeric expression which represents the maximum allowed forward (positive) position for a specified servo in user units. Setting both STL.FWD@ and STL.REV@ to 0 (default) disables the use of software travel limits.

If a servo’s actual position becomes more positive than the "forward software travel limit", then: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.FWD@ Boolean variable for that axis will be asserted, and •amotion error will be generated.

See OTL.FWD@ for a detailed explanation of overtravel limit operation.

STL.REV@ Reverse Software Travel Limit ORMEC Variable

Purpose: Define the maximum allowed reverse position for a servo.

Syntax: STL.REV@[(axes)] = position

Usage: var = STL.REV@[(axes)]

position A long numeric expression which represents the maximum allowed reverse (negative) position for a specified servo in user units. Setting both STL.FWD@ and STL.REV@ to 0 (default) disables the use of software travel limits.

If a servo’s actual position becomes more negative than the "reverse software travel limit", then: • it’s commanded motion will be stopped using USR.ACL.LIM@, • the OTL.REV@ Boolean variable for that axis will be asserted, and •amotion error will be generated.

See OTL.REV@ for a detailed explanation of overtravel limit operation.

STOP Halt Program, Leave Devices Open Statement

Purpose: Stop program execution but leave all devices open.

Syntax: STOP

MotionBASIC reports the line number at which program execution was STOPped.

STOP is generally used for debugging purposes. Program execution can be resumed after a STOP statement by means of a CONT command, provided the program has not been edited during the interruption.

-264- STR$ String Representation of Numeric Expression Function

Purpose: Return either the "decimal representation of a number" or the "elements in a set" as a string.

Usage: var$ = STR$(numexpr)

The string returned by STR$ will contain no leading or trailing spaces.

To support sets, STR$({elem1,elem2,elem3,...}) returns the string "{elem1,elem2,elem3,...}"

See also: CHR$ VAL HEX$ OCT$ BIN$ Differences from GWBASIC

STRING$ String of Specified Length and Character Function

Purpose: Return a string of specified length, whose characters all have the same specified ASCII value.

Usage 1: var$ = STRING$(m,n)

Usage 2: var$ = STRING$(m,stringexpr)

m An integer expression in the range 0 to 255; specifies the length of the string.

n An integer expression in the range 0 to 255; specifies the decimal ASCII value of the character to be returned m times.

stringexpr A string expression. STRING$(m,stringexpr) returns the first character of stringexpr m times.

SYSTEM Return to Operating System (BASIC) Command

Purpose: None. This keyword is currently reserved for future use.

-265- TAB Tab to Specified Position Modifier

Purpose: Move to a specified print position in a PRINT or PRINT # statement.

Usage: PRINT TAB(column)

column An integer expression in the range 1 to 255.

If the current print (or screen) position is already to the right of column, TAB moves to position column on the next line.

If the TAB function comes at the end of a list of data items in a PRINT statement, MotionBASIC behaves as if the PRINT statement were terminated by a semicolon; it suppresses the usual carriage return and line feed.

If column is larger than the width of output device, TAB(column) moves to column MOD width.

If column is less than 1, TAB(column) is treated as TAB(1).

See also: SPACE$ SPC

TALK Console Talk Mode Statement

Purpose: Put the console into "TALK" mode with the devices specified on the command line. This means that all characters typed at the console will be sent to the device specified by the outdev number and all characters received from the device specified by the indev number will be displayed on the console.

Syntax: TALK indev, outdev

indev A numeric expression in the range 1 to the maximum number of devices allowed.

outdev A numeric expression in the range 1 to the maximum number of devices allowed.

The "TALK" mode is terminated by typing a Ctrl-C at the console.

See also: OPEN EOF INPUT$

-266- TAN Tangent Function

Purpose: Returns the tangent of the angle whose value, in radians, is expressed in numexpr.

Usage: var# = TAN(numexpr)

numexpr A numeric expression which represents the angle, in radians. If numexpr is large (greater than 1.0E8), a partial loss of significance in the result may occur. If numexpr is so large that a total loss of significance occurs (greater than 2.0E9), an Overflow error will occur.

PI radians = 180 degrees, and so before executing the tangent function, convert numexpr from degrees to radians by dividing by 180/PI or 57.296.

See also: ATN COS SIN

TIME$ Set System Time or Return it as a String Function

Purpose: Set system time or return it as a string.

Syntax: TIME$ = stringexpr Set the system time

Usage: var$ = TIME$ Get the system time

stringexpr A string expression in the form "hh" or "hh:mm" or "hh:mm:ss". Leading 0s may be omitted in any of the fields.

var$ The value returned will be an 8-character string in the form "hh:mm:ss".

Example: 10 TIME$ = "0" ’reset the system time

See also: TIMER

-267- TIME.MUL@ Time Conversion Factor ORMEC Variable

Purpose: Define the number of internal time units (1 millisecond each) per desired user time unit.

Syntax: TIME.MUL@ = units

Usage: var% = TIME.MUL@

units An integer expression which defines the number of internal time units (1 millisecond each) per desired user time unit.

The default for TIME.MUL@ is 1 which provides user time units of 1 ms for all references to time in a MotionBASIC program.

Example: To specify time in ten-thousandths of a minute, change this multiplier to 60*1000/10000 = 6.

TIMER Return elapsed time in User Units Function

Purpose: Return elapsed time in user units.

Usage: var& = TIMER Get the system time

var& The long integer value returned will contain the time in user units since the system time was last reset.

Example: 10 START.TIME=TIMER ’save current time 20 WAIT 100 30 PRINT "Elapsed Time:";TIMER-START.TIME;"ms" ’print the elapsed time 40 END

TRACE Program Trace Control Statement

Purpose: Enable or disable the program trace mode.

Syntax 1: TRACE [SAVE] {ON | OFF | STEP} Syntax 2: TRACE RESTORE

ON Causes MotionBASIC to output a copy of the program line before it is executed.

OFF Causes MotionBASIC to stop tracing the program.

STEP Same as ON except that MotionBASIC waits for a keystroke before the execution of the printed statement.

In trace mode, MotionBASIC prints the line, enclosed in square brackets, of each program line as it is executed.

-268- TRACE Program Trace Control Statement

The option SAVE keyword will save one level of the setting of TRACE. In other words if you have a particularly annoying piece of code for tracing you can do a TRACE SAVE OFF before it and a TRACE RESTORE after it right in the program buffer. This will prevent unnecessary tracing of the code.

TRACE may be executed in either direct mode or as part of a program execution.

See also: BREAK TRACE VAL Program Initialization

TRACE VAL Variable Trace Control Statement

Purpose: Enable or disable the variable trace mode.

Syntax 1: TRACE VAL [ON] varlist Syntax 2: TRACE VAL OFF [varlist] Syntax 3: TRACE VAL LIST

ON Causes MotionBASIC to trace on the specified variables.

OFF Causes MotionBASIC to stop tracing those specified variables or all variables.

LIST Causes MotionBASIC to list all variables currently being traced.

varlist A list of variables (separated by commas) which, when modified during program execution, will cause MotionBASIC to process the trace.

In variable trace mode, as program lines are executed, MotionBASIC prints the line, enclosed in square brackets, of each program line which changes one of the variables in the list.

TRACE VAL may be executed in either direct mode or as part of a program execution.

When used with ORMEC variables which are indexed by axes, the axes can not be specified in the varlist. TRACE VAL will display changes to that ORMEC variable on all axes.

See also: BREAK CLEAR TRACE Program Initialization

-269- DRV.CMD@ Drive Command ORMEC Variable

Purpose: Return the current real-time value for the drive command output of an axis control loop. Set the drive command output directly when in output mode. (Formerly known as TRQ.CMD@ for MB ver 2.0 and prior.)

Usage: var% = DRV.CMD@[(axes)]

Syntax: DRV.CMD@[(axes)] = intexpr

var An integer value within the range from -DRV.MAX@ to DRV.MAX@, corresponding to the current drive command output. The value is proportional to ±10 VDC, and is positive for "forward" output.

intexpr An integer expression which will directly set the drive command output voltage (DRV-CMD) from -10 to +10 VDC when in output mode.

The DSP Axis Module loop hardware output (DRV-CMD) is interfaced through a 12-bit D/A converter and only the most significant 12 bits of the DRV.CMD@ variable affect the output voltage. i.e. The analog output voltage is changed only at increments of 16 in the value of DRV.CMD@.

The value for the DRV.CMD@ variable is always positive for "forward" commands. For Generation III drives, motor rotation should be "counter-clockwise" for a "positive" voltage input to the servodrive. When the axis direction for "forward" is changed to "clockwise", by assigning a non-zero value to CW.FWD@, the polarity of the drive command output voltage is reversed with respect to the DRV.CMD@ variable. Also reversed at that time is the direction of the servomotor feedback.

The Drive Command output is normally changed indirectly by MotionBASIC motion statements, and this variable is only for checking status. However, in output mode this variable can only be set directly resulting in a "step" change of drive command voltage to the servodrive. See also: DRV.MAX@

TRQ.GAIN@ Torque Gain of Motor & Drive ORMEC Variable

Purpose: Define the torque gain of the motor and drive for a servo axis.

Syntax: TRQ.GAIN@[(axes)] = gain

Usage: var! = TRQ.GAIN@[(axes)]

gain A single precision floating point expression which represents the torque gain of the motor and drive from 0.10 to 655.35 lb-in per volt. Default = 0.5

Note that no changes will be made to the actual servo loop parameters after changing TRQ.GAIN@ until a value is assigned to INERTIA@.

See Also: Loop Architecture Ka Kaf

-270- DRV.MAX@ Maximum Drive Command ORMEC Variable

Purpose: Define the maximum allowable value for the drive command output. (Formerly known as TRQ.MAX@ for MB ver 2.0 and prior)

Syntax: DRV.MAX@[(axes)] = maximum Usage: var% = DRV.MAX@[(axes)]

maximum An integer expression from 1 to 32,767, that defines the maximum drive command output value in either direction and proportionally limits the DSP’s 12-bit D/A converter output voltage in a range of 0 to ±10 volts. The default value is 1 as a safeguard against any attempt to operate a servo axis without first executing the MP.CONFIG routine.

With ORMEC’s E-Series and S-Series "torque mode servodrives", a setting of 10000 corresponds to approximately 100.00% of "rated output torque".

With ORMEC’s F-Series "torque mode servodrives", a setting of 26214 corresponds to approximately 100% of "peak output torque".

The fact that the drive command output is being limited by this variable will not by itself cause any error condition.

UCASE$ Convert Lower Cases to Upper Cases Function

Purpose: Return a string with all lower case characters of its argument being converted into upper case characters.

Usage: var$ = UCASE$(stringexpr)

stringexpr A string expression.

See also: LCASE$

UNIT.ID@ Unit Identification Code ORMEC Variable

Purpose: Return the motion controller’s unit identification code.

Usage: var% = UNIT.ID@

var An integer value which is equal to the value selected by the Unit-ID switches on the front of the controller when power was applied to the unit, or the reset button was last pressed.

If UNIT.ID@ is outside the range of 1-32 at powerup, an Invalid Unit ID fault will be generated and a bit in the FAULT@ variable will be set.

-271- UNTIL Define a Stop Condition Modifier

Purpose: Define a stop condition for a motion specified by a MOVE, GEAR or HALT statement; define a terminate condition for a WAIT statement.

Usage 1: [REPEAT] MOVE parameters [AFTER condition] UNTIL condition

Usage 2: [REPEAT] GEAR parameters [AFTER condition] UNTIL condition

Usage 3: HALT parameters [AFTER condition] UNTIL condition

Usage 4: WAIT UNTIL expression

condition ZREF@, ASEN@, BSEN@ or DELAY@

expression Any Boolean expression.

When MotionBASIC executes a MOVE, GEAR or HALT statement, it processes the parameters and places high level information in the shared memory of the DSP Axis Module(s). When AFTER, UNTIL and/or REPEAT modifiers are

included in the statement, the DSP uses this information as it executes or "repeats" the motion, allowing "fast" decision making by the next servo loop update. Note that motions modified by AFTER and UNTIL clauses can be "repeated" independently by the DSP, freeing up MotionBASIC execution for other tasks.

MOVE, GEAR and HALT statements implicitly clear latched variables when executed, causing the UNTIL clause to be satisfied on the next event.

Note that UNTIL clauses can be used with GEAR AT statements but not with GEAR FOR statements.

When an UNTIL clause is used with a WAIT statement, then MotionBASIC repeatedly executes the WAIT statement suspending program execution, except for ON EVENT processing, until the WAIT condition becomes TRUE.

Examples: 10 MOVE AT 500 UNTIL ASEN@ 20 HALT IN 30 UNTIL ZREF@

-272- USER1.LED@ User 1 LED ON ORMEC Variable

Purpose: Allow MotionBASIC to turn on and off the green "User 1" LED on the front of the controller; return the status of the User 1 LED.

Syntax: USER1.LED@ = value

Usage: var% = USER1.LED@

value This Boolean expression is used to turn the LED ON or OFF. If the expression evaluates to 0 (OFF) the LED will be turned OFF, otherwise it will be turned ON. Default USER1.LED@ = OFF (0).

var% A Boolean integer variable which will be TRUE (-1) if the LED is ON. Otherwise it will be FALSE (0).

Note: User 1 LED indicates that a powerup program load from a Memory Disk is in progress by flashing during the load.

USER2.LED@ User 2 LED ON ORMEC Variable

Purpose: Allow MotionBASIC to turn on and off the green "User 2" LED on the front of the controller; return the status of the User 2 LED.

Syntax: USER2.LED@ = value

Usage: var% = USER2.LED@

value This Boolean expression is used to turn the LED ON or OFF. If the expression evaluates to 0 (OFF) the LED will be turned OFF, otherwise it will be turned ON. Default USER2.LED@ = OFF (0).

var% A Boolean integer variable which will be TRUE (-1) if the LED is ON. Otherwise it will be FALSE (0).

-273- USING Define a format for PRINT or INPUT Modifier

Purpose: Define a format for the PRINT, PRINT #, and INPUT @ statements.

Usage: USING format

format A string variable or constant specifying the format in which the data is to be printed.

The following symbols may be used in format:

Symbol Meaning (numeric) Symbol Meaning (string/literal)

# Digit in a number ! First character of string . Decimal point in a number \ \ First n chars of string + Leading/trailing +/- sign & Entire string - Trailing minus sign ^^^^^ Exponent of a number _ Print next format char , Thousands place separator other Print format character

Multiple field formats may be contained in a single format string. Each field’s format should be separated from the next by a non-format character. If the expression list contains more expressions than are specified by the format string, the format string will be replicated as many times as are necessary to print all expressions in the list.

For example, the following two statements are equivalent:

PRINT USING "##.# ##.### "; 1; 2; 3; 4 1.0 2.000 3.0 4.000 PRINT USING "##.# ##.### ##.# ##.### "; 1; 2; 3; 4 1.0 2.000 3.0 4.000

The following pages contain a detailed description of each of the format symbols. Each page describes one format character, and contains examples of its use.

See also: PRINT PRINT # INPUT @

Format Symbol: #

Meaning: A place-holder. If the numeric expression has more digits to the right of the decimal point than the format string has #s, MotionBASIC rounds. If the numeric expression has more digits to the left of the decimal point than the format string has #s, MotionBASIC prints all the digits to the left of the decimal point and also prints a percent sign (%) to the left of the number. If the numeric expression has fewer digits to the left of the decimal point than the format string has #s, MotionBASIC right-justifies the number; that is, it pads the number on the left with spaces. (But if there are any #s to the left of the decimal point in the format string, MotionBASIC always prints at least one digit --a0ifnecessary -- to the left of the decimal point).

Example: PRINT USING "#####"; -123 -123

-274- USING Define a format for PRINT or INPUT Modifier

Format Symbol: . (decimal point)

Meaning: Specifies the position of the decimal point in a numeric expression.

Examples: PRINT USING "###.##"; 12.3 12.30 PRINT USING "###.##"; -1.234 -1.23 PRINT USING "####.##"; 12.345 12.35 PRINT USING "###.#####"; 0 0.00000 PRINT USING "###.##"; -37.8; 14.678; 2 -37.80 14.68 2.00 PRINT USING "#.##"; 12.3 ’Example of width exceeded %12.30

Format Symbol: +

Meaning: Print a plus or minus sign, as appropriate, to the left or right of the number. The sign is always printed immediately to the left or right of the number, depending on the position of plus sign.

Examples: PRINT USING "+###.##"; 12.3; -45.6 +12.30 -45.60 PRINT USING "##.#+"; 2; -7 2.0+ 7.0-

Format Symbol: - (minus sign)

Meaning: Print a minus sign immediately to the right of a negative number (the minus sign should appear after the place holders in the format string). If the number not negative, print a space instead.

Examples: PRINT USING "##.#-"; 2; -7 2.0 7.0-

Format Symbol: ^^^^^ (five carets)

Meaning: Print a number in exponential format. The five carets should appear after all place holders in the format string. The five carets are place holders for E±nnn.

Examples: PRINT USING "##.##^^^^^"; 123.45 1.23E+002 PRINT USING ".####^^^^^"; 555555 .5556E+006 PRINT USING "+.##^^^^^"; 876 +.88E+003

-275- USING Define a format for PRINT or INPUT Modifier

Format Symbol: !

Meaning: Print only the first character of a string expression.

Example: 10 A$="HELLO":B$="WORLD" 20 PRINT USING "!";A$;B$ ’Print "HW" RUN HW

Format Symbol: \\

Meaning: Print only the first n + 2 characters of a string expression, where n is the number of spaces between the two backslashes. If n is larger than the number of characters in the string expression, MotionBASIC pads the string expression on the right with space characters.

Example: 10 A$="TRY":B$="THIS" 20 PRINT USING "!";A$;B$ ’Print "TT" 30 PRINT USING "\ \";A$;B$ ’Print "TRYTHI" 40 PRINT USING "\ \";A$;B$;"!!" ’Print "TRY THIS!!" RUN TT TRYTHI TRY THIS!!

Format Symbol: &

Meaning: Print a string expression without reformatting it.

Example: 10 A$="HELLO":B$="WORLD" 20 PRINT USING "!";A$; ’Print "H" 30 PRINT USING "&";B$ ’Print "WORLD" RUN HWORLD

Format Symbol: _ (underscore)

Meaning: Print next character as a literal. The combination _#, for example, allows you to include a number sign as a literal in your numeric format.

Examples: PRINT USING "_!##.##_!"; 12.34 !12.34! PRINT USING "_######"; 123 # 123

-276- USING Define a format for PRINT or INPUT Modifier

Format Symbol: (other)

Meaning: Characters other than the foregoing may be included as literals in the format string. Thus, for example, a single dollar sign may be positioned to the left of a series of place holders (#s) to achieve vertically aligned dollar signs, and space characters may be placed at the right side of the format string to achieve horizontal separation between a series of numbers.

Example: PRINT USING "[##.##]"; 12.34 [12.34] PRINT USING "TOTAL: ####.# (###%)"; 273.4; 78 TOTAL: 273.4 ( 78%)

USR.ACL.LIM@ Acceleration Limit in User Units ORMEC Variable

Purpose: Define the absolute maximum machine acceleration rate in user acceleration units.

Syntax: USR.ACL.LIM@[(axes)] = accel

Usage: var& = USR.ACL.LIM@[(axes)]

accel A long integer expression representing the absolute maximum machine acceleration rate in user units. Default USR.ACL.LIM@ = 5000 rad/sec².

This variable is used in conjunction with MTR.ACL.LIM@ and CNT.REV@ to define the user acceleration units. It is also used whenever software or hardware overtravel limits are exceeded.

This setup parameter should generally be set only once during program initialization.

-277- USR.SPD.LIM@ Axis Speed Limit in User Units ORMEC Variable

Purpose: Define the absolute machine speed limit for a servo axis in user speed units.

Syntax: USR.SPD.LIM@[(axes)] = speed

Usage: var& = USR.SPD.LIM@[(axes)]

speed A long integer expression representing the absolute maximum machine speed for a servo axis in user units. Default USR.SPD.LIM@ = 4000 RPM.

Note that MotionBASIC sometimes adjusts the value of MTR.SPD.LIM@ in the process of calibrating the DSP speed equations, and therefore you may need to adjust USR.SPD.LIM@ accordingly. MotionPRO’s screen-oriented system configuration capability makes this adjustment for you automatically.

VAL Numeric Value of a String Function

Purpose: Return the numeric value represented by a string expression.

Usage: var = VAL(stringexpr)

stringexpr A string expression.

VAL extracts a number from the first characters of its argument. It ignores leading blanks, tabs, and line feeds, and treats a single hyphen as a signifying negation. For example, VAL(" -32 Main Street") returns -32. If the first character in the argument (or the first character following all space and tab characters) is a letter, VAL returns 0. For example, VAL("HI Mom!") returns 0.

To support sets, VAL("{elem1,elem2,elem3,...}") returns a set containing elem1,elem2,elem3,...

See also: ASC STR$

VEL.ACT@ Actual Velocity ORMEC Variable

Purpose: Return the observed velocity of the servo axis in user units.

Usage: var& = VEL.ACT@[(axes)]

var A long integer value which is equal to the current real-time velocity of the servo axis, as determined by the velocity observer.

-278- VEL.CMD@ Velocity Command ORMEC Variable

Purpose: Return the current real-time value for commanded velocity of a servo axis in user units. Set the commanded velocity directly when in velocity mode.

Usage: var& = VEL.CMD@[(axes)]

Syntax: VEL.CMD@[(axes)] = lngexpr

var A long integer value which is the currently commanded velocity. lngexpr A long integer expression which will directly set the commanded velocity if in velocity mode. See MODE@.

Commanded velocity is normally changed by MotionBASIC statements such as MOVE@ and GEAR@, and this variable is only for checking status. However, in velocity mode this variable can be set directly resulting in a "step" change of velocity command fed directly to the velocity loop.

VEL.LAST@ Last Specified Top Velocity ORMEC Variable

Purpose: This read-only variable is the top velocity last specified in a MOVE command, either directly or indirectly.

Usage: var% = VEL.LAST@[(axes)]

Specifying a top velocity in any MOVE command, either directly or indirectly, will change this parameter.

VLTC@ Velocity Loop Time Constant ORMEC Variable

Purpose: Define the velocity loop time constant for a servo axis.

Syntax: VLTC@[(axes)] = factor

Usage: var! = VLTC@[(axes)]

factor A single precision floating point expression which represents the velocity loop time constant from 0.3 to 30.0 msec. Default = 3.0

See Also: Loop Architecture Kv Kvi Kp Kpi

-279- WAIT Wait for a Condition or Time Statement

Purpose: Suspend MotionBASIC execution to pause until a condition becomes true, for a specified length of time, or for a specified length of time after a condition becomes true.

Syntax 1: WAIT UNTIL condition Syntax 2: WAIT time [AFTER condition]

condition An expression that must evaluate to TRUE before the WAIT time begins or program execution continues.

time A numeric expression representing the time in user units that MotionBASIC execution will pause AFTER the specified condition evaluates TRUE. When the time expires, program execution continues at the next statement.

MotionBASIC event trapping is enabled during WAIT statements. WAIT will wait at least as long as specified, with a 5 msec minimum and a 5 msec resolution. The table below assumes TIME.MUL@ =1.

time Actual wait time

00 1 - 5 5 - 10 msec 6 - 10 10 - 15 msec 11 - 15 15 - 20 msec

WHILE, WEND WHILE...WEND Loop Statement

Purpose: Define a WHILE/WEND loop.

Syntax: WHILE expression . . [statements] . WEND

expression A numeric or Boolean expression.

MotionBASIC starts by evaluating expression.Ifexpression is non-zero (true), the next statement is executed. If expression is zero (false), control passes to the first statement following the next WEND statement.

-280- WHILE, WEND WHILE...WEND Loop Statement

When MotionBASIC encounters the WEND statement, it reevaluates the expression argument to the most recent WHILE. If the argument is still non-zero (true), the process is repeated; otherwise, execution continues at the next statement.

WHILE/WEND loops may be nested to any level of complexity, but there must be a WEND for each WHILE.

MotionBASIC programs should not include GOTO statements which branch out of a WHILE...WEND loop. See the structured programming chapter for details.

See also: FOR...NEXT Differences from GWBASIC

WIDTH Set Output Width Statement

Purpose: Set the line width in characters for an output device.

Syntax: WIDTH [[#]devnum,] width

devnum A numeric expression which specifies the device OPENed for output. If not specified, the width value will affect the screen device.

width A numeric expression in the range 0 to 255 with the following exceptions:

The range for a screen device, (e.g. OIT or MMI)is14 to 132. Default 80. 0 turns off WIDTH support.

The valid range when ITM Driver Support is enabled is 15 to 80. The default is 15.

A carriage return is sent to the device when width has been reached.

Specifying a WIDTH of 0 or 255 disables the automatic generation of a carriage return.

Normally, every character sent through the output device will increment an internal counter. When the counter reaches the width value, MotionBASIC sends a carriage return to the device. There are three special characters that do not simply increment the counter. They are:

ASCII Code Character Name Effect on internal counter

0Dh Carriage Return Resets counter to 0 0Ah Line Feed No effect 08h Back Space decrements counter by 1 (no effect at 0)

An interesting feature of the Color OIT, which normally has a width of 80 columns, is obtained by setting the WIDTH to 40. This provides double-wide characters for the entire OIT display.

-281- WITHIN Set Membership Operator

Purpose: Perform a set membership comparison.

Usage: set1 WITHIN set2

set1, set2 Set expressions. If set2 has all the elements in set1, the result is -1 (TRUE); otherwise the result is 0 (FALSE).

WITHIN may also be used to specify the action to be taken by a FOR...NEXT loop.

This operator is different from <= in the sense that both operands are of, or will be converted to, the set type.

Example: 10 B~ = {2,3,9} :IF 2 WITHIN B~ THEN PRINT "{2} is a subset of B~"

See also: = <> < <= > >= Precedence

XOR Logical Exclusive OR Operator

Purpose: Perform a logical exclusive OR on two binary integers or long integers.

Usage: exp1 XOR exp2

exp1, exp2 Any expressions, including boolean expressions, that produce an integer or long integer result.

The operands must be either integer or long integer. Any other operand types will cause a Type Mismatch error to occur. The result is the same type as the largest operand. If the two operands are different sizes, integer type conversion is performed.

MotionBASIC performs a bitwise XOR, according to the XOR truth table. See the chapter on bitwise operations for an example.

See also: NOT AND OR Precedence

-282- ZREF@ Zero Reference On ORMEC Variable

Purpose: Determine if the "once-per-revolution" reference signal (ENCZ) of the specified axis encoder is asserted; or has been asserted since last cleared. Clear and arm an edge sensitive latch.

Usage: var% = ZREF@[(axes)] ’w/ multiple axes reference, ZREF@s are ORed Syntax: ZREF@[(axes)]=0

var A Boolean value which will be TRUE (-1) if ENCZ either is asserted, or has been asserted since last cleared, depending on SENS.MODE@. Otherwise it will be FALSE (0).

This input signal is used to capture axis position POS.ZREF@. ZREF@ can initiate a motion AFTER it occurs, terminate a motion waiting UNTIL it occurs, and it can be used in any boolean expression.

Setting ZREF@ to 0 always clears it if it was configured by SENS.MODE@ as Rising or Falling edge sensitive. If configured level sensitive, it may be immediately re-asserted depending on the state of the input.

-283- Impact of Set Variables on MotionBASIC

A. Variables 1. The variable type character is ’~’. 2. Set constants, require four bytes of storage and are represented as {,,, ...}. e.g. {1,16,31} is a set of three elements. Set elements must be between 1 and 32. 3. Set variables are represented as variable names followed by the "set type" character. For example, set.variable~ is a set variable. 4. Type Conversion a. SET <-> SNG not allowed b. SET <-> DBL not allowed c. SET <-> STR not allowed d. SET <-> INT 1) a% = a~ will assign the value of the lowest numbered element in a~ to a%. 2) a~ = a% will treat the value of a% as a set element and assign it to a~

e. SET <-> LNG 1) a& = a~ will assign the value of the lowest numbered element in a~ to a&. 2) a~ = a& will treat the value of a& as a set element and assign it to a~ 5. Type promotion is from Integer/Long to set. For example, (3+{4}) or ({4}+3) will result in {3,4}. 6. The boolean value of an empty set is FALSE otherwise it is TRUE.

B. Operators 1. Arithmetic a. (a~ + b~) is equivalent to the union of a~ and b~. b. (a~ - b~) is the set of all elements in a~ that are not also elements in b~. c. (a~ * b~) is equivalent to the intersection of a~ and b~. 2. Relational a. a~= b~ is TRUE if and only if the two sets are identical. b. a~<>b~ is TRUE if the two sets are not identical.

c. a~< b~ is TRUE if a~ is a subset of b~ but not equal to b~. d. a~<=b~ is TRUE if a~ is a subset of b~. e. a~> b is TRUE if b~ is a subset of a~ but not equal to a~. f. a~>=b~ is TRUE if b~ is a subset of a~. g. a~ WITHIN b~ is the same as a~<=b~ except that WITHIN always convert its operands into set type first. 3. Bitwise a. NOT a~ is equivalent to the complement of a~.

C. Functions 1. VAL("{elem1,elem2,elem3, ...}") will return a set containing elem1, elem2, elem3, etc. 2. STR$({elem1,elem2,elem3,...}) will return the string "{elem1,elem2,elem3,...}"

D. Statements 1. PRINT a~ will display "elem1,elem2,elem3, ..." 2. DEFSET [-]

-284- Impact of Set Variables on MotionBASIC

3. All input statements allow set variables. For example, INPUT @, READ, INPUT, etc. 4. Added "Syntax 2" to FOR...NEXT

E. Motion Statements MOVE, GEAR, and HALT use a set type axis parameter. For example, MOVE 3 FOR ... will be changed by automatic type conversion to MOVE {3} FOR ... The statement MOVE {1,2} FOR .... will move both axis 1 and 2.

F. ORMEC Variables Axis oriented ORMEC variables are indexed on set variables. e.g. AXIS.SET@ = 3 will be changed by automatic type conversion to AXIS.SET@ = {3}. MODE@(3) will be interpreted as MODE@({3}).

Some ORMEC variables are set variables and return set values. For example, the statement AXES~ = AXIS.SET@ assigns the current "default set of servos" to variable AXES~.

Tracing the setting of AXIS.SET@ = {1,2} will display AXIS.SET@ = {1,2}.

ORMEC Variables that return set type values are: FAULT@, AXIS.LIST@, AXIS.SET@, AXIS.FLT1@, AXIS.FAULT@ and AXIS.OTL@

G. Set variable Error Codes 1. #1224: Expected Set

ITM Driver Support

The ITM-270 operator interface is supported via a MotionBASIC device driver and through the use of standard statements/functions:

WIDTH, CLOSE, EOF, INPUT #, PRINT #, and IOCTL

The ITM Driver is turned on when an ITM device is opened.

See: OPEN ITM

The following documentation covers the special use of the standard statements and functions that are used with an ITM-270 device:

-285- ITM Driver Support

WIDTH with ITM Support

Purpose: Keep long messages from being refreshed.

Syntax: WIDTH [[#]devnum,] [len]

devnum the device number under which the ITM was OPENed

length the maximum length of a message that will be automatically refreshed on the ITM’s display. Range 15 to 80. Default: 15

Example: OPEN "R",1,"COM1:ITM=5" ’Open COM1 with ITM Support WIDTH #1, 20 ’ Set refresh length to 20 characters

NOTE: Messages longer than length are not refreshed. This allows the user to scroll over the entire message using the ITM’s < and > keys. See: ITM Display

CLOSE with ITM Support

Purpose: It closes the port and turns off the ITM Driver.

Syntax: CLOSE [devnum]

devnum the device number under which the ITM was OPENed

Example: OPEN "R",1,"COM1:ITM=10" ’ Open COM1 with ITM support. ... CLOSE 1 ’ Close COM1 and terminate ITM-270 support.

EOF with ITM Support

Purpose: Determine that there is data available at the ITM. It returns a FALSE flag when data at the ITM is ready.

Syntax: EOF(devnum)

devnum the device number under which the ITM was OPENed

Example: IF NOT EOF(1) THEN ’ Check for ITM Data ready INPUT #1, DATA$,KEYNUM ’ Read ITM Data DATA!=VAL(DATA$) ’ Convert DATA to a value. ENDIF

-286- ITM Driver Support

INPUT # with ITM Support

Purpose: Extract a response from the ITM-270. The response is always a string and an integer.

Syntax: INPUT #devnum, value$, keynum

devnum the device number under which the ITM was OPENed

value$ contains a string representation of the value entered (or null if it was a function key only).

keynum standard EXITKEY values for ENTER and F1 - F6 (there are only 6 function keys. See: ITM Function Keys.)

The user program should check both the value$ and the keynum received from the ITM-270. Operators could enter numeric data and then press a Function Key, rather than the Enter Key as one might expect.

IOCTL with ITM Support

Purpose: Use the features of an ITM-270. (e.g. lighted function keys, flashing display, etc.)

Syntax: IOCTL [#]devnum, ctrl$

devnum the device under which the ITM was OPENed

ctrl$ A string expression to be passed to the ITM driver.

"LED n state" n is LED number or set specification

state ON OFF or number for blink rate

"DISP flash" flash 0- No Change 1 - Flashing Off 2 - Flashing ON

"CURSOR size" size 0 - No Change 1 - No Cursor 2 - Underscore 3 - Flashing Block

Examples: IOCTL #1, "LED {6} ON" ’Turn on LED 6 IOCTL #1, "LED {1,3,5} OFF" ’Turn off LEDs 1, 3, & 5 IOCTL #1, "DISP 2" ’Make the display flash IOCTL #1, "CURSOR 3" ’Change cursor to flashing block

See Also: ITM Display & Function Keys

-287- ITM Driver Support

Errors Generated w/ ITM Support

The only ITM specific errors are ones that deal with a breakdown of communications between the controller and the ITM-270.

In the event of a communications break down, a flag is set internal to the device driver. The next time the device is accessed via an EOF, IOCTL, INPUT # or PRINT # command, an error message will be generated.

Statement Error

PRINT # #1310 Device Write Failed IOCTL #1310 Device Write Failed INPUT # #1312 Device Read Failed EOF #1312 Device Read Failed

DOS File-Naming Conventions

When using MotionBASIC Files a unique name is assigned to each file. A file’s name appears as follows: FILENAME.EXT

A file’s name has two parts, the filename and an extension. A period separates a filename from an extension.

A filename can be from 1 to 8 characters long. An extension is 1 to 3 characters long and indicates the type of file. Only letters, numbers and _ (underscore) are valid filenaming characters.

In MotionBASIC, program files should have the extension, BAS

The following filenames have special significance:

AUTOLOAD.BAS - Loads from a Memory Disk at each powerup. PB1LOAD.BAS - Loads from a Memory Disk at powerup when PB1 is held. SETUP.BAS - The test program provided with controllers & w/ MotionPRO. CONFIG.BAS - Recommended name for the file storing the MP.CONFIG routine.

-288- DOS File-Naming Conventions

-289- Index

MotionBASIC p 8 #1310 91 #1918 110 ! 73 #1311 91 #1919 110 !AUTO 123 #1312 91 #1998 111 !INCLUDE 124 #1313 91 #1999 111 # 74 #1314 91 $ 75 #1000 89 #1315 91 % 72 #1001 89 #1316 91 & 73 #1002 89 #1317 91 ’ 121 #1003 89 #1318 91 ’! 122 #1004 89 #1319 91 ’! 123 #1005 89 #1601 93 ’! 123 #1006 89 #1602 93 ’! 124 #1007 89 #1604 93 ’! 124 #1008 89 #1605 93 ’! 125 #1009 89 #1606 93 ’!AUTO 123 #1010 89 #1607 93 ’!DEFINE 123 #1011 89 #1608 93 ’!ELSE 124 #1012 89 #1609 93 ’!ENDIF 124 #1014 89 #1610 94 ’!IFDEF 124 #1015 89 #1612 93 ’!IFNDEF 124 #1101 90 #1614 93 ’!INCLUDE 124 #1102 90 #1615 93 ’!UNDEF 125 #1103 90 #1616 93 ’’ 122 #1104 90 #1801 94 * 125 #1105 90 #1802 95 + 125 #1106 90 #1803 94 - 126 #1107 90 #1804 95 / 131 #1108 90 #1805 95 10 106 #1109 90 #1806 94 < 126 #1110 90 #1807 94 <= 127 #1111 90 #1808 96 <> 128 #1112 90 #1810 94 = 129 #1114 91 #1811 96 > 130 #1201 91 #1812 94 >= 130 #1202 91 #1813 94 ? 246 #1203 91 #1814 94 @ 77 #1204 91 #1815 96 \ 131 #1205 91 #1816 94 ^ 132 #1206 91 #1900 89 Aa 218 #1207 91 #1901 89 abort 8 #1208 91 #1902 89 ABS 132 #1209 91 #1903 89 abs encoder 239 #1210 91 #1904 89 absolute encod 239 #1211 91 #1905 89 absolute encod 239 #1212 91 #1906 89 absolute encod 239 #1213 91 #1907 89 absolute posit 239 #1214 91 #1908 89 absolute value 132 #1301 91 #1909 89 accel 218 #1302 91 #1910 105 Accel or Decel 93 #1303 91 #1911 105 Acceleration F 24 #1304 91 #1912 108 Acceleration G 26 #1305 92 #1913 109 acceleration u 80 #1306 91 #1914 109 Accessing Rand 48 #1307 91 #1915 109 Accessing Sequ 46 #1308 91 #1916 110 ACL.CMD@ 132 #1309 91 #1917 110 ACL.LAST@ 132 Index

ACL.MAX@ 133 Axis Encoder 30 COLOR 150 actual 240 Axis Encoder O 107 Command Oversp 106 actual positio 240 Axis Fault 105 commanded 242 actual velocit 278 axis fault cod 133 commanded posi 242 Ad 218 axis faults 133 Commands 53 Adding Data to 47 axis modes 212 comment 121 addition 125 Axis Module Fa 109 comments 121 AFAULT@ 133 Axis Operating 82 complement 221 AFTER 134 axis position 240 concatenation 125 Ah 186 Axis Position 78 constant 65 AIN1 135 Axis Range Var 82 Constant Gear 161 AIN1@ 135 axis variables 77 Constants 65 ain2 135 AXIS.FAULT@ 141 CONT 151 AIN2@ 135 AXIS.FLT1@ 141 control c 95 AIO@ 136 AXIS.LIST@ 141 control stack 263 alarm detectio 106 AXIS.OTL@ 142 Control Struct 55 ALARM@ 136 AXIS.SET@ 142 control struct 55 All Functions 61 AXIS.VAR@ 143 Controller Fau 97 All ORMEC Vari 84 backspace 50 Controller Fau 97 All Statements 57 Battery Failur 104 Controller Fau 103 amber 98 Baud Rate 144 Controller Fau 103 Analog I/O 38 BAUD@ 144 Conversion Fun 60 analog input 38 BEL 116 COS 151 Analog Input O 135 BIN$ 144 CR 116 Analog Input T 135 Bitwise 64 Creating Rando 48 Analog Velocit 27 Bitwise operat 64 Creating Seque 46 analog velocit 27 block 188 CSRLIN 151 AND 138 Boolean 67 ctrl c 95 Arithmetic Fun 59 Boolean Axis S 84 ctrl-c 95 Array 68 BPS 44 Ctrl-C detecte 95 Array Dimensio 158 Brain Board 39 Current Electr 184 Array Variable 68 BREAK 144 CW.FWD@ 152 arrays 68 BS 116 Da 218 AS 175 BSEN 145 DATA 152 AS 220 BSEN@ 145 Data File 45 ASC 138 BY 180 Data Files 45 ASCII 114 BY 180 Data type 66 ASCII Table 114 BY 181 data types 66 ASEN 138 BY 182 DATE$ 152 ASEN@ 138 BY 186 DCL.ERR@ 153 assignment 205 BY 214 DCL.LAST@ 153 AT 180 BYE 146 DCL.MAX@ 153 AT 180 Cannot Continu 95 Dd 218 AT 214 Carriage Retur 116 DEF 154 AT.REST@ 139 Cascaded Contr 35 DEF FN 154 AT.SPD@ 139 CHAIN 146 DEF SEG 154 ATN 139 Chart Rules 214 DEFDBL 155 AUTO 140 CHDIR 147 DEFINE 123 AUTOLOAD.BAS 140 Checksum Error 110 DEFINT 155 Automatic Line 123 CHR$ 147 DEFLNG 155 axes 140 CLEAR 148 DEFSET 156 axis 140 CLG 148 DEFSNG 156 Axis Analog In 135 CLOSE 148 DEFSTR 156 Axis Analog In 135 CLREOL 149 DELAY.DIST@ 157 axis control l 23 CLS 149 DELAY@ 157 axis control m 212 CNT.REV@ 149 DELETE 157 Index

Development Co 113 E-STOP OK 105 Exit Keys 173 device open 229 EBC 31 EXITKEY 173 Dh 186 EDIT 164 EXP 174 diagnostics 98 Edit Keys 10 exponentiation 132 Differences 4 EIO.MODE@ 164 expression 10 Differences fr 4 Electronic Gea 31 Expression Err 91 DIM 158 Electronic Lim 37 Expression Err 91 DIO@ 158 Electronic Lim 37 expressions 10 direct 7 Electronic Lim 165 Extended I/O C 39 direct mode 7 Electronic Lim 165 extended key t 17 Direct Mode Op 7 Electronic Lim 166 External I/O S 56 Direct Stateme 92 Electronic Lim 166 F1 50 directive 49 Electronic Lim 167 F2 50 directives 49 Electronic Lim 167 F3 50 Discrete & Ana 38 ELS 37 F3=SEARCH 51 Discrete I/O 38 ELS1.HIGH@ 165 F4 50 disk 50 ELS1.LOW@ 165 Fa 183 disk comment 122 ELS1@ 165 FALSE 67 disk comments 122 ELS2.HIGH@ 166 fault action 97 disks 50 ELS2.LOW@ 166 FAULT@ 174 Display/Keyboa 55 ELS2@ 166 Faults 97 dist 218 ELS3.HIGH@ 167 Fd 183 DIST.BIAS@ 160 ELS3.LOW@ 167 Fdist 183 DIST.GEAR@ 161 ELS3@ 167 FIELD 175 DIST.GRAT@ 161 ELSE 188 file open 230 DIST.MOVE@ 162 ELSEIF 188 filename 288 distance 218 Emergency Stop 105 filename exten 288 distributed fe 27 Encoder Backup 31 FILES 176 Distributed Fe 27 Encoder Ch-A O 102 files data 45 divide 131 Encoder Ch-B O 102 files MotionBA 43 divide 131 encoder oversp 107 files program 43 division 131 encryption 44 files random a 47 division 131 encryption 258 files random a 48 Dos file-namin 288 END 168 files random a 48 Dos file-namin 288 ENDIF 188 files sequenti 45 Double 74 EOF 168 files sequenti 46 Double precisi 74 equal to 129 files sequenti 46 double-quotes 122 ERASE 169 files sequenti 47 drive command 269 ERL 169 FIX 177 DRV.CMD@ 269 ERR 170 flash 20 DRV.MAX@ 270 ERR$ 170 FN 154 DSP 21 ERROR 170 Fn code 117 DSP Axis Modul 21 error code 87 Fncode 200 DSP Axis Modul 21 Error Codes 87 Follower 35 DSP Axis Modul 22 error handler 88 FOR 177 DSP Axis Modul 109 Errors 87 FOR 180 DSP I/O Termin 21 ESC 116 FOR 214 DSP I/O Termin 21 ESTOP.OK@ 171 FOR...NEXT 177 DSP Software F 108 EVENT 171 FORMAT 179 DSP.CTR 162 EVENT INPUT 171 forward hardwa 187 DSP.CTR@ 162 Event Key 224 Forward overtr 231 DSP.DONE@ 163 Event Key Trap 201 Forward Overtr 231 DUMP 164 Event Keys 224 forward softwa 263 Duplicate Defi 91 Event Processi 40 FRE 179 E-STOP 105 event trapping 224 Full-duplex 113 E-Stop Input O 105 Events 40 function 59 Index function key 50 Illegal While 94 itm open 228 function key t 17 impact 283 ITM-270 14 Function Keys 15 Impact of Set 283 ITM-270 16 Function Keys 15 implied GOSUB 6 Ka 26 Functions 59 IN 180 Kaf 24 Fwd hardware T 187 IN 180 KAF@ 199 Fwd software T 263 IN 181 KEY 200 Garbage Collec 76 IN 182 Key ( 201 GEAR 180 IN 186 KEY (n) 201 GEAR AT 182 IN 214 Key Event 224 GEAR Chart 180 IN.ACL@ 190 Key Event Trap 201 Gear Distance 161 IN.DCL@ 190 Key Table 117 GEAR FOR 181 IN.MOT@ 190 Keyboard Chara 191 Gear Ratio 31 IN.POS@ 190 Keyboard scanc 118 Gear Ratio Mul 81 Include File D 124 Keyword 119 Gear Speed Mul 81 Incompatible M 109 Keywords 119 GEAR Statement 180 Index 1 KILL 202 GEAR Syntax Ch 180 INDEX 215 Kp 24 GEAR.RATIO@ 184 indirect 8 KP@ 202 geared 31 indirect mode 8 Kpi 25 Generation III 219 Indirect Mode 8 KPI@ 203 GET 184 INERTIA@ 190 Kv 25 GOSUB 185 INKEY$ 191 Kvf 24 GOTO 185 INP 192 KVF@ 203 greater than 130 INPUT 192 Kvh 26 greater than o 130 INPUT # 193 KVH@ 203 green 98 INPUT @ 194 Kvha 27 GWBASIC 4 input @ using 273 KVHA@ 204 HALT 186 input using 273 Kvi 25 HALT Chart 186 INPUT$ 196 KVI@ 204 HALT Statement 186 Input/Output F 60 Kvl 30 HALT Syntax Ch 186 INPUT@ 194 label 6 Hardware Hands 113 input@ using 273 labels 6 hardware multi 34 INPW 196 Language Exten 20 Hardware Overt 37 INSPD.MUL@ 234 Language Exten 20 Hardware Overt 37 inspeed 183 LCASE$ 204 HEX$ 187 INSTR 196 LEDs 98 Hi Axis Loop r 208 INT 197 LEFT$ 205 Hi Pacer Loop 208 Integer 72 LEM 20 HLF 187 integer divisi 131 LEN 205 HLR 187 integer expres 10 less than 126 HT 116 integer sign e 70 less than or E 127 HTL.FWD@ 187 integer type c 70 LET 205 HTL.REV@ 187 integers 72 LF 116 Hypertext Func 50 Interface 34 lights 98 Hypertext Keys 50 Internal Error 108 limit 231 I/O 38 INTEXPR 10 limit switch 36 I/O Errors 91 Introduction 1 limit switch 37 I/O Terminatio 21 Invalid Unit I 104 limit switch 37 I/O Variables 77 IO.MODE@ 198 limits 187 IF 188 IOCTL 197 limits 187 IF...THEN...EL 188 ITM 14 limits 263 IFDEF 124 ITM Display 16 limits 264 IFNDEF 124 ITM Display & 16 line 9 Illegal Direct 95 ITM Driver Sup 285 Line Editor 9 Illegal Indire 96 ITM Function K 16 Line Format 9 Index

LIST 205 Model 20 13 No Fault LED 112 literals 65 Model 40 12 No Fault Relay 112 LNGEXPR 10 Modifiers 54 no MotionDATA 107 LOAD 206 Modulo Positio 38 Non-Printing A 116 LOC 206 Motion Command 23 non-volatile m 18 LOCATE 207 Motion Control 11 NOT 221 LOF 207 Motion Control 11 Not enough mem 110 log 148 motion error 93 not equal 128 LOG 208 Motion Errors 93 Notation 52 logical operat 64 Motion queue 23 Numeric Axis S 83 Long 73 Motion Stateme 54 Numeric Expres 10 Long Integer 73 Motion Stateme 54 NUMEXPR 10 Loop Architect 23 Motion Stateme 54 OCT$ 222 loop output 269 MotionBASIC 2 OFF 67 loop rate 208 MotionBASIC Ev 40 OIT 14 loop update 208 MotionBASIC Fi 43 OIT Display 15 LOOP.RATE@ 208 MotionBASIC Fi 43 OIT Function K 15 Loss of Feedba 102 MotionBASIC Li 10 oit open 226 LSET 208 MotionBASIC Ov 2 OK to Transmit 100 Machine Fault 89 MotionBASIC Po 7 ON 67 Machine I/O Co 198 MotionBASIC Sy 52 ON ERROR 222 maximum loop o 270 MotionCARD 20 ON EVENT 224 maximum output 270 MotionCARD Fau 110 ON EVENT...GOS 224 maximum positi 237 MotionCARDs 20 ON KEY 224 MBVER$ 209 MotionDATA 33 ON KEY...GOSUB 224 MD.MODE@ 209 MotionDATA Act 101 ON...GOSUB 225 memory 22 MotionDATA Err 107 ON...GOTO 225 memory 155 MotionDATA Int 34 OPEN 226 Memory Card 19 motiondata mon 209 OPEN DEVICE 229 Memory Cards 19 MotionDATA Not 96 OPEN FILE 230 Memory Conserv 18 MotionDATA Ope 209 OPEN ITM 228 Memory Disk 20 MotionNET 103 OPEN ITM-270 228 Memory Disks 20 MotionNET Alar 101 OPEN MMI 227 Memory Dump 108 MotionNET Alar 101 open mmi-840 227 Memory Fault 99 MotionNET Talk 103 OPEN OIT 226 memory map 18 MotionPRO 40 open wire 102 Memory Usage 71 MotionPRO Dire 49 Operator Inter 14 Memory Usage f 71 MotionPRO dire 49 Operator Inter 14 MERGE 210 MOVE 214 Operators 63 Microsoft BASI 4 MOVE AT 217 OR 231 MID$ 210 MOVE Chart 214 ORMEC Service 112 minus 126 MOVE FOR 215 ORMEC Variable 77 Miscellaneous 57 MOVE STATEMENT 213 ORMEC Variable 77 Missing Motion 107 MOVE STATEMENT 213 OTL.FWD@ 231 MKDIR 211 MOVE Syntax Ch 214 OTL.REV@ 232 MMI 14 MOVE TO 216 OUT 233 MMI Display 15 MP.CONFIG 219 Out of Memory 94 MMI Function K 15 MTR.ACL.LIM@ 219 output mode 212 MMI function k 17 MTR.SPD.LIM@ 220 Output Select 209 MMI Keypad Lay 16 multiplication 125 OUTSPD.MUL@ 234 mmi open 227 NAME 220 outspeed 183 MMI-840 14 negation 126 OUTW 234 MMI-840 Functi 15 NEW 221 overtravel 36 MOD 211 NEW RESTORE 221 overtravel 37 mode 212 NEXT 177 overtravel 187 MODE@ 212 No Fault 112 overtravel 187 Index overtravel 231 Power Fault - 104 RND 256 overtravel 263 Power Fault-Te 111 RSET 257 overtravel 264 powerup 7 Rules 214 Overtravel Lim 36 powerup operat 7 RUN 257 Overtravel Lim 36 PPS.DIV@ 246 SAVE 258 Overtravel lim 36 PPS.MUL@ 246 Scan Code 118 Overtravel Lim 232 Precedence 63 Scan Codes 118 Pa 183 PRINT 246 scancode 118 Pacer 34 PRINT # 247 scancodes 118 Pacer Overspee 107 print # using 273 SCURVE@ 259 Pacer Position 81 PRINT @ 246 search 51 Pamux 39 print using 273 SEG 154 parameters 183 print# 247 segment 155 pass-thru 34 print# using 273 segmented memo 155 path 288 PRINT@ 246 segments 155 PB1 234 print@ using 273 Select 209 PB1@ 234 Program Encryp 44 Sending Motion 101 PB1LOAD.BAS 235 Program Error 99 Sending Motion 103 PCR.SPD.LIM@ 235 program errors 99 Sending Serial 100 PCT.REV@ 235 Program file 43 SENS.MODE@ 260 Pd 183 Program Files 43 Sequential Fil 45 Pdist 183 program initia 8 Sequential Fil 45 PEEK 236 Program Initia 56 Serial Port St 100 PEEKW 236 Program Labels 6 Servo Control 23 PERR.INPOS@ 237 program line 9 Servo Fault 100 PERR.MAX@ 237 Program Struct 90 Servo Fault 105 PERR.NORM@ 238 Program Struct 90 Servo Loop Tun 83 PG.LEN@ 238 PUT 248 servo loop upd 208 pi 78 PW@ 248 servo loop upd 208 plus 125 RAM Checksum E 103 Servodrive Ala 106 POKE 238 Random Access 47 servodrive ala 136 POKEW 239 Random Access 47 servodrive ala 136 poll 239 RANDOMIZE 249 Set 71 POS 239 READ 250 set complement 221 POS.ABS@ 239 Ready to Recei 100 set difference 126 POS.ACT@ 240 Receiving Moti 101 set expression 10 POS.ASEN@ 241 Receiving Moti 103 set intersecti 125 POS.BSEN@ 241 Receiving Seri 100 set membership 126 POS.CMD@ 242 red 98 set membership 127 POS.DELAY@ 243 REM 250 set membership 128 POS.DIV@ 245 RENUM 251 set membership 129 POS.ERR@ 243 RENUM Chart 251 set membership 130 POS.MOD@ 244 RENUM Statemen 251 set membership 130 POS.MUL@ 245 RENUM Syntax C 251 set membership 281 POS.ZREF@ 245 REPEAT 252 set union 125 position 218 Reserved Words 119 set variables 283 position 240 RESTORE 253 SETEXPR 10 Position Comma 106 Restore Non-Vo 221 setup 82 Position Comma 160 RESUME 254 setup 82 position comma 242 RETURN 255 Setup 83 position error 237 rev hardware T 187 Setup 84 Position Loop 24 rev software T 264 SGN 261 Position Loop 25 reverse hardwa 187 shared memory 22 position mode 212 reverse softwa 264 shared memory 22 Position Modul 244 RIGHT$ 255 sign extension 70 Power Fault 99 RMDIR 256 signal loss 102 Index signal loss de 102 Ta 218 User Trappable 88 SIN 261 TAB 265 User Trappable 88 Single 73 TALK 266 user trapped 88 Single precisi 73 TAN 266 User Units 78 single-quote 121 Td 218 USER1.LED@ 272 Software Overt 36 Temporary Powe 111 USER2.LED@ 273 Software Overt 36 Terminations 21 USING 273 software overt 263 Text Editor 49 USING 2 214 software overt 264 Th 186 USR.ACL.LIM@ 277 SPACE$ 262 THEN 188 USR.SPD.LIM@ 277 SPC 262 time 218 VAL 278 SPD.MAX@ 262 TIME$ 267 var 62 speed 218 TIME.MUL@ 267 variable 66 speed units 79 TIMER 268 variable name 66 SQR 263 TO 177 Variable Names 66 sram 20 TO 214 Variables 66 SRL1 144 Token Buffer O 96 VEL.ACT@ 278 STACK 263 Torque Mode Se 23 VEL.CMD@ 278 stack clear 263 torque mode se 28 VEL.GAIN@ 30 statement 54 Torque Mode Se 28 VEL.LAST@ 279 Statements 54 TRACE 268 velocity 218 status 98 TRACE VAL 269 Velocity Feedf 24 STEP 177 Troubleshootin 112 Velocity Loop 25 STL.FWD@ 263 Troubleshootin 112 Velocity Loop 25 STL.REV@ 264 TRQ.CMD@ 269 Velocity Loop 30 STOP 264 TRQ.GAIN@ 270 velocity mode 29 STR$ 264 TRQ.MAX@ 270 velocity mode 212 String 75 TRUE 67 velocity mode 29 String Functio 59 truth table 64 Velocity Mode 29 String Garbage 76 Truth Tables 64 velocity mode 29 String Space C 109 two’s compleme 70 velocity mode 29 String Space F 109 Type Conversio 69 Velocity Mode 29 string space s 148 Typical 53 Velocity Mode 30 String Variabl 75 UCASE$ 271 Velocity Obser 26 STRING$ 265 UNDEF 125 Velocity Obser 28 Strings 75 union 125 Velocity Obser 203 Structured Pro 6 Unit Fault 174 Velocity out o 93 subroutine 185 Unit Fault Cod 174 VLTC@ 279 subroutines 185 Unit Identific 271 WAIT 279 subtraction 126 Unit Parameter 77 Watchdog Timeo 111 Syntax 51 Unit Parameter 77 Watchdog Timer 102 Syntax 52 UNIT.ID@ 271 WEND 280 syntax 1 51 UNTIL 271 WHILE 280 syntax 2 51 usage 51 WHILE...WEND 280 syntax 3 51 usage 1 51 WIDTH 281 syntax 4 51 usage 2 51 WITHIN 281 syntax 5 51 usage 3 51 Word 10 Syntax Chart R 214 usage 4 51 write enable 248 Syntax Error 89 User 1 100 write protect 248 Syntax Errors 89 User 2 100 XOR 282 SYSTEM 265 User Accelerat 80 ZREF 282 system error 94 User Defined E 89 ZREF@ 282 System Errors 94 User Defined F 89 { 71 System Functio 60 User Functions 154 } 71 System Status 98 User Speed Uni 79 113 System Watchdo 102 User Trappable 88