Motionbasic Hypertext Manual
Total Page:16
File Type:pdf, Size:1020Kb
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; • more 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-type 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 strings (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 at the same time 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 KILL command will not generate an error when the file to be deleted is non-existent. • The RMDIR 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