Elmo’s Maestro is a network-based multi-axis motion supervisor that operates in
conjunction with Elmo intelligent servo drives to provide a full multi-axis motion control
solution. The Maestro and the
workload in a distributed motion control architecture.
1.1 Maestro Highlights
The Maestro operates as a Multi-Axis Motion Supervisor to:
coordinate motion between various axes in synchronized interpolated mode
integrate event handling into motion control procedures
The Maestro operates as a CANopen Network Node Master for:
This manual is part of a documentation set that, together, can be used to set up and
program the motion of any machine whose motors are controlled by Elmo
drives. Before you can use this manual you will need to carefully follow the instructions
in the Maestro Installation Guide to set up your Maestro.
The software described in this manual is provided on the CD that accompanies the
Maestro or as a download from Elmo's web site. In this manual it is assumed that you
have followed the software setup instructions in the Maestro Installation Guide and have
successfully installed the software.
At least one drive needs to be connected to the Maestro in order for it to function as a
motion controller. The
servo drives. Please read the Installation Guide that arrived with your servo drive before
setting it up. Servo drives are power devices so be careful.
SimplIQ manuals shown below explain how to set up and program
Commands for SimplIQ drives may be specified from the following sources:
User program A program loaded to the servo drive via one of the
communication options. After program execution begins, the
program is managed by the drive.
RS-232 Serial, point-to-point, short-range communication. Although this
method is rather slow, RS-232 is very easy to use and
requirements are minimal: a standard PC with serial port and
ASCII terminal software.
CANopen Serial, multi-drop, medium speed and medium-range
communication. This type of communication requires specialpurpose host hardware and software.
1-3
This manual describes the
Maestro commands that can be specified from each of these
sources. Most of the commands are equally available for all three sources. Certain
commands, however, are limited in scope according to type of program or
communication.
All the commands are available to CAN communication in text form through the OS
service, objects 0x1023 and 0x1024. In addition, the numerical set/get commands are
available to CAN users in short PDO form, called the “binary interpreter.” The binary
and the OS SCAN interpreters are described fully in the CAN manual.
CANopen may also be used to manipulate the drive using the object dictionary (OD)
method, which is the native CAN method. This manual does not cover OD manipulations
with CANopen; refer to the “Object Dictionary” section of the CANopen manual for full
explanations.
The
Maestro drive responds to many privileged commands — such as those used by the
Composer setup wizard — that are not documented in this manual.
1.4 Scope
This manual includes the complete list of commands used by the Maestro servo drives.
The commands are presented in two ways:
A task-related listing
Alphabetically
In the task-related reference, the commands are sorted into groups of related commands.
Each group is presented in a table listing the commands with basic descriptions. The
alphabetical command listing provides a detailed explanation of each command, with
examples and references to the
SimplIQ Software Manual when necessary.
Maestro Software Manual
MAN-MASSW (Ver. Q)
Chapter 2: Functional Overview
This chapter takes a look at the organization of Maestro software.
2.1 Functional Block Diagram
The Maestro’s functionality can be organized into the 5 groups shown below.
The first group (Host Communications Services) contains the standard interfaces and
protocols that enable the
The Command Line Interpreter is a utility that enables individual commands to be executed
immediately by either the
The Kernel is the part of the Maestro that executes user programs.
Maestro to communicates with the “outside world”.
Maestro or by a SimplIQ drive on a specified axis.
2-1
The Motion Manager sends commands and information to all axes and receives
information so that it can coordinate motion between all the axes.
The Maestro is designed to manage multiple axes on a CAN Open network. The CAN
Network Communication Server contains the CAN Open interfaces and protocols that
enable the
Maestro to do so.
Key:
Host Communication Services
Command Line Interpeter
Virtual Machines
(for executing User Programs)
Motion Manager
CAN Network
Communications Server
Virtual
Machine
Host
API
Command Line Interpeter
Virtual
Machine
Virtual
Machine
I/O
Kernel
Group
EthernetRS - 232
WEBTelNet
Gateway
Vector
CAN
Bus
Axis Manager
Services
CANopen (DS-301)
CANopen Master
CANopen API
Figure 2-1 The Maestro's Building Block
Maestro Software Manual Functional Overview
MAN-MASSW (Ver. Q)
2.2 Host Communications Services
A host application can access the Maestro using either a TCP/IP or RS-232 services.
Processes carried out through host communication include:
Transfer of operating instructions (e.g. for running a program or killing it) to the
Maestro
Transfer operational data (such as the trajectory of the next motion)
Status requests
Debugging
Generation of a “transparent path” from a Composer program to any single end-unit
Host communication is used to execute different tasks, including:
Processing of interpreter commands
Maintenance and file download/upload
Processing of direct-axis interpreter commands
2-2
CANopen gateway
2.3 Command Line Interpreter
CLI commands that are sent to the Maestro are either executed by the Maestro itself or
are forwarded directly to the specified axis for immediate execution.
The CLI currently supports the following commands:
Initialization commands
Commands for collect information
Axis commands
Vector commands
Group command
2.4 The Kernel
One of the main Kernel functions is running Maestro User Programs. The part of the
Kernel which executes the User Programs is the Virtual Machine which enables multiaxis programming. Each task (program) can work independently of the other tasks by
running a separate virtual machine. Communication and synchronization between tasks
can be performed by using global variables. Multiple tasks can be used to run different
machine functions in parallel.
Maestro Software Manual Functional Overview
MAN-MASSW (Ver. Q)
2.5 Motion Manager
The Motion Manager is the portion of the Kernel which provides services for the I/O and
the following motion objects:
Axis
Group
Vector
2.6 CANopen Network Communications Services
The CANopen Network Communication is the portion of the Kernel which provides the
following functionality:
CANopen Bus services
CANopen DS 301 Protocol
2-3
CANopen Master
CANopen API
Maestro Software Manual
MAN-MASSW (Ver. Q)
Chapter 3: Host Communications
This chapter explains how to set up the Workspace to work with a specific Maestro as a
host.
3.1 Setting Up the Host through Elmo's Studio
A Select Maestro pick list pops up when starting a new worksheet for the first time. The
window contains a list of Maestros currently attached to the network. The IP Address of the
Maestro and its name are listed. Select the Maestro you plan to work with and click OK.
3-1
Figure 3-1 The Maestro Selection Window
3.2 Verifying or Changing the Host
To verify that you have set up the correct Maestro as the host, or to change to another
Maestro, move the cursor into the File Viewer and click on the right mouse button. When
the menu pops up select Workspace Settings. This will cause the Workspace Settings
window to open. If the IP Address is wrong, click the Find button to open the Select
Maestro window.
Figure
3-2 Right Mouse Button
Selection Options
Figure 3-3 The Workspace Settings Window
Maestro Software Manual Host Communications
MAN-MASSW (Ver. Q)
3.3 Choosing the Host through the Composer
Select Start/Programs/Elmo/Composer to start Elmo's Composer and check the setup.
3-2
1. In the Welcome menu select the Open Communication Directly option.
2. In the Application Name and Communication Type dialog box check the TCP/IP
Gateway option and click the Properties button.
3. In the Select Drive dialog you should see at least one Maestro in the Gateway list.
Select it.
4. Go to the drive window, select one of the drives and click OK to open
communications with the selected drive.
5. If the Composer has no information about the device that was selected, it will
upload the device info. That could take a minute or two.
6. If all is connected properly, the Smart Terminal window in the Composer will
open.
Maestro Software Manual
MAN-MASSW (Ver. Q)
Chapter 4: General and Motion
Instructions; Configuration Tools
This chapter describes the Maestro input/output and motion objects, instructions and CAN
configuration tools.
The Maestro Multi-Axis Controller supports the following set of Input/Output Objects:
4-1
•Internal Maestro I/O Objects: the
eight Digital Outputs and four Analog Inputs.
•External CAN I/O: the
to the CANopen DS 401 protocol and use the I/Os on Elmo SimplIQ
devices.
The Maestro Multi-Axis Controller supports the following set of Motion Objects:
•Axis is the most basic
the motion of a single motor/axis.
•Vector2D: This object is comprised of two axes of the same type and it
is used to define two dimensional trajectories.
•Vector3D: This object is comprised of three axes of the same type and it
is used to define two dimensional trajectories.
•Group is a composite
Maestro axes of the same type. This object can be used to
more
synchronize the operation of all the axes in the group.
All motion objects use the same set of Motion Instructions, which include:
Maestro can control external I/Os that conform
Maestro motion object and it is used to control
Maestro motion object that is comprised of two or
Maestro has eight Digital Inputs,
•Commands – instructions sent to an axis (these are similar to the commands
used by SimplIQ drives and are described in the SimplIQ Command Reference).
• Properties – system parameters used to set the behavior of the Maestro.
• Functions – a pre-defined set of motion functions.
There is also a unique set of functions called CAN Bus Configuration Tools that are used to
set up an LSS slave.
Motion instructions can be sent from a terminal or from a
Maestro user program.
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Table 4-1 Motion Properties and Functions
Axis
Properties
Vector
Properties
Group
Properties
CAN Input
Properties
VAC flr backup
VAE irq
VBT GBT mhl
VCR mlh
VDC msk
ADI plr
ADT VDT
AEL GEL
AEH GEH
AEM GEM
AFP VFP
AID VID GID
ALN VLN
CAN Output
Properties
AMC VMC GMC erm
VNT erv
APE flr
VPE plr
APP VPP
VSC message
VSD
VSE
VSM GSM
VSP
VSR
ATM VTM GTM
ATP
VTT
VUM
VVE
VXT
General
Functions
businfo
bye, quit, or exit
command
date
dynamicip
errlevel
error
find
format
halt
hbperiod
hbrem
ipconfig
isok
kill
list
load
messageex
name
nodeguard
nodeinfo
property
restart
restarta
restartd
restarte
resauto
save
staticip
sync
systime
systimex
time
tstamp
tstampver
umauto
umstart
umstatus
umstop
ver
4-2
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
2D, 3D &
Axis
Functions
Group
Vector
Group
Functions
CAN Configuration
Tools (Functions)
Functions
addcircle plss_activate_bt m_din
adddwell plss_config_bt
addline
addpoint addpoint
plss_config_nid
plss_inq_addr
addsplinep plss_inq_nid
attach attach
circle
clears
detach detach
dotrj dotrj
ends ends
plss_inq_product
plss_inq_rev_num
plss_inq_ser_num
plss_inq_vendor
plss_master_bt
plss_start
error error error plss_store_config
isok isok isok plss_stop
line plss_sw_glb
startstp splinee
plss_sw_sel
splinep
trj splines
startp
starts
trj
m_dout.plr
Maestro I/O
Functions
m_din[]
m_dout
m_dout[]
m_ain[]
m_ain[].offset
m_din.polarity,
m_din.plr
m_dout.polarity,
4-3
Maestro Software Manual
MAN-MASSW (Ver. Q)
4.1 General Functions
Note: Entering a question mark from the terminal before any function name opens the
help text for the function. (Terminal only)
Function
backup
- restart the Maestro with the previous configuration
4-4
Call Format
Limitations
Function
Call Format
Parameters
Limitations
Example
Function
Call Format
Limitations
Example
Function
Call Format
backup
Terminal only
baudrate
- get the CAN bus baud rate
baudrate(BusID)
BusId - CAN bus ID number
Terminal only
baudrate(0)
businfo
- get CAN Bus information
businfo <bus_number> - CAN bus number (default value = 0)
Terminal only
businfo 1
bye, quit or exit
- close the current session
bye
Limitations
Function
Call Format
Limitations
Function
Call Format
Limitations
Example
Terminal only
command
- gets help text with the general structure for the motion
object commands.
?command
Terminal only
date
- get (or set) the current date
date - To change the date, enter a date according to the format
DD.MM.YYYY.
Terminal only
date 16.11.2005.
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-5
Function
Call Format
Return Value
Limitations
Example
Function
Call Format
Example
Function
Call Format
Limitations
dynamicip
– configures the Maestro Network Parameters to work with
a DHCP Server (dynamic IP addressing)
dynamicip
EnableDHCP: 1
Terminal only. Restart (power off/on) the Maestro controller to apply a
new dynamic IP address
- get the error stack from the Maestro Multi-Axis Controller
error - get all errors with the current error level
error <level> - get all errors with the specified error level
Terminal only
Example
Function
Call Format
Limitations
Example
Function
Call Format
Limitations
Function
Call Format
Limitations
error 3
– get all errors with error level 3 only
find - Search for an object according to the object’s logical name. If the
object exists, the information is displayed as a “list”. If the object does
not exist, the Maestro returns “Object not found”.
find <object_name>
Terminal only
find axis_1
format – displays the help text that defines how to format a binary,
hexadecimal or floating-point number.
?format.
Terminal only
halt - halt the virtual machine
<name of virtual machine>.halt
Terminal only
Example
vm.halt
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-6
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Parameters
Return Value
Example
hbperiod
- set heartbeat control period
hbperiod(int <bus_number>,int<period>)
<bus_number> - the CAN bus number to use to send heartbeat
messages
<period> - the interval between heartbeat messages in milliseconds (0–
for cancel).
OK or FAILED: Error message
hbperiod(0,1000) – the system uses bus number 0 to send a heartbeat
message every 1000 ms.
hbrem
- remove the node from heartbeat control
hbrem(int <bus_number>,int<node number>)
<bus_number> - CAN bus number
<node number> - the CAN node number of the node to remove from
heartbeat control
OK or FAILED: Error message
hbrem(0,1)
– on CAN bus 0, remove node 1 from heartbeat control
Function
Call Format
Return Value
Limitations
Example
Function
Call Format
Return Value
Limitations
Function
ipconfig
– display the current network configuration type, IP address
and subnet mask
ipconfig
Displays the network configuration type, IP address and subnet mask
Terminal only
ipconfig
EnableDHCP: 1
DhcpIPAddress: 10.10.20.57
DhcpSubnetMask: 255.255.255.0
isok
- verify the Maestro Multi-Axis Controller status
Isok
OK: Ok FAILED: Error message
Terminal only
kill - kill all programs
Call Format
Return Value
Limitations
Kill
OK: the number of killed programs, or FAILED: Error message
Terminal only
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function
list - gets a list of all the Maestro objects. An object can be a motion
object (axis, vector, etc.) or a virtual machine.
4-7
Call Format
list [-key:
attribute] … [-key:attribute]
Parameters:
[-b:id] - get information for the specified CAN Bus
[-n] - get information about nodes DS301
[-i] - get information about IO DS401
[-a[:attribute]] - get information about axes. Attributes: target object type. Can be:
e[lmo] - Elmo motion drivers only
402 - DS402 profile motion drivers only
[-v[:attribute]] - get information about vectors. Attributes: target object type. Can be:
e[lmo] - vectors of Elmo motion drivers only
402 - vectors of DS402 profile motion drivers only
[-g[:attribute]] - get information about groups. Attributes: target object type. Can be:
e[lmo] - groups of Elmo motion drivers only
402 - groups of DS402 profile motion drivers only
[-t] - get information about trajectories
[-p[:attribute]] - get information about programs. Attributes: target object type. Can
be:
r[un] - running programs only
p[ause] - paused programs only
h[alt] - halted programs only
a[bort] - aborted programs only
f[ile] - all programs in the device file
Limitations
Example
Function
Call Format
Limitations
[-u] - get information about unrecognized objects
[-f] - get full information about current query
[-s] - get status of current motion object
Terminal only
list
list –b:0 -a
list -p:r
load
- loads the values of all global variables and arrays saved during
the previous save() function
load()
Program only
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-8
Function
Call Format
Parameters
Example
Function
Call Format
Parameters
Example
Function
Call Format
Return Value
Limitations
message
- post a message to the host computer (no timestamp)
message(msgID, wParam, lParam) – posts a message without a
timestamp
msgID – user-defined message ID
wParam, lParam – user’s message data (Unsigned integer type)
message ( 0, a1.px, a2.px )
messageex - post a message to the host computer (with time stamp)
messageex(msgID, wParam, lParam) – posts a time-stamped message
msgID – user-defined message ID
wParam, lParam – user’s message data (Unsigned integer type)
messageex( 0, a1.px, a2.px )
name
- get (or set) the logical device name
name – gets the device name
name <device_name> - sets the device name
period - the interval between nodeguard messages in milliseconds (0–to
cancel).
nodeguard (0,1,500) – On CAN bus 0, sets the interval between
nodeguard messages arriving at CAN node 1 to 500 milliseconds.
nodeinfo
– gets the CAN node information
nodeinfo(int <bus_number>,int < node number >)
bus_number - CAN bus ID
node number – CAN node ID
Terminal only.
nodeinfo(0,1)
property
- gets the help text for the motion object property
Call Format
Limitations
? property
Terminal only
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-9
Function
Call Format
Limitations
Function
Call Format
restart - Restarts the Maestro and:
• Closes all existing objects
• Kills all virtual machines
• Restarts the Maestro kernel
• Applies the sessions and objects according to the existing
configuration file.
restart
Terminal only
restarta - Restarts the Maestro and:
• Closes all existing objects
• Kills all virtual machines
• Restarts the Maestro kernel
• Applies the sessions and objects according to the existing
configuration file.
•Starts the AUTOEXEC program (if it exists).
restarta
Limitations
Function
Call Format
Limitations
Example
Function
Call Format
Limitations
Terminal only
restartd
configuration
- restarts the Maestro kernel with the default
and sets the baud rate for each CAN bus.
restartd() – for baud rate 500 (default setting)
restartd(baudrate1, baudrate2) –baud rate 0 is not used. If the default
baud rate is not selected, a separate baud rate for each CAN bus must
be specified. If a baud rate for one bus is omitted, an error message is
displayed.
Terminal only
restartd(1000, 1000)
restarte
.
bus
- restarts the Maestro kernel without running the CAN
restarte()
Terminal only
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-10
Function
Call Format
Limitations
Example
Function
Call Format
Limitations
Function
Call Format
rsauto
- get (or set) the RS-232 autorun parameter
rsauto() – to get the current autorun parameter
rsauto(val) – to set the current autorun parameter
val can be 0 or1
Terminal only
rsauto(1) – allows the RS-232 bus to access the Command Interpreter
rsauto(0) – does not allow the RS-232 bus to access the Command
Interpreter
save
- to save the values of all the global variables and arrays
save()
Program only
staticip
– configures the Maestro Network parameters to work with
a static IP address
staticip(ip_address, subnet_mask)
ip_address - new IP Address of Maestro device
subnet_mask - new Subnet Mask of Maestro device
Return Value
Limitations
Example
Function
Call Format
Parameters
Return Value
Example
Function
IP Address and Subnet Mask, Network configuration type,
Terminal only. Restart (power off/on ) Maestro to apply Static IP
address.
staticip (10.10.20.57, 255.255.255.0)
IPAddress: 10.10.20.57
SubnetMask: 255.255.255.0
EnableDHCP: 0
sync
- begin sending SYNC messagesto a CAN bus
sync (int <bus_number>,float<sync_period>)
<bus_number> - which CAN bus to send the SYNC messages to
<sync_period> - the value of the SYNC period, in milliseconds
OK or FAILED: Error message
sync(0,20) – for bus number 0 activate the send sync every 20
milliseconds.
systime
- returns the system-defined time in milliseconds
Call Format
Function
Call Format
systime()
systimex
systimex()
- returns the CAN bus time in microseconds
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function
- get (or set) the current time
time
4-11
Call Format
Limitations
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Limitations
Time
Terminal only
tstamp
- set the timestamp period
tstamp(int <bus_number>,int<period>)
<bus_number> which CAN bus sends the timestamp
<period> - specifies how many sync periods must pass before the new
timestamp is set.
OK or FAILED: Error message
tstamp(0,5)
sync periods.
5
umauto
– for bus number 0, send a timestamp message after each
- get (or set) the user module autorun parameter
umauto() – to get the current autorun parameter
umauto(val) – to set the current autorun parameter
val can be 0 or 1
Terminal only
Function
Call Format
Limitations
Function
Call Format
Limitations
Function
Call Format
Limitations
Function
Call Format
Limitations
umstart
- run the user module
umstart()
Terminal only
umstatus
- get the user module status
umstatus()
Terminal only
umstop
- terminate the user module
umstop()
Terminal only
ver
- get current Maestro version
Ver
Terminal only
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4.2 Axis
4.2.1 Axis Motion Commands
SimplIQ commands can be sent to the drive through the Maestro terminal or from a Maestro
program.
Motion Commands are described in detail in the SimplIQCommand Reference Manual. When
a Motion Command is used to program the
• To send a command to set a parameter value:
<Axis name>.Command=<Value>
• To receive a parameter:
<Value>=<Axis name>.Command
For example:
A1.UM = 2
A1.MO = 1
A2.BG
A2.ST
Maestro, its syntax is as follows:
4-12
4.2.2 Axis Properties
Motion properties apply to Maestro programs only. Axis related properties are listed
below:
• To set a property value:
<Axis name>.Property=<Value>
Motion properties apply to
below:
• To set a property value:
<Axis name>.Property=<Value>
• To get a property value:
<Value>=<Axis name>. Property
Property ADI - Axis Drive Input event initialization
Explanation This property is used to control the message mechanism from the
Note 0 – event disabled, 1 – event enabled.
Maestro programs only. Axis related properties are listed
drive to the Maestro.
The message mechanism notifies the Maestro when a Digital Input
(DI) event has occurred.
When this property is enabled, the Maestro can react to DI events
with a callback function. (The user must define the callback
function in his program).
Default 0
Limitation 0-1
Example A1.ADI=1 (see Appendix B.4.5.2 InputOutputTest1)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Property ADT - Axis Delay Time – delay the start of the "do trajectory" (dotrj)
command
Explanation The ADT property defines when to start the trajectory and must be
specified when dotrj commands are used. The default value is 20 ms.
Dimension Milliseconds
Default 20
Limitation 20-254
Type Unsigned integer
Property AEL - CAN Encoder Low Limit
Explanation AEL is needed when Axis works as a CAN Encoder slave. The
property provides Encoder limitations.
Limitation 0-0x4000
Type Integer
Property AEH - CAN Encoder High Limit
4-13
Explanation AEM is needed when Axis works as CAN Encoder slave. The property
provides Encoder limitations.
Limitation 0-0x4000
Type Integer
Property AEM - CAN Encoder interpolation time
Explanation AEM is needed when Axis works as CAN Encoder slave. The property
provides mode initialization and interpolation (Sync) time definition.
Dimension Milliseconds
Limitation 1-64
Type Unsigned integer
Property AFP – Axis First Point
Explanation Defines the number of lines of a PVT table that are sent to the drive at
the start. SimplIQ drives are capable of storing 64 lines. Less than 64
lines are required for starting an axis as otherwise the start of the
other axis would be delayed. This would reduce the efficiency of the
system.
Default 5
Limitation 3 – 10
Type Unsigned integer
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Property AID – get axis ID
Explanation Used to get the NodeID of an axis. For example, in a callback function
the NodeID can be compared with a specific motion object so that
something specific can be done in each case (event / NodeID).
Limitation Read only
Type Unsigned integer
Example Function @input (BusID, NodeID, data)
switch(NodeID)
case a1.aid
val=1
case a2.aid
val=3
end
end
(see Appendix B.4.5.2 InputOutputTest1)
Property ALN – number of trajectory cycles for an Axis
Explanation Initialize Motion Event notifies the system that axis motion is
complete and continues to notify until turned off. This is intended for
when one axis starts only after another axis motion has stopped.
Note 0 – event disabled, 1 – event enabled.
Default 0
Limitation 0 – 1
Example (see Appendix B.4.6 Motion Completed Callback Samples)
Property APE – Axis Program Emit event initialization
Explanation To initialize a reaction (maestro callback function) upon calling the
emit(i) function in a SimplIQ program.
Note Bit field:
bit 0 – PDO1 (emit(1)), bit 2 – PDO3 (emit(3)), bit 3 – PDO4 (emit(4))
bit value 0 – event disabled,
bit value 1 – event enabled.
Default 0
Limitation 0 – 15 (see Appendix B.4.4.2 EmitCallback)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Property APP – Axis Points in Portion - number of PVT points in portion of
PVT trajectory
Explanation Limits the number of PVT lines sent to a drive. The Maestro
communicates with the drive first to see if space is available.
Default 5
Limitation 3 – 10
Type Unsigned integer
Property ATM – Axis Tabulated Motion– used to prepare the axis for PVT motion
Explanation Prepares axis for PVT motion.
Default 0
Limitation 0 – disable, 1 - enable
Type Unsigned integer
Example A1.atm=1
Property ATP – Last motion complete position
4-15
Explanation Axis position is sent with event notifications automatically with the
Maestro (for example: "last position 1001"). The information can be
retrieved with an x=a.atp command. In other words, this property
contains the current position and is readable.
Default 0
Limitation read only
Type integer
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4.2.3 Axis Functions
Motion functions apply to Maestro programs only. Axis related functions are listed below:
Function addpoint - add PVT point to user's trajectory sequence
Call Format < Axis_name>.addpoint(<Pos >,<Vel >, <T>)
Parameters <Pos > - position for PVT point (counts),
<Vel > - velocity for PVT point (counts per second),
<T> - interpolation period for PVT point (milliseconds)
Return Value OK or FAILED: Error message
Example
Function dotrj – Do Trajectory
a1.addpoint(1000, 30000, 10)
For more information see the starts and ends function
(see Appendix B.1.2.2 Add Point Sample)
4-16
Explanation Used to initialize the PVT mechanism and load the initial portion of the
PVT trajectory table to an axis and start motion.
Start motion is delayed. The delay specified by the ADT command.
The default delay value is 20 ms.
By comparison the trj command requires a bg command to start motion.
Call Format <Axis name>.dotrj(<Trajectory name>)
Parameters <Trajectory name> - name of PVT table (trajectory)
Return Value OK: Trajectory name
FAILED: Error message
Example A1.dotrj(table)
for axis name A1 run trajectory name “table”
(see Appendix B.1.2.2 Add Point Sample)
Function
ends - user's trajectory sequence for Axis motion object
(latest operator in startp(starts) – ends sequence)
Call Format < Axis_name>.ends()
Return Value OK: Ok
FAILED: Error message
Example a1.startp(mytable) the trajectory name mytable
a1.addpoint(10, 1000, 10)
a1.addpoint(1000, 30000, 10)
………….
a1.addpoint(5000, 1000, 10)
a1.ends() after this the trajectory named “mytable” will contain the user’s PVT
table
(see Appendix B.1.2.1 Circle Sample)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-17
Function
error – to get motion object last error
Call Format <Axis name>.isok
Return Value
OK: Ok ()
FAILED: Error message
Example A2.error
Function isok – used to verify motion object status
Call Format <Axis name>.isok
Return Value OK: Ok
FAILED: Error status
Example A2.isok
Function startp - begin user’s PVT trajectory sequence for an Axis
first operator in startp(starts)–ends sequence
Call Format < Axis name>.startp()
< Axis name>.startp(<Trajectory name >)
Parameters <Trajectory name> - name of Axis PVT table (trajectory) to save
Example a1.startp(mytable) – begin user’s PVT trajectory named “mytable”
For more information see the ends function example.
(see Appendix B.1.2.2 Add Point Sample)
Function trj – used to initialize the PVT mechanism and load a PVT trajectory table
to an axis
Call Format <Axis name>.trj(<Trajectory name>)
Parameters <Trajectory name> - name of PVT table (trajectory)
Return Value OK: Trajectory name
FAILED: Error message
Example A1.trj(table); A1.bg
for axis name A1, run trajectory name “table ”
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4.3 Vector
4.3.1 Vector Motion Commands
Vector commands can be sent simultaneously or serially according to VSM value simultaneously to a Vector or serially to individual axes (components of a vector). However,
only the parcel sent serially to the axes provides a reliable check of operating performance
results. When commands are sent individually, in a serial manner, the results of each
motion can be checked. If a vector is sent as a group (simultaneously), the results cannot be
checked.
A vector is a set of axes that provide two or three dimensional interpolated motion.
When a vector is active, the member axes can receive commands not only from it, but also
from the axes' objects.
A Vector cannot be activated if one of its member Axes is a member of another active
Vector. Access condition is set by attach/detach operator
• To send a set parameter value:
< Vector name>.Command [=<Value>]
For example:
V1.AC = V1.DC=1000000;
V1.MO = 0;
V2.BG;
V2.ST.
4-18
4.3.2 Vector Properties
•To set a property value:
< Vector name>.Property=<Value>
•To get a property value:
<Value>=< Vector name>. Property
All properties are valid for Vector2D and Vector3D
Property
Dimension
Default
Limitation
Type
Example
Property
Explanation
Default
VAC - vector acceleration
Counts per second
28000000
squared
Unsigned integer
(see Appendix B.1.2.1 Circle Sample)
VAE - calculated acceleration margin
Prevents the Maestro's calculated trajectory from exceeding the
maximum Axis acceleration.
0.9
Limitation
Example
Property
0-1
Type
VBT - synchronized start command delay
Float
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-19
Explanation
Dimension
Default
Limitation
Type
Property
Note
Default
Limitation
Type
Property
Dimension
Once the begin command is sent, the Vector motion begins after the
delay specified by the VBT value. This command property is only
valid when the sync command is used.
Milliseconds
20
2-254
Unsigned integer
VCR - constant PVT table resolution flag
1 - constant PVT resolution (each time interval is the same)
0 – various PVT resolution (the time intervals vary to fine tune the
motion and make it more accurate)
0
0, 1
Unsigned integer
VDC - vector deceleration
counts per second squared
Default
Type
Example
Property
Explanation
Dimension
Default
Limitation
Type
Example
28000000
Unsigned integer
(see Appendix B.1.2.1 Circle Sample)
VDT – defines delay for dotrj command
VDT is needed when the DOTRJ command is used. It defines when
to start the trajectory. The default delay is 40ms.
Milliseconds
40
20-254
Unsigned integer
(see Appendix B.1.2.2 Add Point Sample)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Property
VFP –number of lines downloaded in the first portion of a PVT
trajectory
4-20
Explanation
Default
Limitation
See also
Example
Property
Limitation
Type
Example
Property
SimplIQ drives work according to information that is in their PVT
table. If the table is empty they do not drive the motor. SimplIQ
PVT tables have 64 lines. If the Maestro were to fill each drive
serially, then motion could not start until after the last drive was
loaded. If, on the other hand, only a few lines of each PVT table
were filled, than motion could start relatively quickly. While the
motors are moving, more lines for each PVT table can be loaded.
There is a fine balance between loading the minimum number of
PVT lines and "starving" the drive. Each application is different.
The VFP command is used to find and then set the initial number
of PVT lines sent to a drive.
5
3 – 10
Type
Unsigned integer
VPP – single points portion size for PVT trajectory
(see AppendixB.1.6 Polygon Sample)
VID – get the group ID of the vector
Read only.
Unsigned integer
(see Appendix B.4.6.1 MCompleteCallback)
VLN – number of trajectory cycles for a vector; used to repeat
predefined PVT motion.
Note
Default
Limitation
Type
Property
Explanation This notifies the system that vector motion is complete and
continues to notify it until turned off. For example, the X-Y table
on a drilling machine needs to come to a stop before the Z-axis
Note
Default
Limitation
Example
drill head starts moving.
0 – event disabled, 1 – event enabled.
0
0 – 1
(see Appendix B.4.6.1 MCompleteCallback)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-21
Property
Explanation
Dimension
Default
Limitation
Type
See also
Example
Property
Explanation
Dimension
Default
Type
See also
Property
VNT – low limit of calculated PVT
trajectory step time
Set/get PVT trajectory min step time
Milliseconds
2
1–255
Unsigned integer
VXT (max step time)
(see Appendix B.1.6 Polygon Sample)
VPE – calculated position error for PVT trajectory
Difference between the theoretical trajectory and calculated
trajectory.
counts
100
Float
VVE - calculated velocity error for PVT trajectory
VPP – single point size portion for PVT trajectory
Explanation
Default
Limitation
Type
See also
Property
Explanation
Note
See also
Default
Limitation
The number of PVT lines sent to a drive at a time. This helps to
"distribute" the information evenly across a multi-axis system so
that no axis is "starved" of information.
5
3 – 10
Unsigned integer
VFP –number of lines downloaded in the 1
st
portion of a PVT trajectory
VSC – PVT trajectory smoothing curve mode
Used with addcircle and addline to smooth the operation of the
motor at corners or joints.
Available:
0-non smoothed
1-smoothed with max velocity (use the VSE command)
2-smoothed with fixed radius (use the VSR command)
3-smoothed with fixed dist from the corner (use VSD)
VSD, VSE, VSP, VSR
0
1 - 254
Type
Unsigned integer
Example
Appendix B.1.2.1 Circle Sample)
(see
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-22
Property
Explanation
Dimension
Default
Example
Property
Dimension
Default
Example
Property
Note
Default
Limitation
Property
VSD – PVT trajectory smooth distance from the corner point
When using VSC smoothing mode 3, VSD defines the distance
from the "corner" (point of change of trajectory)
Counts
0
Type
(see Appendix B.1.3.1 )
Unsigned integer
d
d
VSE – velocity at the end of a segment in a PVT trajectory
Counts per second
0
Type
Float
(see Appendix B.1.3.1)
VSM – send vector command mode simultaneously or one after the
other (serially)
0 – simultaneous mode, use Group ID of Vector
1 – serial mode, use Node ID of members
0
0,1
Type
Unsigned integer
VSP – PVT trajectory fixed (profile) velocity
Explanation
When the trajectory is set for maximum velocity, fixed time or fixed
velocity, the VSP command sets the velocity.
Dimension
Default
Dependencies
Counts per second
0
In max velocity mode (vum = 1) vsp=the limit of max vel. value
In fixed time mode (vum = 2) vsp=the limit of max velocity value
In fixed velocity mode (vum = 3) vsp=fixed velocity value
When using VSC smoothing mode 2, VSR defines the radius of the
curve at the "corner" (trajectory point of change)
Dimension
Default
Type
Counts
0
Unsigned integer
r
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-23
Property
Explanation
VTM – PVT motion initialization
Used to prepare the vector for PVT motion when the trajectory is set
for maximum velocity, fixed time or fixed velocity.
VTM is used to initialize "ready-made" PVT tables as well as
trajectories created with the Motion Library.
Default
Limitation
Type
Example
Property
Explanation
0
0 – disable, 1 - enable
Unsigned integer
(see Appendix B.1.5.1 Circle-to-Line Sample)
VTT – defines PVT trajectory fixed time when VUM=2
VTT sets the time to perform the motion when using addline or
addcircle.
Dimension
Default
Milliseconds
0
See also VUM
Type
Property
Unsigned integer
VUM – PVT trajectory build mode (for the Maestro's
Mathematical Library)
Note
1 – max velocity mode
2 - fixed time mode
3 - fixed velocity mode
Default
Limitation
Type
3
0-254
Unsigned integer
See also VTT
Example
Property
Explanation
(see Appendix B.1.5.1 Circle-to-Line Sample)
VVE - calculated velocity error for PVT trajectory
Limit range of error in terms of velocity – PVT tables can be
calculated accurately for two of the three constraints – VVE tells the
Maestro to "loosen" the constraints on the velocity.
Dimension
Default
Limitation
Type
%
0.005
0-1
Float
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-24
Property
Explanation
Dimension
Default
Limitation
Type
See also
Example
VXT – high limit of the calculated PVT trajectory step time
int <Radius> - radius of circle segment (counts)
float <Start Angle> - start angle of circle segment (degrees)
float <Sweep Angle> - sweep angle of circle segment (degrees)
OK or FAILED : Error message
Vec1.addcircle(rad, alpha, delta)
For more information see the vector ends function example.
(see Appendix B.1.5.1 Circle-to-Line Sample)
Polyline trajectory program examples can be found in
int <Pos X>,<Pos Y> - position for PVT point (counts),
int <Vel X>,<Vel Y> - velocity for PVT point (counts per second),
int <T> - interpolation period for PVT point (milliseconds) 0 - 255
OK or FAILED : Error message
Vec1.addpoint(1000, 30000, 2000, 40000, 10)
For more information see the vector ends function example.
(see Appendix B.1.2.2 Add Point Sample)
addsplinep - add two-dimensional point to the spline segment of the
polyline trajectory sequence
<Vector name>.addsplinep(int <Pos X>,int <Pos Y>)
The last point of the previous polyline segment or the first point of the
trajectory is automatically added to the spline segment. It means that the
minimal number of the addsplinep() operators that define the same spline
segment inside the polyline must be greater than or equal to 2.
This requirement is valid for every spline segment inside the polyline – not
only for the first one.
int <Pos X>,<Pos Y> - position of the point (counts)
OK or FAILED : Error message
Vec1. addsplinep (1000, 2000)
Polyline trajectory program examples can be found in
attach – used to synchronize all members of the Vector according to the
resource file. The attach function must be called before the first vector
operation.
Sometimes two vectors "share" an axis. If the axis was used simultaneously
by both vectors, then errors will occur. Attach is used to tell the axis with
which vector to work.
< Vector name>.attach()
OK or FAILED : Error message
G1.attach() (see Appendix B.4.6.1 MCompleteCallback)
circle - make circle trajectory for vector motion object
int <Radius> - radius of circle trajectory (counts)
float<Start Angle> - start angle of circle trajectory (degrees)
float<Sweep Angle> - sweep angle of circle trajectory (degrees)
OK or FAILED : Error message
Vec1.circle(rad, alpha, delta);Vec1.bg
(see Appendix B.1.2.1 Circle Sample)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-26
Function
Call Format
Return Value
Example
Function
Explanation
Call Format
Return Value
Example
Function
Explanation
Call Format
Parameters
Return Value
Example
clears - remove user's or polyline trajectory sequence in a vector motion
object – erases previously sent commands before they are executed
<Vector name>.clears()
OK or FAILED : Error message
Vec1.clears()
Circle trajectory program examples can be found in Samples Tutorial –
Motion Library Tutorial Examples – Vector 2D
detach – cancel vector synchronization
Sometimes two vectors "share" an axis. If the axis was used simultaneously
by both vectors, then errors will occur. Detach is used to free the axis from
the vector with which it is working.
< Vector name>.detach()
OK or FAILED : Error message
V1.detach() (see Appendix B.4.6.1 MCompleteCallback)
dotrj – do trajectory
Used to initialize the PVT mechanism on each of the vector's axes, load the
initial portion of the PVT trajectory table to each axes and start motion. Start
motion is delayed by 20 ms unless otherwise specified by the VDT
command.
The trj command requires a BG command to start motion.
<Vector name>.dotrj(<Trajectory name>)
<Trajectory name> - name of Vector PVT table (trajectory)
OK : Trajectory name
FAILED : Error message
V1.dotrj(table)
for vector name v1 run trajectory name “table ”
(see Appendix B.1.2.2 Add Point Sample)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-27
Function
Call Format
Return Value
Example
Function
Call Format
Return Value
Limitation
Example
Function
Call Format
Return Value
Limitation
ends - closes a polyline trajectory sequence and a sequence of user defined
PVT points
<Vector name>.ends()
OK or FAILED : Error message
v1.startp(mytable) - begin the trajectory name mytable
v1.addpoint(10, 1000, 20, 2000, 10)
v1.addpoint(1000, 30000, 4000, 50000, 10)
………….
v1.addpoint(5000, 1000, 4000, 2000, 10)
v1.ends() - after this, the trajectory name “mytable” contains the user’s PVT
table
* * *
v1.start(mytable) - begin the polyline trajectory "mytable"
v1.addline(1000,2000)
v1.addcircle(1000, 180, -180)
………….
v1.addline(5000, 1000)
v1.ends() - after this the trajectory file “mytable” contains an updated PVT
table
(see Appendix B.1.3.1 Line-to-Line Sample)
Polyline trajectory program examples can be found in
Samples Tutorial – Motion Library Tutorial Examples – Vector 2D
error – request info about the last error
<Vector name>.isok
OK or FAILED : Error message
Terminal only
V.error
isok – used to verify if all OK
<Vector name>.isok
OK or FAILED : Error message
Terminal only
Example
Function
Call Format
Parameters
Return Value
Example
V.isok
line - builds a linear trajectory from point to point
<Vector name>.line(int <Pos X>, int <Pos Y>)
int <Pos X>,<Pos Y> - destination position of linear trajectory (counts),
beginning of trajectory – current position
OK or FAILED : Error message
Vec1.line(1000, 2000); Vec1.bg (see Appendix B.1.1 Line Sample)
splines - begin spline trajectory sequence for Vector2D and Vector3D objects
<Vector name>.splines()
<Vector name>.splines(<Trajectory name >)
<Trajectory name> - name of Vector PVT table (trajectory) to be saved
OK or FAILED : Error message
V1.splines() - begin spline trajectory calculation with saving the results in a
file with a standard name v1.trj
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 2D
splinep - add a point to the sequence of points that define the spline
trajectory
<Vector name>.splinep(int <Pos X>,int <Pos Y>)
The first point of the sequence must define the current position after homing.
This behavior differs from the spline segment inside a polyline where start
point is added automatically.
int <Pos X>, int Y> - spline point position (counts)
adddwell - add delay to a PVT trajectory at the end of a segment
adddwell(int delay)
int delay - delay value in milliseconds
together with addline,
addline - add linear segment to the polyline trajectory sequence for the
vector motion object
<Vector name>.addline(int <Pos X>,int <Pos Y>, int <pos Z >)
int <Pos X>, int <Pos Y>, int <Pos Z> - destination position of linear segment
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
(counts), beginning of segment – current position
Return Value
Example
OK or FAILED : Error message
Vec1.addline(1000, 2000,400)
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 3D
4-30
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Parameters
Return Value
Example
Function
Explanation
Call Format
Return Value
Example
Function
Call Format
addpoint - add PVT point to user's trajectory sequence to a vector
<Vector name>.addpoint(int <Pos X>,int <Vel X>,int <Pos Y>,<Vel Y>, int
<Pos X>, int <Vel Z> int <T>)
int <Pos X>,<Pos Y>, <Pos Z> - position for PVT point (counts),
int <Vel X>,<Vel Y>, <Vel Z> - velocity for PVT point (counts per second),
int <T> - interpolation period for PVT point (milliseconds) 0 - 255
OK or FAILED : Error message
Vec1.addpoint(1000, 30000, 2000, 40000, 3000, 5000, 10)
For more information see the vector ends function example
addsplinep - add three-dimensional point to the spline segment of the
polyline trajectory sequence
<Vector name>.addsplinep(int <Pos X>,int <Pos Y>, int <Pos Z>)
The last point of the previous polyline segment or the first point of the
trajectory is automatically added to the spline segment. This means that the
minimal number of the addsplinep() operators that define the same spline
segment inside the polyline must be greater or equal to: 2 points . This
requirement is valid for every spline segment inside the polyline – not only
for the first one.
int <Pos X>,<Pos Y>,<Pos Z> - position of the point (counts)
OK or FAILED : Error message
Vec1. addsplinep (1000, 2000, 8500)
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 3D
attach – used to synchronize all members of the vector according the
resource file. The attach function must be called before the first vector
operation.
Sometimes two vectors "share" an axis. If the axis was used simultaneously
by both vectors, then errors will occur. Attach is used to tell the axis with
which vector to work with.
< Vector name>.attach()
OK or FAILED : Error message
V1.attach() (see Appendix B.4.6.1 MCompleteCallback)
clears - removes the user's or polyline trajectory sequence in a vector
motion object – erases previously sent commands before they are
executed
<Vector name>.clears()
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-31
Return Value
Example
Function
Explanation
Call Format
Return Value
Example
Function
Explanation
Call Format
Parameters
Return Value
Example
Function
Call Format
Return Value
Example
OK or FAILED : Error message
Vec1.clears()
detach – cancel Vector synchronization
Sometimes two vectors "share" an axis. If the axis was used simultaneously
by both vectors, then errors will occur. Detach is used to free the axis from
the vector with which it is working.
< Vector name>.detach()
Ok or FAILED : Error message
V1.detach() (see Appendix B.4.6.1 MCompleteCallback)
dotrj – do trajectory
Used to initialize the PVT mechanism in each of the vector's axes and load
the initial portion of the PVT trajectory table to each axes and start motion.
Start motion is delayed by 20 ms unless otherwise specified by the VDT
command.
The trj command requires a BG command to start motion.
<Vector name>.dotrj(<Trajectory name>)
<Trajectory name> - name of Vector PVT table (trajectory)
OK : Trajectory name
FAILED : Error message
V1.dotrj(table)
for vector name v1 run trajectory name “table ”
ends - closes a polyline trajectory sequence and a sequence of user defined
PVT points
<Vector name>.ends()
Ok or FAILED : Error message
v1.startp(mytable) - begin the trajectory name mytable
v1.addpoint(10, 1000, 20, 2000, 3000, 60000, 10)
v1.addpoint(1000, 30000, 4000, 50000, 8000, 60000, 10)
………….
v1.addpoint(5000, 1000, 4000, 2000, 30000, 4000, 10)
v1.ends() - after this, the trajectory name “mytable” will contain the user’s
PVT table
* * *
v1.start(mytable) - begin the trajectory name "mytable"
v1.addline(1000,2000, 5000)
v1.addsplinep(2500, 4000, 6000)
v1.addsplinep(4000, 5000, 9000)
v1.addline(25000, 18000, 15000)
v1.ends() - after this the trajectory name “mytable” will contain an updated
PVT table
3D polyline trajectory program examples can be found in
Samples Tutorial – Motion Library Tutorial Examples – Vector 3D
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function
Call Format
Return Value
Limitation
Example
Function
Call Format
Return Value
Limitation
Example
Function
Call Format
Parameters
error – request info about the last error
<Vector name>.isok
OK or FAILED : Error message
Terminal only
V.error
isok – used to verify if all is OK
<Vector name>.isok
OK or FAILED : Error message
Terminal only
V.isok
line - builds a linear trajectory from point to point
<Vector name>.line(int <Pos X>, int <Pos Y>, int <Pos Z>)
int <Pos X>, int <Pos Y >, int < Pos Z> - destination position of linear
trajectory (counts), beginning of trajectory – current position
Return Value
Example
OK or FAILED : Error message
Vec1.line(1000, 2000, 7000); Vec1.bg
3D line trajectory program examples can be found in Samples Tutorial –
Motion Library Tutorial Examples – Vector 3D
Function
splinee - closes a spline trajectory sequence for Vector2D and Vector3D
objects
Call Format
<Vector name>.splinee()
<Vector name>.splinee(int parameter)
If parameter≠0 three PVT tables for axes X,Y and gear are built
Return Value
Example
OK or FAILED : Error message
v1.splines(mytable) - begin the trajectory with file name mytable
v1.splinep(10, 1000)
v1.splinep(1000, 30000)
………….
v1.splinep(5000, 1000)
v1.splinee() - after this, the trajectory file named “mytable” will contain PVT
table for the spline trajectory
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-33
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
Parameters
Return Value
Example
Function
Call Format
splinep - adds a point to the sequence of points that defines the spline
trajectory
<Vector name>.splinep(int <Pos X>,int <Pos Y>, int <Pos Z>)
The first point of the sequence must define the current position after homing
(this behavior differs from the spline segment inside a polyline where the
start point is added automatically)
int <Pos X>, int <Pos Y>, int <Pos Z> - spline point position (counts)
OK or FAILED : Error message
Vec1.splinep(1000, 30000, 7000)
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 3D
splines - begins spline trajectory sequence for Vector2D and Vector3D
objects
<Vector name>.splines()
<Vector name>.splines(<Trajectory name >)
<Trajectory name> - name of Vector PVT table (trajectory) to be saved
OK or FAILED : Error message
V1.splines() - begin spline trajectory calculation with saving the results in a
file with a standard predefined name v1.trj
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 3D
startp - begin user’s PVT vector trajectory sequence
<Vector name>.startp()
<Vector name>.startp(<Trajectory name >)
<Trajectory name> - name of Vector PVT table (trajectory) to be saved
OK or FAILED : Error message
V1.startp() - begin user’s PVT trajectory
V1.startp(traj_name) - begin user’s PVT trajectory and save result I a file
trajectory named “traj_name”
For more information see the vector ends function example.
starts - begin polyline trajectory calculation sequence for Vector
<Vector name>.starts()
<Vector name>.starts(<Trajectory name >)
<Trajectory name> - name of Vector PVT table (trajectory) to be saved
OK or FAILED : Error message
V1.starts() - begin polyline trajectory calculation
Program examples can be found in
Samples Tutorial – Motion Library Tutorial Examples – Vector 3D
trj – used to initialize PVT mechanism and load the vector PVT trajectory
table on each axis of the vector
<Vector name>.trj(<Trajectory name>)
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-34
Parameters
Return Value
Example
<Trajectory name> - name of Vector PVT table (trajectory)
OK or FAILED : Error message
v1.trj(table); v1.bg
for vector name v1 run trajectory name “table ”
Program examples can be found in Samples Tutorial – Motion Library
Tutorial Examples – Vector 3D
4.4 Group
4.4.1 Group Motion Commands
Group motion commands can be sent simultaneously to a Group with the same ID, or serially to
all members of a group according to the
serially to all members of a group are able to provide a reliable check of the operating
performance.
• To send set parameter values:
<Group name>.Command[=<Value>]
For example:
G1.PX = 0;
G1.MO = 1;
G2.BG;
G2.ST.
GSM property value. However, only parcels sent
4.4.2 Group Properties
• To set property values:
< Group name>.Property=<Value>
• To get property values:
<Value>=< Group name>. Property
Property
Explanation
Dimension
Default
Limitation
Type
Property GEL - CAN Encoder Low Limit
Explanation GEL is needed when Group works as CAN Encoder slave.
Limitation 0-0x4000
Type Integer
GBT - synchronized start command delay
This command only functions when the sync command is used and
delays the start of motion after a begin command.
Milliseconds
3
2-254
Unsigned integer
The property provides the Encoder limitations.
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Property GEH - CAN Encoder High Limit
Explanation GEM is needed when Group works as CAN Encoder slave. The
property provides Encoder limitations.
Limitation 0-0x4000
Type Integer
Property GEM - CAN Encoder interpolation time
Explanation GEM is needed when Group works as CAN Encoder slave. The
property provides mode initialization and interpolation (Sync) time
definition.
Dimension Milliseconds
Limitation 1-64
Type Unsigned integer
Property
GID – get Group ID
4-35
Limitation
Example
Property
Read only
(see Appendix B.4.6.1 MCompleteCallback)
GMC – motion completed event initialization
Type
Unsigned integer
Explanation This notifies the system that group motion is complete and continues
to notify until turned off. This is useful when one group only starts
after another group has stopped.
Note
Default
Limitation
Example
0 – event disabled, 1 – event enabled.
0
0 – 1
Type
(see Appendix B.4.6.1 MCompleteCallback)
Unsigned integer
Property
Note
Default
Limitation
Type
GSM – send group command mode simultaneously or serially
0 – simultaneous mode, use Group ID
1 – serial mode, use Node ID of members
0
0,1
Unsigned int
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-36
Property
– Group Tabulated Motion – used to initialize PVT motion
GTM
for all members of a group
Explanation
Used to prepare the group for PVT motion when the trajectory is
set for maximum velocity, fixed time or fixed velocity.
Send this before the PVT tables for each member of the group
have been downloaded.
Groups use "ready-made" PVT tables only (not trajectories
created with the Motion Library).
attach – used to synchronize all members of the Group according the
resource file.
The attach function must be called before the first group operation.
Explanation
Call Format
Return Value
Example
Function
Explanation
Call Format
Return Value
Example
Function
Sometimes more than one group object "shares" an axis. If the axis
were used simultaneously by several members of a group then
errors will occur. Attach is used to tell the axis which group member
to work with at any given time.
<Group name>.attach()
OK or FAILED : Error message
G1.attach()
detach
Group operation calls, after detach, and cause a RUNTIME error.
– cancel Group synchronization.
Sometimes more than one group object "shares" an axis. If the axis
were used simultaneously by several members of a group then
errors will occur. Detach is used to free an axis from the group
member it is working with.
<Group name>.detach()
OK or FAILED : Error message
G1.detach()
error – to get motion object last error
Call Format
Return Value
Limitation
Example
<Group name>.isok
OK or FAILED : Error message
Terminal only
Grp.error
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-37
Function
Call Format
Return Value
Example
isok – to verify motion object status
<Group name>.isok
OK or FAILED : Error message
Grp.isok
4.4.4 Group Arrays
Function
Call Format
Parameters
Return Value
Note
Example
Function
Enables access to each object in a group individually
<Group name>[Index]
The Index is always an integer value
OK: Returns reference
FAILED: Error message (such as "Out of Range" or "Bad Index)
Indexes starts at 0
G[0].MO=1 This sends a message to the first object (axis 1)
Same as a1.MO=1 if a1 is a member of the group
(see Appendix B.3.13.2 Group as Array)
Enable program to retrieve the size of the group
Call Format
Return Value
Example
<Group name>.size
Size of group
S=G1.size
(see Appendix B.3.13.2 Group as Array)
4.5 CAN Bus Configuration Tools (for DSP 305
support)
The CAN bus configuration tools, listed below, are based on CiA DSP 305 CANopen Layer
Setting Services (LSS) and Protocols. They were created to enable the following parameters to be
read and changed through the network:
• CANopen Node ID
• CAN bus baud rate
With the Maestro an LSS Slave is identified by an LSS Address. An LSS Address consists of a
Vendor ID, a Product Code, a Revision Number and a Serial Number. The Vendor ID and
Product Code are numerical numbers. The Revision Number contains the major and minor
revision in numerical form. The Serial Number is coded numerically as well.
Function plss_activate_bt(busID,delay) - activates the CAN bus bit timing parameter
as defined by the plss_config_bt function. This enables all LSS Slaves to be in
configuration mode.
busID CAN bus ID - possible value: 0, 1
Delay activation delay, milliseconds;
Return Value
"OK" or error code
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function plss_config_bt(busID,baudrate) - sets the new bit timing on an LSS Slave …
allows all LSS Slaves to be in configuration mode.
busID CAN bus ID - possible value: 0, 1
Baud Rate bit timing period - possible value: 10,20,50,100,125,250,500,800,1000;
Return Value "OK" or error code
Function plss_config_nid(busID,nodeID) - used to configure the Node ID. Only one
LSS Slave can be in configuration mode at any given time.
busID CAN bus ID - possible value: 0, 1
nodeID destination Node ID
Possible value: 1 – 127
Return Value "OK" or error code
Function plss_inq_addr(busID, nodeID) - used to retrieve the LSS address
4-38
Parameters busID - CAN bus ID, possible values: 0, 1
nodeID – CAN node ID
Return Value Node ID LSS address or an error code
Function plss_inq_nid(busID) - used to retrieve the Node ID by DS 301 protocol
busID CAN bus ID - possible value: 0, 1
Return Value List of Node IDs as comma-separated values (CSVs) or an error code
Function plss_inq_product(busID) - used to retrieve the Product Code
busID CAN bus ID - possible value: 0, 1
Return Value Product Code list as CSVs or an error code
Function plss_inq_rev_num(busID) - used to inquire about Revision Number
busID CAN bus ID - possible value: 0, 1
Return Value Revision Number list as CSVs or an error code
Function plss_inq_ser_num(busID) - used to inquire about Serial Number
busID CAN bus ID - possible value: 0, 1
Return Value Serial Number list as CSVs or an error code
Function plss_inq_vendor(busID) - used to inquire about Vendor ID
busID CAN bus ID - possible value: 0, 1
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Return Value Vendor ID list list as CSVs or an error code
Function plss_master_bt(busID,baudrate) - used to define the LSS Master bit timing
busID CAN bus ID - possible value: 0, 1
Baud Rate bit timing period - possible value 10,20,50,100,125,250,500,800,1000;
Return Value “OK” or error code
Function plss_start() - used to initialize LSS configuration tools
Return Value “OK” or error code
Function plss_store_config(busID) - used to store the configured parameters in
nonvolatile memory
busID CAN bus ID - possible value: 0, 1
4-39
Return Value “OK” or error code
Function plss_stop() - used to de-initialize LSS configuration tools.
Return Value “OK” or error code
Function plss_sw_glb(busID,configMode) - to switch all LSS Slaves on the network
between operation mode and configuration mode.
busID CAN bus ID - possible value: 0, 1
configModeconfiguration mode - 1, working mode – 0
Return Value “OK” or error code
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function plss_sw_sel(busID,vendorID,productCode,revisionNum,serialNum) -
used to switch the a specific LSS Slave to configuration mode.
busID CAN bus ID - possible value: 0, 1
vendorID Vendor ID of selected device (for Elmo - 154)
productCode Product Code of selected device
revisionNum Revision Number of selected device
serialNumSerial Number of selected device
Return Value “OK” or error code
4.6 I/O Functions
Maestro supports two types of I/O: internal and external. "Internal" I/O's refers to devices
that are connected directly to the Maestro through its I/O ports (labeled DIGITAL I/O and
ANALOG INPUT). "External" I/O's refers to I/O devices that are connected to the
Maestro through the CAN network using the CANopen DS 401 protocol. External
devices can be controlled with
To get interrupts from a
and the
SimplIQ device must be initialized with an ADI command (value 1).
SimplIQ commands through the network.
SimplIQ device, the user program must contain a callback function
SimplIQ
4-40
Syntax : <Elmo axis name>.ADI=1 to initialized
<Elmo axis name>.ADI=0 to uninitialized
4.6.1 Maestro I/O Functions
Function m_din – get all Maestro digital inp uts valu es (in ternal digital input)
Call Format m_din
Parameters None
Example int inputData
intputData = m_din
for more details see: \SamplesTutorial\
CallBackFunctions\InputCallBack
Function m_din[] – g et specific digital input va lue (internal digital input)
Call Format m_din[dinput_num]
Parameters dinput_num=0…7
Example int input1data
intput1 = m_din[1]
for more details see: \SamplesTutorial\
CallBackFunctions\InputCallBack
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
4-41
Function
m_dout – set all Maestro digital outputs (internal digital output)
Call Format m_dout
Parameters None
Example int outputData
outputData = 255
m_dout = outputData
for more details see: \SamplesTutorial\
CallBackFunctions\InputCallBack
Function
m_dout[] – set specific digital output (internal digital output)
Call Format m_dout[output_num]
Parameters output_num=0..7
Example m_dout[2]=1
for more details see: \SamplesTutorial\ CallBackFunctions\
InputCallBack
Function
m_ain[] – get specific analog input (internal analog input)
Call Format m_ain[ainput_num]
Parameters ainput_num=0…3
Example int input1data
intput1 = m_ain[1]
for more details see ..\SamplesTutorial\MaestroAnalogInput
Function
m_ain[].offset – set offset for specific analog inpu t (internal an alog input)
Call Format m_ain[ainput_num].offset
Parameters ainput_num=0…3
Example int input1data
m_ain[1].offset = 10
for more details see: \SamplesTutorial\MaestroAnalogInput
Function
m_din.polarity, m_din.plr – used to define polarity of Maestro digital
input
Call Format variable = m_din.polarity - get polarity value
m_din.polarity = expression - set polarity value
Limitation 0 – 0xFF
Note: all of the polarity value bits defines the polarity for the
corresponding digital input channel: polarity 0x01 – for m_din[0]
(channel 0), polarity 0x02 – for m_din[1] (channel 1), polarity 0x04 – for
m_din[2] (channel 2), ect. For all 8 digital input channels the polarity
value is – 0xFF (binary value: 1111 1111).
Example m_din.plr = 0xFF
for more details see: \SamplesTutorial\
CallBackFunctions\InputCallBack
Maestro Software Manual General and Motion Instructions
MAN-MASSW (Ver. Q)
Function m_dout.polarity, m_dout.plr – used to define polarity of Maestro digital
output
Call Format variable = m_dout.polarity - get polarity value
m_dout.polarity = expression - set polarity value
Limitation0 – 0xFF
Note: all of the polarity value bits defines the polarity for the
corresponding digital output channel: polarity 0x01 – for m_dout[0]
(channel 0), polarity 0x02 – for m_dout[1] (channel 1), polarity 0x04 – for
m_dout[2] (channel 2), ect. For all 8 digital output channels polarity value
is – 0xFF (binary value: 1111 1111).
Example m_dout.plr = 0x0F
for more details see: \SamplesTuto rial\ Cal lBa ck Func tion s\InputC all Ba ck
4.6.2 CAN I/O Functions (DS 401 Object Properties)
For more details see the CiA CANopen DS 401 protocol.
To set output values: <output_name> = <value>
<output_name>[const_index]= <value>
To get output value: <val> = <output_name>
<val> = <output_name>[const_index]
To get input value: <val> = <input_name>
<val> = <input_name>[const_index]
To set one output channel values: <output_name>[channel_number] =
<boolean_value>
To get one output channel value: <boolean_value > =
<output_name>[channel_number]
To get one input channel value: <boolean_value> =
<input_name>[channel_number]
Device defined value: all bites, which determines input activate
are set to 1
Limitation
Type
Property
Default
Limitation
Type
0 – 0xFFFFFFFF
Unsigned integer
plr (polarity) – polarity input
0
0 – 0xFFFFFFFF
Unsigned integer
4.6.2.2 Digital Output
Property
Default
erm (errorm) – error mode output
0
Limitation
Type
Property
Default
Limitation
Type
Property
Default
Limitation
Type
Property
Default
Limitation
Type
0 – 0xFFFFFFFF
Unsigned integer
erv (errorv) – error value output
0
0 – 0xFFFFFFFF
Unsigned integer
flr(filter) – filter constant output
0
0 – 0xFFFFFFFF
Unsigned integer
plr (polarity) – polarity output
0
0 – 0xFFFFFFFF
Unsigned integer
Maestro Software Manual
MAN-MASSW (Ver. Q)
Chapter 5: MAXL Program Language
This chapter describes how to write Maestro programs using the MAXL programming
language.
5.1 Lexical Conventions
This section includes the fundamental elements of a MAXL (Multi Axis Language)
program, as they are interpreted by the compiler. These elements, called “lexical
elements” or “tokens”, are used to construct statements, definitions, declarations, and
so on, which are used to make programs. Tokens include:
• Comments
• Identifiers
• MAXL keywords
5-1
• Punctuations
• Operations
5.1.1 Comments
A comment is text that the compiler ignores but that is useful to programmers.
Comments are normally used to annotate code for future reference. The compiler
treats them as white space. You can use comments in testing to make certain lines of
code inactive.
MAXL comments (as with C++) are written in one of the following ways:
• /* (slash, asterisk) characters, followed by any sequence of characters
(including new lines), followed by the */ characters. This syntax is the
same as ANSI C.
• // (two slashes) characters, followed by any sequence of characters. A
new line not immediately preceded by a backslash terminates this form of
comment. This is commonly called a “single-line comment” (as in ANSI
C++).
The comment characters (/*, */, and //) have no special meaning within a character
constant, string literal, or comment. Comments using the first syntax, therefore, cannot
be nested. Consider this example:
/* Intent: Comment out this block of code.
Problem: Nested comments on each line of code are illegal.
a = b*56 /* Initialize file string */
b=a/17; c=b*cos(alfa) /* Print status message */
*/
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
The preceding code will not compile because the compiler scans the input stream from
the first /* to the first */ and considers it a comment. In this case, the first */ occurs at
the end of the initial file string comment. The last */ is then no longer paired with an
opening /*.
Note that the single-line form (//) of a comment followed by end of line can have
surprising effects. Consider this code:
function run()
a=b*(sqrt(c)+ // 5 )
end function
After preprocessing, the preceding code contains errors and appears as follows:
function run()
a=b*(sqrt(c)+
end function
5.1.2 Identifiers
5-2
An identifier is a sequence of characters used to denote one of the following:
• Variable name
• Object name
• Function name
• Label name
Syntax
identifier : {letter}({letter}|{digit})*
letter - one of the following:
_ a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
digit - one of the following:
0 1 2 3 4 5 6 7 8 9
5.1.3 MAXL Keywords
Keywords are predefined reserved identifiers that have special meanings. They cannot
be used as identifiers in your program. The following keywords are reserved for
MAXL:
Syntax
break
case
const
continue
else
elseif
end
exit
float
for
function
global
goto
if
int
otherwise
reset
return
switch
TRACE
wait
waitvar
while
until
AXIS
VECTOR
GROUP
PROGRAM
IO
NODE
TRJ
m_din
m_dout
m_ain
#define
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
5.1.4 Punctuators
Punctuators in MAXL have syntactic and semantic meaning to the compiler but do
not, of themselves, specify an operation that yields a value.
Syntax
! % ^ & * ( ) - + = /
| [ ] ; :"< >, #
The punctuators [ ] and ( ) must appear in pairs.
5.1.5 Operators
Operators specify an evaluation to be performed on one of the following:
• One operand (unary operator)
• Two operands (binary operator)
Table
5-1 lists the operators available in MAXL.
5-3
Operators follow a strict precedence, which defines the order of expressions
containing these operators. Operators associate with either the expression on their left,
or the expression on their right; this is called “associativity.” Operators in the same
group have equal precedence and are evaluated left to right in an expression unless
explicitly forced by a pair of parentheses, (). Table
5-1 shows the precedence and
associativity of MAXL operators (from highest to lowest precedence).
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
Table 5-1 Operator Precedence and Associativity
Operator Name or Meaning Associativity
( ) Function callLeft to right
. Member selection (object)Left to right
+ Unary plusNone
– Arithmetic negation (unary)None
* MultiplicationLeft to right
/ DivisionLeft to right
% Remainder (modulo) Left to right
+ AdditionLeft to right
– SubtractionLeft to right
5-4
<< Left shiftLeft to right
>> Right shiftLeft to right
< Less thanLeft to right
> Greater thanLeft to right
<= Less than or equal toLeft to right
>= Greater than or equal toLeft to right
== EqualityLeft to right
!= InequalityLeft to right
& Bitwise ANDLeft to right
^ Bitwise exclusive ORLeft to right
| Bitwise ORLeft to right
&& Logical ANDLeft to right
|| Logical ORLeft to right
= AssignmentRight to left
, Comma Left to right
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.1.6 Literals
Invariant program elements are called “literals” or “constants.” The terms “literal”
and “constant” are used interchangeably here. Literals fall into four major categories:
integer, named constant
Integer constants are constant data elements that have no fractional parts or
exponents. They always begin with a digit. You can specify integer constants in
decimal, octal, or hexadecimal form. They can specify signed or unsigned types and
long or short types.
To specify integer constants using octal or hexadecimal notation, use a prefix that
denotes the base. To specify an integer constant of a given integer type, use a suffix
that denotes the type.
To specify a decimal constant, begin the specification with a nonzero digit. For
example:
i = 157; // Decimal constant
To specify a hexadecimal constant, begin the specification with 0x or 0X (the case of
the “x” does not matter), followed by a sequence of digits in the range
a (or A) through f (or F). Hexadecimal digits a (or A) through f (or F) represent values
0 through 9 and
in the range 10 through 15.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
For example:
i = 0x3fff; // Hexadecimal constant
j = 0X3FFF; // Equal to i
5-6
5.1.6.2
Named Constant - #define and const.
Constants must be declared in the “global declarations” section, i.e. before the first
function. Named constants declared with #define are accessible only in the current
program. Constants declared using
const can be used by other programs.
#define is used to declare named constants locally. For example, if a program uses the
same constant several times, a named constant can be used as in the following
example:
// program : test1
#define AC 200000000
function run()
…
a1.ac=AC
a2.ac=AC
a1.dc=AC
a2.dc=AC
…
end function
To declare a global constant, which is visible to other programs and the command
interpreter, use
const as in the following example:
// program test1
const AC=200000000
function run()
…
a1.ac=AC
a2.ac=AC
a1.dc=AC
a2.dc=AC
…
end function
Now the command interpreter has access to the named constant:
>test1.AC
200000000
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5-7
5.1.6.3
Floating-Point Constant
Floating-point constants specify values that must have a fractional part. These values
contain decimal points (.) and can contain exponents.
Floating-point constants have a “mantissa,” which specifies the value of the number,
an “exponent,” which specifies the magnitude of the number, and an optional suffix
that specifies the constant’s type. The mantissa is specified as a sequence of digits
followed by a period, followed by an optional sequence of digits representing the
fractional part of the number. For example:
18.46
38.
The exponent, if present, specifies the magnitude of the number as a power of 10, as
shown in the following examples:
18.46e0 // 18.46
18.46e1 // 184.6
If an exponent is present, the trailing decimal point is unnecessary in whole numbers
such as
18E0.
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
5.1.6.4 String Literals
A string literal consists of one or more characters from the source character set
surrounded by double quotation marks ("). A string literal represents a sequence of
characters that, taken together, form a null-terminated string.
Syntax
string-literal
s-char-sequence :
s-char :
:
"s-char-sequence"
s-char
s-char-sequence s-char
any member of the source character set except the double quotation
mark (")
5-8
5.2 Basic Concepts
5.2.1 Declarations and Definitions
Declarations tell the compiler that a program element or name exists. Definitions
specify what code or data the name describes.
5.2.1.1
A declaration introduces one or more names into a program. MAXL supports
following syntactic of declarations:
Function declarations also serve as definitions.
Global variable declaration inside function body specified by a global keyword.
Syntax
Declarations
• Variable declaration
• Function declaration
• Global variable declaration inside body of function
int a,b // declaration global variables
function run() // begin function declaration
global int a // global variable declaration inside body of function
int c // local variable declaration in function run()
c=56
a=b+c // !!!error!!! variable b not declared in this function
a=c+17
end function // end of function declaration
5-9
5.2.1.2
Array Declarations
An "array declaration" names the array and specifies the type and the number of its
elements. The current release of MAXL supports only global arrays.
Syntax
array-declaration:
type-specifier array-name [define-dimension]
type-specifier:
int
float
define-dimension:
integer-constant
define-dimension , integer-constant
Examples:
int a[10],b[5] // declare global arrays
int xy_positions[100, 2] // declare multi dimensional array
function run() // begin function declaration
global int a[] // global array declaration inside of function
global int xy_positions[100,2]
a[0]=56 // define value of first element
end function // end function declaration
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5-10
5.2.1.3
A definition is a unique specification of a function or callback. Because definitions
must be unique, a program can contain only one definition for a given program
element.
Definitions
5.2.2 Program
A program consists of one-translation unit. Execution, in concept, begins in the
translation unit that contains the function run.
MAXL programs consist of following parts:
• Global variables declarations
• Functions and callback definitions
o global variable declaration for access inside of functions
o local variables declaration
o Program lines.
5.2.3 Startup and Termination
RUN is used to start a program startup. Programs are terminated at the end of a run
function or with the exit keyword.
5.2.3.1
A special function called run is the entry point to all MAXL programs. The compiler
does not predefine this function; rather, it must be supplied in the program text. The
declaration syntax for run is:
Program Startup – the run Function
Syntax
function run( )
//… Some code
end function
5.2.3.2
In MAXL, there are several ways to exit a program:
Program Termination
• Call the exit operator
• Finish program by finishing the run function
• Call the return operator from function run
5.2.3.2.1 exit Operator
exit operator immediately ends program flow.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.2.3.2.2 return Operator
Issuing a return operator from run is functionally equivalent to using the exit
operator. Consider the following example:
function run()
int i
…some code…
if(i>2)
exit
return
end if
...some code…
end function
The exit and return statements in the preceding example are functionally identical.
5.2.4 Types
MAXL supports three kinds of object types:
5-11
• Fundamental types
are built into the language (such as int and float).
Instances of these fundamental types are called “variables.”
• Object types
are built-in types with encapsulated methods and
properties (such as axis and vector).
• Debug strings
used for formatting debug messages
5.2.4.1 Fundamental Types
Fundamental types in MAXL are divided into two categories: integer and floating.
The following table explains the restrictions on type sizes.
Table 5-2 Fundamental Types of the MAXL
CategoryTypeContents
Integer
Floating
5.2.4.2
int
float
Object Types
32 bits integer type.
64 bits float point type. Like double in C/C++
An object is a base unit of the Maestro.
There are several types of MAXL objects:
• Axis
• Vector
• Group
• Trajectory
• Program
Each of these objects is defined by its name and uses a specific set of attributes. These
attributes set depends upon object type.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
MAXL supports two kinds of object attributes:
•Command
o Getter
o Setter
o Getter/Setter
o Executer
• Method
5.2.4.3 Debug string
To facilitate the debugging process MAXL supports run-time debug messages. It is
very similar to the TRACE macro in the MFC. The program places the TRACE
operator inside MAXL program source code with formatted debug strings. This string
will appear in the Elmo Studio when the program executes to this point. Elmo Studio
uses a debug window to display debug messages.
Syntax
TRACE ( format-string [, arguments])
5-12
Examples:
function fun(int val)
TRACE(“input value : %”, val)
…
end function
This example shows how to use the debug mechanism to retrieve the real-time value
of variable val.
5.3 Standard Conversions
•Automatic conversion from integer to float and vice versa is
performed.
For example:
int i
float f
i = 5.5 // after this program line is executed, variable i contains 5
f = i // after this program line is executed variable f contains 5 as well
• Type of any binary operation is defined according to operands type:
First
Operand
Type
Second Operand
Type
Result Type
Integer Integer Integer
Float Integer Float
Integer Float Float
Float Float Float
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
•The type of result does not depend upon the type of operands. The
result of a logical operation is either true (1) or false (0).
• Operator ‘%’(modulo) is used only for integer operands.
• Bitwise operators are used only for integer operands.
5.4 Expressions
Expressions are sequences of operators and operands that are used for one or more of
these purposes:
• Computing a value from the operands.
• Designating objects or functions.
• Generating “side effects.” (Side effects are any actions other than the
evaluation of the expression — for example, modifying the value of an
object.)
5-13
5.4.1 Types of Expressions
MAXL expressions are divided into several categories:
• Primary expressions. These are the building blocks from which all other
expressions are formed.
• Postfix expressions. These are primary expressions followed by an operator
— for example, the array subscript or postfix increment operator.
• Expressions formed with unary operators. Unary operators act on only one
operand in an expression.
• Expressions formed with binary operators. Binary operators act on two
operands in an expression.
• Logical Operators. Used to combine multiple conditions formed using
relational or equality expressions.
• Simple Assignment.
5.4.1.1 MAXL Primary Expressions
Primary expressions are the building blocks of more complex expressions. They are
literals and names.
Syntax
primary-expression:
literal
( expression )
name
A literal is a constant primary expression. Its type depends on the form of its
specification. See Literals
for complete information about specifying literals.
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
An expression enclosed in parentheses is a primary expression whose type and value
are identical to those of the unparenthesized expression.
5.4.1.1.1 Names
In the MAXL syntax for primary-expression, a name is a primary expression that can
appear only after the member-selection operators and names the attribute of an object.
Syntax
name :
identifier
object . attribute
5.4.1.2 Postfix Expressions
Postfix expressions consist of primary expressions or expressions in which postfix
operators follow a primary expression.
5-14
The postfix operators are listed in the table below:
Table 5-3
Postfix Operators
Operator Name Operator Notation
Get array element
Function call operator
Method selection
[ ]
( )
.
operator
Postfix increment
++
operator
Postfix decrement
– –
operator
Syntax
postfix-expression :
array-name [expression]
function-name (<expression-list>)
object . method (<expression-list>)
name ++
name - expression-list :
expression
expression-list , expression
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.2.1 Get Array Item Operator
A postfix-expression followed by the "get array" element operator [ ], specifies array
indexing.
5.4.1.2.2 Function-Call Operator
A postfix-expression followed by the function-call operator, ( ), specifies a function call.
The arguments to the function-call operator are zero or more expressions separated by
commas — the actual arguments to the function.
5.4.1.3 Expressions with Unary Operators
Unary operators act on only one operand in an expression. The unary operators are:
• Unary Plus Operator (+)
• Unary Minus Operator (–)
5-15
• Logical NOT Operator (!)
These operators have right-to-left associativity.
Syntax
unary-expression:
postfix-expression
++ name
–– name
unary-operator expression
unary-operator: one of the following
+ – !
5.4.1.3.1 Unar y Plus Operator (+)
The result of the unary plus operator (+) is the value of its operand. The operand to
the unary plus operator must be of an arithmetic type.
Integer promotion is performed on integer operands. The resultant type is the type to
which the operand is promoted
5.4.1.3.2 Unar y Minus Operator (-)
The unary minus operator (–) produces the negative of its operand. The operand to
the unary negation operator must be an arithmetic type.
5.4.1.3.3 Logical NOT Operator (!)
The result of the logical NOT operator (!) is 0 if its operand evaluates to a nonzero
value; the result is 1 only if the operand is equal to 0. The operand must be of
arithmetic or pointer type. The result is an int type.
For an expression e, the unary expression !e is equivalent to the expression
(e == 0).
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
The following example illustrates the logical NOT operator (!):
if( !(x < y) )
If x is greater than or equal to y, the result of the expression is 1 (true). If x is less than
y, the result is 0 (false).
Unary arithmetic operations on pointers are illegal.
5.4.1.4 Expressions with Binary Operators
Binary operators act on two operands in an expression. The binary operators are:
• Multiplicative Operators
• Multiplication (*)
• Division (/)
• Modulo (%)
• Additive Operators
• Addition (+)
• Subtraction (–)
5-16
• Shift Operators
• Right shift (>>)
• Left shift (<<)
• Relational and Equality Operators
• Less than (<)
• Greater than (>)
• Less than or equal to (<=)
• Greater than or equal to (>=)
• Equal to (==)
• Not equal to (!=)
• Bitwise Operators
• Bitwise AND (&)
• Bitwise exclusive OR (^)
• Bitwise inclusive OR (|)
• Logical AND (&&)
• Logical OR (||)
5.4.1.4.1 MAXL Mul tiplicative Operators
The multiplicative operators are:
• Multiplication (*)
• Division (/)
• Modulo or “remainder from division” (%)
These binary operators have left-to-right associativity.
The multiplicative operators take operands of arithmetic types. The modulo operator
(%) has a stricter requirement in that its operands must be integer type.
The multiplication operator yields the result of multiplying the first operand by the
second.
The division operator yields the result of dividing the first operand by the second.
The modulo operator yields the remainder given by the following expression, where
e1 is the first operand and e2 is the second: e1 – (e1 / e2) * e2, where both operands are
of integer types.
5-17
Division by 0 in either a division or a modulo expression is undefined and causes a
run-time error. Therefore, the following expressions generate undefined, erroneous
results:
i % 0
f / 0.0
If both operands to a multiplication, division, or modulo expression have the same
sign, the result is positive. Otherwise, the result is negative. The result of a modulo
operation’s sign is implementation-defined
5.4.1.4.2
5.4.1.4.3 MAXL Additive Operators
The additive operators are:
• Addition (+)
• Subtraction (–)
These binary operators have left-to-right associativity.
The additive operators take operands of arithmetic type. The result of the addition (+)
operator is the sum of the operands. The result of the subtraction (–) operator is the
difference between the operands.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.4.4 MAXL Shi ft Operators
The bitwise shift operators are:
• Right shift (>>)
• Left shift (<<)
These binary operators have left-to-right associativity.
Syntax
shift-expression :
expression << expression
expression >> expression
expression:
additive-expression
Both operands of the shift operators must be integer types. The type of the result is the
same as the type of the left operand. The value of a right-shift expression e1 >> e2 is e1
e2
/ 2
, and the value of a left-shift expression e1 << e2 is e1 * 2e2.
5-18
The results are undefined if the right operand of a shift expression is negative or if the
right operand is greater than or equal to the number of bits in the (promoted) left
operand.
The left-shift operator causes the bit pattern in the first operand to be shifted left by
the number of bits specified by the second operand. Bits vacated by the shift operation
are zero-filled. This is a logical shift, as opposed to a shift-and-rotate operation.
The right-shift operator causes the bit pattern in the first operand to be shifted right
the number of bits specified by the second operand. Bits vacated by the shift operation
are zero-filled for unsigned quantities. For signed quantities, the sign bit is propagated
into the vacated bit positions. The shift is a logical shift if the left operand is an
unsigned quantity; otherwise, it is an arithmetic shift.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.4.5 MAXL Rel ational and Equality Operator s
The relational and equality operators determine equality, inequality, or relative values
of their operands. The relational operators are shown in the table below.
Table 5-4 Relational and Equality Operators
Operator Meaning
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
5-19
>= Greater than or equal to
5.4.1.4.5.1 Relational Operators
The binary relational operators determine the following relationships:
The relational operators have left-to-right associativity. Both operands of relational
operators must be of arithmetic type. They yield values of type int. The value returned
is 0 if the relationship in the expression is false; otherwise, it is 1.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.4.5.2 Equality Operators
The binary equality operators compare their operands for strict equality or inequality.
Syntax
equality-expression :
expression == expression
expression != expression
expression:
equality-expression
The equality operators, equal to (==) and not equal to (!=), have lower precedence
than the relational operators, but they behave similarly.
The equal-to operator (==) returns 1 if both operands have the same value; otherwise,
it returns 0. The not-equal-to operator (!=) returns 1 if the operands do not have the
same value; otherwise, it returns 0.
Equality operators can compare pointers to members of the same type.
5-20
5.4.1.4.6 MAXL Bitw ise Operators
The bitwise operators are:
• Bitwise AND (&)
• Bitwise exclusive OR (^)
• Bitwise inclusive OR (|)
These operators return bitwise combinations of their operands
5.4.1.4.6.1 Bitwise AND Operator
The bitwise AND operator (&) returns the bitwise AND of the two operands. All bits
that are on (1) in both the left and right operand are on in the result; bits that are off
(0) in either the left or the right operand are off in the result.
Syntax
and-expression :
expression & expression
expression:
and-expression
Both operands to the bitwise AND operator must be integer types.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.4.6.2 Bitwise Exclusive OR Operator
The bitwise exclusive OR operator (^) returns the bitwise exclusive OR of the two
operands. All bits that are on (1) in either the left or right operand, but not both, are on
in the result. Bits that are the same (either on or off) in both operands are off in the
result.
Syntax
exclusive-or-expression :
expression ^ expression
expression:
exclusive-or-expression
Both operands to the bitwise exclusive OR operator must be integer types.
5.4.1.4.6.3 Bitwise Inclusive OR Operator
The bitwise inclusive OR operator (|) returns the bitwise inclusive OR of the two
operands. All bits that are on (1) in either the left or right operand is on in the result.
Bits that are off (0) in both operands are off in the result.
5-21
Syntax
inclusive-or-expression :
expression | expression
expression:
inclusive-or-expression
Both operands to the bitwise inclusive OR operator must be integer types.
5.4.1.5
MAXL Logical Operators
The logical operators, logical AND (&&) and logical OR (||), are used to combine
multiple conditions formed using relational or equality expressions.
5.4.1.5.1 Logical AND Operator
The logical AND operator (&&) returns the integer value 1 if both operands are
nonzero; otherwise, it returns 0. Logical AND has left-to-right associativity.
Syntax
logical-and-expression :
expression && expression
expression:
logical-and-expression
The operands to the logical AND operator must be integer types. The operands are
commonly relational or equality expressions. The first operand is completely
evaluated and all side effects are completed before continuing evaluation of the logical
AND expression.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.1.5.2 Logical OR Operator
The logical OR operator (||) returns the integer value 1 if either operand is nonzero;
otherwise, it returns 0. Logical OR has left-to-right associativity.
Syntax
logical-or-expression :
expression || expression
expression:
logical-or-expression
The operands to the logical OR operator must be an integer type. The operands are
commonly relational or equality expressions.
The first operand is completely evaluated and all side effects are completed before
continuing evaluation of the logical OR expression.
5-22
5.4.1.6
Simple Assignment
The simple assignment operator (=) causes the value of the second operand to be
stored in the object specified by the first operand. If both objects are of arithmetic
types, the right operand is converted to the type of the left, prior to storing the value.
5.4.1.7
Size of Array
MAXL’s array supports a “size” operator. This operator retrieves the size of an array.
Syntax
array-size:
array-name.size
This operator may be useful in the next construction:
Example:
int a[10] // declaration global array
function run() // begin of function declaration
global int a[] // global array declaration inside function body
int I // declare local variable
for i=0:(a.size-1) // loop from 0 to 9
// 10 is retrieved from the global array declaration
// 10-1 is 9
a[i]=1 // set each array element to 1
end for
end function // end of function declaration
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.4.2 Semantics of Expressions
This section explains when, and in what order, expressions are evaluated.
5-23
5.4.2.1
Order of Evaluation
This section discusses the order in which expressions are evaluated but does not
explain the syntax or the semantics of the operators in these expressions.
Consider this example:
function run()
int a , b , c, res1, res2, res3
a = 2
b = 4
c = 9
res1 = a + b * c
res2 = a + (b * c)
res3 = (a + b) * c
end function
The output from the preceding code is:
res1 = 38
res2 = 38
res3 = 54
The order in which the res1 is evaluated is determined by the precedence and
associativity of the operators:
1. Multiplication (*) has the highest precedence in this expression; hence the
sub expression
2. Addition (+) has the next highest precedence, so
b and c.
b * c is evaluated first.
a is added to the product of
3. Assignment operator (=) has the lowest precedence in the expression.
When parentheses are used to group the sub expressions, they alter the precedence
and also the order in which the expression is evaluated
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.5 Statements
MAXL statements are the program elements that control how and in what order
objects are manipulated.
MAXL statements are executed sequentially, except when an expression statement, a
selection statement, an iteration statement, or a jump statement specifically modifies
that sequence.
To transfer program control directly to a given statement, the statement must be
labeled.
Syntax
labeled-statement
##identifier statements
case (
otherwise
5.5.1.1
The appearance of an identifier label in the source program declares a label. Only a
goto statement can transfer control to an identifier label. The following code fragment
illustrates use of the goto statement and an identifier label to escape a nested loop:
Using Labels with the goto Statement
Syntax
goto labeled-statement
labeled-statement
Example:
for ( i = 0 : 2 : 20 )
for( j = 2 : 16 )
if( i > j+10)
goto ##label
end if
end for
end for
## label
I=0
:
expression) statements
statements
:
A label cannot appear by itself but must
always be attached to a statement.
The label has function scope and cannot
be re-declared within the function.
However, the same name can be used as a
label in different functions.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5-25
5.5.1.2
Labels that appear after the case keyword cannot also appear outside a switch
statement. (This restriction also applies to the otherwise keyword.) The following
code fragment shows the correct use of case labels:
Using Labels in the case Statement
Syntax
case (expression)
Example:
switch( cmd )
case(1) //begin motion
axis.bg
case(2) // motor On
axis.mo = 1
case(3) // motor Off
axis.mo = 0
otherwise // get motor status
cmd = axis.ms
end switch
5.5.2 Selection Statements
The MAXL selection statements, if and switch, provide a means to conditionally
execute sections of code.
Syntax
selection-statement
expression
if (
if (
expression
switch (
5.5.2.1
The if statement evaluates the expression enclosed in parentheses. The expression
must be an arithmetic type. In both forms of the if syntax, if the expression evaluates
to a nonzero value (true), the statement dependent on the evaluation is executed;
otherwise, it is skipped. In the if...else syntax, the second statement is executed if the
result of evaluating the expression is zero.
The MAXL if Statement
:
)
statement
)
statement
expression
)
statement
end [ if]
else
statement
end [ switch ]
end [ if]
Syntax
if ( expression ) statement end [ if]
if ( expression ) statement else statement end [ if]
Example:
if (b == 4 )
if( c == 18 )
a=1 // b is 4; c is 18
else
a=2 // b is 4; c isn`t 18
end if
else
a=3 // b isn`t 4;
end if
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.5.2.2 The MAXL switch Statement
The MAXL switch statement allows selection among multiple sections of code,
depending on the value of an expression.
The switch statement causes an unconditional jump to, into, or past the statement that
is the “switch body,” depending on the value of the controlling expression, the values
of the case labels, and the presence or absence of a otherwise label.
The switch body is normally a compound statements (although this is not a syntactic
requirement). Usually, some of the statements in the switch body are labeled with case
labels or with the otherwise label. Labeled statements are not syntactic requirements,
but the switch statement is meaningless without them. The otherwise label can appear
only once.
Syntax
switch ( expression ) case-statements end [ switch ]
case-statements:
5-26
case (expression) statements
otherwise statements
The expression in the case label is converted to the type of the controlling expression
and is then compared for equality. The behavior is shown in the table below.
Table 5-5 Table Switch Statement Behavior
Condition Action
Converted value matches that of the
promoted controlling expression.
None of the constants match the constants
in the case labels; otherwise label is
Control is transferred to the
statement following that label.
Control is transferred to the
otherwise label.
present.
None of the constants match the constants
in the case labels; otherwise label is not
present.
Control is transferred to the
statement after the switch
statement.
A switch statement can be nested. In such cases, case or otherwise labels associate
with the most deeply nested switch statements that enclose them. For example:
switch( attribute_type)
case (1) // Object attribute is command.
switch( cmdName)
case (1) // Begin motion command.Axis.bg
case( 2) // Motor On command.
Axis.mo=1
end switch
case (3) // Object attribute is method.
...
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
otherwise
TRACE (“Error attribute ”)
end switch
The preceding code fragment shows how switch statements can be nested.
The switch statement that selects on the value of
cmdName is executed only if attribute is
1. The case labels for menu selections, 1 (BG) and 2 (MO=1), associate with the inner
switch statement.
5.5.3 Iteration Statements
Iteration statements cause statements (or compound statements) to be executed zero
or more times, subject to some loop-termination criteria. When these statements are
compound statements, they are executed in order, except when either the break
statement or the continue statement is encountered. For a description of these
statements, see The break Statement
MAXL provides two iteration statements — while and for. Each of these iterates until
its termination expression evaluates to zero (false), or until loop termination is forced
with a break statement.
and The continue Statement sections.
5-27
Syntax
iteration-statement :
while ( expression ) statements end while
for identifier-variable=expression : [step-expression :] terminate-expression
statements
end for
5.5.3.1
The MAXL while Statement
The while statement executes a statement repeatedly until the termination condition
(the expression) specified evaluates to zero.
The test of the termination condition takes place before each execution of the loop;
therefore, a while loop executes zero or more times, depending on the value of the
termination expression.
Syntax
while ( expression ) statements end while
Example:
while( attribute < 56)
attrbute=attribute+17
TRACE(“Attribute : %”, attribute)
end while
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
5.5.3.2 The MAXL for Statement
The for statement can be divided into three separate parts, as shown in
Table 5-6 Table for Loop Elements
5-28
Syntax
When Executed Contents
Name
Identifier-variable
= expression
Before any other element
of the for statement or the
Used to initialize loop
indices.
substatement.
stepexpression
terminateexpression
Before execution of a
given iteration of the
loop, excluding the first
iteration.
At the end of each
iteration of the loop.
Calculates iteration
step. If this field is
absent iteration step is
1.
Used as looptermination criteria.
The for-statement executes the statements repeatedly until the identifier-value is less or
equal to terminate-expression value. The step-expression field is optional. If the step-expression has a negative value then the for-statement executes the statements
repeatedly until the identifier-value is greater than or equal to the terminate-expression
value.
Syntax
for identifier-variable=expression : [step- expression :] terminate-expression
statements
end for
Example:
for i=1:1:10
test(i)
end for
5.5.4 Jump Statements
The MAXL jump statements perform an immediate local transfer of control.
Syntax
jump-statement:
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
break
continue
return
goto identifier
5-29
5.5.4.1
The break statement is used to exit an iteration statement. It transfers control to the
statement immediately following the iteration statement.
The break statement terminates only the most tightly enclosing loop. In loops, break
is used to terminate before the termination criteria evaluate to 0.
The MAXL break Statement
Syntax
break
The following example illustrates the use of the break statement in a while loop:
While(1) // No termination condition.
if( program.status() == 2) //program halt
break
end while
Note
There are other simple ways to escape a loop. It is best to use the break
statement in more complex loops, where it can be difficult to tell whether the loop
5.5.4.2
should be terminated before several statements have been executed
The MAXL continue Statement
.
The continue statement forces immediate transfer of control to the loop-continuation
statement of the smallest enclosing loop. (The “loop-continuation” is the statement
that contains the controlling expression for the loop.) Therefore, the continue
statement can appear only in the dependent statement of an iteration statement.
Syntax
continue
5.5.4.3
The return statement allows a function to immediately transfer control back to the
calling function. A function can have any number of return statements.
The MAXL return Statement
Syntax
return
5.5.4.4
The goto statement performs an unconditional transfer of control to the named label.
The label must be in the current function.
The goto Statement
Syntax
goto labeled-statement
Maestro
MAN-MASSW (Ver. Q)
Software ManualMAXL Program Language
5-30
labeled-statement
##identifier
:
5.5.4.5
Declaration statements introduce new names into the current function. Before using
global variable inside function it must be declared by keyword global.
Declaration Statements
Syntax
declaration-statement:
global type name-list
type name-list
type:
int
float
name-list:
name
name-list , name
Multiple declarations of the same name in the same function are illegal.
5.6 Functions
5.6.1 Function Definition
A function definition specifies the name of the function, the types and number of
arguments it expects to receive, and types and number of return arguments. A
function definition also includes a function body with the declarations of its local
variables, and the statements that determine what the function does.
function-definition:
function function-name ( argument-list )
function-body
end function
function [ type variable-name ] = function-name ( argument-list )
function-body
end function
function [ argument-list ] = function-name ( argument-list )
function-body
end function
argument-list:
type name
argument-list , type name
function-body:
Maestro
MAN-MASSW (Ver. Q)
Software Manual MAXL Program Language
declaration-statements statements
5-31
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
Examples:
function int max_value = MAX_INT(int a, int b, int c)
int max_a_b
if(a>b)
max_a_b = a
else
max_a_b = b
end if
if(max_a_b > c)
max_value = max_a_b
else
max_value = c
end if
end function
This function, named MAX_INT, has three integer input arguments (a, b, c) and one
integer return argument (max_value). The function body includes one declaration-statement (local integer variable max_a_b) and two if-else statements.
5-32
function [int min1, int min2] = MIN_2_INT(int a, int b, int c)
int max_a_b
int min_a_b
if(a>b)
max_a_b = a
min_a_b = b
else
max_a_b = b
min_a_b = a
end if
if(max_a_b > c)
min1 = min_a_b
min2 = c
else
min1 = a
min2 = b
end if
end function
This function, named MIN_2_INT, has three integer input arguments (a, b, c) and two
integer return arguments (min1, min2). Function body includes two declaration-statements (local integer variables max_a_b and min_a_b) and two if-else statements.
The If function does not need to return arguments, it’s header does need to contain
any return argument. For example:
function foo()
// to do something’s
……
end function
This function does not return any values.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.6.2 Built-in Functions
Table 5-7 MAXL has predefined functions.
5-33
Function
Name
sin float float
cos float float
Input
Argument(s)
Return
Argument(s)
Remarks
tan float float
asin float float
Trigonometry functions, input angle value
in radians.
acos float float
atan float float
exp float float
Calculates the exponential function value
of a floating-point number.
pow float x,
float y
log float float
float
Calculates the value of x raised to the
power of y, x^y.
Calculates the natural logarithm (base e)
of a floating-point number
log10 float float
Calculates the common logarithm (base
10) of a floating-point number.
min float a,
float
Returns minimum value
float b
max float a,
float
Returns maximum value
float b
abs float float
Calculates the absolute value of a floatingpoint number.
sqrt float float
Calculates the square root of a floatingpoint number.
round float int
floor float float
Rounds float value to integer.
Calculates the floor (greatest integer less
than or equal to) value of a number.
ceil float float
Calculates the ceiling (smallest integer
greater than or equal to) value of a number.
This is the result of rounding up.
sync int busId,
float delay
Starts CanOPEN SYNC mechanism. BusID
– bus identifier [1,2]. Delay in
milliseconds, minimum value 1.
tstamp int busId,
Defines TIME-STAMP interval in number
int
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5-34
sync_coun
t
message int msgID,
int
int data1,
int data2
messagex int msgID,
int
int data1,
int data2
systime - int
systimex - int
SYNC messages. Default value 50.
Posts messages from the Maestro to the
host computer. The user chooses the
message ID according to logic of the
application. Function returns 0 if the
message was not accepted by even one
listener. Otherwise returned value is equal
to 1.
Posts message from the Maestro to host
computer (as in the previous case). But
the message in this case includes
automatically obtained CAN bus time in
microseconds.
Returns system defined time in
milliseconds.
Returns CAN bus time in microseconds.
5.6.3 Callback (interrupt) Functions
MAXL supports a callback function mechanism. The callback function is called, by the
system, when a specific event occurs.
Below is an sample callback definition:
function @callback-name ( argument-list )
function-body
end function
MAXL supports the following callback functions (note: the functions begin with an
"@"):
•@perror(int error_number) – called when a runtime error occurs
error_number contains error code.
When a runtime error occurs the MAXL program status is set to ABORT.
If the @perror callback function was declared, the function will be called
first and program finished with a HALT status. Use the restart keyword in
@perror callback function to restart program. Without the callback
function, the program would stop immediately upon reaching a runtime
error.
•@emcy(int busID, int nodeID, int first4bytes, int second4bytes) – called
when the CANopen EMERGENCY message appears on the bus.
o BusID – CAN bus identifier [0,1].
o NodeID – CAN node identifier [1,127].
o First4bytes – first 4 bytes CAN message data.
o Second4bytes – last 4 bytes CAN message data.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
• @emcy(int nodeID, int first4bytes, int second4bytes)
o NodeID – CAN node identifier [1,127].
o First4bytes – first 4 bytes CAN message data.
o Second4bytes – last 4 bytes CAN message data.
• @emcy(int nodeID, int first4bytes)
o NodeID – CAN node identifier [1,127].
o First4bytes – first 4 bytes CAN message data.
•@hbevent(int busID, int nodeID, int nodeState) – called when the CAN
node state is changed. For example, when a node has stopped producing
heartbeat messages, this function is called and returns a state value of –1.
The Maestro supports the following CAN node states:
5-35
Name
Valu
e
Boot Up 0
Pre operation 127
Operation 5
Stopped 4
No Heartbeat -1
•@motioncompleted(int busId, int objId) - called when the target
reached event appears for the motion object (axis, vector, group). The
event must be previously initialized for selected motion object (See
also: amc, vmc, gmc property)
o BusID – CAN bus identifier [0,1].
o ObjID – CAN node or group identifier [1,127].
•@emit(int busId, int nodeId, int data) - called when the Simple IQ
program emit event (by command emit(channel_num)). The event
must be previously initialized for selected Elmo axis (See also: ape
property)
o BusID – CAN bus identifier [0,1].
o NodeID – CAN node identifier [1,127].
o Data – event data (channel number), channel number can be
1, 3 or 4.
•@input(int busId, int nodeId, int data) - called when the input event
appears for Maestro or Simple IQ drive. The event must be previously
initialized for selected Elmo axis (See also: adi property). Maestro input
always is initialized.
o BusID – CAN bus identifier [0,1].
o NodeID – CAN node identifier [0 - 127]. If NodeID = 0 –
this is the Maestro input event, NodeID = 1 – 127 – drive
digital input event.
o Data – input data.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
Example:
function @perror(int error_number)
if(number == 1)
TRACE (“Divided by zero! ”)
end if
restart
end function
5.7 Virtual Machine Control Statements
5.7.1 wait control statement
The wait keyword suspends the execution of the program until the specified time has
elapsed. The expression may be within round parentheses or without parentheses. The
expression specifies the waiting time in milliseconds. It can be a numerical expression
only, which is evaluated in a single value.
5-36
Syntax
wait(numerical-expression)
Example:
function foo()
// do something
……
wait(1000) // program waiting one second
end function
5.7.2 waitvar control statement
The waitvar keyword suspends the execution of the program until the specified
variable value has changed or timeout elapsed. Variable name specifies the global
variable for waiting. The expression specifies the waiting time in milliseconds. It can
be numerical expression only, which is evaluated in a single value.
Syntax
waitvar(variable-name, numerical-expression)
Example:
function foo()
// do something
……
waitvar(g_var, 1000) // program wait for g_var to chang in one second
end function
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5.7.3 until control statement
The until keyword suspends the execution of the program until the specified
expression has a false value (0).
Syntax
until(expression)
Example:
function foo()
// do something
……
until(g_var>0) // program wait until g_var >0
end function
5.7.4 TRACE control statement
5-37
To send messages from the virtual machine to Elmo Studio uses a program statement
with a TRACE keyword. The Elmo Studio is the standard IDE for development and
debugging of MAXL programs. If Maestro’s virtual machine comes across a statement
with TRACE during debugging MAXL programs, an Elmo Studio output window
appears with a TRACE message.
5.7.5 reset control statement
The reset keyword is used to restart the program. After a program reaches a reset,
program flow will be restarted from the next run function. At the same time the entire
call function stack resets.
5.8 Difference Between Static and Dynamic Group
The Maestro supports both static and dynamic group. Table 5-8 below describes the
differences between the two groups.
Table 5-8 Static and Dynamic Groups
Feature Static Group Dynamic Group
Dynamic Group is created
always independently of the
amount switched-on nodes in
the group.
Definition
Static Group is a group
created only if all nodes of
the group exist
Size of group
Number of nodes in the
group after its initialization
Number of switching-on nodes
in the group after the Maestro restarts or performs a Refresh
function call.
Maestro Software Manual MAXL Program Language
MAN-MASSW (Ver. Q)
5-38
Recipients of
group
commands
Command
Control
Initialization of
several groups
Group usage
Switching-on a
node in a group
during program
performance
All elements which are
certain for the given group
Only to switching-on nodes
certain for the given group
The same for both the Static and Dynamic group.
The Maestro sends a command to all nodes, in the case of the
Static Group, and to all switching-on nodes, in the case of
Dynamic Group, and waits for a response.
The same node can belong to
various groups.
The conflict is solved using
the following commands:
attach()/detach()
All nodes MUST exist
(switching-on) upon group
operation
Each group has a unique set of
nodes.
Each node belongs to one group only. The commands
attach()/detach() are not
applicable.
At least one node MUST exist
(switching-on) when calling a
group operation
After switching-on, the node is
Not applicable
automatically connected to a
group
Switching-off a
node from the
group during
program
performance
Initialization of
Run time error Run time error.
Solution
: Call “refresh”
function before using group
operation .
See Fig 1 and Fig 2
group (create
group in
resource file)
5.8.1 Recommendations on using dynamic groups
1. Use only for mechanically independent nodes.
2. Pay attention that switching-on node will connect to dynamic group
automatically.
Loading...
+ 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.