SPiiPlus ACSPLplus Programmers Guide (V4-20)
SPiiPlus ACSPLplus Programmers Guide (V4-20)
Programmer’s Guide
Website: http://www.AcsMotionControl.com/
E-mail: [email protected]
[email protected]
4.20 July 03 5-55 sysinfo function now supports retrieving analog I/O voltage
ranges and the size of the controller DPRAM (DPRAM is
available in PCI models only).
4.20 July 03 9-8 New analog I/O section includes description of signal monitoring
via the outputs.
4.20 July 03 5-94 start, call, and goto commands no longer support line-number
argument, only label-name argument.
4.20 July 03 8-40 Extended fault handling capabilities.
4.20 July 03 7-21 Mechanical braking via digital outputs.
4.20 July 03 6-10 New motion command: track. Generates a new move each time
the TPOS (target position) variable changes.
4.20 July 03 Pg. 11-34, New motion-related standard variables: GMTYPE (motion type)
Pg. 11-69 and TPOS (target position).
4.20 July 03 10-5 DPRAM (PCI-based controllers) functionality expanded with two
new commands:
• The copyfromdpr command instructs the controller to
continuously copy values from the DPRAM to standard
variables.
• The stopcopytodpr command cancels all previously
executed copytodpr and copyfromdpr commands, stopping
the copying of variables to/from the DPRAM.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
R e c e n t C h a n ge s t o t hi s G ui de III
CONTENTS
FIGURES XVII
1. INTRODUCTION 1-1
2. GLOSSARY 2-1
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
C o n ten t s VI I
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
C o n t en t s IX
5.8.7. BITWISE AND LOGICAL OPERATORS & (AND), | (OR), ~ (EXCLUSIVE OR (XOR)) 5-70
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
C o n t en t s XI
6. MOTION 6-1
6.1. POINT TO POINT MOTION 6-1
6.8.1. MSEG, PROJECTION, LINE, ARC1, ARC2, STOPPER, ENDS COMMANDS 6-33
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
C o nt en t s XII I
8.3.3. USING THE FAULT BITS IN COMMANDS: IF, WHILE, TILL 8-11
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
C o n t ent s XV
10.1.1. PEG OUTPUT ASSIGNMENT FOR SPIIPLUS PCI-4/8 AND SPIIPLUS PCI-DDM4 10-1
10.2.1. BRAKE OUTPUT ASSIGNMENT FOR SPIIPLUS PCI-4/8 AND SPIIPLUS PCI-DDM4 10-3
10.3. DPRAM FOR FAST HOST COMMUNICATION (PCI-BASED CONTROLLER MODELS) 10-5
INDEX 12-1
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Fi gu r es XVI I
FIGURES
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In t ro d u c t io n 1-1
1. INTRODUCTION
This guide describes the ACSPL+ programming language for SPiiPlus™ motion controller
products. ACSPL+ is a powerful programming language developed specifically for SPiiPlus
motion controllers. ACSPL+ incorporates many advanced features, including:
powerful programming elements such as arithmetical and logical expressions, user-defined
variables with local and global scope, user-defined one- and two-dimensional arrays
execution of up to 10 programs simultaneously
program isolation: each program resides in a separate buffer
rich set of motion types, providing a large degree of versatility
advanced implementation of master-slave motion
axis-independent programming
on-condition autoroutines
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In t ro d u c t io n 1-3
Document Description
Tool Description
Tool Description
SPiiPlus C Library A DLL (Dynamic Link Library) that supports host application
programming in a variety of languages including C/C++ and
Visual Basic. The library introduces a new level of application
support with a built-in controller simulator and it also provides
outstanding debugging capabilities. All tools are provided with
a full simulator of the controller.
SPiiPlus SPiiDebugger A developing and debugging environment for real-time motion
control algorithms.
Text Description
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In t ro d u c t io n 1-5
Warning
A warning describes a condition that may result in serious bodily injury or death
Caution
A caution describes a condition that may result in damage to equipment
Note
Notes contain helpful information and tips
MODEL
DEPENDENT
Highlights a specification, procedure, condition, or statement that
depends on the product model.
2. GLOSSARY
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Glo s sar y 2- 3
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Glo s sar y 2- 5
leading axis The first specified axis in an axis group. The standard variables
related to the leading axis define motion parameters for the
entire group. The same variables of other axes in the group
have no effect on the group motion.
local variables Variables that are accessible only within the buffer that they
are declared.
A variable can have either global or local scope. All standard
variables have global scope. A scope of user variable is
assigned in the variable declaration.
mark A dedicated controller input signal that latches the current
encoder position (saves the position to a register). The register
value is assigned to the MARK variable. A similar mechanism
supports secondary encoders, with the input signal called
MARK2 and the value assigned to the M2ARK variable.
master-slave motion Motion that evolves according to some external or internal
signal, as opposed to the time-based motion that evolves as a
function of the time.
In a simple case, an axis involved in a master-slave motion can
reproduce the motion of another axis.
matrix A two-dimensional array.
motion Process in the controller that results in a change in internal
variables of the controller, and can result in physical effects
such as motor movement.
motion profile Diagram of position or velocity against the time in a time-
based motion. The controller provides a third-order motion
profile using the velocity, acceleration, deceleration and jerk
supplied by the standard variables.
motor The part of the controlled plant that performs physical
movement on one axis.
mpu Main Processing Unit. The hardware component that executes
mpu program.
mpu program The principal part of the firmware. Implements the most
controller functions. Is stored in the nonvolatile memory and
cannot be modified by the user. The controller automatically
retrieves the MPU program on the power-up.
nonvolatile memory A type of memory that retains the values when the power is off.
In the SPiiPlus PCI-4/8 the nonvolatile memory stores the
firmware and the application.
protected mode Mode of application protection where application and critical
data are protected from user intervention. Opposite of
configuration mode.
read-only variable A standard variable that can be read from the controller but
cannot be assigned.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Glo s sar y 2- 7
safety control The function of the controller that ensures safe operation of the
system. Consists of the verification of numerous fault
conditions that the controller executes each controller cycle
irrespective of any other activity. Once a fault condition is
satisfied, the controller raises the corresponding fault.
safety inputs Digital inputs that the controller examines in the process of
safety control.
scalar A standard variable or user variable that contains one value, as
opposed to array.
servo tick The period of SP program execution. The SPiiPlus PCI-4/8
controllers have a standard servo tick of 50 microseconds (20
kHz). This defines the sampling rate implemented in the servo
processor for digital servo control and fine interpolation .
settling time The time required for a motor to reside within a target envelope
(see also TARGRAD variable on page 11-68) around the target
point before the controller raises the in-position bit in the MST
variable.
simulator An integrated part of each SPiiPlus PCI-4/8 tool that emulates
the controller operations without producing actual movement.
The Simulator is useful while developing the user application,
for learning ACSPL+ and for demonstration purposes.
SP (servo processor) The component that incorporates a powerful RISC processor
and an extensive periphery for connecting sensors and
actuators. The controller includes 2 or 4 SPs; one SP provides
control for 2 axes. The SP executes the most time-consuming
tasks like digital closed-loop control and fine interpolation. The
latest version is the SPii.
SP program The part of the firmware executed in a servo processor. The SP
program is stored in the nonvolatile memory. The controller
automatically retrieves the SP program on power-up.
The user can modify an SP program in order to implement
specific filters and tailor the control algorithm to the controlled
plant.
SP variables Variables declared in SP program.
SPii Current version of SPii (written SPii).
SPiiPlus Family of controller products built around the SPii.
SPiiPlus C library A library of subroutines developed with the controller. The
library facilitates creating Windows®-based applications that
support the controller.
standard variable Predefined ACSPL+ variable. Standard variables are used for
many tasks including configuring the controller and providing
information about application. Standard variables can be used
in any Error! Reference source not found. or ACSPL+
command without explicit declaration, as opposed to user
variables.
time-based motion Motion that evolves as a function of time, as opposed to
master-slave motion. The characteristic feature of a time-based
motion is a motion profile that shows the motion progress
against the time.
tools A set of Windows applications provided with the controller to
aid the user in developing and implementing an application.
Each tool communicates with the controller in order to perform
various functions. Each tool includes a controller simulator,
which enables the tool to be used without requiring a physical
connection to the controller.
user variable User defined ACSPL+ variable as opposed to standard
variables.
vector A one-dimensional array.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s So f t w a r e A r c h i t e c t u re 3-1
MPU Interaction
SPii with
Interaction SPii
SPii the controlled
with SPii
the Host plant
computer
Flash memory
Nonvolatile (flash) memory retains its stored data after the power to the controller is cut off. In
the SPiiPlus PCI-4/8 the firmware and the application are stored in the nonvolatile memory.
3.1.2. Firmware
The firmware consists of a set of files factory-written in the nonvolatile (flash) memory.
The user cannot erase or modify the firmware. However, the user is able to update the firmware
version with a special tool that is part of the SPiiPlus MMI that is supplied with the controller.
The firmware files include the following:
MPU program.
SP program (one for all SPs, or individual programs for each SP).
Default values of the controller’s configuration variables.
Executing #SAVE command pairs stores user ACSPL+ programs files and configuration
variables in the nonvolatile (flash) memory. Executing #SAVESP command pairs does the same
for user SP programs The controller will then use the user-written configuration values and SP
programs instead of the factory default. However, the factory-written files are retained and never
erased. The controller retrieves the factory default following execution of #RESET command
pairs.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s So f t w a r e A r c h i t e c t u re 3-3
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s So f t w a r e A r c h i t e c t u re 3-5
Host-based Command SP
program interpreter program
Controller
ACSPL+ variables
program
Configuration
variables
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s So f t w a r e A r c h i t e c t u re 3-7
3.3.1. Commands
The controller supports a rich set of commands.
The controller can either execute a command immediately when the command is received through
one of the communication channels or the controller can store a sequence of commands in a
buffer and execute them as a program. The command set is subdivided into two types of
commands:
• terminal command (page 4-1) that cannot be stored in a buffer and always are executed
immediately. Each terminal command starts with ? (query command) or # (management
command). For example:
?FPOS Display the current position of all motors.
• ACSPL+ commands (page 5-71) that can either be executed immediately or can be stored in
a buffer. Examples of ACSPL+ commands:
enable X Enable motor X
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s So f t w a r e A r c h i t e c t u re 3-9
If the prompt contains a line number like 2:00001>, a program buffer is open for editing, and an
ACSPL+ command, transmitted to the controller through any communication channel, is stored in
the open buffer, as part of an ACSPL+ program.
Immediate execution of ACSPL+ commands is a background task. Therefore, the processing time
can be affected by a high MPU usage. The real-time tasks always have the highest priority. If the
usage (percentage of the real-time tasks in the controller cycle) reaches 90% or more, the response
time of the controller deteriorates. If an application requires the fastest response to terminal
commands, the user must keep the usage below 50%.
Executing an ACSPL+ program from a buffer is different, because the controller executes a
buffered ACSPL+ program as a real-time task. Up to 10 buffered ACSPL+ programs can be
executed simultaneously, and in parallel, the controller can execute a terminal command.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-11
CONTROLLER
RPOS Direct
transform SP ±10V signals
to drivers
FPOS Feedback
transform Encoder
signals
IST
IND
MARK Feedback Mark inputs
MARK2 transform
FAULT
S_FAULT Safety
control Safety signals
IN
Digital inputs
OUT
Digital
outputs
AIN
Analog inputs
AOUT
Analog
outputs
EXTIN
HSSI
EXTOUT
• MARK – Mark Position, array of eight elements, reads the position of the last encountered
Mark signal.
• M2ARK – Secondary Mark Position, array of eight elements, reads the position of the last
encountered Mark2 signal.
• FAULT – Faults, array of eight elements, the bits of the variable report the axis-related
faults detected by the safety control
• S_FAULT – System Faults, scalar, the bits of the variable report the system faults detected
by the safety control.
• IN – General Purpose Inputs, array of eight elements, each bit reports the state of one
general-purpose input.
• OUT – General Purpose Outputs, array of eight elements, each bit defines the state of one
general-purpose output.
• AIN – Analog Inputs, array of 16 elements, each element reads the numerical value of the
voltage supplied to one analog input. The number of analog inputs varies depending on the
controller model.
• AOUT – Analog Outputs, array of 16 elements, each element defines the voltage generated
by one analog output. The number of analog inputs varies depending on the controller
model.
• EXTIN – Extended Inputs, array of eight elements, each bit represents a bit in the input or
HSSI register.
• EXTOUT – Extended Outputs, array of eight elements, each bit represents a bit in the HSSI
register
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-13
Internal Multiplier: x4
User units: 360 degrees per rotation
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-15
SAFINI and S_SAFINI, configuration variables – define the active state of each signal,
specifying inversion of a signal if required
FMASK and S_FMASK, configuration variables – enable or disable using each signal in
the safety control
FAULT and S_FAULT, read-only variables – indicate the faults detected by the safety
control
FDEF and S_FDEF, configuration variables – enable or disable the controller default
response when the fault occurs
See also safety, page 8-1.
The range of the AIN/AOUT arrays depends on the type of the input/output and the bit resolution
of the ADC/DAC.
Example, for ±10V analog outputs with 16-bit DAC resolution, the AOUT range is from -32768
(for –10V) to +32767 (for +10V).
Example: For ±1.25V analog inputs with 14-bit DAC resolution, the AIN range is from -8192 (for
–1.25V) to +8192 (for +1.25V).
If an analog output is connected to a drive it has a dedicated destination and cannot be used as a
general-purpose analog output.
For model-dependent analog I/O information (for example, the number and range of inputs and
outputs) see the controller's Hardware Guide.
The following example represents an autoroutine in SPiiPlus PCI-4/8 that displays a message
when the voltage in the 3rd analog input rises above +.75V:
on AIN3 > 4096 Activate autoroutine once the value of AIN3
exceeds 4096 (+.75V)
disp “AIN3 > .75V” Display a message
3.4. Motion
This section provides a brief description of the concept of motion in SPiiPlus controllers. For
more implementation information, see Chapter 6.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-17
The user or the application can change the connect formula by using the connect command. The
controller overwrites the old formula and continues calculations according to the new formula –
similar to the master command.
Occasionally, the connect formulas must be changed during program execution. In most
applications using connect definitions the definitions are in the application's AUTOEXEC area.
The controller transfers each RPOS element to the corresponding SPii program as a reference
value for the corresponding physical motor (see page 3-13 for explanation of the direct and
feedback transforms). The SPii program executes the control algorithm that causes the motor to
follow the reference value.
builds the motion profile using the parameters X_VEL, X_ACC, X_DEC, X_JERK.
Parameters Z_VEL, T_VEL, Z_ACC, etc. have no effect on the motion. Similarly, during
the motion the controller updates variables X_GPATH, X_VEL and so on, but does not
update Z_PATH, T_PATH, Z_VEL, etc.
Motion initiated by the command:
ptp ZXT,200,100,50 Move X,Z,T to the point X=100, Z=200, T=50
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-19
builds the motion profile using the parameters Z_VEL, Z_ACC, Z_DEC, Z_JERK and
updates variables Z_GPATH, Z_VEL and so on.
In other respects, the order of axes in a group is insignificant. The effect of the following two
commands is the same:
ptp XZT,100,200,50 Move X,Z,T to the point X=100, Z=200, T=50
and
ptp XTZ,100,50,200 Move X,Z,T to the point X=100, Z=200, T=50
In some cases, the user may wish to explicitly manage axis groups, not relying on the automatic
handling by the controller. The ACSPL+ command group creates an axis group and the command
split destroys it. The controller never automatically destroys a group created with the explicit
group command. Explicit group managing can be useful if several axes must be always used
together or for a long time.
A single axis in a one-axis motion plays the same role as a leading axis in a multi-axis motion. A
single axis can be treated as an axis group consisting of one axis.
The M suffix for the PTP command causes the controller to automatically calculate and use the
maximum motion parameters available for the group. An advantage of using this suffix is that it
frees you from having to keep track of the leading axis' motion parameters.
ptp /m XYZ,20,40,300 Move X,Y,Z to the point X=20, Y=40, Z=300
using the maximum motion parameter values
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-21
GVEL = JERK*T2/2
GPATH = JERK*T3/6
2. Move with constant acceleration:
GJERK = 0
GACC = ACC
GVEL = GVEL1 + ACC*T
GPATH = GPATH1 + GVEL1*T + ACC*T2/2
3. Approaching the desired velocity:
GJERK = –JERK
GACC = ACC – JERK*T
GVEL = GVEL2 + ACC*T – JERK*T2/2
GPATH = GPATH2 + GVEL2*T + ACC*T2/2 – JERK*T3/6
4. Move with constant velocity:
GJERK = 0
GACC = 0
GVEL = VEL
GPATH = GPATH3 + VEL*T
5. Approaching the desired deceleration:
GJERK = –JERK
GACC = –JERK*T
GVEL = VEL – JERK*T2/2
GPATH = GPATH4 + VEL*T – JERK*T3/6
6. Move with constant deceleration:
GJERK = 0
GACC = – DEC
GVEL = GVEL5 – DEC*T
GPATH = GPATH5 + GVEL5*T – DEC*T2/2
7. Approaching the desired position:
GJERK = JERK
GACC = –DEC + JERK*T
GVEL = GVEL6 – DEC*T + JERK*T2/2
GPATH = GPATH6 + GVEL6*T – DEC*T2/2 + JERK*T3/6
The profile may lack one or more segments. For example, if the desired velocity is too high, the
profile will not include the constant-velocity segment.
The profile remains basically the same for all time-based motion types.
Conversion of GPATH values to APOS values depends on the motion trajectory. The controller
calculates APOS values as projections of the current motion point to each axis.
X axis
slave X Activate the master-slave motion of X
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-23
At power-up the controller establishes default connection between RPOS and APOS. By default
connection the controller in each controller cycle assigns value of APOS to RPOS that
corresponds to the result of command connect RPOS = APOS. In many applications, this default
connection is appropriate. When working with the default connection, the user can ignore the
difference between the logical axes and the physical motors, and changing APOS directly causes
motion of the motor.
The user can modify the connection between APOS and RPOS by using the connect command.
In most applications, the connect command is executed once for each motor, normally as part of
the AUTOEXEC execution. Listed below are some of the tasks that can be resolved using the
appropriate CONNECT formulae:
Introduce a gear ratio between the logical axis and the physical motor.
Compensate for encoder errors and backlash.
Compensate for non-orthogonality of the machine slides.
Compensate for undesired mutual interference between machine coordinates.
Define the physical motion as a sum of a logical motion and a compensating signal.
Define the physical motion as a sum of two or more logical motions.
Inverse kinematics, such as programming in Cartesian coordinates the machine that actually
has a polar kinematics.
encoder counts. The controller automatically makes all necessary transforms. The user only needs
to configure the EFAC value for each axis, to set the units used for the application.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-25
In the left column of each table a bit constant is specified that can be used to address the required
bit in an ACSPL+ command. For example, the following command can be used to wait for the
end of the X-axis motion:
till ^X_AST.#MOVE Wait until the X axis finishes its motion
The following command waits until the T motor reaches the target point:
till T_MST.#INPOS Wait until the T motor reaches the target point
Both the AST and MST include similar bits #MOVE and #ACC. However, the meaning of the
bits may be different. Obviously, if the application defines a sophisticated connect formula, the
motor may move while the corresponding axis is not moving. However, even with the default
connection when the RPOS element simply follows the APOS element, the #MOVE bits may be
different. The #MOVE bit in AST reflects the state of a logical motion and drops to zero
immediately after the motion end. The #MOVE bit in MST drops to zero only when the motor is
not moving and the #INPOS condition is satisfied. Usually, the #MOVE bit in MST indicates the
end of motion later than the #MOVE bit in AST.
See also the reference for AST (page 11-17) and MST (page 11-48).
ST: Label
goto ST Repeat
Let’s see what happens on each cycle when the ptp command is executed.
When the ptp command is executed for the first time, motion towards point +1000 is generated. If
the motor is enabled and not moving, the motion starts immediately (in the next controller cycle).
The command does not delay the program, therefore the execution of the command takes one
controller cycle. The motion continues in parallel with program execution. The controller
executes the assignment of Targ, then the goto command, and then to the ptp command
The next ptp command activates the second motion towards point –1000. The first motion is not
yet finished, and the second motion does not start immediately. Instead, the motion is placed into
the motion queue waiting for the termination of the first motion. Like the first ptp command, the
second ptp command is not delayed, and execution takes one controller cycle.
The 3rd, 4th and 5th ptp commands proceed in the same way. In most cases, the first motion is still
in progress, and all activated motions are placed into the motion queue to be executed in turn. The
program continues without any delay.
This behavior changes when the motion queue is full (the motion queue capacity is four waiting
motions). The motion activated by the 6th ptp command cannot be placed into the motion queue if
the first move is still in progress. At this point the controller automatically delays execution of the
command. The program waits as long as the first motion is in progress. When the first motion
ends, the controller extracts the second motion from the motion queue and starts its execution.
The motion queue now has a place for another motion, and in the same cycle the controller
accomplishes execution of the 6th ptp command and places the 6th motion into the motion queue.
When executing the 7th and all subsequent ptp commands, the motion queue is likely to be full.
Therefore, the command execution is delayed until the end of a motion.
Note that the controller automatically manages synchronization of the program and motion
sequence, and no action is required from the user.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
SP i i P l u s S of t w a r e A r c h i t e c t u re 3-27
Example:
ptp X,100 Move X to point 100
Assuming that the X axis is not in a group and that the X motion queue is not full, the first ptp
command activates the motion and is executed without any delay. The following ptp requires
creation of XYZ axis group. The group cannot be created as long the X motion is in progress.
Therefore, the controller delays the program. Only when the X motion is over, does the controller
create the axis group, and activate the motion, allowing the program continues.
Upon the break command, the controller does not build the deceleration profile for the first ptp
motion. Instead, the controller terminates the motion immediately and builds a smooth profile for
the next ptp motion.
Neither the first nor the second motion must necessarily be point to point (ptp) motion. Motions
of any type are compatible with the break command. However, if the break command is applied
to multi-axis motion, the following limitation must be taken into account: The break command
provides smooth transition to the next motion in terms of the motion profile. In the case of a
single-axis motion, this guaranties smoothness of motion. In case of multi-axis motion, this
guaranties the smoothness of the vector motion. If the interrupted and the interrupting motions
have different direction of vectors at the break time, there will be an abrupt change in an axis
velocity. Therefore, when applying the break command to a multi-axis motion, the user must
assure that the two motions to be tangent or nearly tangent to each other at the break point.
NOTE
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Ter m inal C o mman ds 4- 1
4. TERMINAL COMMANDS
4.1.1. General
Use program management commands to:
Open and close program buffers
Insert program lines in a buffer
Delete program lines in a buffer
List a full program or selected lines in a buffer
Search for specific a name in a buffer
Display information about standard and user variables
Compile or decompile a program
Start, stop, pause, resume a program
Debug a program
Check the integrity of firmware and user application
Display the real-time usage of the controller
Program management commands are executed immediately and cannot be part of a program.
They are usually issued through the Terminal.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Ter m inal C o mman ds 4- 3
#[buffer number]
to open a buffer, and the command:
#
to close the buffer.
S Stop
SR Stop and reset
P Pause
F Find
FI Find (case insensitive)
BS Set breakpoint
BR Reset breakpoint
SI List system information
SC List safety system configuration
VS, VSF List Standard Variables
V, VF List User Variables
VSP List SP variables
The requirements for using a line qualifier depend on the command used.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Ter m inal C o mman ds 4- 5
1: MovePTP:
2: X_VEL = 20000
3: ptp X, 4000
4: till ^X_MST.#MOVE
5: stop
4: till ^X_MST.#MOVE
List lines from 1 to 3 inclusively in buffer 5
#5L1,3
1: movePTP:
2: X_VEL = 20000
3: ptp X, 4000
List the line that contains the label MovePTP in buffer 5:
#5L/MovePTP
1: movePTP:
List 3 lines, starting from the label movePTP in buffer 5:
#5L/MovePTP, 3
1: movePTP:
2: X_VEL = 20000
3: ptp X, 4000
Buffer 0
Buffer 1
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Ter m inal C o mman ds 4- 7
Note
It is recommended to place a remark with a short program description in the
first line of each your programs. This allows you to use the command ##L1
to get quick information about all loaded programs.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Ter m inal C o mman ds 4- 9
1: X_VEL = 20000
2: ptp X, 4000
3: till ^X_MST.#MOVE
4: stop
0:0005> The buffer remains open
#0I1 Change the insert line number to 1
0:0001> Insert line is set before the first line
MovePTP: Insert label
0:0002>
#0L List the program
1: MovePTP:
2: X_VEL = 20000
3: ptp X, 4000
4: till ^X_MST.#MOVE
5: stop
0:0002> The buffer remains open
# Close the buffer
: The prompt indicates that all buffers are closed
:
#0D3 Delete line 3 in buffer 0.
:
#0L List buffer 0
1: MovePTP:
2: X_VEL = 20000
3: till ^X_MST.#MOVE
4: stop
:
#0 Open buffer 0
0:0005>
#0D2,3 Delete lines 2-3 in buffer 0
0:0002> Insert point shifts to deleted lines
#0L List buffer 0
1: MovePTP:
2: stop
0:0002>
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-11
Examples:
#0L List buffer 0
1: MovePTP:
2: X_VEL = 20000
3: ptp X, 4000
4: till ^X_MST.#MOVE
5: stop
:
#0F/X Find X in buffer 0
0002 First entry in line 2
:
#0F/X,3 Find the next entry
0003 Next entry in line 3
:
#0F/X,4 Find the next entry
0004 Next entry in line 4
:
#0F/X,5 Find the next entry
?1078 No more entries
:
##F/MovePTP Find MovePTP in all buffers
Buffer 0: No matches
Buffer 1: No matches
Buffer 2: No matches
Buffer 3: 0001 Entry is found in line 1
Buffer 4: No matches
Buffer 5: No matches
Buffer 6: No matches
Buffer 7: No matches
Buffer 8: No matches
Buffer 9: No matches
:
ACC
AERR
AFLAGS
AIN
… and so on
Provide a list of standard variable names with additional information:
#VSF
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-13
to print additional information about user variables. Additional information includes the variable
type, the dimension (for array only) and the address of the variable in the controller memory.
Example:
Provide a list of user variables in buffer 9:
#9V
ITIME Global
TS_AMP1 Local
TS_AMP0 Global
Provide a list of user variables in buffer 9 with additional information:
#9VF
#VSPn
where n is an SP number, provides a list of SP variables that are defined in the program in the
specified SP. Each variable name in the list is accompanied by an SP address of the variable.
For example:
#VSP0 List the variables in SP 0
X_I_RMS_SUML @089 Variable X_I_RMS_SUML resides in SP address 089
X_I_RMS_SUMH @08a Variable X_I_RMS_SUMH resides in SP address 08a
A_I_RMS_SUML @08b Variable A_I_RMS_SUML resides in SP address 08b
A_I_RMS_SUMH @08c Variable A_I_RMS_SUMH resides in SP address 08c
X_OPEN_L @08d Variable X_OPEN_L resides in SP address 08d
A_OPEN_L @08e Variable A_OPEN_L resides in SP address 08e
X_FN_SW @08f Variable X_FN_SW resides in SP address 08f
A_FN_SW @090 Variable A_FN_SW resides in SP address 090
#P
#X
Run Suspended
#S
#X
#X #S
#SR
#SR
Not Compiled
#C
compiled
#SR
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-15
4.1.7.2. Compile
The C command compiles a program in the buffer or all programs in all buffers, depending on the
qualifier. If the buffer qualifier is specified as the # character instead of the buffer number, the
Compile command compiles all programs in all buffers.
The Compile command must not include a line qualifier and is prohibited when the buffer is in
Run or Suspended states.
The Compile command is not obligatory in order to execute a program. When the X (Execute)
command is issued, the controller automatically compiles the program if it was not previously
compiled. However, a separate compilation step is required in the following cases:
The user desires to check program correctness without execution.
The program is not intended for direct start, but contains autoroutines. The autoroutines are
ready for execution only after compilation.
The program is intended for starting from another program by the start command. The
program started by the start command must be compiled before the start command can be
executed.
If the program is successfully compiled, the controller prints a short report of how many lines
were compiled. If an error was encountered, the controller reports the error code and the line
number in which the error was found.
Examples:
#0C Compile the program in buffer 0
5 lines compiled The program was compiled successfully
:
#9C Compile the program in buffer 9
?2026 in line 16 Error 2026 was found in line 16
:
??2026 Explain error 2026.
Undefined variable name
##C Compile the programs in all buffers
Buffer 0: 5 lines compiled The program was compiled successfully
Buffer 1: 18 lines compiled The program was compiled successfully
4.1.7.3. Execute
The Execute command X starts a program in a specific buffer, and can be executed in any
program state except the Run state
The buffer qualifier in the command must specify one buffer only.
The line qualifier in the command can be a line number or a label. Execution starts from the
specified line. The line qualifier is optional. If the line qualifier is omitted, the program starts from
the first line.
If the state of the program is Not Compiled, the controller first compiles the program and then
starts it. If an error was encountered during compilation, the program does not start.
If the state of the program is Suspended, the X command resumes the program execution. In this
case the command must not contain line qualifier because execution resumes from the point where
the program was suspended.
Examples:
#1X Execute the program in buffer 1
:
?1 Query status of buffer 1
Buffer 1: 18 lines, running at line 7
:
4.1.7.4. Stop
There are two commands that terminate program execution:
S - Stop
SR - Stop and Reset
The Stop command S terminates program execution in a buffer or execution of all programs in all
buffers.
The Stop and Reset command SR terminates program execution in a buffer or execution of all
programs in all buffers, and resets the buffer or all buffers to the Not Compiled state.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-17
4.1.7.5. Pause
The Pause command P suspends program execution in a buffer or, if preceded by the # character
instead of a buffer number, the execution of all programs in all buffers.
Pause commands must not include a line qualifier.
Pause commands are allowed in any program state, but in all states other than Run the command
has no effect.
If the program is in Suspended state, the X (Execute) command resumes execution. The S (Stop)
command transfers the buffer to Compiled state. The SR (Stop and Reset) command transfers the
buffer to Not Compiled state.
Examples:
#1P Suspend the program in buffer 1
:
?1 Query status of buffer 1
Buffer 1: 18 lines, suspended in line 7
:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-19
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-21
Size Checksum
Registered Actual Registered Actual
c:\
sb4.exe 0009C270 0009C270 1D3E468E 1D3E468E
sb4.bin 000057D4 000057D4 D71BE07B D71BE07B
c:\sb4\dsp
dsp.### 000017EC 000017EC 97E015CF 97E015CF
c:\sb4\startup
par.### 0000048F 0000048F A7EF3712 A7EF3712
System Integrity is OK
:
#SC
9 #DRIVE Drive Alarm KD+ KD+ KD+ KD+ KD+ KD+ KD+ KD+
13 #CPE Critical Position KD+ KD+ KD+ KD+ KD+ KD+ KD+ KD+
Error
16 #CL Overcurrent KD+ KD+ KD+ KD+ KD+ KD+ KD+ KD+
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-23
4.2.1. General
Use query commands to obtain information from the controller. Query com mands start with the ?
character and are followed by one or more query specifications. Query commands are executed
immediately and cannot be part of a program. They are usually issued through the Terminal (For
additional information about the Terminal see the SPiiPlus MultiDebugger User’s Guide).
The following data may be addressed by a query command:
Status of a program buffer
Status of an axis and motor
Value of a standard variable
Value of a standard state or flag variable
Value of a user global variable
Value of a user local variable
One element, range of elements, or all elements of standard array, user global array or user
local array
Examples:
?VR Display the version number of the controller.
?FPOS,RPOS Display the current position of all motors and reference value of all
axes.
?Var Display the value of user global variable Var. The variable may be
of either integer or real type, and may be either scalar or array.
?5:Var Display the value of local user variable Var in buffer 5. The variable
may be of either integer or real type, and may be either scalar or
array. A user variable must be declared in a program and the
program must be compiled.
? Repeat the last executed query command
A query command may contain several query specifications in one line, separated by comma or
space. For example, the command
?FPOS, RPOS
and
?RPOS
The only exception to this format is that the multiple status queries ?#, ?$ and ?% must appear in
separate lines.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-25
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-27
For example, the following query displays the motor feedback for each axis:
: ?FPOS What is the feedback position of each of the motors?
1823 –8220 22900 1000 0 0 0 0
The standard variable V represents an array of 100 integer values. Query of V without indexes
reports the values of all array elements:
: ?V
0 2 4 6 8 10 12 14
16 18 20 22 24 26 28 30
32 34 36 38 40 42 44 46
48 50 52 54 56 58 60 62
64 66 68 70 72 74 76 78
80 82 84 86 88 90 92 94
96 98 100 102 104 106 108 110
112 114 116 118 120 122 124 126
128 130 132 134 136 138 140 142
144 146 148 150 152 154 156 158
160 162 164 166 168 170 172 174
176 178 180 182 184 186 188 190
192 194 196 198
1823
-8220
22900
The following three queries, that request the feedback position of the X motor, are identical:
: ?X_FPOS, FPOS0, FPOS(0)
1823
1823
1823
One element of V can be queried with indexing:
: ?V(97)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-29
194
20 22 24 26 28 30 32 34
36 38 40
Note
The data reported by Axis and Motor status queries, is a compressed
extraction from AST, MST and FAULT variables
For example:
The first column in the response contains the bit number in MST. Only the bits that have a
defined function are listed in the reply, in this example bits 0,4,5,6. The second column indicates
the state of each bit. The third column displays short explanation for each bit. In the example the x
motor is enabled, is located within target envelope from the desired position, is not moving and is
not accelerating.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-31
1234
3.141
: ? UserGlobArray
154
213
: ? UserGlobArray (3, 7)
Both programs are compiled. The following queries are then issued:
: ? 3:UserLocInt, 6:UserLocReal What is the status of
variable UserLocInt in
buffer 3, and UserLocReal
in buffer 6?
3
114.7
: ? 6:UserLocArray What is the status of
variable UserLocArray in
buffer 6?
0.012 0.43 9.8 0.42 7.134 0 0 213.3
0 1.4
: ? 6:UserLocArray(3), 6:UserLocArray(7) What is the status of
element 3 of variable
UserLocArray in buffer 6,
and element 7 of variable
UserLoc Array in buffer
6?
0.42
213.3
: ? 6:UserLocArray (3, 7) What is the status of
elements 3 and 7 in
variable UserLocArray in
buffer 6?
0.42 7.134 0 0 213.3
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
23
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-33
21 22 23 24 25
The following query displays a range of elements from one row of the matrix:
: ? UserMatrix(1)(2, 4)
23 24 25
13
23
33
23 24
33 34
? SP-variable-specification
SP variable specification consists of two parts separated by colon. The first part contains the
letters "SP" followed by the requested Servo Processor number. The second part is a variable
name. For example:
?SP0:X_POS_GA Query position loop gain of the X axis
?@ SP-variable-specification
displays the SP address of the variable and the permitted range (maximum and minimum allowed
values). SP variable specification consists of two parts separated by colon. The first part contains
the SP letters and the requested Servo Processor number. The second part is a variable name.
For example:
?@SP0:X_POS_GA Query information about X_POS_GA variable in SP 0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-35
?B/ Binary format. This format is identical to the default format for
variables IN, OUT. When applied to an integer variable, the format
displays the binary presentation of the variable.
?E/ Extended format. This format is useful for very large or small real
values, when the default format produces ambiguous results because
the default does not provide enough positions to display very large or
very small numbers. When applied to a real variable, the format
displays each value in 20 positions. C-equivalent: "%20G".
Examples:
: ?D/ MST Display the motor state in
decimal format
3 15 15 3 0 0 0 0
: ?X/Y_MST
00000000
: ?B/X_MST Display the state of motor x in
binary format
00000000,00000000,00000000,00000011
: ?E/UserReal Display the status of variable
UserReal in extended format
1.00000000000001
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-37
or with factory default if no value was stored. Also stops all programs and
disables all drives.
#LOADPAR With argument, loads the configuration variables for the specified axis with
their saved values or factory default. Also stops all programs and disables
all drives.
#LOADSP Without argument, loads saved or factory SP data to all SPs.
#LOADSP With argument, loads the saved or factory SP data to the specified DSP.
#CLEAR Clears ACSPL+ programs in all buffers. Also stops all programs and
disables all drives.
#RESET Clears all previously saved data in the nonvolatile memory and restarts the
controller. As a result, the controller resets to the factory default state.
Also stops all programs and disables all drives.
#HWRES Restarts the controller. The controller initiates power-up initialization (See
next page). Also stops all programs and disables all drives.
Examples:
#SAVE Save the controller state (configuration variable values and all ACSPL
programs) to nonvolatile memory.
#LOAD
Load the controller state from the nonvolatile memory.
#SAVEPROG 2
Save ACSPL+ program from buffer 2.
#LOADPROG Load all previously saved ACSPL+ programs to the corresponding
buffers.
#SAVEPAR
Save all configuration variables.
#LOADPAR 2
Load the configuration variables of the Z axis.
#SAVESP 2
Save the SP data (program and memory initialization) from second SP.
#LOADSP
Load SP data to all SPs and start them up.
#RESET
Reset to the factory default and restart the controller.
#HWRES
Restart the controller and reload all data.
The command
#SAVE
saves a complete set of data, comprising a "user application," to the nonvolatile memory.
The following data is saved:
ACSPL+ programs in all the buffers. If a buffer is empty, the command clears up any
ACSPL+ program saved before from this buffer
The current values of all configuration variables
The result of the #SAVE command is equivalent to the result of the following commands:
#SAVEPROG
#SAVEPAR
The saved data replaces any data that was saved before by any save command. Therefore the
#SAVE command erases the result of any save command that was previously executed. Recovery
of the erased data is impossible. However, the #RESET command restores the factory default
settings.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-39
without a parameter saves all ACSPL+ programs in all buffers in the nonvolatile memory.
The command
#SAVEPROG "buffer number"
saves the ACSPL+ program from the specified buffer in the nonvolatile memory.
The saved program replaces any ACSPL+ program that was previously saved to this buffer. The
SAVEPROG command with a buffer number affects only the saved program for the specified
buffer. All other buffers are unaffected.
without parameter specification saves the values of all the configuration variables in the
nonvolatile memory.
The command
#SAVEPAR "axis number"
saves the values of the configuration variables for the specified axis in the nonvolatile memory.
The newly saved values replace the previously saved values.
The command SAVEPAR with axis number specification affects only the saved values for the
specified axis. All other axes are unaffected.
without parameter specification saves the SP data of all SPs in the nonvolatile memory.
The command
#SAVESP "SP number"
Use the SPiiPlus SPiiDebugger and SPiiPlus MMI to configure SP memory initialization and to
interact with the SP program. The Adjuster in the SPiiPlus MMI (See the SPiiPlus Setup Guide) is
designed for adjusting the control loop parameters in SP memory initialization.
The command
#LOAD
loads a set of data from the nonvolatile memory, that makes up the whole user application.
The following data is loaded:
ACSPL+ programs into all buffers.
The values of all configuration variables.
SP data into all SPs.
The result of the #LOAD command is equivalent to the result of the following three commands:
#LOADPROG
#LOADPAR
#LOADSP
Using the #LOAD command the user can restore the initial state of the application.
Note that the #LOAD command does not restart the controller. Therefore, the specific
initialization sequence executed on power-up is not run. For example, report variables like FPOS,
which shows the current motor position, are zeroed at power-up, but are not reset and retain their
current values when the #LOAD command is executed. For full initialization, use the #HWRES
command.
This command also stops all programs and disables all drives.
without parameter specification loads all the ACSPL+ programs from the nonvolatile memory
into all buffers.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-41
The command
#LOADPROG "buffer number"
loads an ACSPL+ program from the nonvolatile memory into the specified buffer.
If a buffer was not previously saved, the command loads the factory default for that buffer, which
is typically an empty program).
#LOADPROG with a specific buffer number affects only the specified buffer. Other buffers
remain unchanged.
This command also stops all programs and disables all drives.
without parameter specification loads the values of all configuration variables from the
nonvolatile memory.
The command
#LOADPAR "axis number"
loads the values of the configuration variables for the specified axis from the nonvolatile memory.
The #LOADPAR command with an axis number affects only the specified axis. All other axes are
unaffected.
This command also stops all programs and disables all drives.
without parameter specification loads the SP data into all SPs from the nonvolatile memory, and
starts up all the SPs.
The command
#LOADSP "SP number"
loads the SP data into the specified SP from the nonvolatile memory and starts up the SP.
SP data consists of the SP program and SP memory initialization. Memory initialization includes
the control loop parameters, such as gains and PID coefficients.
The #LOADSP command with a specified SP number affects only the specified SP.
The command
#RESET
clears all previously saved data in the nonvolatile memory and restarts the controller. As a result,
the controller resets to the factory default state.
The #RESET command deletes the user application stored in the nonvolatile memory and the
result of any previous save command will be lost.
The following data in the nonvolatile memory is cleared:
All ACSPL+ programs in all buffers.
Values of all configuration variables.
SP data of all SPs.
The #RESET command restarts the controller. Since the nonvolatile memory is erased, the
controller resets to factory defaults.
This command also stops all programs and disables all drives.
Caution
The #RESET deletes all previously stored applications. Deleted applications
are irrecoverable.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Te r m ina l C o m m a n ds 4-43
This command also stops all programs and disables all drives.
5. ACSPL+ MULTIPROGRAMMING
LANGUAGE
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-3
command redirects execution and defines another line to be executed in the next controller
cycle.
A number of commands can delay program execution. For example, the command
wait 50
will execute for 50 milliseconds instead of one controller cycle. The command
till ^MST.#MOVE
Within a controller cycle, the immediate line is executed after all lines from the running programs.
Therefore, in one cycle the controller executes a line from buffer 0, then a line from buffer 1, 2,
up to 9, and then executes an immediate line (If any have been received).
5.1.6. Autoroutines
An autoroutine is a part of ACSPL+ program and can be placed in any program buffer. Each
ACSPL+ program can contain from zero to unlimited autoroutines. An autoroutine placed in a
buffer shares with other autoroutines in the same buffer and with the rest of ACSPL+ program,
the local variables and the same thread for execution.
If a buffer contains one or more autoroutines, the execution model described is slightly modified.
Each controller cycle, the controller examines the conditions of all autoroutines in the buffer,
before executing the next line in a buffer. If a condition is satisfied, the controller does not
execute the next line but executes the first line of the body of the corresponding autoroutine.
Therefore, the autoroutine interrupts the program executed in the same buffer. An autoroutine in
one buffer has no effect on the program or autoroutines in another buffer.
Autoroutines provide an interrupt-like response to external or internal events. For more
information about autoroutines see page 5-90.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-5
. . . . . Critical section
must be in one line. If they are placed in two sequential lines, they cannot provide mutual
exclusion.
5.1.7.2. Synchronization
Assume two programs that run mostly asynchronously must execute certain commands at the
same time. There is a point in each program that whichever program comes to the point first, it
must wait for the second program to come to its synchronization point. Then the next lines in both
programs will be executed in the next controller cycle.
The problem is solved by the following construction:
global int Sem Variable Sem implements a
general semaphore
. . . . . Asynchronous part of the
program
Sem = Sem+1; till Sem = 2; Sem = 0 Synchronization point
The same definition of the Sem variable and the same line of synchronization point must be in the
second program.
Whichever program comes to its synchronization point first, command till Sem = 2 provides
waiting for the second program. The assignment Sem = 0 provides reuse of the construction if
necessary.
The solution can be also be extended to three or more concurrent programs.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-7
Buffer 0: dynamic, 875 bytes are used, 14485 bytes are free
The controller response indicates that the buffer is dynamic and displays the number of used and
free bytes in the buffer. The number of used bytes increases each time when a new command is
inserted into the buffer and decreases each time when a command finishes its execution and is
removed from the buffer. The number of free bytes changes accordingly.
A dynamic buffer stores the compiled code of a command. The number of bytes occupied by a
specific command is a complex function of the command complexity, the functions used in the
command, and other factors. Therefore, the number of used and free bytes gives only an overall
evaluation of the buffer state, and it is impossible to determine the exact number of commands
waiting for execution in a dynamic buffer.
“TILL ^X_MST.#MOVE\n”;
acsc_DownloadBuffer(
New commands in a dynamic buffer are always appended to the end of the buffer, after any
command that is currently in the buffer.
A new command can be inserted only if the dynamic buffer has enough free space for storing the
command. If the space is not enough, the insertion fails due to error 2078. The error does not
affect execution of the commands inserted in the buffer before. When a command finishes its
execution, it is removed from the dynamic buffer and the number of free bytes increases.
Therefore, a command that failed to be inserted, can be inserted after one or more previous
commands have finished.
As stated above, there is no way to know exactly how many bytes in a dynamic buffer are
required for a specific command. Therefore, the recommended procedure for working with a
dynamic buffer is as follows:
1. Insert the first command.
2. Continue inserting the next commands until error 2078 occurs.
3. Wait a several seconds, and try inserting the last command again. Repeat this step until the
command is successfully inserted.
4. Repeat steps 2 and 3 as required.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-9
As explained above (page 5-7) error 2078 may frequently occur when working with a dynamic
buffer. If a command cannot be inserted (error code 2078), the application must attempt inserting
again until the command will be inserted successfully.
All other insertion and compile-time errors with codes less than 3000 indicate an error in the
inserted command. The command must be corrected to be inserted successfully. This error does
not affect execution of the commands inserted into the buffer before. The commands already
inserted into the buffer continue normally executing.
Conversely, if a run-time error (codes more than 3000) occurs in a dynamic buffer, all commands
currently stored in the buffer are aborted and will not be executed. However, the buffer remains
ready for insertion. Therefore, the next inserted command will be stored and executed as usual.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-11
The following is an example of a program line that contains two assignment commands:
V0 = V1 + 2*(V2 – V3) ; V4 = 0
White spaces (spaces and tabs) may be inserted arbitrarily inside or between commands.
However, white spaces must not be inserted within a keyword or variable name.
A Command aggregate consists of several commands. It starts with a specific command and
terminates with the end command. For example, a loop structure starts with the loop command
followed by an arbitrary number of commands and terminates with the end command. The
commands of a structure may reside in one or more program lines.
5.2.6. Comments
A comment is text in a program that the controller stores along with the program but ignores
while executing the program. Comments are normally used to annotate a program.
A comment starts with an exclamation mark (!). An exclamation mark encountered in a line
designates all subsequent characters in the line as part of a comment. If the exclamation sign is the
first character in a line, the whole line is a comment.
! This entire line is a comment.
5.3. Variables
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-13
Size
Value
5.3.2. Name
Variable names follow the general syntax rules (page 5-9).
The controller has a set of standard variables with predefined names. The user cannot change
these names. Standard variables can be used in ACSPL+ commands without explicit declaration.
User variable names must be specified by explicit declaration. For example:
int Var1, Var2 Declare local variables Var1 and Var2
5.3.4. Scope
Variables have either global or local scope.
5.3.5. Lifetime
All standard variables are valid as long as the controller firmware is active; from power-up to
power-down.
A user local variable is valid as long as the containing program is compiled. Therefore, a local
variable becomes active when the program it is contained in is inserted into one of the buffers and
is successfully compiled. After compilation, the variable is assigned its value and is available for
terminal command #V (list of variables) and queries.
Local variables are erased when the program they belong to returns to non-compiled state.
Programs may enter a non-compiled state as a result of:
Explicit #SR command (Stop and Reset)
Editing or inserting another program in the buffer
When a program terminates normally it remains in a compiled state and local variables therefore
remain valid. In addition, if a controller-executed program causes an error, the controller
terminates the program, but the buffer remains in a compiled state. Any user variable in the buffer
therefore remains valid.
A user global variable declared in one or more ACSPL+ programs is valid as long as at least one
of the programs that contains it is compiled. After compilation, the global variable is assigned its
value and is available for terminal command, #V (list of variables) and queries.
A user global variable disappears when the last program that it is contained in returns to a non-
compiled state. The conditions when a program may return to non-compiled state are discussed
above.
A special case of user global variable is the persistent global variable. A global variable is
defined as persistent when the variable declaration is not a part of any program but is issued as an
immediate ACSPL+ command.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-15
Assume, that the user executes the following commands via the Terminal:
global real PersistentVar Declaration
: Controller’s prompt
?PersistentVar Query
0 Initial value
: Controller’s prompt
The controller immediately accepts the declaration and creates the persistent global variable
PersistentVar. The variable is now valid and can be queried as illustrated by the following query
command.
The lifetime of a persistent global variable is not connected with any program. A persistent
variable survives any change in the program buffers and may be erased only by the explicit
terminal command #VGV (Clear Global Variables).
5.3.6. Accessibility
All user variables have read-write access and are not protected. Any ACSPL+ command located
in the scope of a variable can use or assign the variable’s value at any time.
A standard variable can belong to any of three access classes:
read-write
read-only
protected
Read-write standard variables such as user variables can be used or assigned at any time.
Examples of read-write standard variables are VEL (Velocity) and IST (Index State).
Many standard variables are read-only. These variables cannot be assigned. The read-only
variables provide readout of the controller state. Examples include RPOS (Reference Position),
FPOS (Feedback Position), MST (Motor Status).
Protected standard variables define the configuration of the controller, and are therefore called
configuration variables. The values of configuration variables can be read at any time.
Assignment to configuration variables is allowed only in configuration mode (5.10). Examples of
configuration variables are ENTIME (Enable Time), and XACC (Maximal Acceleration).
In most applications, the user sets the values of configuration variables during the application
development process by using the special tools provided for this purpose in the Protected
Function window of the SPiiPlus MMI (See the SPiiPlus MMI User’s Guide or Help).
The controller provides automatic conversion from integer to real and from real to integer if
required. Therefore the user is not restricted in using variables of both types in ACSPL+
commands.
For example in the following fragment:
int Var1 Declare Var1 integer variable
5.3.8. Size
A variable can be a scalar, one-dimensional or two-dimensional array. A two-dimensional array is
called a matrix.
The size of each standard variable is predefined in the controller. For example, the S_FAULT
(System Faults) variable is a scalar variable, and the FAULT (Motor Faults) variable is an array
of 8 elements.
Many standard variables are sized according to the number of axes, with one element per each
axis. For example, each element of the FAULT array displays faults for one axis.
The size of user variables is defined in the variable declaration. For example:
int ScalarVar Declare scalar variable ScalarVar
5.3.9. Value
Value is the only variable attribute that can change during a variable lifetime. In most
applications, a value is changed explicitly, as a result of assignment.
Read-only variables change their values implicitly. For example, the controller updates the
elements of variable FPOS (Feedback Position) each controller cycle, so that each element
displays the actual position of the corresponding motor.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-17
scope-specification:
local
global
type-specification:
int
real
size-specification:
( constant )
( constant ) ( constant )
Any of the parts of either the scope-specification or the type-specification can be omitted, but not
both. If scope-specification is omitted, local specification is implied. If type-specification is
omitted, int specification is implied.
If no size-specification is specified, the variable is scalar.
If size-specification contains one constant in parenthesis, the variable is a one-dimensional array
with the specified number of elements. If size-specification contains two constants in parenthesis,
the variable is a two-dimensional array.
Generally user variables are created in RAM. However, to create a global variable in DPRAM
there is an alternative declaration syntax, which is described in Section 10.3.2.
Examples:
local int Var1 Local integer variable Var1
int Var3, Var4(2)(100) Local integer scalar Var3 and array Var4 of
size 2x100
global int Var3, Var4(2)(100) Global integer scalar Var3 and array Var4 of
size 2x100
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-19
buffer does not affect the persistency of the variable. Once declared in a terminal command, the
variable remains persistent irrespective of all re-declarations.
A local variable cannot be declared by terminal command.
For example:
Assume that the user communicates with the controller through the Terminal and wants to start
data collection without preparing a special ACSPL+ program. The following dialog occurs:
Declare persistent global array of size
global Data(2)(1000)
2x1000
: Controller’s prompt
A typical use of an array requires access to a specific element of the array. To specify an element
of an array the array name must be followed by index specification. For example:
Declare local integer Ar1 of size 100 and
int Ar1(100),Ar2(3)(100)
local integer Ar2 of size 3x100
Ar1(4) = 3000 Assign 3000 to element 4of Ar1
Indexing of arrays starts from zero. In the example above the first element of Ar1 has index 0, the
last element has index 99.
For information on saving user arrays in the nonvolatile memory, see Nonvolatile Memory
Management Commands, page 4-38.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-21
For example:
Declare local real Ar1 of size 100 and local
real Ar1(100),Ar2(2)(8)
integer Ar2 of size 2x8
int J Declare local integer scalar J
J = 0 Assign 0 to J
J = J + 1 Increment
J = 0 Assign 0 to J
J = J + 1 Increment
Note that explicit index can be either constant or expression, while axis-like index is always
constant.
MODEL
DEPENDENT The number of axes depends on the controller model. For example,
a four-axis model would support only X, Y, A, B as axis-like
indexes (or 0, 1, 4, 5 as the corresponding explicit indexes).
Axis-like indexes and explicit indexes can be used interchangeably in one program. However, it is
recommended to select one style and to use it throughout the application.
where the first number after name IN is a postfix index and selects a group of 32 inputs. The
number after the period is a bit specifier used to select one of the 32 bits.
Note that explicit indexing can be either constant or expression, while postfix indexing is always
constant.
Postfix indexing and explicit indexing can be used interchangeably in one program. However, it is
recommended to select one style and to use it throughout the application. If an application
requires non-constant indexing of axis-related variables, neither axis-like or post-fix indexing can
be used.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-23
Examples:
?FPOS Query feedback positions of all motors
1003 4001 233000 1 0 -1 0 1
: Controller’s prompt
?X_FPOS Query feedback positions of the X motors
1003
:
?X_FPOS,Z_FPOS Query feedback positions of the X and Z motors
1003
233000
:
?GlobVar Query global user variable GlobVar
23.35
:
?0:LocVar Query local user variable LocVar from buffer 0
100
:
?0:LocVar,5:LocVar Query two local user variables from different
buffers
100
233.7
:
Explanation: The first argument of the dc command is required to be an array. The user array
Data is specified without indexes, as a whole.
The second argument is an expression that defines the number of samples to be collected.
Constant 1000 is a simple expression.
The third argument is an expression that defines the sampling period. Variable V0 is a simple
expression. Using a variable instead of constant provides changing the sampling period, based on
V0, from one execution of this data collection to another.
The fourth argument must be a variable or an array element. The values of the variable (in this
case V0) will be collected in the array. The syntax of DC requires that the fourth element be a
variable or an array element. Neither a general expression nor an array without indexes can be
specified. An array without indexes neither can be specified. FPOS(0) addresses element 0 of the
array FPOS that corresponds to the X feedback position.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-25
After assignment, the previous value of the variable is erased and the variable stores the new
value.
The left side of an expression can appear in several forms:
Standard or user variable
One element of standard or user array
One bit of integer variable or integer array element
Assigning to a standard variable is limited by the following rules:
Assignment to read-only variable (for example, FPOS) is prohibited
Assignment to a protected variable (for example, ERRI) is allowed in configuration mode
(see Section 5.10).
Examples:
VEL(0) = 1000 Assign 1000 to X default velocity - explicit indexing
5.7. Functions
The ACSPL+ variable declaration types (page 5-17) are also used for function arguments and
function return value types (if a function does not return a value, the return type is void).
The following table briefly summarizes each function:
ARITHMETICAL FUNCTIONS
NAME ACTION SEE PAGE
abs Calculates the absolute value 5-28
acos Calculates the arccosine 5-28
asin Calculates the arcsine 5-29
atan Calculates the arctangent 5-29
atan2 Calculates the arctangent of Y/X 5-30
ceil Calculates the ceiling of a value 5-30
cos Calculates the cosine 5-31
exp Calculates the exponential 5-31
floor Calculates the floor of a value 5-32
hypot Calculates the hypotenuse 5-32
idexp Calculates a value of x*2exp 5-33
log Calculates the natural logarithm 5-33
log10 Calculates the base-10 logarithm 5-34
pow Calculates x raised to the power of y 5-34
sin Calculates the sine 5-35
sqrt Calculates the square root 5-35
tan Calculates the tangent 5-35
sign Returns -1, 0 or 1 depending on the sign of x 5-36
STATISTICAL FUNCTIONS
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-27
MISCELLANEOUS FUNCTIONS
5.7.2.1. abs
Calculates the absolute value.
real abs(real x)
Arguments
Output
3.14
5.7.2.2. acos
Calculates the arccosine.
real acos(real x)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-29
Arguments
Output
3.141592654
5.7.2.3. asin
Calculates the arcsine.
real asin(real x)
Arguments
real The asin function returns the arcsine of x in the range –π/2 to π/2
radians.
Error conditions
Run-time error if the argument is beyond the range –1 to 1.
Example
disp asin(-1)
Output
-1.570796327
5.7.2.4. atan
Calculates the arctangent.
real atan(real x)
Arguments
Return value
real The atan function returns the arctangent of x in the range –π/2 to π/2
radians.
Error conditions
None.
Example
disp atan(-1)
Output
-0.7853981634
5.7.2.5. atan2
Calculates the arctangent of Y/X.
real The atan2 function returns the arctangent value of Y/X. atan2
calculates a value in the range -p to p radians, using the signs of both
parameters to determine the quadrant of the return value. If both
parameters of atan2 are 0, the function returns 0. atan2 is well
defined even if x equals 0.
Error conditions
None.
Example
real XArg, YArg
Output
3.1459
5.7.2.6. ceil
Calculates the ceiling of a value.
real ceil(real x)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-31
Arguments
real The ceil function returns a value representing the smallest integer that
is greater than or equal to x.
Error conditions
None.
Example
disp ceil(3), ceil(-3), ceil(2.1), ceil(-2.1)
Output
3 -3 3 -2
5.7.2.7. cos
Calculates the cosine.
real cos(real x)
Arguments
real The cos function returns the cosine value of x in the range –1 to 1.
Error conditions
None.
Example
disp cos(3.141592654)
Output
-1
5.7.2.8. exp
Calculates the exponential.
real exp(real x)
Arguments
Return value
real The exp function returns the exponential value of x. On overflow, the
function returns the largest real number.
Error conditions
None.
Example
disp exp(1)
Output
2.718281828
5.7.2.9. floor
Calculates the floor of a value.
real floor(real x)
Arguments
real The floor function returns a value representing the largest integer that
is less than or equal to x.
Error conditions
None.
Example
disp floor(3), floor(-3), floor(2.1), floor(-2.1)
Output
3 -3 2 -3
5.7.2.10. hypot
Calculates the hypotenuse.
real The hypot function calculates the length of the hypotenuse of a right
triangle, given the length of the two sides x and y. A call to hypot is
equivalent to the square root of x2 + y2.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-33
Error conditions
None.
Example
disp hypot(3,4)
Output
5
5.7.2.11. ldexp
Calculates a value of x * 2exp.
real The ldexp function returns the value of x * 2exp. On overflow ldexp
returns the largest real number with sign depending on the sign of x.
Error conditions
None.
Example
disp hypot(3,4)
Output
5
5.7.2.12. log
Calculates natural logarithm.
real log(real x)
Arguments
Output
1
5.7.2.13. log10
Calculates the base-10 logarithm.
real log10(real x)
Arguments
Output
1
5.7.2.14. pow
Calculates x raised to the power of y.
real The ldexp function returns the value of xy. On overflow ldexp
returns the largest real number with sign depending on the sign of x.
Error conditions
None.
Example
disp pow(2,3)
Output
8
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-35
5.7.2.15. sin
Calculates the sine.
real sin(real x)
Arguments
real The sin function returns the sine value of x in the range –1 to 1.
Error conditions
None.
Example
disp sin(1.570796327)
Output
1
5.7.2.16. sqrt
Calculates the square root.
real sqrt(real x)
Arguments
Output
2
5.7.2.17. tan
Calculates the tangent.
real tan(real x)
Arguments
Pi = 3.141592654
disp tan(Pi/4)
Output
1
5.7.2.18. sign
Returns -1, 0 or 1 depending on the sign of x.
real sign(real x)
Arguments
Output
-1 0 1
5.7.3.1. min
Finds the minimal value in an array.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-37
real min(array x)
Arguments
Output
0.5
5.7.3.2. max
Finds the maximal value in an array.
real max(array x)
Arguments
Output
3
5.7.3.3. avg
Finds the average of all values in an array.
real avg(array x)
Arguments
real The avg function returns the average of all elements in array x.
Error conditions
None.
Example
real Ar(3)
Ar(0)= 1; Ar(1)= 0.5; Ar(2)= 3;
disp avg(Ar)
Output
2.25
5.7.4.1. deadzone
Implements dead-zone routine.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-39
Fun
-10 +10
Arg
The command
Fun = deadzone(Arg-5, 10)
Implements an asymmetrical deadzone:
Fun
-5 +15
Arg
5.7.4.2. dsign
Implements a dynamic version of the standard sign function (reflects change over time).
Error conditions
None.
Remarks
The standard sign function returns the following result:
-1 if X < 0
0 if X = 0
+1 if X > 0
The dsign function adds the following:
• If X is zero, the function retains its previous value
• If Delay is positive the function provides anti-bouncing effect
• If Ramp is positive the function restricts the rate of change from –1 to +1 and
vice versa
If X = 0, instead of returning 0 the function retains its previous value. If X = 0 when the
function is called the first time, the function returns +1.
If Ramp is zero, the function returns only two values: –1 or +1.
If Delay and Ramp are both zero, the function immediately returns +1 when X > 0 and
immediately returns –1 when X < 0.
If Delay is positive, the function provides an anti-bouncing effect, namely:
• The function changes its result to +1 if X becomes positive and remains positive
for at least Delay milliseconds
• The function changes its result to -1 if X becomes negative and remains negative
for at least Delay milliseconds
Positive Ramp affects the function as follows:
When the function result must change from –1 to +1 or vice versa, it does not change
immediately. Instead, the process of change takes Ramp milliseconds and each millisecond
the result value gets incremented by ±2/Ramp.
5.7.4.3. edge
Returns 1 on positive edge of x (see discussion below).
int edge(real x)
Arguments
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-41
Error conditions
None.
Remarks
Unlike most functions, the edge function is dynamic; it depends not only on the present value of
argument, but also on the previous values.
Although the function accepts any real or integer argument, the typical use implies the logical
argument; an integer variable or expression that can supply only the values 0 or 1. For arguments
that supply only the values 0 or 1, the positive edge is defined as the moment when the argument
changes from 0 to 1. For an argument that supplies values other than 0 and 1, the function
considers positive edge as the moment when the argument changes from zero to a non-zero value.
The exact operation of the function follows the algorithm:
On each call of the function the current value of x is stored in the internal storage.
On each call except the first, the function returns 1 if the current value of x is non-zero and
the stored previous value is zero. Otherwise the function returns 0.
On the first call the function always returns 0.
The following diagram shows the results of the edge function that is called in a program
periodically with period T:
Argument 1
Result 1
0 0 0 0 0
T 2T 3T 4T 5T
The edge function returns 1 only once after the positive edge of argument.
If the argument reaches 1 only for the brief period between successive calls of the edge function,
and then returns to zero, the edge function may miss the edge. An example is shown in the next
diagram where the first positive edge (A) of the argument is missed.
Argument 1
A
0
Result 1
0 0 0 0 0
T 2T 3T 4T 5T
Time
The edge function is used primarily in PLC programs if an action must be taken only once when a
condition becomes true.
The edge function is rarely used in autoroutine conditions, because the autoroutine facility
includes built-in edge detection.
5.7.4.4. intgr
Implements an integrator with deadzone and saturation.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-43
The Min and Max arguments define a working range of the integrator so that the result of
the function is always within the range from Min to Max.
5.7.4.5. lag
The function provides delayed switching on argument change (anti-bouncing effect).
Argument
1
0
Time
Result 1 1 1 1 1
0 0 0 0 0 0
T
1 2 3 4
POINT EXPLANATION
1 The function detects the change of argument and stores the current system time as
the last transition time, Ts = TIME.
2 The time interval between the current system time and the last transition time
becomes more than UpDelay: TIME – Ts >= UpDelay. As the argument is
non-zero, the function returns 1.
3 The function detects the change of argument and stores the current system time as
the last transition time, Ts = TIME.
4 The time interval between the current system time and the last transition time
becomes more than DownDelay: TIME – Ts >= DownDelay. As the
argument is zero, the function returns 0.
5.7.4.6. map
Implements a table-defined function with constant step.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-45
Return value
5.7.4.7. mapby1
Implements a table-defined function with variable step. The first row of the table defines
argument values, the second – function values.
If the value of argument X falls within the definition range, the function provides linear
interpolation between the specified points.
If the value of argument X falls beyond the definition range, the function returns value of
argument X.
5.7.4.8. mapby2
Implements a table-defined function with variable step. The second row of the table defines
argument values, the first – function values.
5.7.4.9. map2
Implements a table-defined function with two arguments and constant step along each argument.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-47
Arguments
5.7.4.10. map2free
Implements a table-defined function with two arguments and variable step along each argument.
Arguments
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-49
If at least one of the values of arguments X, Y falls beyond the definition range, the
function returns zero.
5.7.4.11. roll
Calculates a result rolled-over to within one pitch. The function is a real-number equivalent of the
integer modulo operation.
5.7.4.12. sat
Implements a saturation characteristic.
The connect function specifies that the reference position be calculated by subtracting the
interpolated error from the desired position so that the actual value will be closer to the desired
value.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-51
In this case the application can implement an initialization routine like this:
real X_CAL(2)(11)
By using this connect, the value added to desired position changes immediately when the
direction of the motion changes. In many cases such jumps in the desired position are harmful. In
this case the third parameter in the dsign function can be used to gradually implement the
backlash compensation. In the following example the backlash compensation is introduced by
small steps, so that the compensation growth to the entire value by 20 milliseconds:
connect X_RPOS = X_APOS + 10*dsign(X_RVEL, 0, 20)
If the X axis executes master-slave motion slaved to some physical value like encoder feedback,
the RVEL value contains noise that can cause undesirable switching of the backlash sign. In this
case the second parameter of the dsign function can be used to introduce antibouncing effect. In
the following example the backlash compensation changes its sign only if RVEL holds its new
sign for more than 10 milliseconds:
connect X_RPOS = X_APOS + 10*dsign(X_RVEL, 10, 20)
read X_CAL,X_CALIBR Read calibration table from the nonvolatile (flash) memory
Assume that the Y axis must provide a cam motion following the X axis. File CAMTABLE in the
nonvolatile (flash) memory contains 2 rows and 1000 columns. Each column contains an X
coordinate in the first row and the corresponding Y coordinate in the second row. The X
coordinates in the first row can be spaced either equally or non-equally.
The following fragment initializes the cam motion:
real CAMTABLE(2)(1000)
5.7.4.13.6. Joystick
Assume that a joystick that controls the motion of an XY table is connected to analog inputs
AIN0, AIN1. The velocity of each coordinate must be proportional to the corresponding analog
input. Analog input lower than 20 counts must be ignored to avoid motion due to analog drift or
bias. The X motion is limited in the range from –500 to 100000 counts. The X motion is limited
in the range from –500 to 500000 counts.
The following program fragment initializes the joystick motion:
real JK
JK = 10 Joystick factor
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-53
MODEL
DEPENDENT
The quantity of Servo Processors is model-dependent. Check the
controller Hardware Guide.
5.7.5.1. getsp
Reads a value from the specified SP address.
5.7.5.2. monsp
Initiates monitoring of the specified SP address through an analog output.
none
Error conditions
The function causes an error if:
• the specified analog output is illegal or cannot be used with the specified SP
• the SP number specified isn't legal
• the address specified is illegal
Remarks
An address from a specific SP can be monitored only through analog output belonging to the
same SP. This rule applies limitations to possible values of arguments AOut and SP. Two
addresses from one SP can be monitored simultaneously.
The function overwrites the value stored in the corresponding AOUT standard variable with a
special monitoring code. Once SP the receives the monitoring code, it starts transferring the value
from the specified address to the analog output. The SP also provides the required scaling shift of
the monitored variable.
The next assignment to the corresponding AOUT element overwrites the monitoring code and the
analog output returns to displaying the AOUT value.
5.7.5.3. setsp
CAUTION
The setsp function is for advanced users only. Misuse of this
function may damage your controller
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-55
none
Error conditions
The function causes an error if an illegal SP number is specified.
The function causes an error if an illegal address is specified.
Remarks
SP addresses can be looked up in the SPiiPlus MMI | Tools | SP Monitor. Some are accessible
from SP only, others from MPU only and the dual-port area from both SP and MPU. The function
writes a value to any of these areas. The only thing that the function cannot do is writing to a
write-only register – in this case the function does nothing.
The function returns immediately if the address lies in an area accessible directly from MPU.
Otherwise the function provides delay by one controller cycle
5.7.6.1. sysinfo
Provides access to system information.
Return value
The meaning of the return integer depends on the calling argument.
Error conditions
None.
Remarks
The sysinfo function accepts an integer argument and returns an integer value relating to that
argument.
5.7.6.2. input
int input(arg)
Arguments
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-57
Return value
5.7.6.3. getconf
Return value
5.7.6.4. setconf
Use the setconf to write system configuration data.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-59
No fault 0 0 0 0 5060
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-61
21 0–3 getconf retrieves the Index Counter. The Index Counter is an up-
The down counter. The counter increments each time when the motor
function is crosses the index in positive direction and decrements each time
valid for when the motor crosses the index in negative direction.
axes
X,Y,Z,T setconf zeroes the Index Counter (the value argument is ignored).
only
22 0–3 getconf retrieves the Mark Counter. The Mark Counter is an up-
The down counter. The counter increments or decrements on each pulse
function is of the Mark signal. The direction of a count corresponds to the
valid for direction of motion at the counting moment.
axes
X,Y,Z,T setconf zeroes the Mark counter (the value argument is ignored).
only
26 Ignored getconf retrieves the mask that determines for each digital input, the
signal edge (leading or trailing) that will trigger an interrupt.
setconf sets the mask that determines for each digital input, the
signal edge (leading or trailing) that will trigger an interrupt.
The mask contains a bit for each available input signal. The location
of bits in the mask corresponds to the location of bits in the IN0
variable.
If a bit is 0, the controller generates an interrupt on the rising edge
of the corresponding input signal.
If a bit is 1, the controller generates an interrupt on the falling edge
of the corresponding input signal.
After power-up the mask contains 0 in all bits.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-63
130 1or 5 getconf retrieves the present value of the constant current level for
the specified axis (Y or B only, represented by the index value 1 or
5 respectively). The default maximum value that can be set is 16%
for axis Y and 30% for axis B (this value can be changed, see
description of key 131 below).
setconf defines the constant current level as a percentage of the
maximum current for the specified axis.
131 1 or 5 getconf retrieves the present maximum allowable constant current
level (as a percentage of the maximum current) for the specified
axis (Y or B only, represented by the index value 1 or 5
respectively).
setconf sets the maximum allowable value for the constant current
level for the specified axis.
133 1 This key applies for integrated modules (SPiiPlus PCI-DDM4A)
only:
getconf retrieves the constant current mode status for axes Y and B:
returns zero if the mode is on, nonzero if the mode is off.
setconf disables/enables constant current mode for axes Y and B.
Value 0 disables the mode, value 1 enables the mode.
203 0–7 getconf retrieves the value of MFLAGS.1 (Open Loop).
Specifies setconf sets the value of MFLAGS.1.
one of the
axes.
204 0–7 getconf retrieves the value of MFLAGS.9 (Commutation OK).
Specifies setconf sets the value of MFLAGS.9.
one of the
axes.
205 0–3 The Value argument specifies the output mask that defines the
The source of the digital outputs. The mask defines whether a digital
function is output is allocated to the corresponding bit of the OUT array (for
valid for general purpose use) or allocated for PEG function use.
axes
The PEG can control up to four outputs for each axis. Both
X,Y,Z,T
incremental and random PEGs produce pulse output. In order to use
only
this pulse the user must configure the output mask so that the PEG
controls the corresponding output. Additionally, the random PEG
can produce up to three state outputs. In order to use these states the
user must configure the output mask so that the PEG controls the
corresponding outputs.
getconf retrieves the value of output mask.
setconf sets the value of output mask.
Only the following bits of the output mask are meaningful:
Axis X (Index 0)
Bit 0 assigns pin OUT0.0: 0 – OUT0.0, 1 – X PEG state 0
Bit 1 assigns pin OUT0.1: 0 – OUT0.1, 1 – X PEG state 1
Bit 2 assigns pin OUT0.2: 0 – OUT0.2, 1 – X PEG state 2
Bit 3 assigns pin X_PEG_3: 0 – undefined, 1 – X PEG state 3
Bit 8 assigns pin OUT0.3: 0 – OUT0.3, 1 – X PEG pulse
Axis Y (Index 1)
Bit 0 assigns pin OUT0.4: 0 – OUT0.4, 1 – Y PEG state 0
Bit 1 assigns pin OUT0.5: 0 – OUT0.5, 1 – Y PEG state 1
Bit 2 assigns pin OUT0.6: 0 – OUT0.6, 1 – Y PEG state 2
Bit 3 assigns pin Y_PEG_3: 0 – undefined, 1 – Y PEG state 3
Bit 8 assigns pin OUT0.7: 0 – OUT0.7, 1 – Y PEG pulse
Axis Z (Index 2)
SPiiPlus PCI-4/8 assigns pin Z_PEG_PULSE: 0 – undefined, 1
– Z PEG pulse
Axis T (Index 3)
SPiiPlus PCI-4/8 assigns pin T_PEG_PULSE: 0 – undefined, 1
– T PEG pulse
See also PEG, page 7-6.
206 0–3 getconf only.
The
function is The low 9 bits of the returned value display the actual state of the
valid for output pins of the specified SP. The pins are shared between the
axes low 9 bits of the SP output register and the PEG outputs.
X,Y,Z,T See also PEG, page 7-6.
only
214 0–7 Only valid for brushless motors (MFLAGS.8 = 1).
Specifies
one of the getconf retrieves the commutation phase (degrees) at the current
axes. point.
setconf adjusts the commutation offset so that the commutation
phase at the current point will be equal to the specified value
(degrees).
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-65
215 0–7 Only valid for brushless motors (MFLAGS.8 = 1) and where the
Specifies index has been encountered (IND contains a valid value).
one of the
axes. getconf retrieves commutation phase (degrees) at the point of the
last index stored in the IND variable.
setconf adjusts commutation offset so that commutation phase at
the point of last index will be equal to the specified value (degrees).
216 0–7 getconf retrieves commutation state (bit 9 of MFLAGS):
Specifies 0 - Commutation is not OK (not initialized)
one of the 1 - Commutation is OK.
axes.
setconf executes the following actions:
If value = 0:
• clears bit 9 of MFLAGS (state ‘Commutation is not OK’);
• clears bits 1, 4, 5, 6 of MFLAGS;
• sets bit 8 of MFLAGS;
• resets DCOM to zero.
If value = 1:
Same as when value = 1 but also adjusts RPOS value so that
RPOS = FPOS.
217 0–7 The functions work correctly only if the motor is brushless
Specifies (MFLAGS.8 = 1) and the index was encountered (IND contains a
one of the valid value).
axes.
getconf is not supported.
setconf combines actions of setconf (215…) and
setconf (216,…,1):
• adjusts commutation offset so that commutation phase at the
point of last index will be equal to the specified value
(degrees);
• sets bit 9 of MFLAGS (state ‘Commutation is OK’);
• clears bits 1, 4, 5, 6 of MFLAGS;
• sets bit 8 of MFLAGS;
• resets DCOM to zero;
• adjusts RPOS value so that RPOS = FPOS.
301 Ignored getconf retrieves the size of the segment queue in segmented
motions (mptp, mseg, path, pvspline).
setconf is not supported.
Return value
none
Error conditions
None.
5.8. Expressions
5.8.1. General
An expression is a sequence of operators and operands that specify a calculation.
Expressions serve as building blocks for many ACSPL+ commands. For example, assignment
commands include expressions to the right of the equal sign:
V0 = V1 + 2*(V2 - V3)
When the controller executes a command that includes an expression, the expression is calculated
and the result is used as required by the command.
Complexity of expression ranges from the simplest expressions that include only one constant or
variable name, to extended formulae containing multiple operators and functions with several
levels of brackets. For example:
I99 = 5 5 is a simple expression
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-67
Symbol Operation
If several operators appear on the same line or in a group, they have equal precedence.
In this assignment command, the integer variable V0 is left of the equals sign, while a real
expression is to the right of the equal sign. The controller automatically uses rounding type
conversion of the result obtained on the right side, so that the real value can be converted to an
integer variable and stored.
The types of operands and operators used in the expression define the expression type. Each
operator has an associated rule that defines the type of result according to the types of operands.
The rules are summarized in the following tables. Integer (0,1) is specified for the operators that
produce only two values: 0 or 1 (logical result).
Unary operators:
5.8.4. Operands
An operator requires one or two operands.
An operator that requires one operand is called a unary operator. A unary operator is placed
before its operand.
An operator that requires two operands is called a binary operator. A binary operator is placed
between its operands.
Each operand can be either integer or real. If the operator requires, the controller automatically
converts the operand to the required type.
Operands can be one of the following:
Constant
Symbolic constant
Scalar variable name
Array name with indexing
Function call
Expression
A constant can consist of any integer or real number. Integer constants can be presented in
decimal, hexadecimal and binary notation. Real constants can include a decimal point and/or
exponent.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-69
Symbolic constants are predefined in the controller. Each symbolic constant presents an integer
number.
A variable name is a name of any standard or user-defined variable. If a user-defined name is
used, it must be declared before being used in the program. If the variable presents an array, the
name must be fully indexed to specify one element of the array.
Any ACSPL+ function can be used in an expression. Using expression as an operand of other
expression provides unlimited variety of expressions. In many cases expression used as operand
must be enclosed in brackets. For example:
(V0+5)*7 Expression V0+5 is the left operand of multiplication
Var = 5/4
on IN0.5 = 1 ...
Because they always produce a result as an integer, compare operators can be used in arithmetical
calculations, for example:
V1 = (V0 = 5) * V4
The following two examples illustrates the difference between the ~ and ^ operations:
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-71
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Operand X 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0
Result of ~X 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1
Result of ^X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Operand X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Result of ~X 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Result of ^X 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Note
Inversion is a bitwise operator, while logical not is not.
provides waiting for the end of the X axis motion. The symbolic constant #MOVE (5) provides
selection of bit 5 of the MST variable (Motor State). The 5th bit of MST reflects the state of the
motion: it is 1 while the axis is in motion, and is 0 while the axis is idle.
5.9. Commands
A command is the smallest executable unit of ACSPL+.
See also how axes are designated in commands, page 5-11.
Examples:
The following is an example of a program line that contains one assignment command:
V0 = V1 + 2*(V2 – V3)
The following is an example of a program line that contains two assignment commands:
V0 = V1 + 2*(V2 – V3); V4 = 0
White spaces (spaces and tabs) may be inserted arbitrarily inside or between commands.
However, white spaces must not be inserted within keywords and variable names.
A control structure consists of several commands. Control structures start with a specific
keyword and terminate with the end command.
For example, a loop control structure starts with the loop command followed by an arbitrary
number of commands and terminates with the end command. The commands of a control
structure may reside in one or more program lines.
Examples:
The following two loop control structures are logically equivalent:
loop 5 Execute the loop body 5 times
V0 = V0 + 1 Increment V0
Assignment Command
= Assigns right side of expression to variable on left
side.
Program-Flow Commands
if, elseif, else, end If control structure. 5-79
while, end While control structure. 5-80
loop, end Loop control structure. 5-82
call, ret Implements subroutine. 5-83
goto Transfers program execution to another point in the 5-86
program.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-73
Synchronization Command
wait Delays program execution for a specified number of 5-88
milliseconds.
till Delays program execution until a specified 5-88
expression produces a non-zero (true) result.
Autoroutine Command
on Specifies autoroutine header. 5-90
Interaction Commands
disp Builds a string and sends it to a communication 5-97
channel.
send Same as disp, but also specifies which 5-99
communication channel.
interrupt Causes an interrupt that can be intercepted by the 5-100
host.
copytodpr Instructs the controller to copy a variable to an 5-101
address in the DPRAM.
stopcopytodpr Invalidates all previously executed copytodpr 5-101
commands.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-75
Miscellaneous Commands
dc Activates data collection. 7-1
stopdc Terminates data collection prematurely. 7-1
assignpeg Assigns outputs to PEG and sets the initial state of 7-7
PEG state outputs.
peg_i Activates incremental PEG™, where pulses are 7-9
generated at predefined position intervals.
peg_r Activates random PEG, where predefined pulses are 7-10
generated upon position events.
read Reads an array from a file in the nonvolatile (flash) 5-119
memory.
safetyconf Configures a fault for a group of axes. 5-120
safetygroup Groups axes into a safety group, wherein the fault 5-121
configuration of the first axis is applied to the
others and a kill or disable operation on any axis in
the group affects all axes in the group.
setprotection Changes protection attribute for a variable. 5-120
stoppeg Terminates PEG operation prematurely. 7-11
write Writes an array to a file in the nonvolatile (flash) 5-119
memory.
Left-term
Equal sign
Expression.
The controller executes assignment commands in the following order:
1. Calculate right-side expression
2. Convert the type of calculated value to the type of left-term (if the types differ)
3. Assign the result to the left-term
The right side expression can be of integer or real type.
By using different operators and parenthesis, you can construct an unlimited number of
expressions.
The left-term may consist of several elements. Only variable-name is obligatory. Variables that
are specified on the left side may be standard or user variables.
Different variants of left-term provide assignment to the following objects:
Standard or user variable
One element of standard or user array
One bit of integer variable or integer array element
The following sections explain assignment for specific types of the left-term.
It is a legal command. However, when the command executes, if the controller is in protected
mode, the assignment fails and produces a run-time error.
• If a standard variable is scalar, no indexing is required.
• If a standard variable is an array, explicit or implicit indexing is required. For indexing of
standard variables on page 5-20.
Examples:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-77
In the controller, an integer number is presented by 32 bits. The bits are numbered from 0 to 31.
The least significant bit is bit 0. The expression in a bit specifier must calculate to integer number
in the range 0..31.
A bit can have only two possible values: 0 (false) or 1 (true), while the right-side expression
result, which defines the bit value, can be any value. Assignments convert the value as follows:
If the value is zero, the bit is set to zero
If the value is non-zero, the bit is set to one
Although bit assignments are applicable to any integer variable or array element, they are mainly
used for changing flag variables and output bits.
Examples:
OUT0.13 = 1 Set output 13 to one.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-79
The commands if, while, loop open a control structure that may include a number of commands:
control-structure :
if-control-structure
while-control-structure
loop-control-structure
The following program fragment activates either output 5 or 6 and shuts off the other, depending
on the state of input 3:
if IN0.3 Check if the third bit of IN0 is raised
else Execute the next commands only if the if condition was false
The result of the two fragments is identical, but the execution time is different. The second
executes faster, because the controller executes one program line per each controller cycle.
However, packing too many commands in one line is not recommended, because it increases the
calculation load and may cause a Time Overuse exception.
Note, that the same result can be achieved without if command:
OUT0.5 = IN0.3 ; OUT0.6 = ^IN0.3
The following fragment implements saturation effect by limiting variable V0 to the range of-256
to +256:
if V0 < -256 Check if V0 is less than -256
elseif V0 > 256 If V0 is not less than -256, check if it is greater than 256
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-81
The following fragment waits for motion termination, and calculates how long the controller
waits:
V0 = 0 Assign V0 to zero
Note, that the same result can be achieved without while command:
V0 = TIME Store the current time in V0
The purpose of the till command after the jog command is to prevent the loop execution during
the acceleration segment of the motion profile because it is a transient process. The external while
loop does nothing as long as the position error falls into the allowed interval 10-50. If the error is
greater than 50, the first internal loop slows down the motion until the error returns to the interval.
If the error is smaller than 10, the second internal loop increases the velocity until the error returns
to the allowed interval. The imm command provides for changing Z_VEL in the current motion,
and is necessary because a simple Z_VEL command without imm would become effective for the
next motion and not the current motion.
V2 = 0 Assign 0 to V2
V2 = V2 + 1 V2 = V2 + 1
V1 = V1 * V2 V1 = V1 x V2
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-83
The following fragment starts point-to-point motions individually for X, Y and Z axes, waits for
termination of all three motions, checks the reason for the termination and provides error
messages:
V0 = 0 Assign 0 to V0
till ^X_MST.#MOVE & ^Y_MST.#MOVE & ^Z_MST.#MOVE Wait until all motions finish
V0 = 0 Assign zero to V0
Display a message
describing the axis and the
reason (error code) for
termination
end End of the if body
V0 = V0 + 1 Increment V0
label specified in the label-name argument must be defined somewhere in the same buffer. The
subroutine starts after the label and spans all commands up to the subsequent ret command.
The call command transfers execution to the start of the subroutine and stores the return point in
the stack. When the subsequent ret executes, the return point is extracted from the stack and
execution continues from the command that follows the call command.
Subroutine calls can be nested, i.e. a subroutine can call another one and so on.
You must enter a subroutine with the call command and exit a subroutine with the ret command.
Otherwise, the stack will be left in an improper state, resulting in program termination due to the
stack violation error.
Examples:
The following program defines and uses subroutine Factorial that calculates Fact as factorial of
Arg (given Arg >= 0):
local int Fact, Arg, In; Declare local variables
stop
In = 0 Assign 0 to In
In = In + 1 Increment In
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-85
Standard variable AERR stores termination code of the last motion. Codes greater than or equal
to 5010 indicate motion failure.
V0 = 0 Set V0 to 0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-87
end
stop
Standard variable MERR stores the reason for the last motor disable. Standard variable AERR
stores termination code of the last motion. Codes greater than or equal to 5010 indicate motion
failure.
Examples:
The following example is a program that tests the wait command:
V0 = 0 Assign 0 to V0
loop 100
V1 = TIME
wait V0
disp TIME – V1
V0 = V0 + 1
stop
If the controller cycle is 1 millisecond and PRATE is one, the program displays a list of numbers
from 2 to 101. The first number 2 corresponds to the standard execution time of two lines,
because the first time the additional delay provided by the wait command is zero. Each loop
executed adds one to the requested delay, therefore the displayed time grows correspondingly.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-89
If the expression result is zero, wait one controller cycle and repeat the till command
execution.
Examples:
The following fragment demonstrates a typical use of till command that provides waiting for a
specific state before the execution of the next command:
ptp X, 2000 Start positioning of the X axis to absolute point
2000
till ^X_AST.#MOVE Wait until the motion finishes
Bit X_AST.#MOVE is raised as long as the X axis is involved in a motion. Inversion of the bit
(^X_AST.#MOVE), causing the bit to becomes non-zero, occurs when the motion ends for any
reason. Therefore the above till command provides delay of execution of the next command, until
the motion is over.
In the following example, the program starts a data collection and then a motion. The feedback
position is sampled with a period of 1 millisecond and stored in the data array. After the data
collection finishes, the data array contains a transient process of ptp motion. Synchronous data
collection used in the example displays its state in bit Y_AST.#DC which is raised as long as the
data collection is in progress. The collected data can be safely used only after the data collection
process has terminated. The till command below validates that both the motion and the data
collection are over:
global real Data( 1000 ) Declare global real array Data of
1000 elements
dc/s Y, Data, 1000, 1, Y_FPOS Start data collection of Y_FPOS to
array Data, 1000 samples, 1ms period
ptp Y, 2000 Start positioning of the Y axis to
absolute point 2000
till ^Y_AST.#MOVE & ^Y_AST.#DC Wait until both the motion and the
data collection finish
The following example provides Z axis motion in negative direction until a general purpose input
becomes active and then terminates the motion:
jog Z, - Start jog motion in negative direction
In the following example a general purpose output must be activated 25 millisecond before the
motion end. Standard variable GRTIME displays the estimated time that remains to the motion
end.
ptp X, 10000 Start positioning of the X axis to
absolute point 10000
till X_GRTIME <= 25 ; OUT0.4 = 1 Activate output 4 25 milliseconds
before the motion ends.
Output activation OUT0.4 = 1 is placed in the same line that the till command in order to avoid
one controller cycle delay between program lines.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-91
As explained above, an autoroutine interrupts the program in the host buffer, but is executed in
parallel with programs that are executed in other buffers.
The user can specify different execution rates (number of lines executed per one controller cycle)
for regular program and for autoroutines in the same buffer. Standard array PRATE that contains
elements for each program buffer, specifies the execution rate for regular program. Standard array
ONRATE specifies the execution rate for autoroutines.
For example, the user configured the controller so that PRATE(2) is one, but ONRATE(2) is
four. Therefore, the program in buffer 2 will be executed one line per one controller cycle, and
any autoroutine specified in buffer 2 that interrupts the program will be executed four lines per
one controller cycle. When the ret command that terminates the autoroutine is executed, the
controller switches back to the rate of one line per one cycle.
5.9.6.4. Examples
The following fragment demonstrates a typical use of autoroutine for processing the controller
faults. The autoroutine provides an error message when the Drive Alarm of X drive occurs:
on X_FAULT.#DRIVE Activate autoroutine when bit
X_FAULT.#DRIVE changes from 0 to
1
disp “X Drive Alarm” Display an error message
The following autoroutine responds when either the Left Limit and Right Limit are activated:
on Y_FAULT.#LL | Y_FAULT.#RL Activate autoroutine when the
right or left limit switch is
activated on the Y axis
disp “Y Limit Switch activated” Display an error message
The following example assumes that an extra ventilator must be activated when the motor
Overheat input signal is activated. The ventilator is controlled by output bit OUT0.4. The
ventilator must be disabled when the signal returns to inactive state.
on Z_FAULT.#HOT Activate autoroutine when bit
Z_FAULT.#HOT changes from 0 to 1.
OUT0.4 = 1 Set output 4 to 1
All bits, not only faults, can be used in autoroutine conditions. Assuming that output OUT0.6 is
connected to an LED indicator, the following autoroutines signals the motion state bit to activate
the indicator, and deactivate it when the axis is no longer in motion:
on X_MST.#MOVE When the X_MST.#MOVE X bit changes from 0
to 1 (signaling that the axis is moving)
OUT0.6 = 1 Set output 6 to 1 (turn on the LED)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-93
An autoroutine condition can be any type of expression, not only bit verification. The following
autoroutine provides an alarm message if a fault occurs in the controller:
1 on S_FAULT When a fault occurs
The above autoroutine displays the alarm message only on the first fault. If one fault bit is already
raised, and another fault occurs, the second fault does not cause the alarm message. For further
discussion, see Chapter 9: Safety Control.
Standard array MERR (motor error) can be used for motor failure processing. While a motor is
enabled, the corresponding element of MERR is zero. If a motor is disabled, the element stores
the reason why the motor was disabled. Codes greater than or equal to 5010 correspond to fault
conditions. The following autoroutine displays a message when the controller disables the X
motor due to any fault.
on X_MERR >= 5010 When the X motor
is disabled
disp “Motor X was disabled. Error code: Display a message
“, X_MERR stating that the
motor was disabled,
and the error code
of the fault
ret End of autoroutine
The standard array AERR can be used to detect abnormal motion termination.
Variables MERR, AERR expose only those faults that cause motor disable or abnormal motion
termination.
As any other command, a program management command can be either executed immediately
from the command prompt, or stored in a buffer. Using program management commands within a
program provides the ability to create a master program that manages execution of other
programs.
start 2, Pstart
The following terminal command displays change in buffer state after the start command was
executed:
?2
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-95
stopall-command :
stopall
The stop command without buffer-number the program in the buffer is the normal method of
program termination.
The stop command with buffer-number terminates a program in the specified buffer. A master
program that manages the whole application can use this command in order to terminate a certain
activity.
The stopall command executed by a program terminates all other concurrently executed
programs, but the program itself continue executing.
After termination by the stop or stopall command a program remains in compiled state.
Therefore, if the program contains autoroutines, an autoroutine can be activated after the program
termination as soon as its condition is satisfied.
Examples:
The following command terminates the current program:
stop
The following command terminates the program only if the X axis is disabled:
if ^X_MST.#ENABLED stop; end
The following command executed in buffer 0 terminates the programs currently executed in all
buffers except buffer 0:
stopall
The following terminal command displays change in buffer state after executing the stop
command:
?3
The resume command resumes execution of the program suspended in the specified buffer. If the
program was not suspended, the command has no effect.
Examples:
The following command suspends the program currently executed buffer 0:
pause 0
The following terminal command displays change in buffer state after executing the pause
command:
?0
The following terminal command displays change in buffer state after executing the resume
command:
?0
:
?0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-97
enableon 0
:
?0
The disp command takes as its argument(s) one or more expressions and/or input strings.
An input string argument can include one or more of the following:
Text.
Escape sequence - replaced in output string with a non-printing character or other specified
character (\xHH).
Formatting specification - determines how the results of an expression that follows the
input string is formatted in output string.
The format specification syntax adheres to a restricted version of the C language syntax.
The format specification syntax is: % [width] [.precision] type
width
Optional number that specifies the minimum number of characters output.
precision
Optional number that specifies the maximum number of characters printed for all or part of the
output field, or the minimum number of digits printed for integer values
type
Required character that determines whether the associated argument is interpreted as a character, a
string, or a number. The following types are supported:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g La n g u a ge 5-99
If an input string argument contains n format specifiers, the specifiers apply to the n subsequent
expression arguments.
The disp command processes the arguments from left to right. The processing is as follows:
Expressions: The expression is evaluated and the ASCII representation of the result is
placed in the output string. The format of the result is determined by a formatting
specification (if any) in the input string.
Input strings: Text is sent as-is to the output string. Escape sequences are replaced by the
ASCII codes that they represent. Formatting specifications are applied to the results of any
expressions that follow the string.
Examples with descriptions:
disp “%15.10f”,X_FPOS
disp “%1i”,IN0.2
The output string is sent to a communication channel. The channel is specified by the current
value of standard variable DISPCH (default channel). The following values are available:
1 – serial communication channel COM1.
2 – serial communication channel COM2.
10 – Ethernet network.
-1 – no default channel is specified, the disp command uses the last channel activated by the host.
1 Serial port 1
2 Serial port 2
10 Not available
12 Communication through PCI
bus
The disp-arguments are the same as those for the disp command (see page 5-97).
Printout: 0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-101
The set command determines a current value of the feedback, reference or master position.
The group, split and splitall commands manage grouping of the axes in coordinate systems for
multi-axis motion.
The connect command defines the relation between motors and axes.
The master command defines a master value for an axis.
The go command starts a motion that was created using the w (wait) suffix. A motion that has
been created without this suffix starts automatically after creation and does not require the go
command.
The halt command terminates a motion using a deceleration profile. The deceleration value is
specified by the DEC variable.
The break command provides premature termination of a motion with smooth transition to the
next motion.
The imm command provides on the fly change of the motion parameters; velocity, acceleration,
deceleration, jerk, kill deceleration.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-103
If the MFLAGS.#ENMOD bit is 1, the ENTIME value defines the time of enable execution.
Executing the enable command, an ACSPL+ program always waits for ENTIME milliseconds. If
then the drive alarm fault is zero, the enable command is considered successful; otherwise the
enable command fails.
If the MFLAGS.#ENMOD bit is 0, the ENTIME value defines the maximum time allotted for
enable execution. Executing enable, an ACSPL+ program monitors the drive alarm input signal.
As soon as the drive alarm becomes inactive, the enable command finishes execution with
success. If the drive alarm signal does not change to inactive state within ENTIME milliseconds,
the enable command fails.
Examples:
enable X Enable motor X
disable Y,5011 Disable motor Y, store 5011 as a disable reason. Code 5011
corresponds to left limit error, therefore the Y motor will be
reported as disabled due to fault involving left limit.
disable XT Disable motors X and T
A cause stored in the MERR variable is cleared by the fclear or enable command.
Each motor specified in a kill operation decelerates individually using its KDEC deceleration
value.
Any motion related to the killed motors is terminated. If a motion involves several motors and
only some of the motors are specified in a kill command, all other motors decelerate
synchronously using a third-order profile and the DEC deceleration value (same behavior as with
the halt command, see halt command, page 5-114).
The following examples illustrate kill execution under different conditions. (Some of the
examples involve a default connection. This is a condition where a motor depends only on the
corresponding axis and the difference between motor and axis can be ignored. For more
information about default and non-default connections, see connect and depends commands, page
5-109.)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-105
Kill cause 6088 (user-defined code) is stored in X_MERR, Z_MERR and A_MERR. However,
if at the moment one of these variables contains a non-zero value, the value is not overwritten and
the previously stored cause is retained.
Command kill A (again with default connection) kills the A motor and terminates the A motion,
but does not effect motors and motions X and Z.
depends X,X
(in this case the depends command is not necessary), the kill X command starts the same kill
process on the X motor and the halt process on the motion that involves the X axis. All above
considerations about the idle motor, single-axis motion and multi-axis motion remain the same.
The result is a little different if a motor depends on another axis or on several axes, for example
connect Z_RPOS = X_APOS + Z_APOS – A_APOS
depends Z,XZA
(in this case the depends command is required). The difference is that the kill Z command applies
the halt operation to all executed motions involving any of the axes X, Z, or A. Correspondingly,
bits Z_AST.#MOVE and Z_MST.#MOVE remain 1 as long as any of these motions continues
its termination process.
Note that a killall (or kill all) command always terminates all executed motions and therefore
makes no difference between the default and non-default connection.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-107
set X_FPOS = 0
places the origin of the X axis to the point where the motor is located this moment.
FPOS and RPOS provide a reference and a feedback value for a motor. If a control loop works
properly, FPOS follows RPOS with small or zero error.
If the error is zero, both set FPOS and set RPOS provide the same result: both FPOS and RPOS
become equal to the right-side value. This is not a simple assignment, and the command adjusts
the controller offsets so that the periodic calculation of FPOS and RPOS will provide the
required results.
If the error is non-zero, the result of set FPOS and set RPOS may differ slightly. Consider the
following example:
?X_RPOS, X_FPOS Query X_RPOS and X_FPOS
Note, in both set commands no physical motion occurs. The X axis remains in the same position,
only the internal offsets in the controller are adjusted to shift the origin as required.
Note, that even if a motor is idle, several identical set FPOS commands may place the origin at
slightly different points due to the jitter in feedback.
If a motor is flagged by Default Connection bit (MFLAGS.#DEFCON), variables RPOS and
APOS are conjugate. Therefore, any command that changes RPOS, also changes the
corresponding APOS to the same value.
The command set F2POS shifts the origin of secondary axis feedback. For example, command
set X_F2POS = 0
places the origin of the X axis secondary feedback to the point where the motor is currently
located.
As a result of the command execution, F2POS becomes equal to the right-side value. This is not a
simple assignment, as the command adjusts the controller offsets so that the periodic calculation
of F2POS will provide the required result (The specified value in the current point).
Note, that even if a motor is idle, several identical set F2POS commands may place the origin in
slightly different points due to the jitter in feedback.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-109
splitall-command :
splitall
In simple cases axes-specification consists of axis letters like XZ. After power-up each controller
axis is a single axis, no one axis group exists. One-axis motion does not require any axis group.
One-axis motion can be activated immediately after power-up, assuming that the motor is
enabled. Several one-axis motions can be activated in parallel, and do not require any axis group
definition.
An axis can belong to only one group at a time. If the application requires restructuring the axes,
it must split the existing group and only then create the new one.
For example, the command
group XZT
where axis RPOS is an axis RPOS variable(for example, X_RPOS), which receives the value
of the expression.
For more information about RPOS and other common motion variables, see motion overview,
page 3-16.
The connect command is not an assignment command (see , assignment commands page 5-75). It
does not simply assign the result of the formula on the right side to the axis RPOS.
The formula not evaluated when the connect command is executed (which would be the case for
an assignment command). Instead, the formula is stored and then evaluated by the controller
every controller cycle to calculate the corresponding RPOS.
After power-up the controller always starts with the default connection. The default connection
means the following for each axis:
• Bit MFLAGS.#DEFCON is raised.
• The default connect formula is defined as connect RPOS = APOS.
• APOS and RPOS are linked, i.e., explicit (through the set command) or implicit change of
one of these variables causes the same change in the other one.
Once an application resets MFLAGS.#DEFCON, it can then execute a connect and (typically) a
depends command. At that point, the motor is considered to be in non-default connection.
Consider the following examples:
The commands
Y_MFLAGS.#DEFCON = 0
depends Y, X
connect the Y motor position to the X axis reference. If the X motor is also connected to the X
axis reference, this provides gantry-like motion of two motors.
The command
ptp X, 1000
connects the X motor position to the X axis reference plus analog input 1. In this case the X axis
provides a motion and the analog input (for example, an external sensor) supplies a correction for
the X motor.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-111
depends Z, ZT
connects the Z motor to the sum of axes Z and T. The axes can each execute an independent
motion, with the Z motor following the sum of the two motions. Or the axes can participate in a
single multi-axis motion.
. . . Continue.
A more sophisticated application may require changing the connection in the middle of
operations. The controller applies no limitations regarding when a connection can be changed. In
a typical case, changing connection requires three commands:
connect X_RPOS=… Specify connection of X motor.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-113
The connect command specifies a basic formula that the controller uses to calculate the RPOS.
However, in the process of RPOS calculation the controller also adds an implicit offset which is
not specified in the connect formula.
The controller calculates the offset automatically and recalculates it in the following
circumstances:
• Execution of connect RPOS=… command for the motor.
• Execution of set RPOS=… or set FPOS=… command for the motor.
• Execution of set APOS=… command for any axis that the motor depends on.
• Execution of enable command for the motor.
When a connect command is executed, the offset is adjusted so that the RPOS specified on the
left side of the connect formula and any APOS specified on the right side retain their current
values. For this reason the connect command can be executed while the motor is enabled and
does not cause a motor jump. Using this implicit offset the controller ignores any explicit offset
specified in the connect formula. For example, the following commands have exactly the same
effect:
connect X_RPOS = 0.5*X_APOS + 1000
and
connect X_RPOS = 0.5*X_APOS + 2000
5.9.9.7. go Command
The go command starts a motion that has been created using the w (wait) suffix. A motion that
has been created without this suffix starts automatically after creation and does not require the go
command.
The command syntax is:
go-command :
go axes-specification
In simple cases motor-specification is single axis letter like X or Z, or a string consisting of axis
letters like XZ, or keyword all.
There following possibilities are available:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-115
A halt command specifies a leading axis in a group. The command terminates the currently
executed motion in the same axis group. If no motion is executed, the command has no effect.
Terminating several motions.
A halt command specifies several axes. Each axis in the specification must be either a single axis
not included in any group or a leading axis in a group. The command terminates currently
executed motions in all specified axes and groups. If any of referenced axes are idle, the
command does not affect this axis/group but does affect all other specified axes/groups.
executed motions in all specified axes and groups. If any of referenced axes are idle, the
command does not affect this axis/group but does affect all other specified axes/groups.
NOTE
Although the imm command resembles assignment, execution of the imm command differs from
normal assignment to the same variables.
As in conventional assignment, execution of the imm command starts from calculation of the
right-side expression. The calculated right-side value is assigned to the left-side variable.
Execution of flat assignment finishes at this point.
The difference between conventional assignment and the imm command becomes apparent when
the command executes while a motion is in progress. The assignment command does not affect
the motion in progress or any motion that was already created and waits in a motion queue. Only
the motions created after the assignment will use the motion parameters changed by the
assignment. The imm command, on the other hand, not only changes the specified variable, but
also affects the motion in progress and all motions waiting in the corresponding motion queue. To
change a motion on the fly, the imm command must change a variable of the axis that is a single
axis of the motion or a leading axis if the motion is in axis group.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-117
The command will operate properly only after the SPiiPlus MMI Adjuster has been used to:
• perform initial commutation adjustment
• adjust the motor properly
• save the adjustment parameters to the controller’s flash memory.
Commutation using the SPiiPlus MMI Adjuster is described in depth in the SPiiPlus Setup
Guide.
Motor movement during commutation very much depends on the servo settings.
The commut command will not operate properly if variable SLPKP is set to zero, or the
integrator is very low.
The command has the following syntax:
commut-command :
imm-command :
commut axis, excitation-current, settle-time, slope
If one of the parameters is omitted then default values are used.
The excitation-current is given as a percentage of the full command. Its default value is set to
98% of the XRMS variable, which indicates the nominal current of the system. Note:
• In air bearing systems a lower excitation current may be required.
• In high friction systems a higher excitation value is required.
The excitation current should be the same as that determined by the user in the initial
commutation adjustment process.
The settle-time parameter determines settling time (default: 500 msec) for the autocommutation
process initiated by the commut command. The entire autocommutation process lasts
approximately three times longer, since the command executes the algorithm three times for
verification. Note:
• In low-bandwidth systems (high inertia, etc.) a higher value may be required.
The settling time should be the same as that determined by the user in the initial commutation
adjustment process.
The slope parameter is optional, and used only in special cases. If a value is assigned to this
parameter then the excitation current command builds up with some slope. The parameter sets the
duration of the current build-up process in milliseconds. It is usually recommended to omit this
parameter, in which case the excitation current is built instantly.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-119
Remarks
If a user array is specified for the array-name argument, the user array name must be declared in
the buffer where the command is executed. If the command is executed as a terminal command,
the array name must specify an array with global scope, i.e. any standard or user global variable.
The file name must contain only the name without an extension. Quotation marks are not
required. The name cannot include spaces. If a file with the specified name does not exist, it is
created. If the file already exists, it is overwritten.
If a file with the specified name does not exist, or the size of the saved variable does not
correspond to the size of the specified variable, the function causes a run-time error.
axis-list List of axes for the group. Fault configuration of first axis in
list is applied to all the axes.
fault A fault constant, (example: #LL).
conf-string String enclosed in double quotation marks. The string contains
one or more of the following characters:
K: enables kill response
D: enables disable response
Both K and D: enable kill-disable response
+: provides fault generalization
-: disables fault detection
If an empty string is specified, fault detection is enabled, but
the controller has no response to the fault. However, an
autoroutine can intercept the fault and provide a response.
Remarks
The safetyconf command overwrites any previous configuration for the specified fault for the
specified axes. However, the command does not invalidate any active safety groups.
The following examples illustrate fault configuration:
safetyconf X,#PE,”K” X motion will be killed if the X Position Error fault occurs.
safetyconf ZA,#LL,”KD” X motion will be killed and then the X motor will be disabled
if the X Left Limit fault occurs.
A motion will be killed and then the A motor will be disabled
if the A Left Limit fault occurs.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-121
safetyconf all,#DRIVE,”D+” All axes will be disabled if a Drive Alarm fault occurs on any
axis.
safetyconf all,#VL,”-” The Velocity Limit fault will not apply for any axis.
safetygroup axis-list
Arguments
5.10. Protection
Application protection does the following:
At any time the user can enable or disable application protection. When application protection is
disabled, none of the protections specified above apply.
When application protection is enabled, the controller is said to be in protected mode. When
application protection is disabled, the controller is said to be in configuration mode.
At any time the user can intentionally delete the application in the controller. This operation
brings the system to factory default state and disables all protections.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-123
Any command that involving a prohibited action will be rejected with the error “Protection
violation.”
Protection does not affect power-up operations of the controller. Therefore, the user application
stored in the flash memory will be loaded on power-up, including the saved values of all protected
variables and all saved ACSPL+ programs. If one or more programs contains an AUTOEXEC
label, the program will automatically start executing from this label.
The user is able to change the protection attribute for each variable individually. The following
command specifies the variable to be protected:
setprotection variable = 1
The following command specifies the variable to be not protected:
setprotection variable = 0
The variable is any standard variable name except the read only variables.
Only standard variables can be protected. Assignment to a user variable is allowed in any
controller mode.
If a variable represents an array, all elements of the array share the same protection attribute.
Therefore the array as a whole can be protected or not protected. Protection cannot be specified
for individual elements of the array.
The setprotection command can be executed only in configuration mode.
The state of protection attribute for each variable is stored in the flash memory when the
controller executes the #PROTECT command.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A C S PL + M u lt ip r og r a mm in g L an g u a ge 5-125
6. MOTION
If the axis is moving when the command is executed, the controller creates the motion and inserts
it into the axis motion queue. The motion waits in the queue until all motions before it finish, and
only then starts.
This command creates a motion of the X-axis to the absolute target point of 1000. If the axis is
idle when the command is executed, the motion starts immediately.
If the e suffix is specified, the controller will wait until the motion terminates before executing the
next command. The e suffix is a convenient substitute for following the ptp command with
another command that waits for motion termination.
For example, the command:
ptp/e Y,1000
is equivalent to
ptp Y,1000
till ^Y_AST.#MOVE
Append the w suffix to the command to prevent the motion from starting immediately even if the
axis is idle.
The command:
ptp/w X, 1000
creates a motion to the absolute target point 1000, but the motion will not start until the go X
command is executed.
In the two examples above the value 1000 is an absolute target point. Use the r suffix to specify a
relative value:
ptp/r X, 1000
This command creates a motion to relative target point, which will be defined exactly only when
the motion starts. When the motion starts, the target point is calculated as instant axis position
plus the specified value.
For example, the following two commands
ptp X, 1000
ptp/r X, 1000
are equivalent to
ptp X, 1000
ptp X, 2000
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 3
In the previous examples the motion executed using the default velocity X_VEL for the specified
axis. Use the v suffix to override the default velocity, as shown in the following example:
ptp/v X, 1000, 15000
The motion created will ignore the default velocity X_VEL and execute at a velocity of 15000.
The default value X_VEL remains unchanged.
Several suffixes can be combined in one command. For example, the command
ptp/rv X, 1000, 15000
creates a temporary axis group that includes axes XYT and executes motion in one group.
Temporary axis groups are automatically created and split-up by the controller. A group is
automatically split-up if the following motion does not address all the axes in the group.
As mentioned in Section 3.4.2, in multi-axis PTP move the controller normally takes the motion
parameter values from the leading axis. However this can be overridden by using the M suffix,
which causes the controller to calculate the maximum allowed common motion velocity,
acceleration, deceleration and jerk.
The calculation examines the VEL, ACC, DEC, JERK parameters of the axes involved and the
projections of the motion vector to the axes.
Example:
X _ VEL × x 2 + y 2
Vx =
x
Y _ VEL × x 2 + y 2
Vy =
y
as follows:
If V x < V y then Vc = Vx else Vc = V y
This applies irregardless of the order in which the axes appear. Vc will be the same for
ptp/m XY, 1000, 2000
as it is for
ptp/m YX, 2000, 1000
The calculation works the same way where more than two axes are in the group. For example, if
there are four axis moving, the maximum common velocity allowed for each axis is calculated
and compared, with the lowest of them assigned to Vc.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 5
If the m suffix is combined with the v suffix, the m suffix is ignored for the velocity and the
velocity specified in the command is used. However, common acceleration, deceleration, and jerk
are still calculated.
J = J + 1 Increment J
end
stop
The program executes the ptp command 30 times. Each time, the command defines a new target
point in the XY plane with a dwell of 100 msec. at each point. The motion trajectory between the
specified points is straight, and the target points are spread equally along the ellipse as shown in
the following figure:
J = 0 Set J to zero
J = J + 1 Increment J
end
When ptp executes the first time J = 0, which corresponds to the X axis. Therefore, the command
starts motion of X to point 0. The second time J = 1 and the ptp command starts motion of the Y
axis to point 0. The third time the ptp command starts motion of the Z axis, and so on. When the
program finishes, all axes are positioned at their origin.
Note that each ptp command creates a motion, without waiting for the previous motion to finish
before the next motion starts. The program executes at a default rate of one command line per
controller cycle, and the default is one millisecond. The Y axis will therefore start moving a few
milliseconds after the X axis starts moving, and the Z axis will start moving a few milliseconds
after the Y axis. Thus, all axes will simultaneously be in motion
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 7
The controller provides position latch facility with extra fast response.
When the MARK1 input signal is activated, the instantaneous position is automatically latched
into the MARK variable. Simultaneously, the corresponding bit IST.#MARK is raised indicating
that the MARK variable contains a valid value. Additional occurrences of the MARK1 input
signal are not latched as long as the corresponding bit IST.#MARK remains raised. The MARK
variable therefore retains the position of the first occurrence until the application explicitly resets
the IST.#MARK bit. The latched position accuracy is ±1 encoder count at any velocity up to
5,000,000 counts/sec.
Assume that the following motion must be built:
1. Move to the mark position
2. Latch the exact mark position and continue moving
3. Stop the motion smoothly at the position calculated as mark position plus 15000 units
The following program fragment performs the task:
X_IST.#MARK = 0 Enable MARK1 signal latching
jog X, + Start jogging in the positive direction
till X_IST.#MARK Wait for MARK1 signal
ptp X, X_MARK + 15000 Start positioning to the point X_MARK+15000
Assignment X_IST.#MARK = 0 in the first line, resets the status bit of MARK1. The reset is
required, in case the MARK1 signal previously occurred, which would have raised
X_IST.#MARK and prevent further latching. To approach the mark position, a jog motion is
used (line 2). Mark position is assumed to be located in the positive direction.
The till command provides waiting for MARK1 signal to change from zero to one. When the till
command terminates, the X_IST.#MARK is raised and the X_MARK contains a valid value of
mark position. The value is used in the ptp command to specify the target point. The controller
automatically provides smooth transition from jog to PTP motion without deceleration to zero.
Suffix f attached to the ptp command allows specification of a user-defined final velocity. The
value of the final velocity is specified as an additional argument after all other required
arguments.
Caution
Your application must create the next motion before the motion with non-
zero final velocity finishes. If the motion with non-zero final velocity reaches
the final point and no further motion is created, the motion stops
immediately, which may damage the mechanical parts of the system.
If the motions are multi-axis, a smooth vector velocity profile does not always
assure smooth motion of the coordinates. The user application must provide
nearly tangent motion trajectories at the transition point, to avoid jumps in
coordinate velocity.
Motion with non-zero final velocity is often required in registration mark motion. Assume that the
required motion profile is as follows:
2000
2
3
5
4
6
600
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 9
This command creates a jog motion of the X axis in positive direction using the default velocity
X_VEL.
Motion direction may be specified in the command:
jog X, –
This command creates a jog motion of the X axis in negative direction using the default velocity
X_VEL.
The command:
jog X, +
is equivalent to:
jog X
The v suffix allows a specific velocity to be used instead of the default velocity VEL. The
command
jog/v X, 30000
Ignores the default velocity and creates a jog motion with a velocity of 30000.
As with other types of motion, jog motion may be terminated by the halt, kill, or break
commands. Unlike any other motion, jog motion also terminates when the next motion command
for the same axis executes. For example, the following program fragment:
jog X, +
wait 500
jog X, –
provides jogging in positive direction for 500msec and then switches to negative direction. The
controller automatically ensures a smooth transition from motion to motion.
creates jogging in three axes: X in the negative direction, and Y and T in the positive direction.
The motion uses the default velocity X_VEL as a vector velocity for the three-axis motion.
Additional commands (copy from DPRAM to standard variable, stop copy from DPRAM to
standard variable) are added to enhance the effectiveness of the tracking mode.
The track command initiates a track motion. In a track motion, a new move is generated to a new
target position whenever the TPOS (target position) variable changes. (See also TPOS, page 11-
69.)
The track command accepts the following suffix:
w – Create the motion, but wait to start until the go command
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 11
While the code with ptp commands looks shorter and simpler, there are applications where track
motion is preferable to PTP motion. See for example, Starting PTP motion from the host (page
10-11).
Track motion is not terminated automatically. If the TPOS is not changed, the axis at the last
target point until TPOS is assigned a new value, and then the motion continues.
Use a halt or kill command to terminate track motion.
Any subsequent motion command (except another track command) for the same axis also
terminates the tracking motion. In this respect track motion is similar to the jog motion.
The motion profile while in track mode, like in a standard PTP motion, is defined by the standard
variables VEL, ACC, DEC and JERK. The track command accepts the values of these variables
at the beginning of each component PTP motion within the track motion. Therefore, if an
application assigns a new value to VEL, ACC, DEC or JERK, while track mode is in effect, then
the new value will be used the next time that the application initiates a motion (by assigning a
new value to TPOS).
The following ACSPL+ program fragment sets a specific velocity for each PTP motion:
track Y Create track motion of Y axis
In the example above the application updates TPOS only after the previous PTP motion ends.
In the following example the application updates the TPOS while the motion is still in progress:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 13
In this case, the controller does not execute two separate motions. As soon as the TPOS is
changed to 2500 (before the controller reaches 2000), the controller changes the move on the fly
to the new target position of 2500. The change on the fly is done smoothly, similar to end-point
correction on the fly (see also changes on the fly, page 3-27).
The same result is provided by the following fragment:
ptp X, 2000 Move to point 2000
This command creates a multipoint motion of the X axis and specifies dwell of 1000 msec at each
point. If dwell is not required, the second argument and the comma may be omitted. The mptp
command itself does not specify any point, so the created motion starts only after the first point is
specified. The points of motion are specified by the point or mpoint commands that follow the
mptp command.
Consider the following program fragment:
mptp XY Create multipoint motion in group XY with no dwell
The mptp command in line 2 creates the multipoint motion. However, the motion does not start
until a point is defined. After the first point command (line 3) the motion starts if all involved
axes are idle (not involved in some previous motion), or waits until a motion that is in progress
ends, and then starts. The four point commands (lines 3, 4, 5 and 6) specify the following
sequence:
Y
(100,200)
Start
(200,100)
(0,100)
(100,0) X
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 15
The controller performs sequential positioning to each point. The ends command informs the
controller, that no more points will be specified for the current motion. The motion cannot finish
until the ends command executes. If the ends command is omitted, the motion will stop at the last
point of the sequence and wait for the next point. No transition to the next motion in the queue
will occur until the ends command executes.
Normally, multipoint motion starts with the first point command, and the next point command
executes while the motion is already in progress. However, sometimes you may need to delay
starting the motion until all points are defined. Append the w suffix, to the command, to prevent
the motion from starting until a go command executes. The motion, created by the command:
mptp/w X, 1000
The mptp command uses the default velocity VEL for positioning to each point. The v suffix
allows using specific velocity for each positioning. The desired velocity must be specified in the
point command after the point coordinates. The previous example is modified for using different
velocities:
mptp/v XY Create multipoint motion in group XY
point XY, 100, 200, 10000 Move to second point at velocity 10000
point XY, 200, 100, 5000 Move to third point at velocity 5000
Several suffixes can be appended to one command. For example, the command
mptp/rv X, 1000
creates a multipoint motion with dwell of 1000msec. The points will be specified by relative
coordinates, and velocity will be specified for each point.
The point command does not require a specific value for all axes involved in a multipoint motion.
If an axis is not specified in a point command, the axis remains idle and retains the previous
value. Similarly, if a multipoint motion is created with the v suffix, the velocity argument in a
point command can be omitted, and the velocity of the previous segment will be used. If velocity
is omitted for the first point, the default velocity VEL will be used.
Consider the following example:
mptp/v XY Create multipoint motion in group XY with no dwell
(100,100) (200,100)
(200,0) X
(100,0)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 17
end
ends XY
The program executes the point command 30 times. Each time the command adds a new point in
the XY plane. The points are spread equally along the ellipse, as shown in the following figure:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 19
10 end
12 stop
while (Continue)
calculate N (<= 50) points in array HPoints;
do
acsc_ReadInteger(Com, NBuf, “Sync”, -1, -1, -1, -1, &HSync, 0);
while HSync;
N = -1
acsc_WriteReal(Com, NBuf, “Points”, 0, N-1, 0, 6, HPoints, 0) ;
Synchronization between the host and the controller is provided by Sync variable. When the host
has finished transmitting the next batch of points to the controller, it writes to Sync the number of
points in the batch. The controller waits for non-zero Sync and then adds the points to the motion.
When the controller has added the points, it writes zero to Sync, that signals to the host to
transmit the next batch of points.
When the host comes to the end, it writes –1 to Sync, to indicate the end of the motion.
Points for arbitrary path motion are defined by point and mpoint commands (See point and
mpoint Commands, page 6-21).
The ends command terminates the point sequence. After the ends command, no point or mpoint
commands for this motion are allowed.
The trajectory of the motion follows through the defined points. Each point presents the instant
desired position at a specific moment. Time intervals between the points are uniform, or non-
uniform as defined by the t suffix.
Motion generated by the path command does not use motion profile generation. Typically, the
time intervals between the points are short, so that the array of the points implicitly specifies the
desired velocity in each point. For this reason, variables VEL, ACC, DEC, JERK have no effect
on this motion.
If the time interval does not coincide with the controller cycle, the controller provides linear
interpolation of the points.
Commands halt, kill, killall are executed in a specific way with this type of motion; as with other
motion types, the controller provides a smooth deceleration profile using DEC (halt command) or
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 21
KDEC (kill, killall commands) for the leading axis. However, unlike other motions types, the
controller does not provide following the motion trajectory during deceleration.
Arbitrary path motion created without the t suffix implies uniform intervals between the points.
Command path, specified without the t suffix, must have time-interval specification as its last
argument. The argument defines time interval between the motion points in milliseconds.
Command path, specified with the t suffix, must not have time-interval specification. Instead, the
time interval must be specified for each point as additional argument for the point command or as
additional array column in the mpoint command.
NOTE
10 end
12 stop
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 23
The program running in the host looks like the following pseudo code:
double HPoints(6)(50);
int N, HSync;
HANDLE Com;
while (Continue)
calculate N (<= 50) points in array Hpoints;
do
zl_ReadInteger(Com, NBuf, “Sync”, -1, -1, -1, -1, &HSync, 1000);
while HSync;
N = -1
zl_WriteInteger(Com, NBuf, “Sync”, -1, -1, -1, -1, &N, 1000);
Synchronization between the host and the controller is provided by Sync variable. When the host
has finished transmitting the next batch of points to the controller, it writes to Sync the number of
points in the batch. The controller waits for non-zero Sync and then adds the points to the motion.
When the controller has added the points, it writes zero to Sync, which signals to the host to
transmit the next batch of points.
When the host comes to the end, it writes –1 to Sync, to indicate the end of the motion.
In PV/PVT mode the controller provides cubic spline interpolation between the specified points.
As a spline mode, it minimizes the amount of data that the host-based program (or ACSPL+
program) needs to generate to produce the multi-axis arbitrary profile and provides precise
trajectory generation.
The generated profile between the specified points is characterized by a constant jerk, a linear
acceleration profile, a parabolic velocity profile, and cubic position profile.
Between each two specified points the controller constructs a curve known as a Hermit
polynomial. The following formulae explain the process:
Assume P0, V0 are the position/velocity at the beginning of a segment, PT, VT are the
position/velocity in the end of the segment and T is the time of the segment. Values P0, V0, PT, VT
and T are supplied (usually by a host-based program) as segment data. The controller constructs
the segment motion as a cubic polynomial:
p = a0 + a1t + a2t2 + a3t3
where t is a relative time within the segment, t = 0 at the beginning of the segment and t = T at
the end of the segment. The controller calculates coefficients a0, a1, a2, a3 to satisfy the boundary
condition.
In case of multi-axis motion a host-based program (typically) supplies position and velocity data
for each axis involved. The P0, V0, PT, VT are vectors, and the controller calculates coefficients
a0, a1, a2, a3 as vectors that contain a component for each axis involved.
Points for PV and PVT motion are defined by point and mpoint commands.
The ends command terminates the point sequence. After the ends command, no point or mpoint
commands for this motion are allowed.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 25
The trajectory of the motion follows through the defined points. Time intervals between the points
are uniform, or non-uniform as defined by the t suffix.
Motion generated by the pvspline command does follow the standard motion profile. Variables
VEL, ACC, DEC, JERK have no effect on this motion. The motion profile is defined
exclusively by the positions and velocities specified by point and mpoint commands.
The halt command is executed in a specific way with this type of motion; as with other motion
types, the controller provides a smooth deceleration profile with the DEC value of the leading
axis. However, unlike other motions types, the controller does not follow the motion trajectory
during deceleration.
Spline motion created without the t suffix implies uniform intervals between the points.
Command pvspline, specified without the t suffix, must have time-interval specification as its last
argument. The argument defines time interval between the motion points in milliseconds.
Command pvspline, specified with the t suffix, must not have time-interval specification. Instead,
the time interval must be specified for each point as additional argument for the point command
or as additional array row in the mpoint command.
For each segment the controller constructs a third-order polynomial known as a Hermit spline or
PV-spline and calculates the reference coordinates using the polynomial.
The spline provides exact following through the specified points and exact specified velocity at
the points. The spline also provides continuous velocity at all intermediate points.
In general the spline does not guarantee acceleration continuity at the connection points.
However, the acceleration can be continuous if the proper velocity values are specified, and many
host-based programs that prepare data for PV-interpolation actually calculate velocity values that
will provide continuous acceleration.
The time interval between the points may be either uniform or non-uniform. In both cases the time
interval is not required to be an integer or to be equal to an integer number of controller cycles.
The controller uses the exact specified time interval to calculate the interpolated reference
positions.
T 2T 3T 4T 5T 6T 7T 8T
T – the controller cycle,
– the specified motion points,
Æ – the specified velocity values,
– the interpolated reference points
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 27
• GPATH, GVEL, GACC, GJERK, GPHASE, GRTIME are not updated while the motion
is in progress.
10 end
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 29
12 stop
The program running in the host looks like the following pseudo code:
double HPoints(12)(50);
int N, HSync;
HANDLE Com;
while (Continue)
calculate N (<= 50) points in array Hpoints;
do
acsc_ReadInteger(Com, NBuf, “Sync”, -1, -1, -1, -1, &HSync, 0);
while HSync;
N = -1
acsc_WriteInteger(Com, NBuf, “Sync”, -1, -1, -1, -1, &N, 0);
Synchronization between the host and the controller is provided by Sync user variable. When the
host has finished transmitting the next batch of points to the controller, it writes to Sync the
number of points in the batch. The controller waits for non-zero Sync and then adds the points to
the motion. When the controller has added the points, it writes zero to Sync, which signals to the
host to transmit the next batch of points.
When the host comes to the end, it writes –1 to Sync, to indicate the end of the motion.
6.7.1. Basics
Command master – Define master value for the axis
slave – Create multipoint motion
Associated commands go, halt, kill
Suffixes w – Create the motion, but do not start until the go command has
been executed.
t – Stall when approaching interval boundary
p – Use position lock instead of velocity lock (see Advanced
section)
In slaved motion the axis follows a master value. In addition to basic slaved motion there are
more sophisticated forms; the slaved mode of segmented motion and the slaved mode of spline
motion.
NOTE
The break command (Section 5.9.9.9) is not designed to be used with
master-slave and will lead to inaccurate results.
When the command executes, the controller stores the formula specified to the right of the equals
sign, and then calculates the master value X_MPOS according to this formula (in the example
above, it simply assigns the current Y_FPOS value to X_MPOS). The controller does this
calculation every controller period, independent of program execution. Even if the program that
executed the master command terminates, the controller continues calculating the last specified
master expression, until the another master command for the same axis executes.
The master value can be redefined at any time by the application. If the program that executed the
above command then executes the command.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 31
A more sophisticated use of the master command connects the axis to another axis feedback with
a scale factor:
master X_MPOS = 2.3 * Y_FPOS
The following example defines axis Z to follow the RPOS (reference position) of axis X
translated through a conversion table (cam motion):
master Z_MPOS = mapby1(X_RPOS, Table)
In this example Table is a user-defined array that contains a table for conversion.
Similarly, the master value may be connected to other sources such as the sum of two or more
axes, or to an analog input.
The motion is always slaved to the master value of the specified axis. Therefore, the master
command must precede the slave command for the same axis.
In slaved motion the APOS axis reference follows the MPOS axis master value strictly or with a
constant offset. The only exception to this rule is for transient processes such as acceleration,
when the motion is asynchronous.
APOS = MPOS + C
Where C is constant in velocity lock mode and is zero in position lock mode (see Advanced
section).
Once started, slaved motion terminates only if a failure occurs, or one of the commands halt, kill,
break is executed. The halt and kill commands provide deceleration to zero and then the next
motion starts. If no next motion was created, the axis becomes idle. The break command provides
smooth transition to the next motion without stopping, if a next motion is waiting in the queue.
6.7.4.1. Synchronization
In slaved motion the slave is usually synchronized to the master, meaning that the APOS axis
reference follows the MPOS master value strictly or with a constant offset. However, there are
two cases, when synchronism is not attainable:
The slaved motion starts, and positions (position lock) or velocities (velocity lock) of the
master and slave differ. The motion starts as asynchronous.
The motion was synchronized, but the acceleration of the master exceeds the allowed limit
(the XSACC variable of the axis) for the slave. The slave comes out from synchronism.
In both cases, the motion continues asynchronously, and the correspondence between APOS and
MPOS appears broken. The controller tries to regain synchronism by having the slave pursue the
master within the maximal allowed motion parameters. When the slave overtakes the master,
synchronism is re-established and the motion continues as synchronous.
Slave motion is governed by the variables of the slaved axis. These include:
XSACC Maximal allowed acceleration of the synchronous motion. If the
master acceleration exceeds this value, the slave comes out from
synchronism.
SYNV Allowed difference in master and slave velocities. Used in
asynchronous motion to determine if the synchronism can be re-
established.
JERK, ACC, VEL Default jerk, acceleration and velocity. The slave uses these
variables only in asynchronous motion to overtake the master.
The p suffix, attached to the mseg command, activates the position lock mode of slaved motion.
When synchronized, the APOS axis reference follows the MPOS strictly:
APOS = MPOS
When the motion is asynchronous for any reason (see above), the controller tries to regain
synchronism by having the slave pursue the master with the maximal allowed motion parameters.
The difference between position lock and velocity lock manifests itself at the moment of
regaining synchronism:
Velocity lock motion switches in synchronism when the slave velocity reaches the master velocity
(with allowed error defined by the SYNV variable of the slaved axis). At this moment the
difference between the master position and the slave position is latched as the constant offset C,
which then remains unchanged as long as the motion is synchronous.
Position lock motion switches in synchronism when the slave position overtakes the master
position, i.e. when APOS = MPOS.
Note that each time the motion loses and regains synchronism, the velocity lock offset C may
latch a different value. Under the same conditions, the position lock motion each time re-
establishes the strict equality APOS = MPOS.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 33
The slave command with the t suffix requires two additional parameters that define a permitted
interval for the slaved axis motion. For example, the command:
slave/t X, -1000, 2000
Suffixes w – Create the motion, but do not start until the go command
v – Use the velocity specified for each segment instead of the
default velocity
c – Use the segment sequence as a cyclic array: after the last
segment return to the first segment and so on.
s – Slaved motion: the motion advances in accordance to the master
value of the leading axis (velocity lock).
p – Position lock: slaved motion, strictly conforming to the master
value.
e – Extrapolated: if a master value travels beyond the specified
path, the last or the first segment is extrapolated.
t – Stalled: if a master value travels beyond the specified path, the
motion stalls at the last or first point.
The e and t suffixes are relevant only for slaved motion and must be used with s or p suffix. For
discussion of slaved motion see section 6.7.
Segmented motion can be executed in an axis group with any number of controller axes.
The mseg command specifies axis group and the initial starting point:
mseg XY, 1000, 1000
This command creates a segmented motion of the X axis group and specifies the coordinates of
initial point on the plane. The mseg command itself does not specify any segment, so the created
motion does not start immediately. A line or arc command must follow the mseg command to
specify the segment sequence.
Consider the following program fragment:
mseg XY,1000,1000 Create segmented motion in group X,
coordinates of the initial point are
(1000,1000)
arc1 XY, 1000,0,1000,–1000,– Add arc segment with center (1000,0),
final point (1000,-1000), clockwise
rotation
line XY,–1000,–1000 Add line segment with final point (-1000,-
1000)
arc2 XY,–1000,0,–3.141529 Add arc segment with center (-1000,0)
and rotation angle –π
line XY,1000,1000 Add line segment with final point
(1000,1000)
ends XY End the segment sequence
The mseg command creates the segmented motion. The motion does not start, because no
segment is defined yet. After the first arc1 command the motion starts if the axis group is idle
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 35
(not involved in some previous motion). If the group is not idle, motion will start when the
previous motion stops. The four segment commands specify the following path:
Y
Start
(-1000,1000)
X
(-1000,1000)
(1000,-1000)
mseg XY, 100, 100 Defines the starting coordinates for the first segment,
which are absolute in the plane. The whole plane is
located in such a way that the starting point in the
plane (100,100) coincide with the present position of
the motors (0,100).
The mseg command uses the default velocity VEL for each segment. The v suffix overrides the
default velocity and allows you to define a specific velocity for each segment. Desired velocity
must be specified in the line, arc1 and arc2 segment commands after all other arguments. If the
velocity argument is omitted in a segment command, the velocity from the previous segment is
used. If the velocity argument is omitted in the first segment, the default VEL is used. The
previous example is modified for using individual velocities:
creates a segmented motion with individual velocity for each segment. The motion does not start
until the go XY command is executed.
6.8.2.1. Projection
As mentioned above, all coordinates, specified in the segment commands, are absolute in the
working plane. Projection is a matrix that connects the plane coordinates and the axis values as
specified in the mseg command. If the axis group contains two axes, and no projection command
is specified, the controller provides a default projection that corresponds to the matrix 2x2:
1 0
0 1
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 37
The matrix directly connects the first coordinate of the working plane to the first axis of the axis
group and the second coordinate to the second axis.
The matrix can also define rotation and scaling. The full transform includes also an implicit offset.
The controller calculates the offset automatically in such a way that the initial coordinates
specified in the mseg command match the desired axis values at the moment when the motion
starts. The offset provides the full path to be relative to the starting point.
If an axis group contains N axes, the controller extends the default matrix to N lines. The
additional lines are filled by zeros:
1 0
0 1
0 0
… …
0 0
The matrix connects only the first two axes to the plane coordinates. Therefore the segmented
motion will involve only the first two axes in the group.
If N = 1, the mseg command applies to a single axis, and the matrix contains the first line only:
1 0
In this case the axis will follow the first coordinate of the working plane.
The user can replace the default matrix with the projection command. The following program
fragment
real M(3)(2)
M(0)(0) = 1; M(0)(1) = 0
projection XYZ, M
provides the working plane to be inclined by 45°. In the same way the matrix can define arbitrary
linear transform.
Note, if the group contains N axis, the matrix in the projection command must be of size Nx2.
P = P + S
ends XY
The program executes the line command 2000 times. The line segments build up a curve close to
the Archimedean spiral:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 39
The stopper command is used to avoid velocity jump in the inflection points. If a stopper is
specified between two segments, the controller provides smooth deceleration to zero before the
stopper and smooth acceleration to specified velocity after the stopper. Consider the following
program fragment:
ptp XY, 1000, 1000 Go to initial point
where S is a distance along the segmented path, T stands for time, and F is a function independent
of the specified segments.
In the second stage the controller separates the S path into the involved axes:
X = FX (S)
Y = FY (S)
The second stage supplies the current values of the involved axes. The functions FX, FY depend
only on the specified segments. Only the second stage builds the shape of the path in the XY
plane. The first stage provides the motion progress along the path. If the function F of the first
stage is modified, this affects the motion velocity and time, but does not alter the final shape of
the path.
The s or p suffix connected to the mseg command affects the first stage of the motion generation
process by causing the distance S to follow the value MPOS (Axis Master) of the leading axis in
the group. For position lock (p suffix), following is strict:
S = MPOS
In both cases the second stage of the motion generation remains unchanged and depends only on
the specified segment sequence.
Segment commands specify a path on the plane, and the MPOS value of the leading axis defines
motion progress along the path.
Formulas that calculate the MPOS value must be defined before using the master command .
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 41
Slave dynamics is governed by the parameters of the leading axis in the group. The following
variables have effect (See also section 6.7):
XSACC Maximal allowed acceleration of the synchronous motion
SYNV Allowed difference in master and slave velocities, used to define
when the slave can be synchronized to the master
JERK, ACC, VEL Default jerk, acceleration and velocity. The slave uses these
variables only in asynchronous motion in order to overtake the
master.
The p suffix, attached to the mseg command, activates position lock motion. When synchronized,
the distance along the path strictly follows the MPOS:
S = MPOS
When the motion is asynchronous for any reason (see above), the controller tries to regain
synchronism by having the slave pursue the master within the maximal allowed motion
parameters. The difference between position lock and velocity lock become effective at the
moment of regaining synchronism:
Velocity lock motion switches in synchronism when the slave velocity reaches the master
velocity (with allowed error defined by the LOWV variable of the leading axis). The
difference between the master position and the slave position at that moment is latched as the
constant offset C, which then remains unchanged as long as the motion is synchronous.
Position lock motion switches in synchronism when the slave position overtakes the master
position, i.e. when S = MPOS.
Note that each time the motion loses and regains synchronism, the velocity lock offset C may
latch a different value. If a position lock motion loses synchronism, the slave overtakes the exact
master position and reestablishes the strict equality S = MPOS.
Extrapolated motion (e suffix). If the distance S slaved to the MPOS master value becomes
greater than the overall length of the path, the motion continues along the extrapolated last
segment. If the distance S slaved to the MPOS master value becomes less than zero, the
motion continues along the extrapolated first segment. If the extrapolated segment is a
circular arc, the motion will follow along the extrapolated circle.
Stalled motion (t suffix). When the motion approaches the extreme point, the slave comes
out from synchronism and stalls in the point until the MPOS master value allows to regain
synchronism. For velocity lock synchronism is achieved when the MPOS changes its
direction; after regaining the offset C may have a different value than before approaching the
extreme point. For position lock synchronism regains when the MPOS falls into the interval
(0, L) again. The controller ensures smooth approaching the extreme points and smooth return
to synchronism.
Bounded motion (no additional suffixes). The motion finishes when the slave approaches
any extreme point. The controller activates the next motion in the queue (if any). If the
MPOS master value changes only in positive direction, the behavior is very close to non-
slaved motion. The difference is that non-slaved motion is based upon the time value and
slaved motion is based upon the MPOS master value.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
M o t io n 6- 43
Bit 1 in the MFLAGS variable enables or disables open-loop mode. The following diagram
explains transition between the three modes:
Disabled
Mode
Command Command
DISABLE DISABLE
Command Command
ENABLE if ENABLE if
MFLAGS.1=1 MFLAGS.1=0
Command
MFLAGS.1 = 0
Open-loop Enabled
Mode Mode
Command
MFLAGS.1 = 1
The circles in this diagram represent the motor modes and the arrows with rectangles show the
controller commands that switch the controller from one mode to another.
As shown in the diagram, a motor can be switched from enabled to open-loop mode and back
without changing to disabled state. The controller provides smooth transition between the modes.
Even if the motor experiences uncontrolled move while in open-loop mode, switching back to
enabled mode does not cause any motor jump. However, be careful if you execute a motion while
the controller is in open-loop mode. Once the command switches back to enabled mode, the
controller continues the motion from the point where it finds the motor. No motor jump occurs,
but the motion trajectory and the final point may be shifted by the value of uncontrolled offset in
the open-loop mode.
While in open-loop mode, the controller calculates the drive voltage output based on the DCOM
variable. The DCOM variable sets the drive output as a percentage of the maximum available
drive output voltage. For example, the SPiiPlus PCI-4/8 provides differential drive output in the
range from –10 to +10V. Therefore, assigning 100 to DCOM provides +10V on the drive output,
assigning –100 provides –10V, and assigning 0 provides 0V.
The following program fragment shows an example of torque control implementation through the
open-loop mode.
enable X Enable the X motor.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-1
7. ADVANCED FEATURES
This chapter describes data collection, position event generation (PEG), sin-cos encoder multiplier
option, DPRAM support, interrupts, and mechanical brake support.
when the collection array is full, cyclic data collection does not self-terminate. Cyclic data
collection uses the collection array as a cyclic buffer and can continue to collect data indefinitely.
When the array is full, each new sample overwrites the oldest sample in the array. Cyclic data
collection can only be terminated by the stopdc command.
The dc command is used with the following parameters:
axis Axis to which the data collection must be synchronized. The
parameter is required only for axis data collection (suffix s).
array Array that stores collected data. The array must be
previously defined as global, integer or real. The array size
must be compatible with the number of samples and number
of stored variables (See Understanding System Data
Collection, page 7-4).
number of
The number of data samples to collect.
samples
period Sampling period in milliseconds. Actual sampling period
may differ from this value, because the controller rounds it
to an integer number of controller periods. For example if
you set the period to 3.3 milliseconds, the controller will
round it to 3 milliseconds. If suffix t is attached to the
command, the parameter defines a minimal period (see
explanation of temporal data collection below).
list of Up to eight variable names, whose values are to be
variables collected. Each variable can be a scalar variable, or an
element of an array. Both local and global variables can be
specified. Irrespective of the storage array type, any
combination of integer and real variables is allowed – the
controller automatically executes type conversion if
required.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-3
When the controller executes the dc command, it starts a separate real-time data collection
process that progresses in parallel with ACSPL+ programs and motion execution. Each sampling
period the process latches the values of all specified variables and stores them in the specified
array. The process continues until the specified number of samples is stored, or the command
stopdc is executed. After process termination the array contains a time series of the specified
variables that may then be used for data analysis.
This is shown in the following example:
global real DCA(2)(1000)
In the first line, a matrix consisting of two columns and 1000 lines is set up for data
collection
The second line starts the data collection of the Feedback Position values for axes X and Y.
990 samples are to be collected, with a period of three milliseconds. The first step of the data
collection stores the current value of X_FPOS in DCA(0)(0) and Y_FPOS in DCA(1)(0).
The second step stores X_FPOS in DCA(0)(1) and X_FPOS in DCA(1)(1).
Each variable is stored in one line of the array. Therefore the first dimension of the array (the
number of lines) must be equal or greater than the number of variables. If the number of lines is
greater than the number of variables, the extra array lines remain unaffected by the data
collection. If only one variable is specified for data collection, a one-dimensional array is allowed.
Each sample of data collection fills up one column of the array. Therefore the second dimension
of the array (number of columns) must be equal or greater than the requested number of samples.
If the number of columns is greater than the number of samples, the extra array columns remain
unaffected by the data collection.
The following dc command is not allowed, because the number of variables exceeds the number
of array lines:
global int IA, IC(1000)
The following dc command is not allowed, because the number of required samples exceeds the
number of array columns:
int IA, IC(1000)
dc IC,1001, 1, IA
If suffix s is not specified, the system data collection process starts immediately after executing
the dc command. Normally, data collection stops automatically after <number of samples> x
<period> milliseconds. If the stopdc command executes while the data collection is in progress,
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-5
the data collection stops prematurely, and the remaining array columns remain unaffected. To
terminate system data collection, the stopdc command must contain no parameters.
Note
The variable S_DCN provides the number of samples stored during data
collection
The dc/s command synchronizes the data collection start to the motion of an axis, but is not
limited to collecting data only of that axis. Any parameter for any other axis may be specified for
data collection. For example, the command
dc/s X,Array,500,1,X_FPOS,Y_FPOS
Synchronizes data collection to the start of motion of axis X, but collects data on both axis X and
Y.
Only one data collection process, started by the dc command, can execute at a time. The next dc
command can execute only after the data collection started by the previous dc command finishes.
However, data collection, initiated by the dc/s command, may progress in parallel to the data
collection initiated by the dc command. Moreover, several data collection processes initiated by
the dc/s command may progress in parallel, providing they refer to different axes or axis groups.
For example these two commands are executed serially:
dc/s X, Array,500,1,X_FPOS
dc/s X, Array,500,1,Y_FPOS
While these commands are executed in parallel (unless the X and Y axes belong to the same axis
group):
dc/s X,Array,500,1,X_FPOS
dc/s Y,Array,500,1,Y_FPOS
Note: the syntax of stopdc command that terminates synchronous data collection has been
changed. If your application uses synchronous data collection, slight changes may be required. To
terminate a synchronous data collection that was commanded by a dc/s command, the stopdc
command must also attach suffix s. For example:
dc/s X,ARR,50,10,VAR1 Start synchronous data collection by axis X to array ARR of
size 50, sampling period 50, collect global variable VAR1
stopdc/s X Terminate synchronous data collection by axis X
Multiple axis specification as stopdc XYZT is not allowed in the stopdc command.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-7
match occurs, a pulse is generated on a specific digital output (referred to as the PEG pulse
output) and additionally the state of several digital outputs can be set to desired values (referred to
as PEG pulse outputs) . The function is implemented in hardware, therefore, the delay is
extremely short (fraction of a microsecond).
In addition to position-based pulses, the controller is able to generate a specified number of time-
based pulses. The time-based pulses follow each position-based pulse with a specified period.
NOTE
For stepper motors, PEG is only available if at least one of the following
bits is set: MFLAGS.5 or MFLAGS.6.
In SPiiPlus controllers (except for the SPiiPlus CM), the digital output pins can be configured for
either general use (page 9-1), mechanical braking (page 7-21), or PEG. Each physical pin can be
configured separately.
On power up, all the pins are assigned by default to the general use. The state of the pin is
determined by the state of the corresponding bit of the OUT0 element. PEG commands will
produce no results on the hardware output pins until those pins have been reconfigured for PEG
operation. This is done using the assignpeg command
NOTE
PEG assignment changes the operation of the hardware outputs but has
no effect on the OUT variable.
• When a bit in the mask is clear, the corresponding digital output is assigned to PEG .
• When a bit in the mask is set, the assignment of the corresponding output remains
unchanged.
The following bits are relevant:
0 - PEG state 0
1 - PEG state 1
2 - PEG state 2
3 - PEG state 3
8 - PEG pulse
All other bits must be cleared.
init-mask is a bit mask that specifies PEG state outputs to be initialized (see init-value).
Pulse output cannot be initialized. Therefore, bit 8 must be zero.
The argument can be omitted, in which case the command only assigns outputs to PEG but
does not initialize the value of any PEG state outputs.
init-value specifies the condition of each output selected with init-mask.
• When a bit is clear, the corresponding hardware output receives low voltage.
• When a bit is set, the corresponding hardware output receives high voltage.
Only bits that correspond to non-zero bits in init-mask take effect.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-9
Command PEG_I/S specifies a synchronous incremental PEG. The command creates a PEG entry
in the motion queue and the PEG starts synchronously with the motion sequence. In this example
the PEG waits for the termination of the previous motions (PTP X,10000 and PTP X,0). Once
motion PTP X,0 finishes, the controller activates the PEG and at the same controller cycle starts
the next motion PTP X,3000. Therefore, the PEG will be active while motion PTP X,3000 is
executed and has no effect on previous motions.
In the same example, if PEG_I without suffix S is specified, the PEG is activated asynchronously,
immediately when the PEG_I command is executed, and does not wait in the motion queue.
Likely, at this moment the motion PTP X,10000 is in progress. If the position of 1000 has not
been reached when the PEG command is executed, the PEG will generate events that are based on
that motion. In this case there is no strict automatic synchronization between PEG and motion,
therefore the user must define in the program appropriate waiting conditions in order to start the
PEG at the required moment.
peg_i axis,width,first-point,interval,last-point,tb-
number,tb-period
where axis is an axis specification
width is a desired width of generated pulse (milliseconds)
first-point is a position where the first pulse is generated (user units)
interval is a distance between the pulse-generating points (user units)
last-point is a position where the PEG finishes (user units)
tb-number (optional) is a number of time-based pulses generated after each encoder-based
pulse, the range is from 0 to 511
tb-period (optional) is a period of time-based pulses (milliseconds), the range is from
0.000050 to 0.012775
The last two arguments are optional. If they are omitted, the controller generates only the
encoder-based pulses.
The following limitations apply to incremental PEG function:
1. Only axes X, Y, Z, T support the PEG.
PEG command that specifies any other axis (A, B, C, D) has no effect.
2. Pulse width is limited as follows:
In SPiiPlus PCI-4/8 from 0.000025 to 0.75 milliseconds.
3. PEG function shares the connector pins with the digital outputs. To assign a digital output
to the PEG use the setconf function with key value 205 as described above. The PEG
pulse output has the following destination:
X axis PEG pulse is directed to the pin OUT3.
Y axis PEG pulse is directed to the pin OUT7.
Z axis PEG pulse is directed to the pin Z_PEG_PULSE in SPiiPlus PCI-8.
T axis PEG pulse is directed to the pin T_PEG_PULSE in SPiiPlus PCI-8.
4. Interval must be in the range of –32768 to 32767 encoder counts. If the controller is
configured for user units different from encoder counts, i.e. the EFAC variable is not
equal to one, the argument range is from -32768*EFAC to 32767*EFAC. Specifying the
interval outside the range will cause pulse generation in unexpected positions.
5. If the interval is positive, the last position must be greater than the first position. If the
interval is negative, the last position must be smaller than the first position.
6. The PEG function works correctly if the sign of the interval corresponds to the direction
of motion. If the motor moves oppositely to the sign of the interval, the PEG pulses will
be generated in unexpected positions.
peg_r axis,width,point-array,state-array,tb-number,tb-period
where:
axis is an axis specification,
width is a desired width of generated pulse (milliseconds),
point-array is a real array that contains the positions at which the PEG should generate events
(user units),
state-array (optional) is an integer array, that specifies the desired state of the output at each
PEG position,
tb-number (optional) is a number of time-based pulses generated after each encoder-based
pulse, the range is from 0 to 511
tb-period (optional) is a period of time-based pulses (milliseconds), the range is from
0.000050 to 0.012775
The last three arguments are optional. If state-array is omitted, the controller generates the PEG
pulses at each position but does not change the state of any output. If tb-number and tb-period are
omitted, the controller does not generate time based pulses.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-11
Once a PEG point is compared with the motor position and activates the PEG pulse, the
PEG function transfers the 3 or 4 low bits of the corresponding state-array element to the
corresponding outputs. Only those state-array bits that correspond to the outputs assigned
to PEG are effective.
• The positions in the point-array must follow in the strict ascending or strict descending
order. The direction of motion must correspond to the order in point-array. Otherwise the
function will generate events in unexpected positions.
stoppeg axis
where axis is an axis specification.
The function affects either incremental or random PEG.
7.2.7. Examples
The following example moves the X motor in reciprocated motion between positions 0 and
30000. On each motion in positive direction 11 PEG pulses are generated in points 10000, 11000,
… 20000.
setconf(205,0,0b100000000) Assign output 3 to the PEG pulse output
ST: Label
In the following example the same behavior is achieved with asynchronous PEG. Because in this
case there is no automatic synchronization with the motion, the required synchronization is
provided by autoroutine condition:
setconf(205,0,0b100000000) Assign output 3 to the PEG pulse output
ST: Label
stop
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-13
The following example moves the X motor in reciprocated motion between positions 0 and
30000. On each motion in positive direction 5 PEG pulses are generated in points 10000, 12000,
12500, 15000, 20000.
global real ARR(5) Declare array ARR
ARR(1)=12000
ARR(2)=12500
ARR(3)=15000
ARR(4)=20000
ST: Label
The following example moves the Y motor in reciprocated motion between positions 0 and 3000.
On each motion in negative direction 3 PEG pulses are generated in points 2000, 1000, 500.
Additionally at each PEG point the corresponding state is set at outputs 4, 5, 6.
global real ARR(3) Declare array of PEG points
ARR(1)=1000
ARR(2)=500
STAT(1)=0b010
STAT(2)=0b100
ST: Label
The following example differs from the previous one in that no state outputs are generated, but
additionally to each encoder-based pulse, five time-based pulses are generated:
global real ARR(3) Declare array of PEG points
ARR(1)=1000
ARR(2)=500
ST: Label
The SPiiPlus PCI-4/8 supports the use of sin-cos encoders, which are encoders with analog
outputs.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-15
NOTE
For convenient modification of encoder related variables, use the
SPiiPlus MMI (from the Tools menu, select Configurator, then click
Encoder Parameters).
resolution of index, mark and PEG corresponds to 4 counts per encoder sine period. In the former
example the resolution will be 1/(250*4) = 0.001mm.
The controller continuously checks the integrity of the encoder multiplier feedback. If any error
occurs, the controller activates the Encoder Error fault.
The variable SLEMOS sets the order of the filter. The range is 0 to 4 (default is 0). When
SLEMOS = 0, the filter is not active.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-17
FIGURE 7-10 Jitter without (A) and with (B) Enhanced-Resolution Filter
7.4. Interrupts
Typically, the user works with the SPiiPlus interrupts using the SPiiPlus C Library and does not
need the low-level details specified in this section. See the description of SPiiPlus C Library for
explanation of interrupt managing functions.
Reading any interrupt status register also resets the bits in the register. For hardware interrupts
this enables the interrupt to be generated again. For software interrupts this is not enough: the host
drive must write zero also to an interrupt tag in order to enable the corresponding software
interrupt to be generated again.
Bit Description
3 PEG X
4 PEG Y
5 PEG Z
Bit Description
6 PEG T
7 MARK 1 X
8 M2ARK X
9 MARK 1 Y
10 M2ARK Y
11 MARK 1 Z
12 M2ARK Z
13 MARK 1 T
14 M2ARK T
15 Emergency Stop
Bit Description
0 Physical motion end
1 Logical motion end
2 Motion failure (Motion interruption due to a fault)
3 Motor failure (Motor disable due to a fault)
4 Program termination
5 Command execution
6 ACSPL+ interrupt (by INTERRUPT command)
7 Digital input
14 Controller cycle (the controller raises this interrupt in the beginning
of each controller cycle)
15 Communication interrupt (the controller raises this interrupt after
sending a complete message to the FIFO)
Reading any interrupt status register also resets the bits in the register. For hardware interrupts
this enables the interrupt to be generated again. For software interrupts this is not enough: the host
drive must write zero also to an interrupt tag in order to enable the corresponding software
interrupt to be generated again.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-19
Software interrupt tags occupy the first 8 words of the DPR, addresses from Offset+0x2000 to
Offset+0x2007. When a software interrupt occurs, the corresponding tag contains detailed
information about the interrupt source. For example, the tag of the Physical motion end interrupt
specifies the axes that caused the interrupt. When a specific software interrupt has occurred, the
next interrupt of the same type can be generated only after the host drive reads both interrupt
status register and writes zero to the corresponding tag.
Bit Description
0 Details of Physical motion end interrupt.
Bit 0 specifies that axis X has finished, bit 1 – axis Y, and so on.
1 Details of Logical motion end interrupt.
Bit 0 specifies that axis X has finished, bit 1 – axis Y, and so on.
2 Details of Motion failure interrupt.
Bit 0 specifies that axis X has failed, bit 1 – axis Y, and so on.
3 Details of Motor failure interrupt.
Bit 0 specifies that axis X has failed, bit 1 – axis Y, and so on.
4 Details of Program termination interrupt.
Bit 0 specifies that buffer 0 has finished, bit 1 – buffer 1, and so on.
5 Details of Command execution interrupt (dynamic buffer only).
Bit 0 specifies event in buffer 0, bit 1 – buffer 1, and so on.
6 Details of ACSPL+ interrupt (by INTERRUPT command).
Bit 0 specifies interrupts from buffer 0, bit 1 – buffer 1, and so on.
7 Details of Digital input interrupt.
Bit 0 specifies interrupts from input 0, bit 1 – input 1, and so on.
Bit Description
3 Enable PEG X interrupt
4 Enable PEG Y interrupt
5 Enable PEG Z interrupt
6 Enable PEG T interrupt
7 Enable MARK 1 X interrupt
8 Enable M2ARK X interrupt
9 Enable MARK 1 Y interrupt
10 Enable M2ARK Y interrupt
11 Enable MARK 1 Z interrupt
12 Enable M2ARK Z interrupt
13 Enable MARK 1 T interrupt
14 Enable M2ARK T interrupt
15 Enable Emergency Stop interrupt
16 Enable Physical motion end interrupt
17 Enable Logical motion end interrupt
18 Enable Motion failure (Motion interruption due to a fault) interrupt
19 Enable Motor failure (Motor disable due to a fault) interrupt
20 Enable Program termination interrupt
21 Enable Dynamic buffer interrupt
22 Enable ACSPL+ interrupt (by INTERRUPT command)
23 Enable Digital input interrupt
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-21
Element Description
7.5.2.1. Preconditions
Before a mechanical brake can be controlled by an output, the following conditions must be met:
• The brake control signal is wired to the corresponding controller digital output (page 7-
21) or, in the case of the SPiiPlus CM, to the dedicated brake output. The wiring
arrangement must provide zero (low voltage) output state to activate the brake and one
(high voltage) output state to deactivate the brake.
• - MODEL DEPENDENT (SPiiPlus PCI-4/8 and SPiiPlus PCI-DDM4): The digital
output must be assigned to the brake function using setconf(29) (see brake outputs, page
7-21).
• Bit MFLAGS.#BRAKE for the corresponding axis must be set (see MFLAGS, page 11-
45).
returns 0 if the Y brake is active and returns 1 if the Y brake is not active.
See also the reference information for setconf/getconf(229), page 5-66.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A d va nc e d F e a t u re s 7-23
• If bit MFLAGS.#BRAKE is 1, set the Brake output to one (deactivate the brake) and
wait BOFFTIME milliseconds.
The following diagram illustrates the enable process timing for MFLAGS.#ENMOD = 1 and
MFLAGS.#BRAKE = 1.
Start of End of
enable enable
process process
Enable output
Brake output
Start of End of
disable disable
process process
BONTIME
msec
Enable output
Brake output
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-1
8. SAFETY CONTROL
Safety features are necessary to protect both the equipment and the user from potential injury.
SPiiPlus controllers include numerous safety-related features, but the final responsibility for the
safe use of the controller in a particular application lies with the user. Before you create your
application make sure that you thoroughly read and understand this chapter.
A list of safety-related parameters described in this chapter can be found on page 11-4.
8.1.4. Faults
When the controller detects a malfunction, it raises a specific fault bit. Fault bits are grouped into
standard variables FAULT and S_FAULT.
In certain cases, you may want to define which fault conditions are examined in a specific
application. The standard variables FMASK and S_FMASK specify which fault conditions must
be examined in a particular application.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-3
NOTE
The right limit restricts the motion in the positive direction and the left
limit in the negative direction.
0 #RL Motor RIGHT LIMIT. The controller The controller kills the violating
raises the fault bit when the right motor.
limit switch is activated.
As long as the fault is active, the
controller kills any motion that tries
to move the motor in the direction
of the limit. Motion to return to the
allowed range of motion is allowed.
1 #LL Motor LEFT LIMIT. The controller raises Same as for #RL.
the fault bit when the left limit
switch is activated.
5 #SRL Motor SOFTWARE RIGHT LIMIT. The The controller kills the violating
controller raises the fault bit, motor. As long as the fault is active,
when the motor reference the controller kills any motion that
position (RPOS) is greater than tries to move the motor in the
the software right limit margin direction of the limit. Motion in the
(SRLIMIT). direction out of the limit is allowed.
6 #SLL Motor SOFTWARE LEFT LIMIT. The Same as #SRL.
controller raises the fault bit,
when the motor reference
position (RPOS) is less than the
software left limit margin
(SLLIMIT).
7 #ENCNC Motor ENCODER NOT CONNECTED. The The controller disables the violating
controller raises the fault bit motor.
when the primary encoder is not
connected.
8 #ENC2NC Motor ENCODER 2 NOT CONNECTED. No default response.
The controller raises the fault bit
when the secondary encoder is
not connected.
9 #DRIVE Motor DRIVE ALARM. The controller The controller disables the violating
raises the fault bit, when the motor.
signal from the drive reports a
failure.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-5
10 #ENC Motor ENCODER ERROR. The controller The controller disables the violating
raises the fault bit, when the motor. The faults remain active
primary encoder malfunctions. until the user resolves the problems
and enables the motor again or
executes the fclear command.
14 #VL Motor VELOCITY LIMIT. The controller The controller kills the violating
raises the fault bit, when the motor.
absolute value of the reference
velocity (RVEL) exceeds the
limit defined by the XVEL
parameter.
15 #AL Motor ACCELERATION LIMIT. The The controller kills the violating
controller raises the fault bit motor.
when the absolute value of the
reference acceleration (RACC)
exceeds the limit defined by the
XACC parameter.
16 #CL Motor CURRENT LIMIT. The controller The controller disables the violating
raises the fault bit, when the motor.
RMS current calculated in the
Servo Processor exceeds the limit
value defined by the XRMS
parameter.
17 #SP Motor SERVO PROCESSOR ALARM. The The controller disables the violating
controller raises the fault bit motor and kills the motion that
when the axis Servo Processor involves the motor.
loses its synchronization with the
main processor. The fault
indicates a fatal problem in the
controller.
20 #HSSINC Motor HSSI NOT CONNECTED. The None.
controller raises the fault bit if
the HSSI expansion module is
not connected. See also page 9-7.
25 #PROG System PROGRAM FAULT. The controller The controller kills all motors.
raises the fault bit when a run
time error occurs in one of the
executing ACSPL+ programs.
26 #MEM System MEMORY FAULT. The user The controller kills all motors.
application requires too much
memory.
27 #TIME System TIME OVERUSE. The user No default response.
application consumes too much
time in the controller cycle.
28 #ES System EMERGENCY STOP. The The controller disables all motors.
controller raises the fault bit
when the ES signal is activated.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-7
29 #INT System SERVO INTERRUPT. The servo The controller disables all motors.
interrupt that defines the
controller cycle is not generated.
The fault indicates a fatal
controller problem.
30 #INTGR System INTEGRITY VIOLATION. The No default response
controller raises the fault bit
when an integrity problem is
detected.
FAULT 8 (one per Read-only MOTOR FAULTS. Each motor fault occupies one bit.
axis) Not all bits are occupied by faults. Only those bits
that correspond to motor faults are meaningful.
FDEF 8 (one per Read- FAULT DEFAULT MASK. The variable bits control
axis) write availability of the default responses to motor faults.
(protected The default value for all the bits, 1, enables the
mode) default response. If a bit is 0, the default response is
disabled.
Only those bits that correspond to motor faults are
meaningful.
FMASK 8 (one per Read- MOTOR FAULT MASK. The variable bits control
axis) write whether the controller checks for motor faults. The
Protected default value 1 causes the controller to check for
the fault associated with that bit. Only those bits
that correspond to motor faults are meaningful.
S_FAULT Scalar Read-only SYSTEM FAULTS. Each system fault and each
aggregated motor fault occupies one bit. Only those
bits that correspond to the faults are meaningful.
S_FDEF Scalar Read- SYSTEM FAULT DEFAULT MASK. The variable bits
write control availability of the default responses to
(protected system faults. The default value for all the bits, 1,
mode) enables the default response. If a bit is 0, the
default response is disabled.
S_FMASK Scalar Read- SYSTEM FAULT MASK. The variable bits control
write whether the controller checks for system faults. The
(protected default value 1 causes the controller to check for
mode) the fault associated with that bit. Only those bits
that correspond to system faults are used.
S_SAFIN Scalar Read-only SYSTEM SAFETY INPUTS. Bit #ES reads the current
(read/writ state of the Emergency Stop input. Other bits are
e for meaningless.
Simulator)
S_SAFINI Scalar Read- SYSTEM SAFETY INPUTS INVERSION. Bit #ES
write defines which value of S_SAFIN.#ES bit causes a
(protected fault. Other bits are not used.
mode)
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-9
SAFIN 8 (one per Read-only MOTOR SAFETY INPUTS. Each meaningful bit reads
axis) (read/writ the current value of a motor safety input. Only
e for those bits that correspond to the motor safety inputs
Simulator) are meaningful.
SAFINI 8 (one per Read- MOTOR SAFETY INPUTS INVERSION. A bit of the
axis) write variable defines which value of the corresponding
(protected SAFIN bit causes a fault.
mode)
Only those bits that correspond to the meaningful
SAFIN bits are used.
S_FAULT.#DRIVE Addresses aggregated Drive fault bit. The bit is raised if the
Drive safety input of any motor is active.
Use the literal constants of the system faults to address the system fault bits.
Examples:
S_FAULT.#ES Addresses the Emergency Stop fault bit. The bit is raised when
the Emergency Stop safety signal is active.
S_FAULT.#PROG Addresses the Program fault bit. The bit is raised when any
program has failed due to a run-time error.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-11
The number in the left column is the bit number, followed by an ON/OFF indicator and the fault
description. In the above example all the faults are off except for the Left Limit fault of one or
more axes.
Note that the S_FAULT variable indicates that there is a motor fault, but does not specify which
motor has failed. To determine which motor has failed, query the FAULT variable, or use ?$ to
query the state of all motors.
Fault bits can be queried individually:
?S_FAULT.#LL
1
?X_FAULT.#LL , Y_FAULT.#LL
0
1
The controller answers a query of an individual bit by showing the numerical value of the bit:
either 0 or 1.
A fault-processing autoroutine can reside in any program buffer. When the buffer is compiled, the
controller checks the autoroutine condition each controller cycle. When the condition is satisfied,
the controller interrupts the program that is currently executing in the buffer that the autoroutine
resides in, and starts the autoroutine execution.
A fault-processing autoroutine can supplement or replace the default response to a fault. If the
corresponding FDEF or S_FDEF bit enables the default response, the autoroutine starts and
executes in parallel with the default response. If the corresponding FDEF or S_FDEF bit is zero,
the default response is disabled, and the autoroutine is the only controller response.
8.3.4.2. Examples
The following autoroutine displays a message when the Drive Alarm signal becomes active for
the X motor:
1 on X_FAULT.#DRIVE
3 Ret
In the following autoroutines, the X and Z motors must be disabled simultaneously. Therefore, if
one of the drives fails, the second must be disabled as well. The default response disables the X
motor if the X Drive Alarm occurs and disables Z motor if the Z Drive Alarm occurs. The
following pair of autoroutines supplements the default response, by disabling a motor if the other
motor fails:
1 on X_FAULT.#DRIVE disable Z; ret
When an X drive fault occurs, the following autoroutine terminates the controller activity for all
motors:
1 on X_FAULT.#DRIVE When X drive fault occurs
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-13
The S_FAULT variable contains the bits of the aggregated motor faults. These bits provide a
convenient alternative to the motor faults if an application requires common processing of a motor
fault irrespective of which motor caused the fault.
For example, the following autoroutine displays a message when the Left Limit switch of any
motor is activated:
1 on S_FAULT.#LL
3 ret
Autoroutine conditions can contain more than one fault bit, as is shown in the first line of the
example below:
1 on S_FAULT.#LL | S_FAULT.#RL
3 ret
The S_FAULT variable (used without a bit extension) indicates whether a fault has been detected
by the controller. The following example shows an autoroutine that provides an alarm message if
any fault occurs in the controller:
1 on S_FAULT
3 ret
The controller activates an autoroutine when the condition of the autoroutine changes from false
to true. If the condition remains true the autoroutine is not activated again until the condition
becomes false, and then true again. Therefore the above autoroutine displays the alarm message
only on the first fault. If one fault bit is already raised, and another fault occurs, the second fault
does not generate an alarm message.
The following autoroutine displays a fault message each time a fault occurs:
1 int LastFault
5 end
6 LastFault = S_FAULT
7 ret
In the above example the local variable LastFault stores the current value of S_FAULT (line 6).
The exclusive OR of LastFault and S_FAULT detects the bits of S_FAULT that changed. The
AND with S_FAULT retains only the bits that changed from zero to one, and not from one to
zero (line 3).
0 ON Right Limit
1 ON Left Limit
2 OFF Preliminary Right Limit
3 OFF Preliminary Left Limit
4 OFF Overheat
5 ON Software Right Limit
6 ON Software Left Limit
7 ON Encoder Not Connected
8 OFF Encoder 2 Not Connected
9 ON Drive Alarm
10 ON Encoder Error
11 OFF Encoder 2 Error
12 ON Position Error
13 ON Critical Position Error
14 OFF Velocity Limit
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-15
15 ON Acceleration Limit
16 ON Overcurrent
17 ON Servo Processor Alarm
?S_FMASK
In the above example the user disabled exceptions #RL2, #LL2, #HOT, #ENC2NC, #ENC2, and
#VL of axis X, and system exception #PROG.
Normally, the user enables or disables fault detection through the Safety Window of the SPiiPlus
MMI (See the SPiiPlus Setup Guide) when initially configuring the controller. The configured
values of FMASK and S_FMASK are then stored in nonvolatile memory and left unchanged
during the application lifetime.
Changes to safety variables after initial controller configuration may affect your application. The
following section is relevant only if you need to enable or disable faults after initial configuration.
Example:
?X_FAULT.#DRIVE , X_SAFIN.#DRIVE Display the status of the drive
alarm fault, and the safety signal
1 Drive Alarm fault bit is raised.
1 Drive Alarm safety signal is
: high.
By using SAFINI and S_SAFINI you can change the default, defining the low voltage level as
active for a specific safety input. The low voltage level will now trigger a fault. This is called
inverse polarity.
The standard variables SAFINI, and S_SAFINI define which level is active for each safety input.
If a bit of SAFINI or S_SAFINI is zero (default value), the corresponding input accepts the high
level as active.
Note that the bits of SAFIN, S_SAFIN reflect the physical states of the signals, while the bits of
SAFINI, S_SAFINI define the logical processing of the signals. SAFINI and S_SAFINI
variables have no effect on the physical signal, and the bits of variables SAFIN, S_SAFIN, which
display the raw values of the safety inputs are unaffected by the bits of SAFINI, S_SAFINI
The variables SAFINI, and S_SAFINI are queried like any other variable. The controller reports
the status of each meaningful bit that corresponds to a safety signal.
Example:
?X_SAFINI
0 ON Right Limit
1 ON Left Limit
2 OFF Preliminary Right Limit
3 OFF Preliminary Left Limit
4 OFF Overheat
9 OFF Drive Alarm
?S_SAFINI
In the above example, the fact that the response to the SAFINI query shows that RL and LL are
ON (lines 0 and 1) indicates that the user has defined inverse polarity (low active level) for
signals #RL, #LL of axis X.
Normally, the user defines signal polarity through the Safety Window of the SPiiPlus MMI (See
the SPiiPlus Setup Guide) when initially configuring the controller. The configured values of
SAFINI and S_SAFINI are then stored in the nonvolatile memory and are not changed during the
application’s lifetime.
Example:
?X_FAULT.#LL , X_SAFIN.#LL Display the status of left limit and the left
limit safety signal
1 Left Limit fault bit is raised.
1 Left Limit safety signal is high.
:
X_SAFINI.#LL = 1 Set inverse polarity
:
?X_FAULT.#LL , X_SAFIN.#LL
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-17
ptp/r X,10000
ptp/r X,-10000
goto Reciprocated
In normal case the motor infinitely moves forward and back by 10000 units.
Assume, however, that the first motion brings the motor to the right limit switch. The first motion
terminates prematurely, because the motor is killed. However, the program continues running and
executes the second motion command. In regular mode the second motion starts successfully,
because it is directed out of the limit. Then the first motion command again brings the motor to
the limit. Therefore, in regular mode the reciprocated motion continues and there is no clear
indication of abnormal condition.
Assume further, for the same application, that a broken connection to the right limit switch causes
the controller to mistakenly continuously detect that the right limit has been passed. The first
motion fails immediately after start, but the second one executes. The result is that the motors
moves in negative direction by steps of 10000 units.
In strict mode, the behavior is more predictable. After the first motion failed, the second one
cannot start and the program itself terminates with error. The user can check the information in
MERR and PERR to disclose the reason for the failure.
If at any point of application a fault is an expected condition and the program must continue, the
program in strict mode must analyze the MERR element and execute the fclear command before
activating the next motion.
= Hazardous Area
= Prohibited Area
=Limit Switch
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-19
The example below implements an autoroutine that disables the motor rather than the default
response of killing the motion, in case of a right limit or left limit fault. This response may be
superior to the default response if the motor is equipped with a brake that is activated by the
disable command, because the brake may stop the motor faster than a kill command.
1 on Z_FAULT.#RL | Z_FAULT.#LL. When there is a right limit or left limit fault in
motor Z
2 disable Z Disable motor Z
3 ret
The condition for software limit switches is based on the motor reference RPOS, not the motor
feedback FPOS. Therefore, the fault provides protection against errors in the ACSPL+
application, not against hardware malfunctions.
The controller monitors the reference position RPOS and reference velocity RVEL and
implements the following verifications:
• If RPOS < SLLIMIT, the controller detects #SLL fault.
• If RPOS > SRLIMIT, the controller detects #SRL fault.
• If RPOS is within the range and RVEL is non-zero, the controller calculates the distance
required to decelerate RVEL to zero using KDEC deceleration. If the final point of the
calculated deceleration process < SLLIMIT, the controller detects #SLL fault. If the final
point of the calculated deceleration process > SRLIMIT, the controller detects an #SRL
fault.
This logic provides the moving edge of the software limit fault, depending on the instant velocity.
As the controller kills the motor when the fault is detected, the termination point of the kill
process will be very close to the corresponding software limit point.
The termination point is not exactly the software limit point because the controller checks the
condition every controller cycle, i.e., at discrete time points. The termination point complies with
the following conditions:
• The termination point lies beyond the corresponding software limit.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-21
3 ret
4 on X_FAULT.#SRL
6 ret
Use the #PE fault to detect non-critical violation of position accuracy, and the #CPE (See 8.4.5)
fault to detect uncontrolled, excessive error that indicates loss of control.
The following standard variables are associated with position errors:
ERRI Maximum position error while the motor is idle (not moving)
ERRV Maximum position error while the motor is moving with constant
velocity
ERRA Maximum position error while the motor is accelerating or
decelerating
DELI Delay on transition from ERRA to ERRI
DELV Delay on transition from ERRA to ERRV
The controller raises the FAULT.#PE bit if the position error exceeds the maximum specified
value, which is equal to ERRI, ERRV or ERRA depending on the motion state.
The variables DELI and DELV are used in a similar manner with the #CPE fault (page 8-23).
The following diagram illustrates the use of these variables for a typical motion profile that
includes acceleration, constant velocity and deceleration:
V
PE > ERRI PE > ERRA PE > ERRV PE > ERRA PE > ERRI
DELV DELI
3 ret
The next example corrects the motion conditions by reducing the velocity (Y_VEL) until the
error returns to within limits, instead of killing the motion.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-23
3 wait 10 Delay.
2 end
3 ret
Use #PE fault to detect non-critical violations of position accuracy, and the #CPE fault to detect
uncontrolled, excessive error that indicates loss of control. #CPE should be greater than #PE.
The following standard variables are associated with critical position error :
CERRI Critical position error if the motor is idle (not moving)
CERRV Critical position error if the motor is moving with constant velocity
The variables DELI and DELV are used also in the condition for the #PE fault.
The controller raises the fault bit if the position error exceeds the critical value. The critical value
is equal to CERRI, CERRV or CERRA depending on the motion stage. The following diagram
illustrates the use of these variables for a typical motion profile that includes acceleration,
constant velocity and deceleration:
V
CPE > CERRI CPE > CERRA CPE > CERRV CPE > CERRA CPE > CERRI
DELV DELI
2 disp "T axis shows abnormal error. The motor was disabled."
3 ret
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-25
Unlike most faults, #ENC and #ENC2 faults are latched. The fault bits remain raised even after
the cause of the fault has been eliminated. Only the next enable command resets the fault bits.
Occurrence of #ENC fault indicates a serious problem in motor control. Do not disable the default
response unless it is absolutely necessary in your application, i.e. keep FDEF.#CPE = 1.
Autoroutine examples
The following autoroutine supplements the default response with an alarm message:
1 on Z_FAULT.#ENC
3 ret
Internal safety condition The controller raises fault bit #ENCNC if a primary
encoder is not connected. The controller raises fault bit
#ENC2NC if a secondary encoder is not connected.
If the controller detects a pair of differential encoder inputs that are not in opposite states (high
and low level), it raises the fault, because this may indicate a problem such as a short circuit or
unconnected wire.
An #ENCNC fault indicates a serious problem in motor control. Do not disable the default
response unless it is absolutely necessary in your application, i.e. keep FDEF.#CPE = 1.
Autoroutine examples
The following autoroutine supplements the default response with an alarm message:
1 on X_FAULT.#ENCNC
2 disp "X axis: Encoder Not Connected. The motor was disabled."
3 Ret
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-27
Internal safety condition The controller never sets the fault bit while the
motor is disabled. The controller starts monitoring
the fault condition when the period of time defined
by variable ENTIME elapses after the motor has
been enabled.
Even if the SAFIN.#DRIVE bit is in an active state, the controller never raises the fault bit while
the motor is disabled. When the enable command is executed, the controller waits for the period
of time defined by variable ENTIME, and only then starts monitoring the SAFIN.#DRIVE bit. If
the Drive Alarm signal is still active at that time, the fault condition is satisfied.
The controller continues monitoring the fault condition until the motor is disabled by a disable
command or a fault that disables the motor.
Occurrence of #DRIVE fault indicates a serious problem in the motor control. Do not disable the
default response unless it is absolutely necessary in your application, i.e. keep FDEF.#CPE = 1.
3 if reason = 1
5 elseif reason = 2
7 end
8 ret
3 ret
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-29
#VL uses the motor reference velocity RVEL, not the motor feedback velocity FVEL. Therefore,
the fault bit is raised if an application command calls for excessive velocity, even if the motor has
not reached this velocity. The fault can also be used for program testing without physical motion,
while motors are disabled.
Autoroutine examples
The autoroutine informs the user about the violation.
1 on Z_FAULT.#VL
3 ret
#AL uses the motor reference acceleration RACC, not the motor feedback acceleration FACC.
Therefore, the fault bit is raised if an application command calls for excessive acceleration, even
if the motor has not reached this acceleration. The fault also can be used for a program testing
without motion, while motors are disabled.
Autoroutine examples
The following autoroutine supplements the default response with an alarm message:
1 on X_FAULT.#AL
3 ret
The current limit fault is based upon the Servo Processor algorithm that calculates the RMS value
of the motor current. When the calculated RMS current exceeds the allowed value the Servo
Processor reports an error that the MPU translates into a current limit fault.
Current limit processing uses the following variables:
XRMS Maximum allowed RMS current for each motor
XCURI Maximum instantaneous current if the motor is idle (not
moving)
XCURV Maximum instantaneous current if the motor is moving
To configure the specified variables use the Configurator in SPiiPlus MMI.
Autoroutine examples
The following autoroutine kills the motion (and displays an alarm message) instead of the motor.
(The default response can be disabled by adding FDEF.#CL = 0 to the ACSPL+ program).
1 on Y_FAULT.#CL
2 kill Y
4 ret
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-31
#SP indicates that communication between the MPU and one of the servo processors failed.
Occurrence of the #SP fault indicates a serious hardware problem.
Do not disable the default response unless it is absolutely necessary in your application, i.e. keep
FDEF.#SP = 1.
This fault may be caused by a problem in the SP program. If SP program hangs, the fault remains
permanent. If the SP program time exceeds the tick time (50 microseconds), the fault is
intermittent.
The disable reason reported by the controller is 5027 'Servo Processor Alarm'.
Autoroutine examples
The following autoroutine supplements the default response with an alarm message:
1 on Y_FAULT.#SP
3 ret
Internal safety condition The controller raises fault bit #HSSINC if HSSI is not
connected.
3 Ret
Autoroutine example:
The following autoroutine kills all motions but does not disable the motors (this assumes that the
default response has been disabled by S_FDEF.#ES = 0).
1 on S_FAULT.#ES
2 killall
3 ret
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-33
Internal safety condition The controller latches the fault when any
ACSPL+ program encounters a run-time
error.
Unlike most faults, the #PROG fault is latched. Once raised, the bit remains raised until the
controller resets it on execution of any command that compiles or starts a program in any buffer.
Autoroutine examples
The following autoroutine supplements the controller's default response, terminating all
concurrent programs and displaying an alarm message.
1 on S_FAULT.#PROG
2 stopall
4 ret
Note that a run time error in a buffer stops all activity in the buffer. Therefore, the above
autoroutine cannot intercept an error that occurred in the buffer where the autoroutine is located.
However, it intercepts an error in any other buffer.
This autoroutine can supplement the default response (S_FDEF.#PROG = 1) or can replace it
(S_FDEF.#PROG = 0).
The following autoroutine does the same (stops all programs) and also provides a diagnostic
message:
1 on S_FAULT.#PROG
2 stopall
3 I0 = 0
4 loop 10
7 end
8 end
9 ret
The standard variable PERR contains the termination codes of the ACSPL+ programs. Each
element of PERR contains termination code for a different buffer. At power-up all elements of
PERR are reset to 0. When a program in any buffer finishes or terminates for any reason, the
corresponding element of PERR is assigned with a code that specifies the termination reason. The
element resets to zero again once the corresponding buffer is compiled or program execution
starts.
Termination codes from 3000 to 3020 indicate normal termination. Codes greater than or equal to
3020 indicate run-time errors (see page 12-2).
Internal safety condition The controller latches the fault bit when the
user application requires more memory than
is available in the controller.
Unlike most faults, the #MEM fault is latched. Once raised, the bit remains raised until the
controller resets it on execution of any command that compiles or starts a program in any buffer.
Because the controller uses dynamic memory handling, the amount of the memory available for a
specific user application cannot be exactly determined. If an application shows the fault, the user
needs to reduce the size of application or to add memory.
The following recommendations may be useful in eliminating the error:
Reduce the length of ACSPL+ programs.
Reduce the volume of user local and global variables. Pay special attention to arrays.
Limit the length of commands that are sent to the controller. Do not use commands that
exceed 2032 characters.
Simplify the formulae used with the connect and master commands.
Autoroutine examples
The following autoroutine terminates all executing programs and displays an error message when
the fault occurs:
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-35
1 on S_FAULT.#MEM
2 stopall
4 ret
This autoroutine can supplement the default response (S_FDEF.#PROG = 1) or can replace it
(S_FDEF.#PROG = 0).
The controller raises the fault bit when the user application consumes too much processing time
and S_FMASK.#TIME bit is raised.
The structure of the controller’s real-time cycle is discussed in Chapter 3: SPiiPlus .
As the real-time processing time varies between cycles, the fault may occasionally occur and
requires no special attention. However, frequent or permanent occurrence of the fault requires
measures to correct the situation.
The controller has no default response to the fault. To monitor this fault, you must define your
own autoroutine.
The following recommendations may be useful in reducing real time processing time, thereby
eliminating the fault:
Reduce the number of concurrently executed programs.
Reduce the program execution rates (parameters PRATE, ONRATE).
Reduce the number of command specified in one program line.
Reduce the number of autoroutines.
Simplify the conditions in autoroutine headers.
Reduce the number of concurrently executed motions.
Avoid short-time motions.
Use segmented motion instead of a series of short PTP motions.
Simplify the formulae used in the connect and master commands.
Autoroutine example:
The following autoroutine accumulates statistics on the fault. The autoroutine measures a time of
1000 fault occurrences and then displays the average time between faults. The autoroutine relies
on zero initialization of the local variables.
1 Local int N Declare local variable for
counting the number of
faults
6 disp "#TIME occurs once per ", (TIME – Display average time
ATIME) / N, " ms" between faults
9 end
10 ret
The fault indicates a serious failure. Do not disable the default response unless it is absolutely
necessary in your application., i.e., keep FDEF.#INT = 1
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-37
The MPU sets the fault 'Servo Interrupt' if the 1ms interrupt is not received. The probably cause is
a hardware problem.
The controller response to the fault is to disable all motors. The disable reason reported by the
controller is 5029 'Servo Interrupt'.
Autoroutine examples
The following autoroutine supplements the default response with termination of all ACSPL+
programs and an alarm message:
1 on S_FAULT.#INT
2 stopall
4 ret
The upper part of the diagram shows how motor faults are examined. The list of faults is identical
for each motor and the controller repeats the process for each motor. The end product is the
variable FAULT.
The lower part of the diagram shows the elements that go into constructing the S_FAULT
variable. Part of its bits are set as the OR-aggregate of the FAULT elements, and other bits are
determined by examining the system faults.
Internal Safety
Conditions
XOR
Variable FMASK
AND
Variable FAULT
Internal Safety
Conditions XOR
Variable S_FMASK
AND
Variable S_FAULT
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-39
assigns a value of one to variable V0 if the Drive Alarm signal of the X motor is high and minus
one if low.
The configuration variable SAFINI defines which level of motor safety input causes a fault. In
the above diagram XOR is a bit-wise operation. Therefore, if a bit of SAFINI is zero, high
voltage of the corresponding signal causes fault. If a bit of SAFINI is one, low voltage causes
fault. Only those bits of SAFINI that correspond to the meaningful bits of SAFIN are used in
fault processing. Other bits have no effect.
In addition to the safety inputs, the controller examines a number of internal safety conditions for
each motor each controller cycle. The faults caused by the motor safety inputs and the faults
detected by internal conditions provide a set of motor faults.
A detected motor fault is stored in a bit of variable FAULT only if the corresponding bit of
variable FMASK is one. If a bit of FMASK is zero, the controller does not raise the
corresponding fault bit even if the fault condition or safety input is true. If a bit of FMASK is set
to one, the corresponding bit of FAULT is immediately set when the fault occurs. The bit rises to
one or drops to zero in the same controller cycle as the corresponding safety input or internal
safety condition shows change in the fault state.
Only those bits of FAULT that correspond to the motor faults are meaningful.
When a bit is raised, it activates the default response to the fault. An autoroutine that processes
the fault must use the bit of FAULT in the header condition.
As mentioned earlier in this chapter, the controller response to a fault can be modified with the
standard variables FDEF/S_FDEF and with autoroutines.
The terminal command #SC reports the current safety system configuration. See page 4-22.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S a f e t y C o n t ro l 8-41
9.1.1. General
A digital input is a pin in the controller connector that accepts a binary signal, in the form of low
or high voltage from an external source such as a switch or a relay. A digital output is a pin in the
controller connector that provides a binary signal to an external acceptor such as an LED or
actuator.
The controller provides a set of general-purpose inputs and outputs that have no predefined
function. You can assign a function to any input/output as required by your application.
The exact number of digital inputs and outputs depends on the controller configuration.
For example, the basic I/O configuration of the SPiiPlus PCI-8 controller is:
• 8 digital inputs (5Vdc) for general purpose or position capture (Mark).
• 8 digital outputs (5Vdc) for general purpose or PEG
• 4 digital outputs (5Vdc) for general purpose or additional PEG states
• 16 analog outputs +/-10Vdc for general purpose or drive command
• 16 analog inputs +/-1.25Vdc for general purpose or SIN COS encoder feedback
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In p ut s a n d O u t p ut s 9-3
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In p ut s a n d O u t p ut s 9-5
while IN0.1 & IN0.2 Execute the subsequent commands up to command end
while both IN0.1 and IN0.2 are one.
till IN0.10 Wait until IN0.10 becomes one.
till IN0 & 0x0101 Wait until at least one of IN0.0 and IN0.8 becomes
one.
9.1.3.5. Autoroutines
Autoroutine headers include logical expressions. Using I/O in the logical expression provides
autoroutine activation based on the I/O state. The expression in the autoroutine header is verified
each controller cycle, therefore the controller can respond to I/O changes very quickly.
For example:
till IN(0) & 0x0101 Wait until at least one of IN(0).0 and IN(0).8
become one.
on IN0.0 | IN0.8 Start autoroutine when at least one of IN0.0 and IN0.8
becomes 1. To start the autoroutine again, both IN0.0
and IN0.8 must return to 0 and then at least one of
them must change to 1.
on IN0 & 0x0101 The same as above. Start autoroutine when at least one
of IN0.0 and IN0.8 becomes 1. To start the autoroutine
again, both IN0.0 and IN0.8 must return to 0 and then
at least one of them must change to 1.
See the example in the next section for an application of I/O to implement an emergency-induced
shutdown of all motion.
2 int Bits
3 Start:
4 OUT0.0 = X_MST.#INPOS
5 if T1 <= TIME
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In p ut s a n d O u t p ut s 9-7
7 Bits.0 = ^Bits.0
8 end
10 goto Start
11
Line1 Definition of local variable T1 that is used to store the next switch time. T1 may
be defined as integer, but as a real, it can provide continuous running for an
extended period without overflow. The program relies on the automatic
initialization of all local variables to zero when they are declared.
Line2 Definition of local variable Bits. In this program only one bit of Bits is used. One
temporary integer variable can be used for storing 32 temporary bits.
Line3 Start label. A typical case in PLC programming is a long program cycle that
executes to the end and returns to the beginning. In the example shown above, the
execution period is quite short even with default rate of ‘one Line per each
controller cycle’. In a long program, the execution cycle can reach hundreds of
milliseconds. This is a good reason to divide a typical PLC program into slow and
fast sections.
Line 4 OUT0.0 reflects the ‘in position’ state of the motor. If the motor is not in position,
the output is 0. If it is in position, the output is 1.
Lines OUT0.4 controls a periodic activity that must be executed each 15 minutes for a
5-9 30-second period. It is executed only if IN0.4 is active. In a typical application, the
output might be connected to lubrication pump.
Line10 The end of the main cycle.
Line12 An autoroutine that provides extra fast response to IN0.15, typically an emergency
input. The whole autoroutine is implemented in one line providing an immediate
kill of all motions within one controller cycle when input port 0 bit 15 is 1.
For detailed information about the HSSI interface, see the HSSI Hardware Guide
If a software-commutated brushless motor is connected to the X-axis, both output 0 and output 1
are unavailable.
On the other hand, if a brush motor is connected to the same axis, output 1 is free.
Examples of standard variables that can be monitored at 1kHz by assigning the variable to an
entity of AOUT:
Feedback position - FPOS.
Feedback velocity – FVEL.
Feedback acceleration - FACC.
The same applies for any other ACSPL+ variable (standard or user-defined).
Example
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
In p ut s a n d O u t p ut s 9-9
The following ACSPL+ program assigns X-axis feedback position to output # 3 and acceleration
to output #1. In the example, the user variables SF1 and SF2 are scale factors.
real SF1,SF2
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-3
Physical Output When Used for When Used for When Used for
General Purpose PEG Braking
Output 0 OUT0.0 X PEG State 0 X Brake
Output 1 OUT0.1 X PEG State 1 Y Brake
Output 2 OUT0.2 X PEG State 2 Z Brake
Output 3 OUT0.3 X PEG Pulse
Output 4 OUT0.4 Y PEG State 0 T Brake
Output 5 OUT0.5 Y PEG State 1 A Brake
Physical Output When Used for When Used for When Used for
General Purpose PEG Braking
Output 6 OUT0.6 Y PEG State 2 B Brake
Output 7 OUT0.7 Y PEG Pulse
Output 8 OUT0.8 X PEG State 3 C Brake
Output 9 OUT0.9 Y PEG State 3 D Brake
Output 10 OUT0.10 Z PEG Pulse
Output 11 OUT0.11 T PEG Pulse
If a digital output is assigned to one of these functions (for example, general purpose) it cannot be
used for the other functions (in this case, PEG or brake). For example, if output 8 is assigned to C
brake, it is isolated from the OUT0.8 bit and from the PEG function. Therefore the state of the
output will not be affected by assignment to the OUT0.8 bit or by PEG generation.
After power-up, all outputs are assigned by default to the OUT0 bits for general purpose use and
all OUT0 bits are cleared.
A digital output can be configured for one of the three uses with the setconf(29) function. The key
argument must be 29, the index argument defines the output number, and the value argument
defines the assignment (TABLE 10-11):
Value Assignment
The corresponding getconf(29) function call returns the current assignment of the output specified
by the index argument. See also the reference information for setconf/getconf(29), page 5-62.
See brake output operation (page 7-22).
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-5
If an application does require the mechanical braking function, the SPiiPlus CM high-power
digital brake outputs can be reconfigured for general use simply by clearing bit 24 (#BRAKE) of
the corresponding MFLAGS variable. In that case, the outputs are mapped to the bits of OUT1
variable for general use (TABLE 10-12):
X OUT1.0
Y OUT1.1
A OUT1.4
For example, if bit Y_MFLAGS.#BRAKE is cleared, then the Y axis high power brake output
functions as a general purpose output, and is controlled by OUT1.1.
See brake output operation (page 7-22).
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-7
The command instructs the controller to copy one or more values from the DPRAM to the
standard variables specified in variable-list.
The dpr-address argument specifies the relative DPRAM address for the first variable in the list.
The second variable in the list is allocated in the upper address adjacent to the first variable and so
on. The specified address cannot be less than 128, because the first 64 words (128 bytes) are
reserved for system use.
Example:
copyfromdpr 0xA0, OUT0, X_TPOS, X_VEL, X_ACC
Variable OUT0 is integer, variables X_TPOS, X_VEL, X_ACC, are real. Therefore, the relative
DPRAM addresses for the variables will be allocated as follows:
0xA0 (160) – OUT0 (4 bytes)
0xA4 (164) – X_TPOS (8 bytes)
0xAC (172) – X_VEL (8 bytes)
0xB4 (180) – X_ACC (8 bytes)
Any number of copyfromdpr commands can be executed and at any place within the ACSPL+
program. The command is typically used in the AUTOEXEC section (see page 4-37).
Execution of a copyfromdpr command is dependent on the state of the
S_FLAGS.#COPYFROM bit (page 11-54). When the bit is set, copying is disabled. When the
bit is clear, copying is enabled.
executes a number of copy operations. Therefore the #U command may display low average
usage but high maximal usage. The maximal number of copy operations executed in one cycle is
less than or equal to the overall number of definitions in all copyfromdpr commands. Therefore,
the maximal usage in this mode can reach the maximal usage level of copy-each-cycle mode, but
cannot exceed it.
How close the maximal usage in copy-only-if-requested mode comes to the maximal usage in
copy-each-cycle mode depends on the application. The DPRAM layout can be optimized in order
to minimize the maximal usage.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-9
The relative DPRAM addresses for the variables will be allocated as follows:
0xC0 (192) – First
0xC4 (196) – Second(0)
0xC8 (200) – Second(1)
0xCC (204) – Second(2)
0xD0 (208) – Third
5. Close communication.
#include “stdafx.h”
#include "..\acscgonext\acsc.h"
#include <conio.h>
HANDLE h=acsc_OpenCommPCI(-1);
char command[100],Reply[100];
int N;
acsc_WriteDPRAMInteger(h,0xa8,000);
strcpy(command,"copyfromdpr 0xa8,OUT0\r");
int res=acsc_Transaction(h,command,strlen(command),Reply,100,&N,NULL);
Sleep(100);
int i;
for(i=0;i<100000&&!kbhit();i++)
acsc_WriteDPRAMInteger(h,0xa8,-1);
Sleep(10);
acsc_WriteDPRAMInteger(h,0xa8,0);
Sleep(20);
strcpy(command,"stopcopytodpr\r");
res=acsc_Transaction(h,command,strlen(command),Reply,100,&N,NULL);
acsc_CloseComm(h);
return 0;
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-11
#include "acsc.h"
#include <conio.h>
HANDLE h=acsc_OpenCommPCI(-1);
Char command[100],Reply[100];
int N;
acsc_Enable(h,ACSC_AXIS_B,NULL);
acsc_SetFPosition(h,5,0,NULL);
// Set the link between DPRAM field and the standard variables
strcpy(command,"copyfromdpr 0xa0,B_TPOS\r");
res=acsc_Transaction(h,command,strlen(command),Reply,100,&N,NULL);
strcpy(command,"track B\r");
res=acsc_Transaction(h,command,strlen(command),Reply,100,&N,NULL);
Sleep(100);
int i;
for(i=0;i<100000&&!kbhit();I++)
acsc_WriteDPRAMReal(h,0xa0,i*100);
strcpy(command,"stopcopytodpr\r");
res=acsc_Transaction(h,command,strlen(command),Reply,100,&N,NULL);
acsc_Disable(h,ACSC_AXIS_B,NULL);
acsc_CloseComm(h);
return 0;
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Mo d e l - D e p e n de n t F e a t u re s 10-13
The dynamic brake reduces the motor runoff if the motor becomes disabled during motion. In
dynamic braking the controller short-circuits the motor armature.
If dynamic braking is enabled for an axis, the controller applies the braking when the feedback
velocity falls below the value specified by the VELBRK parameter (default – 0).
The MFLAGS.#BRAKE bit enables dynamic braking (default – off).
Constant current mode provides extra safety. When the mode is activated, and the emergency stop
signal is on, the motor is kept at a standstill by the drive.
• The function, setconf (133, 1, 1) enables constant current mode for axes Y and B. The
function, setconf (133, 1, 0) disables constant current mode for axes Y and B.
• To retrieve the constant current mode status for Y and B axes, getconf (133, 1) is used. It
retrieves a non-zero value if constant current mode is on and zero if constant current mode is
off.
The drive activates constant current mode only if all of the following conditions are true:
• Emergency Stop (ES) signal is on.
• All axes are disabled.
• Dynamic brake mode is off (MFLAGS(Axis).#BRAKE = 0).
Only once these conditions are true can constant current mode be enabled by the function setconf
(133, 1, 1). If any of the conditions is changed, it will deactivate constant current mode.
To set/get the current level used for constant current mode, the following setconf/getconf
parameters are used:
• setconf (130, {1|5}, current level), where current level defines that the constant current level
as a percentage of the maximum current for the specified axis (Y or B only, represented by
the index value 1 or 5 respectively). The default maximum value that can be set is 16% for
axis Y and 30% for axis B (this value can be changed, see description of key 131 below).
• getconf (130, {1|5}) retrieves the present value of current level for the specified axis.
The default value of current level is 0, so it must be defined before constant current mode can be
used.
To set/get the maximum value that can be set with setconf (130, . . .), the following
setconf/getconf parameters are used:
• setconf (131, {1|5}, max current level), where max current level defines the maximum
allowable value of the current level as a percentage of the maximum current for the specified
axis (Y or B only, represented by the index value 1 or 5 respectively).
• getconf (131, {1|5}) retrieves the present maximum allowable current level for the specified
axis.
The following ACSPL+ program illustrates how to implement constant current mode:
! Constant current mode implementation
on S_FAULT.#ES
disableall
wait 100
ret
on ^S_FAULT.#ES | S_FAULT.#DRIVE
ret
See the SPiiPlus PCI-DDM4A Four-Axis Digital Drive Module Hardware Guide for more
information.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-1
Standard variables are predefined in the controller. A standard variable can be used in any
ACSPL+ program without user declaration. Redefinition of standard variable names is prohibited
and causes program error.
All standard variables have global scope; so that all references to a global variable in any program
buffer refer to the same variable.
This reference starts with brief descriptions of the standard variables, first by group and again
listed alphabetically. This is followed by detailed descriptions of the standard variables in
alphabetical order.
11.1.1. State
Name Size Type Accessibility Description Page
11.1.2. Motion
Name Size Type Accessibility Description Page
GPATH 8 Real Read-only Group Path 11-34
GPHASE 8 Real Read-only Motion Phase 11-36
GVEC 8 Real Read-only Group Vector 11-37
GVEL 8 Real Read-only Group Velocity 11-37
GACC 8 Real Read-only Group Acceleration 11-32
GJERK 8 Real Read-only Group Jerk 11-33
GRTIME 8 Real Read-only Remaining Motion Time 11-35
GMOT 8 Integer Read-only Group Motion Number 11-33
GMQU 8 Integer Read-only Group Motion Queue 11-33
GMTYPE 8 Integer Read-only Motion Type 11-34
GSEG 8 Integer Read-only Group Segment Number 11-35
VEL 8 Real Read-Write Default velocity 11-69
ACC 8 Real Read-write Acceleration 11-14
DEC 8 Real Read-write Deceleration 11-22
JERK 8 Real Read-write Jerk 11-41
KDEC 8 Real Read-write Kill Deceleration 11-42
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-3
11.1.5. Input/Output
Name Size Type Accessibility Description Page
IN 8 Integer Read-only General-Purpose Dig. Inputs 11-39
OUT 8 Integer Read-Write General-Purpose Dig. 11-49
Outputs
AIN 16 Integer Read-only Analog Inputs 11-16
AOUT 16 Integer Read-Write Analog Outputs 11-16
FK Scalar Integer Read-only Function Key 11-30
DCOM 8 Integer Read-write Drive Command 11-22
DOUT 8 Integer Read-only Drive Output 11-23
EXTIN 16 Integer Read-only Extended Inputs (HSSI) 11-29
EXTOUT 16 Integer Read-write Extended Outputs (HSSI) 11-29
11.1.7. Monitoring
Name Size Type Accessibility Description Page
SMNA *4 Integer Read-Write Software Monitor Address 11-66
SMNV *4 Integer Read-only Software Monitor Value 11-67
* Size is model dependent – one per SP.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-5
11.1.9. Configuration
Name Size Type Accessibility Description Page
IENA Scalar Integer Read-write Interrupt Enable/Disable 11-38
ISENA 8 Integer Read-write Interrupt-Specific 11-40
Enable/Disable
CFG Scalar Integer Read-only Configuration Mode 11-19
CTIME Scalar Real Read-write Controller Cycle Time 11-20
S_FLAGS Scalar Integer Read-write System Flags 11-54
BAUD Scalar Integer Read-write IO Baud Rate 11-17
DISPCH Scalar Integer Read-write IO Default Channel 11-23
ECHO Scalar Integer Read-write IO Echo Channel 11-27
COMMFL Scalar Integer Read-write Communication IO Flags 11-19
IMASK 8 Integer Read-write Index Mask 11-38
AFLAGS 8 Integer Read-write Axis Flags 11-16
EFAC 8 Real Read-write Encoder Factor 11-26
E2FAC 8 Real Read-write Secondary Encoder Factor 11-26
E_FREQ 8 Integer Read-write Encoder Frequency 11-24
E_TYPE 8 Integer Read-write Encoder Type 11-25
E2_TYPE 8 Integer Read-write Secondary Encoder Type 11-26
E_SCMUL 8 Integer Read-write Encoder Sin-Cos Multiplier 11-24
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-7
11.1.10.2. Commutation
Name Size Type Accessibility Description Page
SLCNP 8 Integer Read-write Number of poles for rotary 11-60
motor, 2 for linear motor
SLCPA 8 Real Read-write Phase advance in electrical 11-60
degrees at XVEL velocity.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-9
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-11
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-13
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-15
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-17
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-19
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-21
Many operation in the controller are synchronized to the controller cycle. For
example, profile generation is executed each controller cycle. Therefore, if
CTIME is 0.5 the profile generation will be calculated twice each
millisecond.
DEC Deceleration
Size 8 (one value per axis)
Type Real
Accessibility Read-write
Comments DEC defines the deceleration of the motion profile. For one-axis motion
DEC defines axis deceleration. If the axis is a leading axis in a group, DEC
defines the vector deceleration of common motion.
If DEC is changed when a motion is in progress, the change does not affect
the motions that are currently executing or were created before the change.
All motions created after the change will use the new value.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-23
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-25
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-27
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-29
FAULT Faults
Size 8 (one value per motor)
Type Integer
Accessibility Read-only
Comments FAULT provides a set of bits that present the current state of each axis fault.
The user can set the bits in variable FMASK to define which faults must be
examined and processed for an axis.
The faults are examined each controller cycle. If the fault condition is true,
the corresponding bit is set; otherwise the bit is reset. The user can check the
fault bits in the ACSPL+ program, or can define automatic response using
autoroutines.
For a list of fault bits see section 0.
FK Function Key
Size Scalar
Type Integer
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-31
FK Function Key
Accessibility Read-only
Comments FK is used by the controller to store functional keys in an input string
processed with the input command (see Section 0).
If the controller encounters a zero character in the input string, it stores value
of the next character in FK.
This is the usual way to receiving function key codes (F1 – F12).
An autoroutine can be used to respond to changes in FK.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-33
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-35
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-37
I I Array
Size 100
Type Integer
Accessibility Read-Write
Comments I defines a general-purpose array that can be used in any application program
as a predefined global variable.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-39
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-41
JERK Jerk
Size 8 (one value per axis)
Type Real
Accessibility Configuration
JERK Jerk
Comments JERK defines the jerk of the motion profile. For one-axis motion JERK
defines the axis jerk. If the axis is a leading axis in a group, JERK defines
vector jerk of the common motion.
If the variable is changed when a motion is in progress, the change does not
affect the motions that are executing or were created before the change. All
motions created after the change will use the new value of JERK.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-43
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-45
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-47
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-49
PE Position Error
Size 8 (one value per motor)
Type Real
Accessibility Read-only
Comments PE is the difference between RPOS and FPOS ( the current position error).
The value is valid only if the motor is enabled.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-51
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-53
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-55
• 0: copy-each-cycle
• 1: copy-only-if-requested.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-57
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-59
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-61
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-63
Default = 0.
The controller supports a standard control loop configuration: X position
feedback is obtained from X encoder, Y – from Y encoder, and so on
A non-default value in a routing variable provides feedback from an
alternative sensor. For example, if X_SLPROUT is 10, the position
feedback is obtained from analog input 0 rather than from the encoder. In
that case, the feedback source could be a potentiometer or any other device
that produce analog voltage proportional to the motor position.
The meaning of the routing value depends on the axis (and the controller
model). For example, value 1 specified for X or A axis selects the X
encoder, the same value for Y or B axis selects the Y encoder.
1 X, A X encoder
Y, B Y encoder
Z, C Z encoder
T, D T encoder
2 X, A A encoder
Y, B B encoder
Z, C C encoder
T, D D encoder
10 X, Y, A, B Analog input 0
Z, T, C, D Analog input 0 for
integrated models,
analog input 8 for
nonintegrated models
11 X, Y, A, B Analog input 1
Z, T, C, D Analog input 1 for
integrated models,
analog input 9 for
nonintegrated models
12 X, Y, A, B Analog input 2
Z, T, C, D Analog input 2 for
integrated models,
analog input 10 for
nonintegrated models
13 X, Y, A, B Analog input 3
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-65
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-67
will move the motor by 320 steps from the current position.
If another unit is required for motion programming, the user must configure
an appropriate value for STEPF. For example, a controlled plant provides a
gear ratio of 500 motor pulses per inch. If the motion programming unit must
be provided in inches, the configured STEPF value must be 0.002.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-69
V V Array
Size 100
Type Integer
Accessibility Read-Write
Comments V defines a general-purpose array that can be used in any application program
as a predefined global variable.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
S t a n da r d V a ri a bl e R e f e r e nc e 11-71
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
E r r or /D ia g no s t ic 12-1
12. ERROR/DIAGNOSTIC
12.1. General
This chapter provides a description of how error codes are generated, and a brief description of
each error.
5000 – Motion termination Codes from 5000 to 5008 do not indicate an error. They
5999 codes and motor report normal motion termination.
disable codes
Codes from 5009 and higher appear when a motion is
terminated or a motor is disabled due to a fault detected
by the controller.
When a motion terminates abnormally, or a motor is
disabled , the error code is stored in the MERR variable.
> 6000 User-defined codes The user can execute commands kill, killall, disable,
disableall with an argument that specifies a user-defined
error code.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
E r r or /D ia g no s t ic 12-3
X_FPOS = 0
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
E r r or /D ia g no s t ic 12-5
Motor z: disabled
Disable reason: 5023 – Critical Position Error
Axis Z: motion was killed because a motor was disabled
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
E r r or /D ia g no s t ic 12-7
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
E r r or /D ia g no s t ic 12-9
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-11
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-13
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-15
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-17
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-19
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-21
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-23
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-25
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-27
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-29
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
Er r or / D ia g no s t i c 12-31
i
For explanation of the drive-specific errors see the Hardware Guide of the specific controller.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A P PE N D I X A – H o s t C o mm un i c a t i on P r ot o c o l A-33
The SPiiPlus host communication protocol is designed to provide efficient and reliable command
exchange between a host computer and the SPiiPlus series controllers. The protocol provides two
communication formats: safe and regular.
Safe format is based on block-by-block transfer of data with delivery confirmation. Any binary
information can be transferred in safe format.
The command in regular format is a sequence of ASCII characters with a ‘\r’ (0xD) character at
the end of command.
The SPiiPlus package includes the SPiiPlus C Library, which implements the host communication
protocol and provides a host-based Windows application with a set of high-level functions to
communicate with the SPiiPlus controller via serial link (RS-232), via Ethernet network, and via
PCI bus (and with the SPiiPlus Simulator).
The SPiiPlus C Library relieves the user in most cases of the need to implement the host
communication protocol. The most common case where a programmer might be required to have
knowledge of the host protocol is where the host application will run on a non-Windows
operating system, such as Unix or Linux. In that case, the host application is unable to
communicate via the Windows-based C Library and will have to follow the host communication
protocol described here.
Safe Format
Safe format is not a separate controller mode. Any command can be transmitted to the controller
in safe format. The controller replies to the safe-formatted command also in safe format. The safe-
formatted commands can be mixed with regular formatted commands.
Safe format appears in two variants: with or without checksum. The controller reply follows the
host:
• If the issued command includes a checksum, the controller will reply with a checksum.
• If the issued command does not include a checksum, the controller will reply without a
checksum.
A command in safe format consists of 4-byte prefix, the command body, and 1- or 5-byte suffix.
Command body is exactly the regular ACSPL+ command with ‘\r’ appended (0xD).
The prefix has the following structure:
Byte 0: Starting frame character
Byte 1: Command ID - any value from 0 to 255.
Bytes 2,3: Command length in bytes (least significant byte appears first). The command
length is the number of bytes in the command body not including the prefix and
suffix.
The suffix has the following structure:
Byte 0: Ending frame character
Bytes 1-4: Appear only in safe with checksum format and contain checksum (least
significant byte appears first).
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A P PE N D I X A – H o s t C o mm un i c a t i on P r ot o c o l A-35
Error reply
To determine whether the controller reply contains an error code, the following condition must be
met.
• First character of the reply body is a question mark ‘?’
• Length of the reply body equals six bytes
The error code consists of four ASCII digit characters (0..9) starting with the second character of
the reply body.
Example: Error reply in safe format with error code 3079:
Chains
To send a command exceeding 2032 bytes in safe format, the command must be sent as a chain of
blocks. The maximum number of data characters in each block of chain must be 2032 bytes or
less. The format of each block is the usual safe format, except the following:
each block, except the last, contains 1 in the most significant bit of the third byte of the prefix.
The ID for all blocks in a chain must be the same. Therefore, the prefix of each block, except the
last, has the following structure:
Byte 0: Starting frame character
Byte 1: Command ID for this block - a value from 0 to 255.
Byte 2: Least significant byte of the command length.
Byte 3, bits 0-6: Most significant byte of the command length.
Byte 3, bit 7: Always one (chain flag) except for the last block in the chain where this
bit is zero.
To each block that contains a chain flag the receiver replies with a safe format prompt reply
(<D9><ID> if the receiver is the host or <E9><ID> if the receiver is the controller) confirming
that the block has been received and requesting the next block in the chain. The sender sends the
next block only after receiving the prompt.
The last block in the chain has the same ID as all the other blocks in the chain but no chain flag.
The receiver accumulates all chained blocks.
When a host sends a chain to the controller, after receiving the last block, the controller executes
the command as an entire unit. Then the controller sends a reply to the host, comprising either the
standard prompt in the case of successful completion or an error message in the case of an error.
Unsolicited Message
When a disp or send command executes in the controller’s program buffer, the controller sends
the output as an unsolicited message. (The unsolicited message is not a reply to a terminal
command.)
If bit 4 of the controller variable COMMFL is set, the controller sends unsolicited messages in
safe format. If bit 6 is also set, the unsolicited messages are sent with a checksum.
In safe format the controller adds a prefix and a suffix to each unsolicited message.
Message ID is incremented by the controller so that consecutive messages have consecutive IDs.
The length of an unsolicited message is always equal to or less than 2032.
Binary Commands
Binary commands must not end with the ‘\r’ (0xD) character. The host must send binary
commands in safe format.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A P PE N D I X A – H o s t C o mm un i c a t i on P r ot o c o l A-37
NOTE
Single quotation marks (') are used in the command syntax as notation
delimiters and are not part of the command.
Finding a String
The command searches for a specified string in a controller’s program buffer. The command
returns the line numbers that contain the requested string.
%F'buffer''line''text'
%FI'buffer''line''text'
where
Finding a Breakpoint
The command provides information about breakpoints in a buffer. The command is a binary
command and has the following structure:
%B'buffer'
‘buffer’ – single byte, contains number of the buffer as binary, not ASCII.
As a binary command, the command must not end with ‘\r’ (0xD) character. The host has to send
binary commands using the safe format.
The controller’s reply to the command consists of sequential short integer values. Each value has
2 bytes, the least significant byte appears first. Each value represents the sequential number of
line that contains a breakpoint. The values appear in ascending order.
Reading/Writing Variables
The command provides read/write to any standard, global or local variable in binary format. The
command is a binary command.
The read command has the following structure:
%?'type''variable_specification'/
%>'type''variable_specification'/'value'...
‘type’ – single byte, contains the length, in bytes, of one element of the variable. It must be 4
for an integer variable and 8 for a real variable as binary, not ASCII.
‘variable_specification’ - must be followed by a slash (/) character and has the following
syntax:
['buffer_specifier']'variable_name'['index'['index']]
‘buffer_specifier’ contains the buffer number as an ASCII number followed by a
semicolon (:). The ‘buffer_specifier’ is used only for local variables. Standard and
global variables must be specified without a ‘buffer_specifier’.
The ‘index’ argument is used only with array variables (scalar variables must be specified without
an ‘index’). If an array variable is specified without indexes, all elements of the array are
addressed by the command. The read command (%?) without an index returns the values of all
the elements in the array. The write command (%>) without indexes sets all the elements in the
array and must contain the same number of ‘values’ as there are array elements.)
If only one ‘index’ is given for a two-dimensional array, the ‘index’ addresses a full row of the
array.
The ‘index’ specification has the following syntax:
'index_value'[,'index_value’]
If one instance of 'index_value' is specified, it specifies a single index. If two instances of
'index_value' are specified (separated by a comma), then they specify an index range from the
first to the second value inclusive.
Each index value is a raw binary representation of a short integer (2 bytes). The least
significant byte appears first.
The write command (%>) sets all specified elements and must contain as many values as required
by the ‘index’ specification for the variable argument.
Each value is a raw binary presentation of integer (4 bytes) or real (8 bytes) number, according to
the variable type. The least significant byte appears first. The binary commands must not be
followed by a ‘\r’ character. The host has to send binary commands using the safe format as
specified above.
The controller’s reply to a read command (>%) consists of as many values as required by ‘index’
specifications. Each value is a raw binary presentation of integer (4 bytes) or real (8 bytes)
number, according to the variable type. The least significant byte appears first.
#nE’text’
n - number of the controller’s program buffer (as an ASCII character),
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A P PE N D I X A – H o s t C o mm un i c a t i on P r ot o c o l A-39
#nLRn1,n2
n - number of the controller’s program buffer (ASCII characters),
Managing Files
SPiiPlus controllers have flash (nonvolatile) memory, which retains data when the power is off.
This memory has a file system organization and keeps the firmware files, files of user application
and etc.
The following commands manage the files in the controller’s flash memory:
The #TW command causes the controller to create the specified file in the flash and to write the
attached data to the file. If the file already exists in the flash, the data is appended to the end of the
existing file.
The data written to the file is attached to the command. If the command is transmitted in safe
mode, the data can be a binary data. As with many of the other controller commands, the
command must end with a ‘\r’ (0xD) character. This ‘\r’ character is not considered a part of the
data and is not written to the file.
The #TC command causes the controller to delete the file in the flash.
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
A pp e n d i x b - P r e vi o us R e l e a s e N o t e s A-41
INDEX
#RESET, 4-42
—#—
#RL, 8-18
#AL, 8-30
#SAVE, 4-38
#CL, 8-31
#SAVEPAR, 4-39
#CLEAR, 4-42
#SAVEPROG, 4-39
#CPE, 8-24
#SAVESP, 4-39
#DRIVE, 8-28
#SLL, 8-20
#ENC, 8-26
#SP, 8-32
#ENC2, 8-26
#SRL, 8-20
#ENC2NC, 8-27
#TIME, 8-36
#ENCNC, 8-27
#U, 4-21
#ES, 8-33
#VL, 8-29
#HSSINC, 8-33
#HWRES, 4-42 —&—
#INT, 8-37 &, 5-72, 9-4
#LL, 8-18
—(—
#LOAD, 4-40
(peg_i command, 7-9
#LOADPAR, 4-41
—^—
#LOADPROG, 4-40
^, 5-72
#MEM, 8-35
#PE, 8-22 —|—
#PROG, 8-34 |, 5-72, 9-4
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
I nd e x A-12-3
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
I nd e x A-12-5
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
I nd e x A-12-7
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
I nd e x A-12-9
SP i i P l u s A C S PL + P ro g ra m me r ' s G ui de - D o c u me n t r e v i s i o n n o . 4 . 2 2
I nd e x A-12-11