Record of Manual Revisions
Revision Date Description of Revision
0 3/1/1999 Preliminary issue for review
1 5/14/1999 Initial release
2 6/5/2000 New PCI and stand-alone models, new firmware features
3 8/31/2001 New firmware features
D 5/11/2005 Update examples
E 6/20/2005 Updated firmware version and dates
DANAHER MOTION® is a registered trademark of Danaher Corporation. Danaher
Motion makes every attempt to ensure accuracy and reliability of the specifications in
this publication. Specifications are subject to change without notice. Danaher Motion
provides this information "AS IS" and disclaims all warranties, express or implied,
including, but not limited to, implied warranties of merchantability and fitness for a
particular purpose. It is the responsibility of the product user to determine the
suitability of this product for a specific application.
SERVOSTAR, GOLDLINE Motors, MOTIONLINK, Motioneering, BASIC Moves Development
Studio, Kollmorgen API and MC-BASIC are trademarks of the Kollmorgen Corporation.
VxWorks is a trademark of Wind River.
Visual Basic, Visual C++, Windows, Windows 95, Windows NT are trademarks of Microsoft
Corporation.
Safety-alert symbols used in this document are:
WARNING
CAUTION
NOTE
Warnings alert users to potential physical danger or harm. Failure
to follow warning notices could result in personal injury or death.
Cautions direct attention to general precautions, which if not
followed, could result in personal injury and/or equipment damage.
Notes highlight information critical to your understanding or use of
the product.
CUSTOMER SUPPORT ............................................................................................................194
viii Rev E M-SS-005-03
Danaher Motion 06/2005 Overview
1. OVERVIEW
This manual describes how to use the SERVOSTAR MC (Multi-axis
Controller) product. To execute the examples described in this manual, you must at least have a SERVOSTAR MC and BASIC Moves Development
installed on your host computer. Some examples further require that
Studio
you have a drive installed and connected to the MC using the SERCOS
Interface
procedures for all the necessary installations.
Version 5.0.0 of the firmware incorporates many new commands, functions,
and properties, and, in some instances, the behavior of functions,
commands, and properties found in previous versions of the firmware have
been changed. This edition of the SERVOSTAR
to version 5.0.0 firmware, and is not necessarily backward compatible with
previous versions of the firmware. If you have used previous versions of the
MC, you may find that some functions, commands, or properties which you
are familiar with, now have different behavior, or may no longer exist. Refer
to the SERVOSTAR
covers all versions of the firmware.
When you complete this manual you should feel comfortable using all the
features available in the SERVOSTAR MC. Related manuals:
The SERVOSTAR MC is Danaher Motion’s multi-axis controller. The MC has
the features and performance required of today’s multi-axis controllers, and
is designed for easy integration into motion control systems and for simplicity
of use. The key benefits of the product are:
Motion Components Guaranteed to Work Together
Danaher Motion can provide a complete motion control system,including
controller, drives, and motors. All the components are supplied by
DanaherMotion, and are tested and guaranteed to work together.
Complete Digital System at an Affordable Price
The MC is fully digital, including communication with the drives. The analog
interface is eliminated, but the price is competitive with analog systems.
Local Field Bus for Simple Set up, Less Wiring, More Flexibility
The MC communicates via fiber-optic cables using an industrial field bus
called SERCOS. SERCOS greatly simplifies system set-up and wiring, while
improving system flexibility and reliability compared to its analog
counterparts.
Windows
C++™, and other Popular Languages
The MC product family includes Danaher Motion's Kollmorgen API, which
allows Windows NT
Communication uses dual-port RAM, so the process is fast and reliable.
TM
cables. The SERVOSTAR MC Installation Manual describes the
MC User's Manual applies
MC Reference Manual for additional information, as it
SERVOSTAR
SERVOSTAR
SERVOSTAR
SERVOSTAR
MC Installation Manual
MC BASIC Moves Development Studio Manual
SC/MC API Reference Manual
MC InstallationManual
-Based Software Supports Microsoft Visual Basic™, Visual
application integration with the MC controller.
M-SS-005-03 Rev E 1
Overview 06/2005 Danaher Motion
1. 1 SYSTEM HARDWARE
The MC hardware is available in two types of implementation: a plug-in
circuit board for a host computer, and a stand-alone model.
The PCI plug-in board hardware installs in a host computer (typically a PC),
running the Windows NT 4.0, Windows 2000/XP operating systems. The MC
contains a fully-independent computer system., so it does not compete with
the host processor system for resources. The MC uses Pentium 233 MHz or
faster microprocessor to provide the power your system needs today, and
the x86 upgrade path allows for future enhancement. The MC includes large
on-board memory with ample capacity for your programs and enough space
for expansion. There is also an onboard Flashdisk for storage of your
programs.
The stand-alone model of the MC is designed for installation as a component
part in industrial equipment. It consists of the PCI version plug-in board and a
power supply in an enclosure. The stand-alone model does not have a host
CPU to provide a Windows operating system and environment, so it can not
directly provide an operator interface. For interactive operation of the standalone MC, you will need a host computer running BASIC Moves
Development Studio software and communicating with the MC via Ethernet
or serial communications with Windows NT, Windows 2000/XP operating
system. For additional information concerning communications configuration
refer to the SERVOSTAR
All implementation models of the SERVOSTAR MC are functionally
equivalent for servo motion control
MC Installation Manual.
1. 2 OPERATING SYSTEM
The SERVOSTAR MC is based on the VxWorks RealTime Operating
System (RTOS), providing a stable platform for the SERVOSTAR's software.
VxWorks is produced by Wind River Systems, Incorporated. VxWorks is
continuously evolving, providing a clear path for future upgrades to the MC.
1. 3 MC-BASIC LANGUAGE COMPILER
The MC uses a language interpreter that semi-compiles commands so they
typically execute in less than 5 microseconds. MC-BASIC
has familiar commands such as FOR…NEXT, IF…THEN, PRINTUSING,
PEEK and POKE as well as common string functions such as CHR$,
INSTR, MID$, and STRING$. It allows arrays (up to 10 dimensions) with full
support for double precision floating-point math. MC-BASIC is extended to
provide support for functions required for motion systems control, (e.g., point
to point moves, circular and linear interpolation, camming, and gearing). In
addition, there is support for multi-tasking and event-driven programs.
Gearing and camming have the versatility required for motion control. You
can slave any axis to any master. You can enable and disable gearing at any
time. The gear ratio is expressed as a double-precision value. The MC also
supports simulated axes, which can be master or slave in gearing and
camming applications and incremental moves run by any axis, master or
slave, at any time.
2 Rev E M-SS-005-03l
is true BASIC. It
Danaher Motion 06/2005 Overview
Camming links master and slave axes by a cam table. Camming has all the
features of gearing, plus the cam table can have any number of points. The
cam points are in x-y format so spacing can be provided independently.
Multiple tables can be linked together, allowing you to build complex cam
profiles from simpler tables. There is a cycle counter that lets you specify
how many cycles to run a cam before ending.
The MC supports multi-tasking with up to 256 tasks, running at up to 16
different priority levels. Each task can generate OnEvent(s), for code that you
want executed when events occur such as switches tripping, a motor
crossing a position, or just about any combination of factors.
1. 4 I/O
The MC provides 23 optically-isolated inputs and 20 optically-isolated
outputs as standard features, in addition to limit switches and other drive I/O
points that are connected directly to the drives and transferred to the MC via
SERCOS. Additionally, each SERVOSTAR drive provides hardware for six
I/O points: three digital inputs, one digital output, a 14-bit analog input, and a
12-bit analog output. An auxiliary encoder can also be connected to any
SERVOSTAR drive.
If you need more I/O, the MC includes a PC104 bus. Each MC can
accommodate as many as two PC104 cards. You can also add I/O to your
PC bus or other field buses such as DeviceNet and ProfiBus, and your
application controls it all. The figure below shows the various possible I/O
options.
SERVOSTAR
Auxillary I/O
SERCOS
SERVOSTAR MC
Standard I/O
PC-104
Mezzanine Bus
PC-104
I/O Cards
PC I/O Cards
PCI Bus
PC Field
Bus Cards
Field
Bus
Host CPU
Field I/O
1. 5 SERCOS
The SERCOS interface™ (developed in the mid-1980’s) provides an
alternative to the analog interface for communicating between motion
controllers and drives. In 1995, SERCOS became an internationally
accepted standard as IEC 1491 and later was continued to standard IEC
61491. The popularity of SERCOS has been steadily growing. All signals are
transmitted between controller and drives on two fiber optic cables. This
eliminates grounding noise and other types of Electro-Mechanical
Conductance (EMC) and Electro-Mechanical Interference (EMI).
M-SS-005-03 Rev E 3
Overview 06/2005 Danaher Motion
Because SERCOS is digital, it can transmit signals such as velocity and
position commands with high resolution. The SERVOSTAR
®
MC and
accompanying drives ( SERVOSTAR CD series), support 32-bit velocity
commands. This provides a much higher resolution than can be achieved
with the analog interface. The most common SERCOS functions are
provided in such a way that you do not have to be an expert to gain the
benefits.
1. 6 API
DanaherMotion's Kollmorgen API is a software package that allows you to
communicate with the SERVOSTAR MC from popular programming
languages, such as Visual Basic. The API provides complete access to all
the elements of your system across dual-port ram. See the SERVOSTAR
SC/MC API Reference Manual for more information.
1. 7 MULTI-TASKING
The SERVOSTAR MC is a fully multi-tasking system (see figure below) in
which you can create multiple tasks and multiple elements (e.g., axes) that
operate independently of one another. Also, because the API supports
multiple applications communicating concurrently, you can write one or more
applications that have access to all of the tasks and elements.
3rd Party Soft PLC
Visual C
Visual BASIC
Kollmorgen API
Host CPU
Task 3
Task 2
Task 1
Dual Port RAM
SERVOSTAR MC
Axis 3
Axis 2
Axis 1
1. 8 USER COMMUNICATION
The ETHERNET and Serial ports of the MC are used for ASCII data transfer.
Non-printable characters are sent using CHR$. Data access is streamoriented. There is no data framing. MC Basic applications gain access to
either raw serial port or TCP socket. The TCP socket guaranties error free
data transfer, while the serial port does not offer error recovery. The
transmitted data does not have any meaning in terms of directly controlling
the MC.
User communication provides the basic features of serial and TCP/IP data
communication, which is not limited to a specific communication protocol,
enabling the usage of any protocol over serial or TCP/IP through an MC
application.
4 Rev E M-SS-005-03l
Danaher Motion 06/2005 Overview
1.8.1. Serial Communication
The MC has two RS-232 ports, which can be used for user communication.
When COM1 is used for communication with BASIC Moves over API, tasks
cannot access it to eliminate interference with BMDS communications. Use
DIPswitch bit #8 to configure this port:
ON (default) COM1 is reserved for communication with the host and cannot
be used by any other application
OFF COM1 is available for user communication
DIP Switch bit #8 state
When DIPswitch bit # 8 is ON, the MC's firmware prints boot status
messages from COM1 using the following serial communication parameters:
Baudrate 9600 bps
Parity none
Stopbits 1
Databits 8
State ON of DIPswitch read as 0.
For example:
Switches 6 & 8 are OFF. All others are ON.
-->?sys.dipswitch bin
NOTE
0b10100000
-->
1.8.1.1. WITH HOST
When DIPswitch #8 is ON, the MC can communicate with the host via serial
port. This mode of communication requires Virtual Miniport driver, which is
installed during setup of BMDS. The driver simulates Ethernet connection
over serial interface using following fixed parameters:
Baudrate 115200 bps
Parity None
Stopbits 1
Databits 8
IP address 192.1.1.101
Subnet mask 255.255.255.0
All the parameters are fixed and cannot be modified.
If the driver is installed correctly and BMDS is running, it appears in the list of
Ethernet adapters as shown below:
C:\>ipconfig /all
Ethernet adapter Local Area Connection 5:
Configurate the serial port with OPEN. Set the following port properties:
BaudRate - baud rate of the device set to a specified value.
Parity – enable/disable parity detection. When enabled, parity is odd or even.
DataBits - number of data bits.
StopBit - number of stop bits.
Xonoff – sets raw mode or ^S/^Q flow control protocol mode (optional parameter
disabled by default).
For example:
OPEN COM2 BUADRATE=9600 PARITY=0 DATABITS=8 STOPBIT=1 AS #1
Opens COM2 at 9600 bps baud-rate, No parity, 8-bit data, 1 stop bit.
OPEN assigns a device handle to the communication port. Any further
references to the communication port uses the device handle number. The
device handle range is 1…255. To change the communication parameters,
close the serial port and reopen it using the new parameters. For more
information, see PRINT # and INPUT$.
1.8.2. TCP/IP Communication
Use TCP/IP communication with other computers and intelligent I/O devices
over the Ethernet network. MC-BASIC uses TCP/IP API (sockets).
TCP/IP provides multi-thread communications. The same physical link
(Ethernet) is shared between several applications. This way, the MC can
connect to BASIC Moves and one or more intelligent I/O devices.
The MC supports both client and server roles for TCP/IP communications.
The TCP/IP client connects to a remote system, which waits for a connection
while the TCP/IP server accepts a connection from a remote system.
Usually, the MC serves as client while interfacing to an intelligent I/O
connected to the LAN, and as a server when working toward remote host like
a software PLC. The MC uses Realtek RTL8019AS Ethernet NIC at a bit rate
of 10 M bps.
1.8.2.1. SETUP
TCP communication starts by opening a socket either to connect to a remote
computer (remote host) or accept a connection from a remote host. Use
CONNECT or ACCEPT, depending on the MC functionality (client or server).
OPENSOCKET creates a TCP socket and assigns the socket descriptor to
the specified device handle. The socket is created with OPTIONS
NO_DELAY (send data immediately= 1). Otherwise, the data is buffered in
the protocol stack until the buffer is full or a time-out is reached. This
improves responsiveness when small amounts of data are sent. This option
is recommended for interactive applications with relatively small data
transfer. Otherwise, OPTIONS = 0.
OPENSOCKET OPTIONS=1 AS #1
OPENSOCKET assigns a device handle to the communication port (as
OPEN). Any further reference to the communication port uses the device
handle number. The device handle range is 1…255.
6 Rev E M-SS-005-03l
Danaher Motion 06/2005 Overview
There are several ways to set the IP address of the controller. By default, the
MC boots without a valid IP address. The following options are available to
set the IP address of the controller:
Static IP address setting
Use SYS.IPADDRESSMASK in the Config.prg file to assign the IP
address and Subnet mask:
SYS.IPADDRESSMASK=”212.25.84.109:255.255.255.128”
Dynamic address setting by Windows API
API assigns an IP address to the MC when it establishes TCP
communication with the controller. The IP address and Subnet mask
are taken out of a pre-defined address pool. BASIC Moves uses this
address assigning method. Refer to the BASIC Moves Development
®
User Manual and SERVOSTAR® MC Reference Manual for
Studio
detailed information.
DHCP
IP address is assigned by the DHCP server. If your network does not
support DHCP, the controller tries to get the address from the DHCP
server and times out after few minutes. During that time, communication
with the controller is not possible.
SYS.IPADDRESSMASK=”dhcp”
If DHCP is used, select Automatic connection method as shown below:
Get the controller’s IP address
Use SYS.IPADDRESSMASK to query the IP address and Subnet mask
of the MC.
-->?SYS.IPADDRESSMASK
172.30.3.11:255.255.0.0
The MC has several IP interfaces: Ethernet, IP over serial and IP
over DPRAM. However SYS.IPADDRESSMASK is only valid fo r
Ethernet interfaces. Others have fixed IP addresses, which
NOTE
cannot be changed.
PING tests that a remote host is reachable. The remote host must
support ICMP echo request.
?PING(”212.25.84.109”)
1.8.2.2. MC AS TCP CLIENT
When acting as a client, the MC tries to connect to a remote server until a
time out value expires or the connection is rejected. Use CONNECT when
the MC acts as a client.
M-SS-005-03 Rev E 7
Overview 06/2005 Danaher Motion
The MC requests a connection from a remote host, according to a specific IP
address and port. CONNECT blocks task execution until the connection is
established or until the command fails. To unblock a task waiting in
CONNECT, close the corresponding socket using CLOSE. In addition, killing
a task (KILLTASK) blocked by CONNECT closes the socket to release the
task. CONNECT may fail due to the following reasons:
1. Invalid socket descriptor
2. Remote host has no application attached to specified port.
3. Destination address is not reachable
The following example illustrates a typical procedure of establishing a
connection to a remote host, and sending and receiving data:
OPENSOCKET OPTIONS=0 AS #1
CONNECT (#1,”212.25.84.100”,6002)
PRINT #1,”HELLO”
?INPUT$(LOC(1),#1)
CLOSE #1
1.8.2.3. MCAS TCP SERVER
When acting as a server. the MC endlessly waits for a connection from the
remote host. Use ACCEPT when the MC acts as server. ACCEPT binds a
socket to a specified port and waits for a connection. Simultaneous
ACCEPTs on the same port are not allowed. ACCEPT blocks the execution
of the calling task until a connection is established. To unblock the task
waiting in ACCEPT, close the corresponding socket with CLOSE. In addition,
killing a task (KILLTASK) blocked in ACCEPT closes the socket and
releases the task. The following example illustrates a typical procedure of
waiting for a connection from a remote host, and sending and receiving data:
OPENSOCKET OPTIONS=0 AS #1
ACCEPT (#1,20000)
PRINT #1,”HELLO”
?INPUT$(LOC(1),#1)
CLOSE #1
1.8.3. Send /Receive Data
Serial and TCP communication use the same commands to send and
receive data. After establishing communication over TCP or after configuring
the serial port communication parameters, send and receive data regardless
the communication type. Data flow differences are communication speed
and the size of the input and output buffers. TCP/IP communication uses
larger communication buffers.
1.8.3.1. RECEIVE DATA
The input-buffer of the serial ports is a fixed512 bytes size. User
communication allows receiving strings using INPUT$. To check if data is
ready at the input buffer, use LOC. The following example checks the
number of bytes available at the input buffers and reads all the available
data:
-->?LOC(1)
11
-->STRING_VAR = INPUT$(11, #1)
-->?STRING_VAR
Hello World
8 Rev E M-SS-005-03l
Danaher Motion 06/2005 Overview
If INPUT$ requests reading a data length larger than available data, the
command returns only the available data:
-->?LOC(1)
11
-->STRING_VAR = INPUT$(20, #1)
-->?STRING_VAR
Hello World
LOC can be used within the INPUT$:
STRING_VAR = INPUT$(LOC(1), #1)
A partial read of the input buffer is allowed. This way, several calls to
INPUT$ empty the input-buffer:
-->?LOC(1)
11
-->STRING_VAR = INPUT$(3, #1)
-->?STRING_VAR
Hel
-->?LOC(1)
8
-->STRING_VAR = INPUT$(8, #1)
-->?STRING_VAR
lo World
When calling INPUT$, the system does not wait for data. If the input-buffer is
empty, the command returns without any return value:
-->?LOC(1)
0
-->STRING_VAR = INPUT$(10, #1)
-->?len(STRING_VAR)
0
1.8.3.2. SEND DATA
PRINT # and PRINTUSING # send data over the serial port. Both
commands use the same formatting as PRINT and PRINTUSING.
PRINT # and PRINTUSING # appends a carriage-return (ASCII
value 13) and line-feed (ASCII value 10) characters at the end of
each message. To print a message without the terminating
NOTE
For example, the following uses PRINT # to send data:
-->STRING_MESSAGE = "ERROR"
-->PRINT #1, STRING_MESSAGE,"A1.PCMD=";A1.PCMD;
The output is:
ERROR A1.PCMD=0.000000000000000e+00
The values of the following variables are sent one after the other. The output
is (hexadecimal) 0x37 0x28:
I1=55
I2=40
PRINT #1, I1;I2
The output is:
5540
carriage-return and line-feed characters use a semicolon at the
end of the command.
M-SS-005-03 Rev E 9
Overview 06/2005 Danaher Motion
1.8.3.3. SEND DATA BLOCK
PRINTTOBUFF # and PRINTUSINGTOBUFF # allows buffering of data
before actually being sent. This eliminates inter-character delays.
When using a specific protocol over Serial or TCP/IP ModBus RTU or
ModBus TCP), the NULL character is part of the message. The message
block cannot be saved in a STRING type variable since the NULL character
terminates the string.
To send a NULL character in a message, send the data as single bytes
instead of a string type message:
COMMON SHARED X[10] AS LONG
X[1]=0x10
X[2]=0
X[3]=0x10
PRINT #1, CHR$(X[1]);CHR$(X[2]);CHR$(X[3]);
The output is the following stream of bytes:
0x10, 0x0, 0x10
When the received data contains a NULL character, read the data from the
input buffer as single bytes instead of reading it into a string type variable.
Convert the incoming data to a numeric value to get its ASCII value:
DIM SHARED TEMP[10] AS DOUBLE
FOR IDX = 1 TO LOC(1)
TEMP[IDX] = ASC(INPUT$(1,#1))
NEXT IDX
The figure below gives a general description of the TCP/IP communication
for both the client and host.
Client
Open TCP connection
(open socket)
Connect to specific
port and specific IP
address
Connect
Read
Write
Listen to specific
port and accept
connection
Server
Accept
Read
Write
Open Socket
Read
Write
Close
Read
Write
Close TCP connection
(close socket)
1.8.3.5. CLOSE CONNECTION
CLOSE closes the connection and releases the device handle:
-->CLOSE #1
10 Rev E M-SS-005-03l
Danaher Motion 06/2005 BASIC Moves Development Studio
2. BASIC MOVES DEVELOPMENT STUDIO
BASIC Moves Development Studio (BMDS) provides Windows-based
project control for each application. BASIC Moves Development Studio
supports development for multi-tasking and also provides numerous tools
and wizards to simplify programming the MC.
BASIC Moves also provides modern debugging features such as allowing
task control by visually setting breakpoints, watch variables, and single
stepping. BASIC Moves automatically displays the data recorded on the MC
during operation. BASIC Moves provides all the tools you need for
developing and debugging your application. When you start Basic Moves,
your first action is to select a method for communicating with your MC.
If you are using either a PCI or ISA model MC, choose ISA/PCI Bus. If you
are using a Stand-alone model MC, select either Serial Port or Ethernet
(communication method configured for your system). For more information
concerning communication with the stand-alone MC, refer to the Software
Installation section of the SERVOSTAR
MC Installation Manual.
2. 1 COMMUNICATION
Communicating with a stand-alone MC is not as automatic as is
comunicating with a PCI or ISA plug-in MC. Assuming you have properly
configured the communication method during installation of the BASIC
Moves Development Studio on your host computer, there are still some
operating procedures you may need to perform.
Ethernet
Serial
2. 2 MC-BASIC
The MC is programmed in MC-BASIC
the BASIC programming language enhanced for multi-tasking motion control.
If you are familiar with BASIC, you already know much of MC-BASIC. For
detailed information on any of the commands (including examples) used in
MC-BASIC, refer to the SERVOSTAR
M-SS-005-03 Rev E 11
If you configured Ethernet communications, subsequent communication
with the MC is automatically enabled and no further intervention is needed
unless you change the Ethernet network environment. If your network
environment changes, you may need to edit the IP address file. Refer to
the SERVOSTAR
The installation package includes the Virtual NIC device driver, which is
started automatically by Basic Moves Development Studio. No special
configuration is required. Refer to the SERVOSTARManual for additional information.
MC Installation Manual for additional information.
MC Installation
® (
Motion Control BASIC), a version of
MC Reference Manual.
BASIC Moves Development Studio 06/2005 Danaher Motion
To develop your application on the MC, you must install BASIC Moves
Development Studio. Refer to the software installation section of the
SERVOSTAR
MC Installation Manual for detailed instructions.
2.2.1. Instructions
Instructions are the building blocks of BASIC. Instructions set variables, call
functions, control program flow, and start processes such as events and
motion. In this manual we will use the terms instruction and command
interchangeably. For detailed information on any of the instructions (including
examples), refer to the SERVOSTAR
Syntax is the set of rules that must be observed to construct a legal
command (that is, a command the MC can recognize).
MC-BASIC is line-oriented. The end of the line indicates the end of the
instruction. Whitespace (i. e., spaces and tabs within the statement line and
blank lines), is ignored by the Basic interpreter. You can freely use
indentation to delineate block structures in your program code for easier
readability. The maximum allowed length of a line is 80 characters.
MC-BASIC is case insensitive. Commands, variable names, filenames, and
task names may be written using either upper case or lower case letters. The
only exception is that when printing strings with the “Print” and “PrintUsing”
commands, upper and lower case characters can be specified.
Syntax uses the following notation:
[ ] indicates the contents are required
{ } indicates the contents are optional for the command
Example lines of text are shown in Courier type font and with a border:
X = 1
MC Reference Manual.
2.2.2. Type
There are many types of instructions: comments, assignments, memory
allocation, flow control, task control, and motion. For detailed information on
any of the commands (including examples), refer to the SERVOSTARReference Manual.
Comments allow you to document your program. Indicate a comment with
either the Rem command or a single apostrophe ('). You can add comments
to the end of an instruction with either Rem or an apostrophe.
Rem This is a comment
' This is a comment too.
X = 1 'This comment is added to the line X = 1
X = 1 REM This is a comment too
Use comments generously throughout your program. They are an asset
when you need support from others and they avoid confusing code.
Declarations allocate MC memory for variables and system elements
(groups, cam tables, etc.). This might be a simple type as an integer, or a
complex structure as a cam table.
Assignments Assignment instructions assign a new value to a variable.
The syntax of an assignment is
[Lvalue] [=] [expression]
For example:
X = Y + 1
12 Rev E M-SS-005-03l
MC
Danaher Motion 06/2005 BASIC Moves Development Studio
The term, Lvalue, is a shorthand notation, which indicates the value to the
left of the equals sign. Valid Lvalues are variables or writable properties,
which can be assigned. Expressions can be variables, constants, properties
and function calls, as well as various combinations of them in arithmetic and
logical statements . An exception to this rule is generic elements’
assignment, at which the right side of the equal sign is not an expression, but
an axis or a group (either real or generic), and Lvalue is a generic elements.
If you assign a Double (floating point) value (expression, variable or
constant) to a Long variable, the fractional portion of the double value is
truncated, and the integer portion is assigned to the long variable. To query a
variable or expression from the BASIC Moves terminal window, use the
PRINT or ? command:
PRINT 1/100
? X1
MC-BASIC also provides the standard PRINTUSING (PrintU) command for
formatted printing.
Commands for flow control change the way your program is executed.
Without flow control, program execution is limited to processing the line
immediately following the current command. Examples of flow control include
GOTO, FOR…NEXT, and IF…THEN.
MC-BASIC is a multi-tasking language in which many tasks can run
concurrently. Generally, tasks run independently of each other. However,
tasks can control each other using inter-task control instructions. One task
can start, idle, or terminate another task.
Most commands are started and finished immediately. For example:
x = 1 ' this line is executed completely…
y = 2 ' …before this line is started
For general programming, one command is usually finished before the next
command starts. Effects of these commands do not persist beyond the time
required to execute them. However, the effects of many other commands
persist long after the execution of the command. In general programming, for
example, the effects of opening a file or allocating memory persist
indefinitely. In real-time systems, persistence is more complicated because
the duration of persistence is less predictable.
Consider a command that specifies a 1,000,000 counts move on an axis
named, A2:
Move A2 1000000.0
Y = 2
The MC does not wait for the 1,000,000 move to be complete before
executing Y=2. Instead, the first command starts the motion and then the MC
continues with the next line (Y = 2). The move continues well after the move
command has been executed.
Persistence can affect programs. For example, you may not want to start one
move until the previous move is complete. In general, you need access to
persistent processes if you are to control your program according to their
state of execution. As you will see later, MC-BASIC provides this access.
M-SS-005-03 Rev E 13
BASIC Moves Development Studio 06/2005 Danaher Motion
2.2.3. Constants and Variables
All constant, variable and system element names must start with an
alphabetical character (a-z, A-Z) and may be followed with up to 31
alphabetical characters, numbers (0-9) and underscores (“_”). Keywords
may not be used as names. For detailed information on any of the constants
and variables (including examples), refer to the SERVOSTAR
MC
Reference Manual.
2.2.3.1. CONSTANTS
Constants are numbers, which are written as ordinary text characters; for
example, 161. Constants can be written in decimal or in hexadecimal (HEX).
To write a constant in hex, precede it by a 0x; for example, 0xF is the hex
representation of 15 decimal.
The MC provides numerous literal constants (reserved words with a fixed
value). You can use these constants anywhere in your program to make your
code more intuitive and easier to read. For example:
A1.Motion = ON
turns on the A1 property Motion. This is more intuitive to read than:
You must declare a variable in MC-BASIC before you can it. In the
declaration, you define variable name, scope and variable type. MC-BASIC
supports Long for integer values, Double for floating point values, and String
for ASCII character strings.
14 Rev E M-SS-005-03l
Danaher Motion 06/2005 BASIC Moves Development Studio
Besides these basic types, MC-BASIC also supports Structure-like variables
and some MC-BASIC specific types, such as points (Joints and Locations),
generic motion elements (Axes and Groups) and UEAs (user error
assertions-Errors and Notes).
DeleteVar deletes a global variable. Since variable name can include
wildcards, a single DELETEVAR can be used to delete more than one
variable.
DeleteVar int1
DeleteVar int* ' Deletes all variables starting with int
Current values of global variables (both scalar and arrays) can be stored in a
Prg file, in assignment format, within an automatically executable Program Continue…Terminate Program block. Obligatory parameters of SAVE are
the name of storage file, and type of stored variables (could be all types).
Optional parameters are robot type (for point variables), variable name
(which may include wildcards) and mode of writing to storage file (overwriting
or appending). Variable types available for storage through SAVE are longs,
doubles, strings, joints and locations, but not structures, user-defined
exceptions nor generic motion elements.
Save File = “IntFile.Prg” Type = All VariableName = “int*”
‘ Save all variables starting with int in IntFile.Prg (overwrite file)
Save File = “Points.Prg” Type = Joint RobotType = XYZR Mode = Append
‘ Append all joint-type points with XYZR robot-type to Points.Prg file
Scope defines how widely a variable can be accessed. The broadest scope
is global. A global variable can be read from any part of the system software.
Other scopes are more restrictive, limiting access of variables to certain
sections of code. MC-BASIC supports three scopes: global, task, and local.
Task variables can be read from or written to anywhere within the task where
it is defined, but not from outside the task. Local variables can only be used
within their declaration block, i.e. program, subroutine or function blocks. The
scope of a variable is implicitly defined when a variable is declared using the
keywords: Common, Shared, and Dim.
Global variables can be defined within the system configuration task,
Config.Prg, within a task files (Prg files), before the program block, within
library files (Lib files), before the first subroutine or function block, or from the
terminal window of BASIC Moves. To declare a variable of global scope use
the Common Shared instruction.
Task variables are defined within a task or a library. To declare a variable of
task scope use the Dim Shared instruction.
All Dim Shared commands must appear above the Program
statement in task files. In library files, all Dim Shared commands
must appear above the first block of subroutine or function. The
values of variables declared with Dim Shared persist as long as the
task is loaded, which is usually the entire time the unit is
NOTE
operational. This is commonly referred to as being static.
Local variables are defined and used within a program, a subroutine, or a
function. To declare a local variable, use the Dim instruction. The Dim
command for local variables must be entered immediately below the
Program, Sub, or Function statement. Local variables cannot be declared
within event blocks, and events cannot use local variables declared within
the program.
M-SS-005-03 Rev E 15
BASIC Moves Development Studio 06/2005 Danaher Motion
2.2.4. Data Types
MC-BASIC has two numeric data types: Long and Double. Long is the only
integer form supported by MC-BASIC. Long and Double are MC-BASIC's
primitive data types.
TypeDescriptionRange
Long 32 bit signed integer -2,147,483,648 (MinInteger)to
Double Double precision floating point
(about 16 places of accuracy)
MC-BASIC provides the string data type which consists of a string of ASCIIcoded characters. MC-Basic strings are dynamic. Reallocation of memory for
new strings is preformed through a simple assignment of the string variable,
and there is no need to specify the length of the new string. A full
complement of string functions is provided to create and modify strings.
TypeDescriptionRange
String ASCII character string (no string length limit) 0 to 255 (ASCII code)
MC-BASIC has two point data types: JOINT and LOCATION. A point
variable is related to a robot type. Robot type examples: XY – two axes XY
table, XYZ – three axes XYZ system, XYZR – three cartesian axes + roll, etc.
TypeDescriptionRange
Joint A set of 2-10 double precision
Location A set of 2-10 double precision
floating point joint (motor)
coordinates
floating point cartesian coordinates
MC-Basic enables definition of structure-like data types, composed of a
limited number of long, double, string and point (joint and/or location) scalar
and array elements. Array elements can have only a single dimension. Name
of structure type and composition of elements are defined by the user within
configuration file (Config.Prg).
TypeDescriptionRange
0-100 longs 32 bit signed integer -2,147,483,648 (MinInteger) to
0-100 doubles Double precision floating point
0-100 strings ASCII character string (no
0-100 points
(joints and/or
locations)
0-10 long
arrays
0-10 double
arrays
0-4 string
arrays
1-2 point
(joints and/or
locations)
arrays
(about 16 places of accuracy)
practical limit to string length)
A set of 2-10 double precision
floating point coordinates
1-32,767 32 bit signed integers -2,147,483,648 (MinInteger) to
1-32,767 double precision
floating point elements
1-32,767 ASCII character
strings
1-32,767 sets of 2-10 Double
precision floating point
coordinates
Danaher Motion 06/2005 BASIC Moves Development Studio
MC-Basic has two UEA (user error assertion) data types (severities): Error
and Note. Each UEA is defined with a string-type error message given by the
user and a unique exception number, which might be determined either by
the user or by the system. The SERVOSTAR
MC handles UEAs similar to
internal exceptions.
TypeDescriptionRange
Error An ASCII message string and a
unique integer exception
number
Note An ASCII message string and a
unique integer exception
number
20001-20499 for user determined
exception number
20500-20999 for system determined
exception number
20001-20499 for user determined
exception number
20500-20999 for system determined
exception number
MC-Basic provides generic element data types designed to serve as a
reference to real axes and groups. Through a simple assignment statement,
the generic element gets the element identifier (see below) of a real motion
element, thus acquiring all its properties. Afterwards, all activities preformed
on the generic element identically affect the real element. The referenced
element can be changed, through recurring assignments, as many times as
the user wishes.
TypeDescriptionRange
Generic Axis An integer element
Generic Group An integer element
identifier
identifier
0 (before first assignment)
1 to number of axes in system (up
to 32)
0 (before first assignment)
33 to number of groups in system
(up to 64)
Each real motion element gets a unique element identifier from the system
during its declaration. Axes get successive element identifiers ranging from 1
to 32 according to axis number. Groups get successive identifiers ranging
from 33 to 64 according to declaration order. Value of element identifier can
be queried directly through ELEMENTID.
SYS.NUMBERAXES = 2
Common Shared G2 As Group AxNm = A1 AxNm = A2
Common Shared G1 As Group AxNm = A1 AxNm = A2
MC-BASIC uses integers to support Boolean (logical) operations. Logical
variables have one of two values: true or false. MC-BASIC uses type Long to
support logical expressions. The value 0 is equivalent to false. Usually, 1 is
equivalent to true, although any non-zero value is taken to be true. Boolean
expressions are used in conditional statements such as If…Then, and with
Boolean operators like And, Or, and Not.
Arrays can be any data type. Arrays may have from 1 to 10 dimensions. The
maximum number of elements in any dimension is 32,767. Array dimensions
always start at 1.
M-SS-005-03 Rev E 17
BASIC Moves Development Studio 06/2005 Danaher Motion
2.2.4.1. STRUCTURES
A structure is a new data type used for storing a list of variables of different
type in one variable.
2.2.4.1.1 Definition
Since a structure is a user-defined data type; it must first be defined.
Structure type definition can be done only in the Config.prg file (before the
PROGRAM block, at the declaration level), using the following syntax:
TYPE <structure_type_name>
<element_name>{[]} AS <element_type> {OF <robot_type>}
…
END TYPE
This block defines the name of the structure type and the names, types and
array sizes of the various structure elements (fields). Data types supported
as structure elements are: long, double, string, and points (JOINT and
LOCATION). Array elements can only have a single dimension. The
maximum structure block can include: 100 longs, 100 doubles, 100 strings,
100 points JOINTs and/or LOCATIONs), 10 long-type arrays, 10 double-type
arrays, 4 string-type arrays and 2 point-type arrays JOINTs and/or
LOCATIONs). The total size of the MC-Basic structure is limited. The
maximum number of each type of element is fixed. Trying to define more
structure elements than allowed results in a translation error. An array of
structures may have up to 10 dimensions.
2.2.4.1.2 Declare
You must declare a structure before you can use it. If you want to declare a
structure variable, you must first declare a structure data type and then use
this data type structure to declare the variable. The structure data type
definition can be done in the Config.prg file only with the following syntax
(before the PROGRAM token, at the declaration level):
TYPE <variable_name>
<variable_name> as <type>
<variable_name> as <type> {<of> <robot_type>}
…
END TYPE
This block defines the new element names of the structure type. The
different types supported for the structure are: long, double, string, and
points. The maximum structure block is defined as:
100 longs
100 doubles
100 strings
100 points
2.2.4.1.3 Syntax
(COMMON SHARED|DIM {SHARED}) <variable_name> AS <variable_name>
or
(COMMON SHARED|DIM {SHARED}) <variable_name>[<index>] AS
<variable_name>(arrays of structure)
where the second variable name = the structure type
18 Rev E M-SS-005-03l
Danaher Motion 06/2005 BASIC Moves Development Studio
For example:
In config file ->
Type X
Type as Long
Length as Long
End Type
In application file ->
Dim shared s1 as X
Program
?s1->Type
End program
Do not define the size of the structure data type. The size of the structure is
constant. If you declare more structure elements than allowed, a translation
error is generated.
2.2.4.1.4 Assignment
The assignment of a structure uses the following syntax:
<variable_name> = <expression> where <expression> is of
structure type
Whole structure assignment is allowed only if both structures are of the same
structure type. For example:
Dim STa1 As Type_1
Dim STb1 As Type_1
Dim STa2 As Type_2
STa1 = STb1 -> Structure types match
STa2 = STa1 -> Error - structure type mismatch
2.2.4.1.5 Elements
A structure element is addressed through the structure’s name and the arrow
sign. For example:
<structure_name>{[]…}-><element_name>{[]}
Structure elements are handled almost like regular variables. Structure
elements are printed, assigned, participate in mathematical operations, and
string-type elements are concatenated to other strings. They can also serve
as arguments of system functions (SIN, UCASE$, etc.), used in logic
statements and as conditions of flow control statements and event
definitions. For example:
Common Shared ST As STRUCT
PRINT ST->LongElm1
ST->LongElm2 = 21.2 * ST->LongArrElm[1]
? UCASE$(“String Element Is: “ + ST->StringElm)
IF ST->LongElm1 > 0 THEN
SELECT CASE ST->LongElm2
2.2.5. System Elements
There are several system elements: axes, groups, cam tables, PLSs,
conveyers and compensation tables. These are not regular data types, but
are more like user interfaces of the system's internal memory or internal
function calls. You cannot handle them as a whole in expressions.
system element has a set of properties, which is accessed through syntax
resembling data elements of a structure, using the point character.
M-SS-005-03 Rev E 19
Each
BASIC Moves Development Studio 06/2005 Danaher Motion
Despite the syntax, properties are not data elements, since a system
element and its properties are not located on a continuous block of memory.
All properties return a value, so they can be printed, combined in
expressions and passed by value to functions and subroutines. Many
properties are also writable and can be assigned like variables.
Unlike variables, properties do not have a fixed address in memory and
cannot be passed by reference. Data types of properties are Long, Double,
String, Joint and Location. For axis A1 and cam table Cam1, and a long type
variable named Var1:
Many variables have associated units. This include variables, which contain
quantities of position, velocity, acceleration, and time. Some units are fixed.
For example, time is always in milliseconds. MC-BASIC allows you to define
units of position, velocity and acceleration independently. In the next chapter,
we will discuss how to set up units.
2.2.7. Expressions
Expressions are combinations of operators and value-returning entities, such
as variables, constants, function calls, which are all calculated into a value.
In MC-Basic, expressions can also contain unique entities like element
properties (see above) and system properties (see below). Operators (like +
and -) specify how to combine the variables and constants. Expressions are
used in almost all commands.
An operand can be a constant (123.4), variable name (X), or another
expression. Most operators are binary (they take two operands), but some
are unary (taking only one operand). So, -5.5 is a valid expression. It has the
unary minus (also called negation) and a single operand.
There are two types of expressions: algebraic and logical (or Boolean).
Algebraic expressions are combinations of data and algebraic operators.
The results of all algebraic operations are converted to double precision
floating-point after executing the expression.
2.2.8. Automatic Conversion of Data Types
If the assignment of an expression is an integer, the expression is still
evaluated in double precision. For example:
Common Shared I as Long
I = 6.33 * 2.79
20 Rev E M-SS-005-03l
Loading...
+ 174 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.