SimplIQ Software Manual - MAN-SIMSW
SimplIQ Software Manual - MAN-SIMSW
SimplIQ Software Manual - MAN-SIMSW
Software Manual
April 2009
www.elmomc.com
Important Notice
This guide is delivered subject to the following conditions and restrictions:
This guide contains proprietary information belonging to Elmo Motion Control Ltd.
Such information is supplied solely for the purpose of assisting users of the SimplIQ
line of servo drives.
The text and graphics included in this manual are for the purpose of illustration and
reference only. The specifications on which they are based are subject to change
without notice.
Information in this document is subject to change without notice. Corporate and
individual names and data used in examples herein are fictitious unless otherwise
noted.
Revision History
Ver. 1.2 April 2009 MTCR 47: Minor correction in section 15.3 (MAN-SIMSM.PDF)
Ver. 1.1 Sept. 2004 Updated for SimplIQ (MAN-SIMSM.PDF)
Ver. 1.0 July 2003 Preliminary Release for Harmonica (HAR_SF_0903.pdf)
Elmo Motion Control Ltd. Elmo Motion Control Inc. Elmo Motion Control GmbH
64 Gisin St., P.O. Box 463 42 Technology Way Steinkirchring 1
Petach Tikva 49103 Nashua, NH 03060 D-78056, Villingen-Schwenningen
Israel USA Germany
Tel: +972 (3) 929-2300 Tel: +1 (603) 821-9979 Tel: +49 (0) 7720-85 77 60
Fax: +972 (3) 929-2322 Fax: +1 (603) 821-9943 Fax: +49 (0) 7720-85 77 70
info-il@elmomc.com info-us@elmomc.com info-de@elmomc.com www.elmomc.com
SimplIQ Software Manual Introduction i
MAN-SIMSW (Ver. 1.2)
Contents
Chapter 1: Introduction ........................................................................................1-1
1.1 Scope ...............................................................................................................1-1
1.2 Abbreviations.................................................................................................1-2
Chapter 2: SimplIQ Drive Description .................................................................2-1
2.1 Software Organization ..................................................................................2-1
2.1.1 Boot Software .................................................................................................... 2-1
2.1.2 Firmware............................................................................................................ 2-2
2.1.3 Personality ......................................................................................................... 2-2
2.2 Related Software............................................................................................2-2
2.3 Units of Measurement...................................................................................2-3
2.3.1 Position............................................................................................................... 2-3
2.3.2 Speed and Acceleration .................................................................................... 2-3
2.3.3 Current and Torque .......................................................................................... 2-3
2.4 Internal Units of Measurement and Conversion .......................................2-4
2.5 SimplIQ Drive Peripherals ..............................................................................2-4
2.5.1 Position Decoders ............................................................................................. 2-4
2.5.2 A/D Converter .................................................................................................. 2-4
2.5.3 Digital Inputs..................................................................................................... 2-5
2.5.4 Digital Outputs.................................................................................................. 2-5
Chapter 3: Communication with the Host.........................................................3-1
3.1 RS-232 Basics ..................................................................................................3-1
3.2 The Echo .........................................................................................................3-2
3.3 Background Transmission ............................................................................3-2
3.4 Errors and Exceptions in RS-232..................................................................3-3
Chapter 4: The Interpreter Language .................................................................4-1
4.1 The Command Line.......................................................................................4-1
4.2 Expressions and Operators...........................................................................4-2
4.2.1 Numbers ............................................................................................................ 4-2
4.2.2 Mathematical and Logical Operators.............................................................. 4-3
4.2.3 General Rules for Operators ............................................................................ 4-4
4.2.4 Operator Details ................................................................................................ 4-5
4.2.5 Mathematical Functions ................................................................................... 4-6
4.2.6 Expressions ........................................................................................................ 4-7
4.2.7 Comments ........................................................................................................ 4-11
Chapter 5: The SimplIQ User Programming Language ......................................5-1
5.1 User Program Organization .........................................................................5-1
5.2 Single and Multiple Command Execution..................................................5-3
5.3 Standard Conventions ..................................................................................5-3
5.3.1 Line and Expression Termination ................................................................... 5-3
5.3.2 Line Continuation ............................................................................................. 5-4
5.3.3 Limitations......................................................................................................... 5-4
5.4 Expressions and Operators...........................................................................5-4
5.4.1 Numbers ............................................................................................................ 5-4
SimplIQ Software Manual Contents ii
MAN-SIMSW (Ver. 1.2)
Chapter 1: Introduction
1.1 Scope
This manual describes, in detail, the software used with the SimplIQ line of digital servo
drives. It is an integral part of the SimplIQ documentation set, which includes:
SimplIQ product line Installation Guides, which provide full instructions for installing
a SimplIQ drive.
The Composer User Manual, which includes explanations of all the software tools that
are a part of Elmo’s Composer software environment.
The SimplIQ Command Reference Manual, which describes all of the software
commands used to manipulate SimplIQ drives.
The Elmo CANopen Implementation Guide, an auxiliary document that describes the
CAN communication objects used with SimplIQ drives.
Servo Drive
Installation Installation Guides
SimplIQ Software Manual Introduction 1-2
MAN-SIMSW (Ver. 1.2)
1.2 Abbreviations
The following abbreviations are used in this document:
EDS Electronic data sheet. The list of CAN objects supported by a device, in a
form suitable for standard configuration software.
PDO Process data object. A CAN message type, which eliminates the need for
allocation the data payload for object addressing by pre-agreement
concerning the message contents (PDO mapping).
2.1.2 Firmware
The firmware implements all other software functions, as described in this manual and in
the SimplIQ Command Reference Manual. The firmware transfers control to the boot software
when a download firmware (DF) command initiates a firmware version upgrade. At the
end of the firmware downloading process, the SimplIQ drive reboots.
2.1.3 Personality
The personality data is loaded to the serial flash memory. It includes a file allocation table
and several files containing data about the SimplIQ drive, including:
List of supported commands
List of error codes
CAN EDS (not yet implemented)
All data items in the personality enable the IDE to deal with the SimplIQ drive. The File
Allocation table reserves space for the storage of application parameters and user
programs. The personality data is burnt into the serial flash memory using the firmware
software. The firmware can boot without personality data, but it does not become fully
functional before the personality data is programmed in place. Full explanations of the
personality data are given in Appendix A.
The Composer software reads the personality data from the SimplIQ drive and can thereby
adapt to the specific drive model.
2.3.1 Position
The SimplIQ drive refers to position using sensor counts, which may be related to physical
units using the following commands:
Command Description
CA[18] For rotary motors, CA[18] is the number of sensor counts per one full
mechanical revolution.
CA[23] For linear motors, CA[23] stores the number of counts per user unit
(meter or any other unit selected by the user). This value is stored for
convenience only; the SimplIQ software does not use this number for any
internal calculation. For rotary motors, set CA[23]=0.
YA[1], YA[3] YA[1] is the auxiliary feedback resolution, in counts/physical unit. YA[3]
indicates what that physical unit is: revolution, meter or other. YA[1] and
YA[3] are stored for convenience only; the SimplIQ software does not use
these numbers for any internal calculation.
SimplIQ drives have a single motor current definition, although it can run equally well
with sinusoidal, trapezoidal or free-form motor windings. Motor current is defined as the
maximum winding current in a mechanical revolution. This definition is consistent with
the traditional current definition for six-step motors and it can be readily extended to other
winding forms.
SimplIQ Software Manual 1BSimplIQ Drive Description 2-4
MAN-SIMSW (Ver. 1.2)
To obtain the RMS phase current for sinusoidal motors, multiply the motor current
reported by the SimplIQ drive by a factor of 0.71.
These internal measurements are normally transparent to the user, because the SimplIQ
drive translates its internal calculations into standard units of measurements. However,
the following situations require the user to use the internal data representation:
Uploading data from the real-time recorder
Interpreting CAN-mapped synchronous PDOs
Specifying motions in micro-stepping mode
In these situations, the conversion factors can be retrieved using the relevant user interface
commands.
The encoder input is not protected: no hardware identifies illegal transitions. Exceeding
the maximum pulse rate causes a loss of counts that cannot be detected.
The resolution of all the measurements is 12 bits, and, in practice, the last bit is noisy. The
motor currents are measured offset-free, as the result of a special measurement
mechanism. Due to electronic inaccuracies in the SimplIQ drive circuits, the analog inputs
cannot avoid an offset, which can be corrected to a resolution of about 5 millivolts, using
the AS[1] parameter. AS[1] can correct offsets within the limited resolution range of
5 to 10 millivolts. This means that, for example, if AG[2]=10,000, the offset correction
quality of the speed analog reference will be limited to about 100 counts/second.
The digital input response time is limited by the speed of the optical couplers and the
input filters. The encoder index and home input are filtered similarly to the position
decoders. The timing of the position decoder filters is explained in the EF[N] command
section in the SimplIQ Command Reference Manual.
The other digital inputs are filtered in the software only. The timing of the software
filtering is explained in the IF[N] command section in the SimplIQ Command Reference
Manual.
The SimplIQ drive can communicate by RS-232 with baud rates of up to 57,600 baud/
second, depending on the sampling time. Refer to the PP[N] command section in the
SimplIQ Command Reference Manual.
where:
command mnemonic Two (case sensitive) letters assigned to a command
(complete list given in SimplIQ Command Reference Manual).
index Index, if mnemonic refers to a vector parameter or
command.
equal sign The “=” character (optional, if the command assigns a value
to a parameter).
value Parameter value (optional, if the command assigns a value to
a parameter).
The parameter value may be any legitimate arithmetic or
functional expression, as explained later in this section.
terminator <CR> (carriage return), which is the character 0xD
(13 decimal) or “;”.
The drive responds to commands communicated by the host it but never initiates a
message to the host if not requested. The syntax of the drive response is:
{<value>}{<error code>}<terminator>
where:
value Parameter value (optional, if the command requests a
parameter)
error code A binary number that may be interpreted according to the
error code tables (refer to the EC command in the SimplIQ
Command Reference Manual).
terminator “;” if the host command has been successfully executed;
otherwise “;?”
When communicating via RS-232, the Composer must have the echo turned on in
order to operate.
For the command sequence BH=1;MO=0<CR>, the drive will begin to transmit the
recorder data immediately. A few milliseconds later, while the recorder data is still being
transmitted, the drive will execute the MO=0 command. It will then store the response
message to the command in order to transmit it later, immediately after the record
upload terminates.
If the host has not been informed of the communication parameters, it may
transmit a series of terminators and attempt to use several baud rates until it
receives a matching sequence of echoes.
SimplIQ Software Manual Communication with the Host 3-3
MAN-SIMSW (Ver. 1.1)
The communication is defined as 8 bits per character. The SimplIQ drive will normally
only transmit characters in the range [0…127] with the exception of error codes (refer to
section 3.1). The SimplIQ drive accepts RS-232 bytes only in the range [0…127]; received
byte values in the range [128…255] are treated as UART errors.
Empty strings with terminators are echoed back, but are otherwise ignored.
SimplIQ Software Manual The Interpreter Language 4-1
MAN-SIMSW (Ver. 1.1)
The CANopen communication method can access simple numeric interpreter “get” and
“set” commands very efficiently. The CAN binary interpreter uses PDO objects to issue
interpreter commands and to collect the responses. This is the most economical way to
minimize both the communication load and the drive CPU load.
The CAN OS (command prompt) method can be used to access the entire set of
interpreter services, including those inaccessible by the binary CAN interpreter, using a
text format. The CANopen communication method is a broad topic and beyond the scope
of this manual (it is covered in the Elmo CAN Implementation Manual).
Software programs use the interpreter syntax, with extensions that are needed to support
program flow instructions and in-line documentation.
The full set of drive commands is documented in the SimplIQ Command Reference Manual.
A command line may include a comment marker, which is two consecutive asterisks (**).
All text from the comment market to the next line feed or carriage return is ignored. The
comment market is used to prepare documented batch files, sent later directly to the
drive.
SimplIQ Software Manual The Interpreter Language 4-2
MAN-SIMSW (Ver. 1.1)
Example:
4.2.1 Numbers
SimplIQ drives use two number types: 32-bit integers and 32-bit floating-point numbers
(“floats”). At text inputs, numbers containing a decimal point or an exponent notation are
interpreted as floats. Other numbers are interpreted as integers.
SimplIQ drives evaluate floating-point numbers with the standard IEEE floating
point precision of approximately six significant decimal digits. For example, the
number 12,345.0 has an exact IEEE floating point representation. The number 1,
234,568.0 is understood by the SimplIQ drive to be 12,345,680.0 due to truncation
into float IEEE format.
SimplIQ Software Manual The Interpreter Language 4-3
MAN-SIMSW (Ver. 1.1)
SimplIQ drives cannot evaluate numbers with an absolute value greater than 1020. For
example, if you enter =12.3e+20 or -13.56e-20, the SimplIQ drive will respond with a
Badly Formatted Number error.
The following table lists the mathematical and logical operators used in the SimplIQ drive
language. The table also specifies operator precedence, ordered from highest to lowest
precedence level.
If the result of add and subtract operations between two integers exceeds the integer
range [-2,147,483,648…2,147,483,647], the result is truncated and the type remains an
integer. For example:
The result of 2,147,483,647 + 10 is -2,147,483,639
A division operation between two integers may yield a floating-point result if the result
includes a remainder. For example:
8/2 (The result is 4, integer.)
9/2.0 (The result is 4.5, float.)
If a multiplication operation between two integers exceeds the integer range, the result is
converted into a floating-point number and is not truncated. For example:
100,000 * 100,000 (The result is 1.0e+10, float.)
Bit operators require an integer input. Floating-point inputs to bit operators are truncated to
integers. For example:
7.9 & 3.4 is equivalent to 7 & 3 because the floating-point number 7.9 is truncated to the
integer 7 and 3.4 is truncated to the integer 3 before applying the operator & (bitwise AND).
The result of a unary minus operation for the minimum integer value exceeds the
integer range; therefore, the result is truncated to the maximum integer value:
-0x80,000,000 results in 2,147,483,647 or 0x7FFFFFFF.
SimplIQ Software Manual The Interpreter Language 4-5
MAN-SIMSW (Ver. 1.1)
4.2.6 Expressions
An expression is a combination of operands (parameters) and operators that is evaluated
in a single value. Expressions work with immediate numbers, drive commands, and
drive and global user-program variables. The following sections describe the different
types of expressions.
Examples:
Examples:
SP=SP*2/5+AC
OP=IP|5
If the variable or the command is a vector, the assignment is allowed only for its single
member. The syntax of the vector member assignment is:
<parameter or command name>[index]=<simple expression>
The index is an index of the relevant member vector. Indices are enumerated from zero.
Example:
CA[1]=1
Be aware that when different types are assigned, the value may be truncated. If, for
example, the variable or command type is integer and the assigned value is floating
point, the floating value is rounded to the nearest integer. If a rounded integer value
exceeds the integer range, this value is truncated to the nearest valid integer.
Example:
Response
Expression Sent Received Remarks
AC=12,345.6789 – Assign floating value to integer AC command.
AC 12,346 Floating value rounded to nearest integer.
KV[10]=215.789e8 – Assign floating value to integer KV[10]
command.
KV[10] 2,147,483,647 Floating value truncated to maximum integer
value.
Example:
A floating point variable “tempt” is defined in a user program.
Response
Expression Sent Received Remarks
TC=1 – Assign integer value to floating point command
TC.
TC 1.0 Assigned integer value is converted to float.
temp=12,345,678 – Assign integer value to floating point variable.
temp 1.234568e+7 Assigned value is truncated to 12,345,680.0.
User program variables may be used within the command line only if a program was
compiled successfully and downloaded to the drive. The user may then use the
Interpreter to query a user variable value or change it.
The user should pay special attention to the scope of a variable. A variable may be
defined at the global or local level. Local variables are available only within the function
in which they are defined, while global variables are available within any function and
outside a program.
A user variable may be queried or changed when the program is running or halted.
For example, suppose that a compiled program includes the following lines at the global
level:
int ZEBRA,GIRAFFE[3];
float GNU;
Examples:
sin(3.14/3)
AC=abs(DC)
SP=SP+sin(3.14/2)
SimplIQ Software Manual The Interpreter Language 4-11
MAN-SIMSW (Ver. 1.1)
Time differences can be no longer than 31 minutes. To pause for a given time in a user
program, use the Wait function (section 5.7.5).
In a CAN network, the time counter can be changed by the CAN network master,
in which case, the tdif(x) function may return a value different than the time
elapsed since X=TM was sampled.
To prevent an external event from affecting the timer, use the tick function. The time
difference between the present time and an older tick sampling can be determined by one
of two methods, as shown in the following examples:
Example 1:
QP[1] = tick(0) ; ** QP[1] is used as storage only
. . . **Do something
QP[2] = QP[1]-tick(0); **QP[2] is the time difference in microseconds
Example 2:
QP[1] = tick(1000) ; ** QP[1] is used as storage only
. . . **Do something
QP[2] = tock(QP[1]); **QP[2] is the time difference in milliseconds
The tick( ) and tock ( ) functions cannot measure time differences greater than
32 milliseconds.
4.2.7 Comments
Comments are texts written into the code to enhance its readability. A comment starts
with a double asterisk (**) and terminates at the next end of line. The drive ignores
comments when evaluating an expression. The Interpreter handles comments from the
user program only.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-1
HARSF0703
A drive program is a list of commands in a certain order. A user program can be anything
from a simple list of commands to a very complicated machine management algorithm. The
compiled code stored in the SimplIQ drive is a list of commands in a certain order.
This chapter descries how to write, maintain and run user programs for the SimplIQ drive.
Most Interpreter commands can be used in the program text. This feature is given for each
command in the “Source” attribute of the command in the SimplIQ Command Reference
Manual. Interpreter commands that cannot be used in a program are those that:
Upload or download data between the drive and its host.
For example, VR cannot be used for version identification (upload process).
Store data in the flash memory or retrieve data from the flash memory
For example, CD cannot be used to reload parameters from the flash memory.
For example, XC## resumes a halted user program.
Are involved in executing the using program
1 The Elmo Clarinet, Mini-Saxophone and Saxophone digital drives use Elmo Low-level
Language (ELL). The Elmo Studio (part of the Composer) can distinguish between these
languages and activate the compilation process accordingly.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-2
MAN-SIMSW (Ver. 1.2)
In addition to the Interpreter commands, a program may include program flow statements
that manage how the program runs:
Iterations, such as: for I=1:10:100
Subroutine execution commands, such as: If(I>=100)
Conditions, such as: while(I<1000)
In the program text, semicolons, commands, line feeds or carriage returns separate the
commands, as in the following examples:
int x,k; Variable declarations
##Func Label definition
X=0; Initialize
for K=0:10 Iterate
X = x + 1 ; Do something
End End of iteration
Exit End of program directive
##Lab
… More code
The program defines two variables named x and k. ##Func is an entry point. After
compilation, this piece of code can be run by sending the command XQ##Func to the
Interpreter.
When the program starts at ##Func, it clears the user variable x. This is not performed
automatically and an initial value must be set manually for every relevant variable. The
program then iterates 11 times, incrementing x with every iteration. Finally, x = 11.
The Exit command terminates program execution. Another code section can then be
executed by sending the command XQ##Lab.
Example:
switch (IP & 3) Select according to the two low input bits.
case 1 The numerical interpretation of (IP&3) is 1.
PR=1000;
case 2 The numerical interpretation of (IP&3) is 2.
PR=500; If value is two . . .
otherwise
PR=100; Otherwise . . . (last two bits are 0 or 3).
end
BG Begin motion.
This example moves an axis with a step that depends on the state of the digital inputs.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-3
MAN-SIMSW (Ver. 1.2)
The policy of executing a full line ensures that commands are executed in a guaranteed
sequence and enables the user to regulate the speed of program execution. The more
commands in a single program line, the faster program execution will be, at the expense of a
slower response to host communications.
Note, however, that a drawback to this policy is that if the execution of a single program line
takes a long time, or if it loops internally forever, the SimplIQ drive may become totally
unresponsive to its CAN and RS-232 communication. In order to reduce this hazard, the
execution of a single program line is time-out protected by a limitation of 3 seconds as the
maximum time that program line execution can last. If a program line executes more than 3
seconds, the SimplIQ drive stops it with error code 96: User Program Time Out.
Examples:
a = 3 , b = 2 , c = a + b , One line of three expressions separated by commas
a = 3 ; b = 2 ; c = a + b ; One line of three expressions separated by semicolons
a = 3 , b = 2 ; c = a + b One line of three expressions separated by a comma, a
semicolon and terminated with a line feed
[a,b] = func (23, c, 3.14) An expression in which the comma is not an
expression separator because it is inside parentheses
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-4
MAN-SIMSW (Ver. 1.2)
Example:
c = 12 * a + sqrt(2) - sin(3.14 / 2) + 7 ^ 3 * …
(6 + b) * 34
The ellipsis (…) at the end of the first line indicates that this expression is not complete and
is continued on the next line.
5.3.3 Limitations
Every line of user program text may contain a maximum of 128 characters (for proper on-
screen readability). If a text line exceeds this value, the Compiler issues an error.
Expressions also have limitations: the maximum admissible length of an expression is 512
symbols, not including comments and ellipses. If a program contains a complex expression
that takes multiple lines, and the summary length of the expression (without comments and
ellipses) exceeds 512 characters, the Compiler issues an error.
User program text is also limited according to the specific SimplIQ drive. The list of setup
parameters that limit a user program are:
Maximum length of user program text
Maximum number of routines, including functions, labels and auto-routines
Maximum number of variables, both global and local
Maximum length of data segment — space for storing global variables
Maximum length of code segment — space for compiled code
Maximum depth of stack — working space for the program.
5.4.1 Numbers
The number syntax in the user program language is similar to that of the Interpreter
language (section 4.2.1), although ranges and range-exceeding behavior differ. A user
program can be compiled on the PC in off-line mode (without communication), so that it has
more resources than the Interpreter does.
The range for floating-point numbers is [-1e38…+1e38], which is greater than that of the
Interpreter language. If an integer number exceeds the integer range, it is interpreted as a
floating-point number, while the Interpreter interprets it as an error. If a floating-point
number exceeds the floating-point range, it is interpreted as an error.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-5
MAN-SIMSW (Ver. 1.2)
Example:
XOR(170,75) is interpreted as follows:
The binary representation of 170 (a int_value) is 0000 0000 1010 1010. The binary
representation of 75 (b int_value) is 0000 0000 0100 1011. Performing the bitwise exclusive
OR operation on these two values gives the binary result 000 000 1110 0001, which is
decimal 225:
XOR(a,b)
0000 0000 1010
1010
0000 0000 0100
1011
0000 0000 1110 0001
The exclusive OR between the binary bit representation of two integers returns 0 if both
integers are identical; otherwise, it returns 1.
Syntax:
z = XOR(x,y)
where z is the result of an exclusive OR operation between x and y.
Notes:
This operation is valid only in the user program; it is not valid through the
Interpreter.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-6
MAN-SIMSW (Ver. 1.2)
The emit(n) function returns 1 if successful and 0 if it does not succeed in emitting a TPDO.
It returns immediately after the TPDO is placed in the CAN transmitter queue. The actual
emission of the TPDO may be delayed.
Syntax:
EMCY(x)
where x is an error code (integer 4 bytes in length) defined by the user.
When the EMCY( ) function is called, the emergency message is transmitted only if bit
6 of object 0x2F20 (request by user program EMCY function) is set to 1. Refer to the
object 0x2F20 section in the Elmo CANopen Implementation Manual.
When the program reaches a location at which an emergency is specified, the CAN
emergency object (EMCY) is sent. The emergency object data is according to CiA DS301,
with its 8 bytes of data as follows:
6
7
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-7
MAN-SIMSW (Ver. 1.2)
Example:
The following code sends an EMCY from a routine in two cases: timeout (error code 1) or
out-of-range (error code 2):
…
if (isTimeOut) // Check if timeout occurred
EMCY(1); // Issue EMCY with error code 1
end
…
if (isOutOfRange) // Check if out of range
EMCY(2); // Issue EMCY with error code 2
end
If a timeout occurs, the SimplIQ drive sends an EMCY with the following data:
If an out-of-range occurs, the SimplIQ drive sends an EMCY with the following data:
Note that the user error code and the emergency error code are formatted in the messages
starting with the least significant bit.
5.4.8 Expressions
An expression is a combination of operands (parameters) and operators that is evaluated as
a single value. Expressions are used with immediate numbers, drive commands, and drive
and global user-program variables. This section describes the different types of expressions.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-8
MAN-SIMSW (Ver. 1.2)
A variable must first be declared before it is used (in the expression or assignment).
The variable definition line consists of type name (int or float) and variable names. Variables
on the definition line must be separated by commas; alternatively, each variable may be
declared on a separate line. Variables may be scalar (for example, int var1, float temp)
or one-dimensional arrays (for example, int arr[10], float ftemp[4]). If a variable is
a vector, it must be declared with its dimension in brackets after its name. The vector
dimension must be a positive constant number. If the dimension is defined as a floating-
point number, it will be truncated to an integer. A dimension of less than 1 is illegal.
Examples:
int arr[12.5]; The floating-point number defining dimension will be truncated to 12.
int arr[-2]; This variable definition is illegal because the dimension is negative.
Only global variables may be one-dimensional arrays. Neither a local variable nor an
input/output argument of a function may be a vector.
Local variables must be defined at the beginning of function bodies. Any local or global
variable definition after executable code of the function is illegal.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-9
MAN-SIMSW (Ver. 1.2)
Example:
function func (int a) Function definition
int b ; Local variable definition
b = a ; Executable code
float c : Local variable definition
return
The definition of the variable c is illegal because it comes after executable code.
The names of variables may include ASCII letters, digits (not leading) and underscores
(not leading) only. Variable names are case sensitive. The maximum variable name
length is 12 characters. A variable name cannot be a keyword.
After a program is compiled, all program variables may be used within the command line.
For example, assume that a compiled program includes the following lines:
int ZEBRA,GIRAFFE[3];
float GNU;
More information about global and local variables is given in section 5.8.5.
Each command has a 16-bit flag, each bit defining any feature. For example, the fourth bit
(PostProcess flag) defines whether the command can be used to set a value or not.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-10
MAN-SIMSW (Ver. 1.2)
Examples:
a = AC This expression assigns a value of the system command AC to the variable a. It
is valid if the AC command is allowed to “get a value”; that is, it has a
PreProcess flag.
AC = a This expression assigns a value of the variable a to the system command AC. It
is valid if the AC command is allowed to “set a value”; that is, it has a
PostProcess flag.
BG This is an executable command. It cannot be assigned; that is, it has no
PreProcess, PostProcess or Assign flag. For example, the expressions BG = 1 and
a = BG are illegal.
LS This expression is illegal because it uses a command that has a NotProgram flag.
Such commands are not allowed in a user program, although they are available
for use in the Interpreter language.
If only one value is returned, brackets are not required and the syntax is as follows:
OUT=FUNC(IN_1,…,IN_N)
Not all output variables must be assigned. For example, if the function FUNC returns two
values, then
[IA[1],IA[2]]=FUNC()
assigns the two returned values to IA[1] and IA[2].
IA[1]=FUNC() returns the first return value to IA[1] and the other returned values remain
unused. If the returned value type differs from the returned variable type, the result is a
type cast to the type of the variable.
The number of input arguments during a function call is strictly according to its definition.
If a function call is part of an expression, then multiple output of the function is illegal. For
example:
[a, b] = 5 + func(c)
and
[a, b] = func(c) + 5
are both illegal because a function call is part of an expression and must be evaluated in a
single value (refer to section 5.4.8.7).
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-11
MAN-SIMSW (Ver. 1.2)
5.5 Comments
Comments are texts that are written into the code to enhance its readability. They can be
written in three ways, as indicated in the following sections.
Example:
**my first program
PX=1
**UM=5
MO=1; **motor on
In this program, the first line is a comment used to enhance program readability. The
comment terminates at the next end of line, so that the PX=1 instruction will be compiled
and executed. In the third line, the comment marker tells the drive to ignore the UM=5
command. This technique is useful for temporarily masking program lines in the process of
debugging. The last line demonstrates that a comment may start anywhere in the program
line. The MO=1 instruction preceding the comment market will be compiled and executed.
Example:
//my first program
PX=1
//UM=5
MO=1; //motor on
In this example, the double slash acts exactly like the double asterisk from the previous
example.
Example:
/*
This is a multiple line comment.
All this text is ignored.
*/
if ( 1 / x == 1 */)
y=1;
end
The expression y = 1 will always be executed. The x==1 condition enclosed by the comment
markers is ignored.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-12
MAN-SIMSW (Ver. 1.2)
The AUTO_PERR routine enables the user to program failure reactions, which may include,
for example, manipulating certain outputs, stopping the motor, or emitting a CAN
emergency. The AUTO_PERR can determine locate the last error by using the PrgErr(N)
function (described in section 5.4.8.6).
If, after taking emergency steps, the AUTO_PERR is to resume the user program, the
following cautions should be taken:
A return command will resume execution at the next user program instruction. In most
cases, after the unexpected failure of a previous instructions, this should be avoided.
Because the depth of the program stack is unknown at the time of failure, jumping to an
absolute address should be carried out only after the reset command has reset the call
stack.
The AUTO_PERR routine automatically blocks all other auto-routines; therefore, the MI
command should be used to restore reaction to them.
The exit keyword can be used to exit the user program.
A maximum of 12 characters — letters and/or digits (not leading) and underscore (not
leading) only — may be used for a label. The label name must be unique.
Labels can reside inside or outside function bodies, but not within a program flow structure,
such as a for iteration. Labels inside function bodies are regarded as local to the function
and serve as targets for goto instructions with the same function. Labels in the global text
scope serve as possible execution starting points, and also as targets for reset and global
scope goto.
A subroutine is a global label in which the body ends with a return keyword. A subroutine
is similar to a function without input and output arguments. It can be called from any place
in the program and may serve as a target for a reset instruction.
The XQ and the XC program launch commands use labels to specify where to start program
execution and where to terminate. For example, the command XQ ##LOOP2 is used to
begin execution at ##LOOP2.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-14
MAN-SIMSW (Ver. 1.2)
Example 1:
##START; Start program.
##LOOP1; Label
… Body code A
Goto##LOOP1;
##LOOP2;
… Body code B
##LOOP3;
…
According to this example, if the program runs from label ##START, body code A will be
performed forever. ##LOOP2 will never be reached.
Example 2:
…
#@WAIT_POWER: Subroutine definition
wait 3000 subroutine body - wait 3 sec
return End subroutine
…
WAIT_POWER Call subroutine
…
reset WAIT_POWER; Kill stack and call subroutine
In this example, the subroutine WAIT_POWER is called explicitly the first time and is used as
the target for a reset instruction the second time.
Syntax:
for k=N1:N2:N3
…
end Iterates k from N1 to N3 with a step of N2.
or
k=N1:N2
…
end Iterates k from N1 to N2 with a step of 1.
Notes:
If the iteration step is zero, the program is aborted with the error code
INFINITE_LOOP.
If N1, N2 or N3 is a variable, it is evaluated once before the iteration begins. If the
variable changes within the “for” loop, the iteration process is not affected.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-15
MAN-SIMSW (Ver. 1.2)
The iteration variable k must be declared as a variable. The iteration variable must
be scalar, not an array member. For example, the expression:
for k[10]=1:10
is illegal because k is an array.
Example:
… Start user program or function.
float ra[20]; Float array declaration.
int ia[20]; Integer array declaration.
int k; Variable declaration.
…
for k=1:10 Start iteration loop.
ia[k]=100; Update first 10 elements of integer array.
ra[k]=55.55; Update first 10 elements of real array.
…
end End of iteration loop.
…
The while keyword executes a statement repeatedly until expression becomes 0. The
expression can be logical and/or numerical. It may be within parentheses or without
parentheses.
Example:
OB[1]=0 Digital output 1 is OFF.
while(IB[1])
OB[1]=1 While digital input 1 is ON, digital output 1 is ON.
end
OB[1]=0; Digital output 1 is OFF.
…
…
While (IB[2])
end
MO=1; This command will be performed only after digital output 2 is OFF.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-16
MAN-SIMSW (Ver. 1.2)
The until keyword suspends execution of the program until expression becomes true
(nonzero). The expression can be logical and/or numerical.
Example:
…
until ((PX==20,000)&IB[1]); Suspend the program until the variable PX exceeds
20,000 and digital input 1 is ON.
…
The until expression can be useful for synchronizing threads for drives that support multi-
thread programs. For example, if there are two threads and the second thread must start
after the first thread finishes a certain procedure, a global variable should be defined to
indicate whether the first thread has finished or not. The second thread is suspended by the
until expression, as follows:
To suspend the thread without terminating it, until can be used with a false expression.
The wait keyword suspends execution of the program until the specified time elapses. The
expression can be within parentheses or without them. The expression specifies the waiting
time in milliseconds. It can be a numerical expression only, and is evaluated in a single
value.
Example:
PA=10,000
BG
until (MS == 0)
wait (20) ; Wait 20 milliseconds
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-17
MAN-SIMSW (Ver. 1.2)
This sequence initiates a motion using the until (MS == 0) to wait until the motor is
stabilized at a new position. The wait (20) allows an additional 20 milliseconds for final
stabilization.
Notes:
The wait argument range is [0…32,000] milliseconds. This limitation stems from the
implementation of the tick and tock system functions, used in the wait statement
algorithm. If an expression exceeds the valid range, the SimplIQ drive returns an
OUT_OF_RANGE error code.
The wait expression is evaluated only once, at the beginning of iterations, and is
not recalculated.
5.7.6 If Condition
Syntax:
if ( expression1)
…
statement1
…
elseif ( expression2 )
…
statement2
…
else
…
statement3
…
end
Example:
if (IB[4])
PR=1000; PR=1000 only if digital input 4 is ON.
elseif(IB[3])
PR=5000; PR=5000 only if digital input 3 is ON.
elseif(IB[2])
PR=3000; PR=3000 only if digital input 2 is ON.
else
PR=500; PR=500 only if digital inputs 2, 3 and 4 are OFF.
end
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-18
MAN-SIMSW (Ver. 1.2)
The switch statement causes an unconditional jump to one of the statements that is the
“switch body,” or to the last statement, depending on the value of the controlling
expression, the values of the case labels and the presence or absence of an otherwise label.
The switch body is normally a compound statement (although this is not a syntactic
requirement). Usually, some of the statements in the switch body are labeled with case
labels or with the otherwise label. Labeled statements are not syntactic requirements either,
but the switch statement is meaningless without them. The otherwise label can appear only
once, and must appear after at least one case label. In contrast to the case label, the
otherwise label cannot be followed by an expression for evaluation.
The switch and case expressions may be any logical and/or numerical expression. The case
expression in the case label is compared for equality with the switch expression. If the
switch expression and the case expression are equal, then this case is selected and the
statements between the matching case expression and the next case or otherwise label are
executed. After execution of the statements, a break keyword may appear. It is not
necessary a case statement to finish with a break, because after executing the statements, an
unconditional jump to the end of the switch is performed automatically, and the next case
statement is not executed.
If a number of case expressions match the switch expression, then the first matching case is
selected.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-19
MAN-SIMSW (Ver. 1.2)
Example:
The following example selects the size of a point-to-point motion according to the value of
variable k.
ink k Variable declaration
…
switch (k) For example, k=2
case 1
PA=1000;
case2
PA=2000; This statement will be performed.
otherwise
PA=500; If k does not equal 1 or 2, PA=500.
end
5.7.8 Continue
The continue keyword transfers control to the next iteration of the smallest enclosing for or
while loop in which it appears. It thereby enables a jump from the current position to the
beginning of the for and while loop, without executing statements through the end of the
loop.
Example 1:
...
for k=1.5
if arr[k] == 0
continue
end
...
end
In this example, the continue keyword is within an if block. If the condition arr[k] == 0
is true, it jumps to the beginning of the for loop.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-20
MAN-SIMSW (Ver. 1.2)
Example 2:
while 1
...
try
...
for k=0:5
if IB[16+k] == 1
break
end
if MS ! = 0
continue
end
MO=1;PA=0;BG
end
catch
...
end
end
If the condition MS ! = 0 is true, the program jumps to the beginning of the for loop and the
statements MO=1;PA=0;BG are not executed.
5.7.9 Break
Syntax:
break
The break statement terminates the execution of the nearest enclosing for, switch or while
statement in which it appears. Control passes to the statement that follows the terminated
statement. A break statement outside for, switch or while statements is illegal.
Example:
…
while (IB[2]) Loop until digital input 2 is ON.
if (!IB[1]
break; Break the loop when digital input 1 is OFF.
end
MO=1; This command will be performed only after digital input 1 or
2 is OFF.
5.7.10 Return
The return command terminates the current function and returns control to the invoking
function. A called function normally transfers control to the function that invoked it when it
reaches the end of the function. A return may be inserted within the called function to force
an early termination and to transfer control to the invoking function. If the function was
called by an execute (XQ) command, a return command will close that program thread.
Closure of the main thread will close all other active threads.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-21
MAN-SIMSW (Ver. 1.2)
Global variables can still be used and monitored by the user with external terminals,
such as the Composer Smart Terminal.
5.7.11 Try-Catch
A try-catch block is used to react to an expected fault.
Syntax:
try
statement, …, statement,
catch
statement, …, statement
end
The SimplIQ drive stores the status (stack and base pointers) and executes the statements
between the try and the catch. If successful, nothing else happens. If an error occurs, the
status is restored and the SimplIQ drive executes the catch block. A failure in the catch block
is treated as an unexpected failure.
The SimplIQ drive cannot undo statements that were already executed in the try block before
a failure.
5.8 Functions
Functions are program sections that can be defined by parameters and called from
anywhere in the program.
Example 1:
function [int y1, int y2] = func1 (float x1, int x2)
A function named func1 has two input arguments — x1 and x2 — and returns two output
arguments.
The list of output arguments may be empty. In this case, two and three items are absent, or
the brackets can be empty. If there is only an output argument, it can be without brackets.
The maximum admissible number of input and output arguments is 16.
Example 2:
function func2 (float x1)
A function named func2 has a single input argument of float type and returns no output.
Example 3:
[int y1] = func3 (int x1)
This function declaration is illegal because the function keyword is missing.
Example 4:
function y1 = func5
This function prototype is illegal because the type of output variable is missing
The valid function name follows the same rules as the variable name. It must be distinct
from any variable, function or label name. The definition of dimensions of the output and
input arguments at the function declaration is illegal.
Example 5:
function [int x[100]] = func3 ()
This function declaration is illegal because the dimension of the output argument is defined
A function may have a prototype before its declaration. The prototype has the same syntax
as the function declaration, but it must end with a semicolon.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-23
MAN-SIMSW (Ver. 1.2)
Example 6:
function [float y1] = func4 () ;
A prototype of function func4 that has no input argument and returns only the output
argument.
Example 7:
function float y1 = func4 ;
Same as example 6.
Example 8:
function float = func4 ;
Same as examples 6 and 7. The name of input or output argument of the function prototype
may be omitted, but during function definition, it will be an error.
Example 9:
function [int, int] = func1 (float, int);
Prototype of function from example 1. Same as function [int y1, int y2] = func1
(float x1, int x2) ;
The prototype of the same function can be written several times (multiple prototype), but all
prototypes must be identical. The names of the input/output arguments in the function
prototype may be omitted, or may be different from the names of the corresponding
argument names in the function declaration.
Example 10:
function [int y1, int y2] = func (float x1, int x2) ;
function [float y1, int y2] = func (float x1, int x2)
The first expression is the function prototype and the second is the function definition. This
is illegal because the type of first output argument in the prototype does not match that of
the declaration.
Example 11:
function [int y1, int y2] = func (float x1, int x2) ;
function [int a, int b] = func (float x1, int x2) ;
function [int y1, int y2 ] = func (float x1, int x2)
The first two expressions are the function prototype and the third is the function definition,
which is legal.
The body of a function resides below the declaration and must end with the return
keyword. If the return is inside a control block within the function body, it is not the end of
the function body.
Example 12:
function [int y1, int y2] = func (float x1, int x2) Function definition.
y1 = x1; Function body
y2 = x2;
if x2 > 0 If block
Return return inside block is not
end of the function
end End of if block
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-24
MAN-SIMSW (Ver. 1.2)
y2 = y1 + y2 ; Executable code
Return Function end
Before a function call, the function must be declared, either as a function prototype or a
function definition.
Example 13:
function [int y1, int y2] = func (float x1, int x2;) Function prototype
…
function main () Function main definition
int a, b; Local variable definition
[a,b] = func (2.3, -9.0); Function call
Return Function main end
…
function [int y1, int y2] = func (float x1, int x2) Function definition
… Function body
Return Function end
Example 14:
function [int y1, int y2] = func (float x1, int x2) ; Function prototype
…
function main () Function main definition
int a, b; Local variable definition
[a,b] = func (2.3, -9.0); Function call
Return Function main end
…
In this example, function func has a prototype, but no body, so its call is illegal.
Example:
function [float mean, float std]=statistic();
In this function, variables mean and std are dummy variables (full example in section 5.8.3).
The number of outputs is the number of items in the left side of the expression during the
function call. If this number exceeds the maximum number of defined output arguments for
the function, or the maximum admissible number of output arguments, an error will be
declared.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-25
MAN-SIMSW (Ver. 1.2)
If a function does not return any output by definition, a zero output value will be inserted to
the stack. For example, if the function func is declared with no output arguments, the
expression func( ) + 3 is legal because func returns zero by default.
Example:
float vec[11], RA[100]; Declare the global variables.
float value; Declare the global variable.
function [float mean, float std]=statistic(); Function prototype.
…
[RS[1],RA[2]]=statistic() Call the statistic function. After
execution, RA[1] will be equal to
variable mean and RA[2] will be
equal to variable std.
[value]=statistic() In this case, after executing the
statistic function, value will be equal
to variable mean.
…
function [float mean, float std]=statistic(); Declare a function that calculates
mean and standard deviation of the
global vector vec.
int k; Declare k as automatic variable.
global vec[11]; Redeclare for vec variable (vec is
global variable previously
declared).
mean=0;
for k = 1:10
mean = mean + vec[k];
End
mean = mean/10; Calculate mean of vec[ ]
if (nargout>1) Only if standard deviation is
queried . . .
std = 0;
for k = 1:10
std = std + vec[k] * vec [k];
End
st = (1/10) * ssrt. (std – 10 * mean)
End
Return End of function body
…
For count of input arguments, the number of input arguments during a function call must be
the same as declared during the function definition.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-26
MAN-SIMSW (Ver. 1.2)
Example:
In the example of the statistic function in section 5.8.3, variable k is the automatic variable.
The dimension of a persistent variable is defined once in a program, during its definition,
and is the same for the global variable in all functions in which it is used. The legal way to
declare the dimension of a persistent variable within a function is to use empty brackets
after its name, or no brackets at all.
Examples:
In the example of the statistic function in section 5.8.3, variable vec[11] is the global variable.
It is defined above the function definition and is redeclared as global within the function
body.
float temp; Declare the global vector variable.
int vec[10]; Declare the global vector variable.
…
function [float a]=func(int b) Declare a function func.
float temp; Declare temp as an automatic variable,
because the global keyword is absent.
… Function body.
return End of function.
…
function [float a]=func1(float temp) Declare function func1. In this case, temp is
not a global variable, but rather an input
argument.
…
return End of function.
…
function [float a]=func2(float b) Declare function func2.
global float temp; Redeclare global variable temp. In this
function, temp is the global variable.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-27
MAN-SIMSW (Ver. 1.2)
global int vec[] Redeclare global variable vec. Notice that its
dimension is omitted during redeclaration
and that its actual dimension is 10, as defined
above.
5.8.6 Jumps
Syntax:
goto ##LABEL1
The goto command instructs the program to continue its execution at the label specified by
the jump command. It may be specified only for destinations within the present function
scope and is illegal if used in a for loop or switch-case block. Jumps to labels within other
functions are not possible. Jumps to a global label from within a function are illegal.
Example:
… Working code.
if (PX>1000) Condition for jump.
goto##LABEL1; Go to LABEL1 if condition is true.
else Return axis to origin.
goto##LABEL2; Go to LABEL2 if condition is false.
end
… Working code.
##LABEL1; Declare LABEL1.
… Working code.
##LABEL2; Declare LABEL2.
… Working code.
Example:
function JustSo; Function prototype.
…
JV=1000
JustSo() Function call.
BG
…
function JustSo Function definition
IA[1]=1; Function body.
return Function end.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-28
MAN-SIMSW (Ver. 1.2)
After executing JV=1000, the program jumps to the subroutine JustSo. Before doing so, it
stores its return address, which is the place in the code at which execution should resume
after the routine is complete. In this example, the return address is the line number of
instruction BG, which is just after the subroutine call.
The return command instructs the program to resume from the stored return address. After
execution is resumed at that address, it is no longer required and is no longer stored.
Functions may call each other; in fact they may even call themselves. Return addresses for
nested function calls are stored in a call stack, as shown in the following example:
function factorial(); Function prototype.
…
IA[1]=3
IA[2]=1
factorial() Function call.
BG
…
function factorial() Function for factorial.
global int IA[]; Define array as global inside function.
IA[2]=IA[2]*IA[1] Recursive algorithm.
IA[1]=IA[1]-1
if (IA[1]>1) factorial() ; end Recursive call.
return Function end
The factorial function in this example calculates the factorial of 3 in IA[2]. The variable IA[1]
counts how many times the function factorial is executed.
Syntax:
reset<JUMP_NAME>
The valid jump after the reset keyword is one of the following:
Label
Auto-routine
User function with no defined input arguments
All other expressions or absence of expressions after the reset keyword are illegal.
A label in a reset expression must be global. A local label is illegal, because the stack
will be emptied and all local variables and the return address of the function to which
the local label belongs will be erased.
Example:
Assume that a drive (an axis) runs a programmed routine. An inspection station may assert
a “Product defective” digital signal that is coupled with digital input #1. An automatic
routine is therefore coupled to digital input #1 in order to stop the part assembly and
prepare for the assembly of the next part.
##START_NEW Label for starting a new part.
… Working code.
… Last line of working code.
#@AUTO_I1 Subroutine label.
PA=0;BG Return axis to origin.
reset START_NEW Clear stack and go to beginning.
The reset in the #@AUTO_I1 routine is required because it is not known if any function calls
are executing when digital input #1 is asserted. If a function is executing, the reset prevents
junk from accumulating in the call stack. Otherwise, the call stack is empty and reset does
no harm. Note that after the reset, control does not return to the function that was executing
prior to the #@AUTO_I1 routine. The stack is cleared and the return address to the
interrupted function is removed from the stack.
The #@ATUO_I1 routine is executed after the work code is completed for every
assembled part. The program proceeds form the last line of the working code to
PA=0;BG, which resets the machine for another part assembly. The next instruction is
a reset to the START_NEW label.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-30
MAN-SIMSW (Ver. 1.2)
Syntax:
An auto-routine can defined either as a function or as a subroutine:
If defined as a function, all syntax rules for function definition are relevant (see section
5.7.1).
If defined as a subroutine, the auto-routine name follows the sequence of characters ## or
#@ in the definition line. The body of the auto-routine follows the definition line and
ends with the return keyword unless this return is inside a flow control block (see
section 5.7.1).
After calling the auto-routine and performing its body, the return keyword
instructs the program to return to the line in the code after which execution was
halted by a interrupt event.
There are no default handlers for auto-routines. If a user does not define the auto-routine, no
handling will be activated when an automatic event is asserted.
The following table summarizes all automatic routines, ordered from highest to lowest
priority.
All automatic routines except AUTOEXEC are activated only if a program is running.
Example:
##LOOP An endless loop.
goto##LOOP
#@AUTO_I3 Subroutine definition.
… Subroutine body.
return End of subroutine.
In this program, the endless loop in the first two lines of the routine is intended to make the
program run forever, so that the automatic routine will be able to handle the digital input #3
event.
The #@AUTO_I3 routine will be called if digital input #3 is sensed and not masked. Digital
input #4 will not invoke any automatic action in the user program, because no #@AUTO_I4
routine is defined to handle a digital input #4 event. The user has the option to make an
explicit call of an automatic routine, if desired. The syntax for an auto-routine call is the
same as that of a user function.
SimplIQ Software Manual 4BThe SimplIQ User Programming Language 5-32
MAN-SIMSW (Ver. 1.2)
Example:
A drive receives a PLC command. It has an autoexec routine that activates its program upon
boot. The PLC sends instructions to the drive using RS-232 communication for task
parameters and a digital input to start an action immediately. The drive sets the output
according to the state of the program. For safety sake, the drive is not allowed to perform
any task before digital input 2 is set.
function autoexec () Declare the autoexec function.
MI=128; Inhibit the routine #@AUTO_I1.
OP=1; Set output to indicate start.
…
while (!IB[2]) Wait for digital input 2 to be set.
End
goto #@TEST_PARS; Jump to subroutine.
##LOOP Label LOOP.
… Label LOOP body.
goto **LOOP; Endless loop.
#@TEST_PARS Subroutine.
OP=2; Set output 2.
wait 2000; Wait 2 seconds for testing the part.
MI=0; Enable automatic handling of digital input #1.
goto ##LOOP;
return End of automatic function.
The mask may also be used to prevent switch bouncing from generating spurious routine
calls.
Example:
A machine performs a periodic task. Digital input #1 is connected to a sensor to which the
drive should react. The following code limits the automatic response to digital input #1
during execution of the #@AUTO_I1 routine code, even though digital input #1 may
bounce.
##LOOP; Repetitive task.
…
MI=0; Re-enable automatic routine.
…
goto##LOOP;
The Elmo Studio IDE includes all the tools needed to perform this procedure. Using the
Elmo Studio is fully explained in Chapter 4 of the Composer for SimplIQ Software Manual.
6.2 Compilation
Each user program must be compiled after editing. Although the Compiler does not reside
in the DSP software, it is described here because it is an integral part of the program
development process. The Compiler in the Elmo Studio is external, stand-alone software
that can be accessed through the Composer software. The user can write and compile a
program in off-line mode (without establishing communication with the drive) and then use
the Compiler to compile the program in order to produce address maps and run-time code.
If, in the course of compilation, the Compiler finds syntax errors, it stops the compilation
process and informs the user about the errors, presenting them in convenient form.
The Compiler accepts the user program as a text file and files with target SimplIQ drive
information. This information is required in order to ensure that the compiled code can run
on the SimplIQ drive.
Error
Code Error String Meaning Example
8 Operator is During right-hand expression b = a c ;
expected evaluation, there is no After successful evaluation of a,
operator or terminator of a an operator or expression
simple expression after terminator is expected, but c is
successful value evaluation. not recognized as either an
operator or terminator.
9 Out of memory During memory allocation for
in the data a global variable, there is not
segment enough space in the data
segment.
10 Bad colon Error during evaluation of a for k = 10:-1:5:9
expression colon expression. The colon Colon expression contains more
expression may appear only than three values.
in a for statement. Bad syntax
for k = a
— more than three values or
Expected colon expression is
less than two values — in the
missing in the for statement,
colon expression may also
after the =.
cause this error.
11 Name is too Variable or function name int iuyuafdsf_876234 ;
long exceeds 12 characters.
12 No such Left-hand value is not de = sin(0.5)
variable recognized as either a variable de is neither a variable nor a
or as a system command. function.
13 Too many Dimension of array exceeds int arr[12][2];
dimensions the maximum admissible An attempt is made to define a
number of dimensions (syntax two-dimensional array.
allows only one dimensional
array).
14 Bad number of The number of input function func(float a);
input arguments during a function …
arguments call does not match the func(a,2);
number of input arguments at The number of input arguments
the function definition. during the function call is two,
while the function func is
defined with only the input
argument.
15 Bad number of Bad syntax in left-hand a, b = func(1,2);
output expression: multiple output Multiple outputs must be within
arguments without brackets, or multiple brackets.
output that exceeds maximum
admissible number of outputs
(maximum of 16 outputs is
allowed).
SimplIQ Software Manual Program Development and Execution 6-4
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
16 Out of memory Compilation process ran out
of memory. This error may
occur if the user program is
too large or too complex and
there is not enough space in
the code segment or in the
Symbol table.
17 Too many The number of input or function func (int a1, int
arguments output arguments exceeds the a2, int a3, int a4, int
maximum admissible number a5, int a6, int a7, int
of input or output arguments a8, int a9, int a10, int
(16). a11, int a12, int a13, int
a14, int a15, int a16, int
a17, int a18, int a19,
The number of input arguments
exceeds 16.
18 Bad context The Compiler has found an
error in the program context,
such as mismatched brackets/
parentheses or an improperly
closed flow control statement.
19 Write file An error occurred while
error writing to a file.
20 Read file An error occurred while
error reading from a file.
21 Internal A corrupted database has
compiler caused an internal compiler
error: bad error. In this case, email
database technical support at
asusid@elmo.co.il. Attach the
Composer date and version
(in the Help menu) and the
program that you attempted
to compile.
22 Function An illegal function definition. if a<0
definition is a = 0;
inside another function func (int a);
function or end
flow control Attempt to define a function
block inside if block.
23 Too many The user program contains
functions too many functions and there
is not enough space for them
in the database.
SimplIQ Software Manual Program Development and Execution 6-5
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
24 Name is A variable or function has the int switch;
keyword same name as a keyword.
switch is a keyword, so its use as
This error may occur if a
a variable name is illegal.
variable name is identical to
an auto-routine name.
25 Name is not A variable of function name is int func ;
distinct not unique. function func (int a)
The function and the variable
have the same name.
function func (int a)
int a ;
The definition of local variable a
is illegal because this function
already contains a local variable
a as an input argument.
26 Variable name This error occurs when: int_abc ;
is invalid A variable or function The variable name has a leading
underscore.
name starts with a digit or
underscore, not with a function (int a)
letter The function name is missing
after the function keyword.
A variable or function
name is empty. int a, b,
The variable name is missing
On the variable definition
after the comma.
line, a comma is used as a
separator between
variables, but the variable
name after a comma is
missing.
27 Bad separator The only legal separator int a b;
between between variables on the A command as a variable
variables variable definition line is a separator is missing between a
comma. After a variable and b.
name, either a variable
separator (comma) or an
expression terminator is
expected. Any other symbol
causes this error.
28 Illegal global A global variable must be int a1 ;
variable declared inside a function function func (int a)
definition with the global keyword and global float a1;
it must be defined before the The variable type a1 at its
function. This error appears definition is int, while inside
only if the global keyword is the function, it is declared as
used in the wrong context: float.
SimplIQ Software Manual Program Development and Execution 6-6
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
Error
Code Error String Meaning Example
33 Bad function Appears at function definition function func (int a);
format when: function func (float a)
Function name is not Type of input argument in
function definition does not
unique or is empty
match type in prototype.
function definition does
not match its prototype
34 Illegal minus A minus is illegal before a [ab] = -func(c);
function call with multiple Illegal minus before function call
output arguments, and before with multiple outputs.
parentheses that include
-(2+3), c/5);
multiple expressions.
Illegal minus before multiple
expressions within parentheses.
35 Empty program User program is empty.
36 Program is too User program exceeds
long maximum admissible length.
37 Bad function An attempt has been made to [a,b,c] - func(x,y) +5;
call jump at the goto statement to Illegal sentence. The Compiler
a function with a non-zero checks if there is an expression
number of input or output terminator immediately after the
arguments. function call with multiple
outputs. If there isn’t, it issues
this error.
38 Expression is The expected expression — if
expected wait, until, while, if, elseif, a = 0
switch or case — is missing. end
An expression expected after if
is missing.
39 Code is too The user program contains An if block inside a while loop
complex very complex code that
includes too many nested
levels (this expression
actually contains more than
100 nested levels). A nested
expressions means that there
is one flow control block
inside another.
40 Line A general error has occurred
compilation is during an attempt to compile
failed an expression.
SimplIQ Software Manual Program Development and Execution 6-8
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
41 Case must After a switch statement, the switch a
follow switch only legal statement is case; b = 0;
otherwise, this error occurs. case 1,
b = 1;
end
The expression b=0 is illegal
because switch must be followed
by case.
42 Illegal case The otherwise statement must switch a
after be the last statement of a case 1,
otherwise switch block. Any case after b = 1;
otherwise is illegal. otherwise
b = 0;
case 2,
b = 1;
end
The statement case 2 is illegal
because otherwise must be the
last statement of switch.
43 Bad nesting Flow control block
contradiction: else without if,
mismatched end, flow control
without end, etc.
44 Code is not There is some unexpected
expected. code for evaluation after
otherwise, end, else, etc.
45 Bad flow No “=” sign after the iteration for k
control variable name in a for a = 0;
expression statement. end
A = is missing after the k.
46 Too many The compilation error buffer
errors is full.
47 Expression is A function or label must int a1;
out of contain executable code; a1 = 0;
function otherwise this error occurs. function func (int a)
Executable code is illegal
because it is out of the function.
48 Otherwise An otherwise appears switch a
without any immediately after a switch otherwise
case statement. b = 0 ;
end
After a switch statement, case is
expected, not otherwise.
SimplIQ Software Manual Program Development and Execution 6-9
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
49 Misplaced Break is legal only inside a If a < 0
break switch, for or while block; break ;
otherwise, this error occurs. end
break in an if statement is
illegal.
50 Too many The number of actual output function [int b] = func
outputs arguments during a function (int a)
call exceeds the number of …
output arguments during return ;
function definition. …
[c,d] = func(a) ;
The function call is illegal
because the number of outputs is
two, while this function is
defined with a single output
argument.
51 Line is too User program contains a line
long of more than 128 characters.
52 Clause is too User program contains an
long expression for evaluation that
contains more than 512
characters. This expression
may take several lines of user
program text.
53 Cannot find End of sentence not found
end of within range.
sentence
54 Open file There has been an attempt to
failure open a non-existing file; the
file name or path may be
incorrect.
55 Bad file name The full file path is too long.
56 No such An auto-routine, user function
function or label name must follow a
goto and reset statement;
otherwise, this error occurs.
57 Variable is An attempt has been made to int arr[10];
array assign the entire variable ##START
array, not its single member. arr[1] = 0;
arr = 0
The last expression is illegal
because it tries to assign the
entire array.
SimplIQ Software Manual Program Development and Execution 6-10
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
58 Variable is An attempt has been made to int a1; (scalar)
not array assign a scalar variable ##START
according to an index, as an a1[1] = 0;
array. The last expression is illegal
because it tries to assign a scalar
variable according to an index.
59 Mismatch The number of left values [a,b] = 12 + c;
between left- does not match the number of The number of values on the left
and right-hand values in the right side of the is two, while the number of
side expression. values after evaluation of the
expressions right-hand expression is 1.
60 Illegal local Syntax does not allow function func (int a)
array definition of a local array. The int arr[10];
array must be global. …
return;
Local array is illegal.
61 Function Function has more than one function func (int a)
already has body. wait 2000
body return ;
…
function func (int a)
until a
end
Text is illegal because function
func has multiple bodies.
62 Opcode is not The specified version of the
supported by SimplIQ drive does not
SimplIQ drives support a certain virtual
command.
63 Internal If this occurs, email technical
compiler error support at asusid@elmo.co.il.
Attach the Composer date
and version (in the Help
menu) and the program you
have attempted to compile.
64 Expression is The user program contains an The last line of user text may be:
not finished unfinished sentence: an a = b + 8 / 12 /
ellipsis (…) may be missing to (8^2*sqrt(2) - sin
indicate that the expression is (3.14/2))…
continued on the next line. After the ellipsis, the next line
should appear, but in this case it
is missing.
SimplIQ Software Manual Program Development and Execution 6-11
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
65 Compiled code The compiled code exceeds
is too long the maximum space for the
Code Segment in the SimplIQ
drive’s serial flash memory.
66 Corrupted the The file containing the
SimplIQ drive SimplIQ drive setup
setup files parameters is not in the
defined format.
Error
Code Error String Meaning Example
A global label from within
a global space at a goto
statement
A non-label at a goto label
A local label at a reset
statement
75 Illegal The nargout keyword is used ##START
nargout outside a function. if nargout > 2
The keyword nargout is used
outside a function.
76 Function An attempt has been made to
without body call a function that has been
defined but does not have a
body.
77 Bad goto The goto keyword must be goto START
statement followed by ## or #@ before Between goto and the label
the name of a label; otherwise, name, ## or #@ is missing.
this error occurs. This error
may also occur if there is a for k = 1:10
goto statement within the …
body of a for loop. goto##START
…
end
The goto statement in the for
loop is illegal.
78 Auto routine An auto-routine is defined as function start (int a)
is local a local label. …
#@AUTOEXEC
…
return
The AUTOEXEC auto-routine is
defined inside a function as a
local label.
79 Command has The program refers to a LS
‘not program’ command that has a “Not The program attempts to use the
flag program” flag; that is, it LS flag, which has a “Not
cannot be used inside a user program” flag defined for it.
program.
80 Image file too The Image file length exceeds
long the user code partition size.
SimplIQ Software Manual Program Development and Execution 6-13
MAN-SIMSW (Ver. 1.2)
Error
Code Error String Meaning Example
81 System During evaluation of the wait
function tdif flow control, the tdif system
is not function must be defined
supported by inside the SimplIQ drive;
the SimplIQ otherwise, this error occurs.
drive
Error
Code Error String Meaning Example
90 Condition is The condition is missing in an #if
missing #if or #elseif directive. A condition must follow the #if
directive.
91 Misplaced The continue keyword is used
continue outside a for or while loop, or
inside an unclosed try-catch
block.
92 Misplaced #else or #elseif has been used #ifNUM > 10
#else or out of an #if-#endif block, or #elseif NUM > 5
#elseif #else is used more than once #else
in the same #if-#endif block #elseif NUM > 3
or #else is not the last #endif
directive before #endif. The #else directive is not the last
directive before the #endif.
93 Identifier The identifier of an #undef #undef NUM
wasn’t directive was not defined This statement is illegal if it is
declared previously. not preceded by an #define
NUM directive.
94 Mismatched Type of evaluated constant
type expression is neither integer
nor float. If error is received,
contact asusid@elmo.co.il.
Attach the Composer date
and version (from the Help
menu) and the program you
have attempted to compile.
95 Too many User has defined more than
identifiers 100 #define directives in the
have been program.
defined
96 Misplaced #endif directive is not
#endif preceded by #if.
97 Unknown error Unknown error.
Checks the conditions of #if, #elseif, #else, #ifdef and #ifndef directives and –
depending on the results – removes or retains the corresponding processing statements
in the code.
6.4.1.1 #define
The #define directive may be used to assign a name to a literal string, in a manner similar to
that of the C language.
Syntax:
#define identifier token_string
The #define directive substitutes token_string for all subsequent occurrences of an identifier
in the source file. The identifier is replaced only when it forms a token. For instance, identifier
is not replaced if it appears in a comment, within a string or as part of a longer identifier.
A #define without a token_string is not replaced. The identifier remains defined and can be
tested using the #ifdef and #ifndef directives.
The legal identifier name may consist of a maximum of 32 characters. A valid name consists
only of letters, underscores and numbers (not leading). The name is case sensitive, although
uppercase identifiers are accepted.
The maximum admissible number of #define directives in the SimplIQ drive is 100.
When evaluating the token_string (refer to section 6.4.2), if the evaluation is successful, the
identifier is replaced with the obtained value; otherwise, every appearance of the identifier is
replaced with the token_string as a string.
The syntax that defines Compiler directives in the SimplIQ language differs from the C
language in a number of ways. The redefinition of #define with the same identifier is illegal
unless the second definition of #define appears after the first definition is removed with the
#undef directive.
The token_string may contain identifiers of other #define directives as part of the
expression. When such an expression is successfully evaluated, every occurrence of
this identifier is replaced with the evaluation result even if the identifiers that are part
of its token_string were removed with an #undef directive (described in Example 6
following).
SimplIQ Software Manual Program Development and Execution 6-16
MAN-SIMSW (Ver. 1.2)
Example 1:
#define DEBUG_FLAG
Defines the identifier DEBUG_FLAG.
Example 2:
#define ARR_LEN 10
Defines the identifier ARR_LEN as the integer constant 10. Each occurrence of ARR_LEN
will be replaced by 10.
Example 3:
#define ARR_LEN num+10
Defines the identifier ARR_LEN as the string num+10. The precompiler cannot evaluate
token_string because num is not a constant expression. Each occurrence of ARR_LEN will be
replaced by this string.
Example 4:
#define DEBUG_FLAG
...
#define DEBUG_FLAG
The first statement defines the identifier DEBUG_FLAG and the second statement is illegal
because it redefines the #define with an already-defined identifier.
Example 5:
#define DEBUG_FLAG
...
#undef DEBUG_FLAG
...
#define DEBUG_FLAG 1
The first statement defines the identifier DEBUG_FLAG and the second statement removes this
identifier. The third statement defines DEBUG_FLAG again, and is legal because the previous
definition of DEBUG_FLAG was removed by the #undef directive. This identifier has a
token_string and each occurrence of DEBUG_FLAG will be replaced by 1.
Example 6:
#define MAX_LEN 10
#define ARR_LEN MAX_LEN +10
...
#undef MAX_LEN
...
int arr[ARR_LEN];
This example contains two identifiers with token_strings that have been successfully
evaluated. The identifier ARR_LEN contains MAX_LEN as part of its constant expression. In the
last statement, the identifier ARR_LEN will be replaced with 20 despite the fact that the
identifier MAX_LEN was removed with the #undef directive.
6.4.1.2
SimplIQ Software Manual Program Development and Execution 6-17
MAN-SIMSW (Ver. 1.2)
#if
The #if directive checks the conditional expression, as it does in the C language. If the
specified constant expression following the #if has a non-zero value, it directs the Compiler
to continue processing statements up to the next #endif, #else or #elseif. Afterwards, it
skips to the statement following the #endif directive. If the conditional expression has a
zero value, #if directs the Compiler to skip to the next #endif, #else or #elseif directive.
Syntax:
#if constant-expression
Each #if directive in a source file must be matched with a closing #endif directive;
otherwise, an error message is generated.
The #if, #elseif, #else and #endif directives can be nested in the text portions of other #if
directives. Each nested #else, #elseif or #endif directive belongs to the closest preceding #if
directive.
The #if directive must contain a constant-expression, which is evaluated to a single value;
otherwise it causes an error.
Example:
#if MAX_LEN > 10
#define REDUCE_MAX_LEN 10
#endif
In this example, REDUCE_MAX_LEN will be defined as the integer constant 10 only if MAX_LEN
is greater than 10; otherwise, it will not be defined at all.
6.4.1.3 #else
The #else directive, as in C, marks an optional clause of a conditional-compilation block
defined by an #ifdef or #if directive.
Syntax:
#else
The #else directive must be the last directive before the #endif directive. Only a single #else
directive is allowed. The #else directive contains no conditions.
Example:
#if MAX_LEN > 10
#define REDUCE_MAX_LEN 10
#else
#define REDUCE_MAX_LEN 5
#endif
In this example, REDUCE_MAX_LEN will be defined as the integer constant 10 only if MAX_LEN
is greater than 10; otherwise, it will be defined as the integer constant 5.
SimplIQ Software Manual Program Development and Execution 6-18
MAN-SIMSW (Ver. 1.2)
6.4.1.4 #elseif
The #elseif directive marks an optional clause of a conditional-compilation block defined by
an #ifdef or #if directive.
Syntax:
#elseif constant-expression
As with the #if directive, the #elseif directive must contain a constant-expression, which is
evaluated to a single value; otherwise it causes an error.
Example:
#if MAX_LEN > 30
#define REDUCE_MAX_LEN 30
#elseif MAX_LEN > 20
#define REDUCE_MAX_LEN 20
#elseif MAX_LEN > 10
#define REDUCe_MAX_LEN 10
#else
#define REDUCE_MAX_LEN 5
#endif
The #if, #elseif and #else directives in this example are used to make one of four choices,
based on the value of MAX_LEN. The constant REDUCE_MAX_LEN is set to 30, 20, 10 or 5,
depending on the definition of MAX_LEN.
6.4.1.5 #endif
Each #endif directive must close an #if directive, in a manner similar to the C language.
Syntax:
endif
6.4.1.6 #ifdef
The #ifdef directive, as in C, checks for the presence of identifiers defined with #define.
Syntax:
#ifdef identifier
The #ifdef and #ifndef directives can be used anywhere that #if can be used. The #ifdef
identifier statement is equivalent to #if 1 when identifier has been defined, and is equivalent
to #if 0 when identifier has not been defined or has been undefined with the #undef
directive.
SimplIQ Software Manual Program Development and Execution 6-19
MAN-SIMSW (Ver. 1.2)
Example:
#define DEBUG_FLAG
...
#ifdef DEBUG_FLAG
printf((“Parameter is equal to %d”, debug_var);
#endif
In this example, the text between the #ifdef and #endif directives is compiled as
DEBUG_FLAG was defined previously.
6.4.1.7 #ifndef
The #ifndef directive, as in C, checks for the absence of identifiers defined with #define.
Syntax:
#ifndef identifier
The #ifndef directive checks for the opposite of the condition checked by #ifdef. If the
identifier has not been defined (or its definition has been removed with #undef), the
condition is true (nonzero). Otherwise, the condition is false (0).
Example:
#ifndef DEBUG_FLAG
#define DEBUG_FLAG
#endif
In this example, DEBUG_FLAG will be defined only if it has not been defined previously. It
prevents the possible redefinition of DEBUG_FLAG.
6.4.1.8 #undef
The #undef directive, as in C, removes the current definition of the specified name. All
subsequent occurrences of the name are processed without replacement.
Syntax:
#undef identifier
The #undef directive must be paired with a #define directive in order to create a region in a
source program in which an identifier has a special meaning.
Unlike the #undef directive in C, with the SimplIQ drive, you cannot apply #undef to an
identifier that has not been previously defined. Repetition of the #undef directive with the
same identifier is illegal.
Example:
#define DEBUG_FLAG
...
#undef DEBUG_FLAG
In this example, the #undef directive removes the definition of DEBUG_FLAG, previously
created by the #define directive.
SimplIQ Software Manual Program Development and Execution 6-20
MAN-SIMSW (Ver. 1.2)
If the expression contains the identifier of the #define directive, the identifier must have a
successfully-evaluated token_string.
The syntax of the expression of a pre-compilation directive differs from the syntax of
other expressions in that it has the following limitations:
It cannot contain global or local variables; only constant values are valid.
It cannot use any system or user functions, or system commands.
Only integer and float data types are allowed. Arrays and array members are
illegal.
A detailed description of the operators is given in section 4.2.2. The data type of the
evaluation result depends on the operation and the type of operands. The result of logical,
bitwise and comparison operations is always integer. With calculating operations, if both
operands are integers, the result is integer; otherwise, the type is float.
In this step of program development, communication between the Composer and the
SimplIQ drive must be established.
After successfully compilation, the compiled code can be downloaded to the SimplIQ drive.
This step is supported by the Composer IDE. Before each download, the Composer
automatically clears the flash memory sector, which is used for saving the user program.
The serial flash performs downloads and uploads using two commands: DL and LS. Both
commands use the auxiliary LP command, which is a vector integer command. The CP
command can be used to clear the user flash area, and the CC command can be used to
checksum-verify the program, and set the program read flag.
SimplIQ Software Manual Program Development and Execution 6-21
MAN-SIMSW (Ver. 1.2)
After a successful download, global variables can be used — for monitoring and
modifications — from an external terminal such as the Composer Smart Terminal.
In order to prevent this problem, a hexadecimal binary format is used during data upload
and download, although this increases the amount of data to be transmitted.
Every byte in hexadecimal format consists of two numbers (such as 0x12), considered to be a
single character. For example, the 8-bit number 0x12 in hexadecimal binary format is the
sequence of two characters: 1 and 2.
The representation of numbers in the DSP flash memory differs from its representation
inside a personal computer.
The 8-bit number is represented the same way.
The 16-bit number, represented in hexadecimal format as equal to 0x1234, is represented
in the DSP memory in the following two bytes:
Byte 1 equals the value 0x12 in hexadecimal form
Byte 2 equals the value 0x34 in hexadecimal form
The 32-bit number, represented in hexadecimal format as equal to 0x12345678, is
represented in the DSP memory in the following four bytes:
Byte 1 equals the value 0x56 in hexadecimal form
Byte 2 equals the value 0x78 in hexadecimal form
Byte 3 equals the value 0x12 in hexadecimal form
Byte 4 equals the value 0x34 in hexadecimal form
Examples:
The TW[11] parameter indicates the type of program partition: user or factory.
The DL process takes time to proceed, because it needs to burn and verify.
5. Use the CC=checksum command to declare the end of loading and to verify the entire
download process.
Failures in executing the LS command may occur if the LS sequence (including <ESC>s)
exceeds 200 characters (internal SimplIQ buffer management limit). The LS output will be
terminated with the proper checksum and terminator. The data transmitted in the payload
will be good and meaningful, but not to the defined length.
Presently, it is not possible to run more than one task, the virtual machine,
simultaneously. This will, however, be possible in the future.
The XQ command does not reset program variables; initial values for all variables
must be set by the user.
The XQ command clears the call stack, kills any pending automatic routines and clears the
interrupt mask. For a description of the XQ command, refer to section 6.7.1.
Example 1:
MO=1; Start motor.
JV=2000; Set jog speed.
##LOOP; Repetitive task
BG;
wait(1000) Wait and switch direction.
JV=-JV;
goto##LOOP; Repeat.
This program indicates that the motor should travel at 2000 counts/second for one second,
then reverse direction for one second, and then continue to travel back and forth forever.
If the HP command is applied when the program is waiting (executing the wait(1000)
instruction), the motor will continue to travel at the same direction for an unlimited time.
An XC command reverses the direction immediately, because the waiting time has already
elapsed.
Example 2:
A servo axis in a machine has two different tasks to perform, in two different machine
modes. The following routine implements the two tasks.
##TASK1;
##LOOP; Repetitive task 1.
… Task 1 body.
goto##LOOP; Repeat task 1.
##TASK2;
##REP; Repetitive task 2
… Task 2 body.
goto##REP; Repeat task 2.
SimplIQ Software Manual Program Development and Execution 6-26
MAN-SIMSW (Ver. 1.2)
The first task is invoked by XQ##TASK1. In order to switch to the second task, the first task
must be killed before:
HP;
XQ##TASK2;
6.7 Debugging
This procedure enables a user to debug a program that is downloaded to the flash memory
of the SimplIQ drive. This step may be useful when developing the user program and
examining the user flow.
Notes:
XQ without a label or function name is designed to run a program written in the
Elmo Saxophone or Clarinet; that is, without function definitions, local variables
and so on. If the program starts from a function definition, the XQ command
without a label or function name causes an error to occur. If the function starts
from a label, the dummy start label is inserted into the Function Symbol table and
execution begins at the start of the program.
XQ does not change the current values of global variables; the initial values of
global parameters must be set by the programmer.
SimplIQ Software Manual Program Development and Execution 6-27
MAN-SIMSW (Ver. 1.2)
The DB command was designed for use with the Elmo Studio IDE. Therefore, users of
the Elmo Studio require no further knowledge of its functionality. The information in
this section is provided for advanced programmers and may be changed without
further notice.
This command assists in analyzing the user program, enabling the user to:
Set and remove breakpoints.
Get information about existing VAC machines.
Get the running status of the program.
Get the error status of a VAC machine.
Ask for or change values of local variables.
Get the program call stack.
The DB command should be used by IDE managers. The syntax of the command is strict:
Spaces and white characters are not allowed, in order to simplify the treatment of the
command. All values must be numbers; expressions are illegal.
SimplIQ Software Manual Program Development and Execution 6-28
MAN-SIMSW (Ver. 1.2)
Syntax:
DB##MS
This command returns a string in hexadecimal binary format containing a 16-bit number.
Every 4 bits characterize the status of the VAC machine; therefore, the command can give
the status of a maximum of four VAC machines. The most significant bit (bit 4) is dedicated
to run-time errors. If it is set to 1, it indicates that a run-time error has occurred. The
DB##ES[N] command reports further details about the specific VAC errors and resets this
bit. If the run-time error bit is 0, no run-time error has occurred or else it has been reset by a
previous DB##ES[N] command.
The remaining least significant bits (0…3) of the returned status use the following values:
0: Halted
1: Running
2: Idle/Not running
3: Aborted/Fault
4: Does not exist
Syntax:
DP##PS[N]
where N is a handle of a specified VAC machine.
The DB##PS command returns a string containing hexadecimal binary data with the
following information:
Size
Name Meaning Data Type in Bytes
1 Status Running status (section 6.7.4). Signed short 2
2 Error code Last error code or 0 for no error Signed short 2
(section 6.7.6).
3 Program counter Program counter of current Unsigned short 2
(PC) executing line.
4 Base pointer (BP) Current base pointer, which is the Unsigned short 2
saved stack pointer marking the
function entry point. BP is used to
reference local variables of a
function.
5 Stack pointer (SP) Current stack pointer. Unsigned short 2
When an error occurs inside a specified VAC machine, it returns an error to the main loop
responsible for running the entire set of VAC machines. This manager stops all other VAC
machines with a “Program Aborted by another thread” error. The VAC machine in which
the error occurred is designed by the error code that is different from the “Program Aborted
by another thread” error.
The DB##PS command enables the user to analyze the various debugging functions
described later in this section.
Syntax:
DB##ES[N]
where N is a handle of a specified VAC machine.
DB##ES returns a string of hexadecimal binary data with the following information:
Size
Name Meaning Data Type in Bytes
1 Error code Last error code, or 0 for no error Signed short 2
2 Program counter Program counter in which the last Unsigned short 2
(PC) error was latched
3 Program error Number of errors that occurred in N Unsigned short 2
counter program, or 0 if no error occurred. It
can be more than 1 if, after an error,
execution was resumed by an
AUTO_PERR routine. This number
starts again from 0 when the error
reaches 65,525. The program error
counter is reset each XQ.
A non-zero error code indicates that an error occurred. The DB##ES[N] command is used to
isolate an error that did not stop the user program, but rather jumped it to an AUTO_PERR
routine. The command clears both the “program error” bit in the status register and the
“run-time error” bit of machine N in the DB##MS command.
SimplIQ Software Manual Program Development and Execution 6-30
MAN-SIMSW (Ver. 1.2)
Syntax:
DP##BP=xxx Sets a breakpoint at program counter xxx
DB##BP=xxx,n Sets a breakpoint at line program counter, activated only after
n repetitions
DB##BC=xxx Removes a breakpoint at the program counter
DB##BC Removes all breakpoints
where:
xxx is 4 bytes unsigned long.
n is 2 bytes signed short.
Syntax:
DB##GO and DB##GO[N]
where N is a handle of a specified VAC machine.
The program continues to run from the current program counter. The DB##GO command
continues running all VAC machines, while the DB##GO[N] command continues running
the specified VAC machine.
In order to determine which existing VAC machine has a program counter equal to the
program counter of the breakpoint, the DB##MS command must first be sent in order to
determine which VAC machines exist. Afterwards, the DB##PS command must be sent for
all existing VAC machines in order to get the program counter for comparison with the
breakpoint program counter. It is possible that several VAC machines will have a program
counter equal to the breakpoint program counter; in such a case, they may all be chosen as
the specified VAC machine.
Syntax:
DB##SO[N]
where N is a handle of the specified VAC machine.
This command is implemented inside the SimplIQ drive, using the following process:
Save the current base pointer.
Start the loop.
Run to the nearest end of line.
Compare the current base pointer with the saved base pointer.
If both are the same, jump to the end of the loop (step over); otherwise, go to the start of
the loop.
End of loop.
When the nearest end of line is reached, the VAC machine enters the halt state. In case of a
jump, infinite loop or other reason within the line execution, the program may not reach the
end of line and will simply run and not enter the halt state.
6.7.9.3 Step In
The DB##SI command executes a step in by entering a function body and running to the
nearest end of line.
Syntax:
DB##SI[N]
where N is a handle of a specified VAC machine.
This command is implemented inside the SimplIQ drive, using the following process:
Start the loop.
Run to the nearest end of line.
End of loop.
When the nearest end of line is reached, the VAC machine enters the halt state.
Syntax:
DB##SU[N]
where N is a handle of a specified VAC machine.
This command is implemented inside the SimplIQ drive, using the following process:
Save the current base pointer.
Start the loop.
SimplIQ Software Manual Program Development and Execution 6-32
MAN-SIMSW (Ver. 1.2)
When the nearest end of line is reached and the current base pointer is less than the saved
base pointer, the VAC machine enters a halt state. Otherwise, it simply runs and does not
enter the halt state.
Syntax:
DB##GS[N]=N1,N2
where:
N is a handle of a specified VAC machine whose stack is queried.
N1 is an index of the first stack entry.
N2 is an index of the last stack entry (not inclusive).
The command returns a string containing hexadecimal binary data with a sequence of stack
entries from N1 to N2. If a single stack entry is of interest, then N2 = N1+1.
The command, which is very useful during debugging, returns a string in the hexadecimal
binary format. Every stack entry contains the following fields:
Size
Name Meaning Data Type in Bytes
1 value Stack entry value Float or long, 4
depending on type
2 type Type of stack entry: 0 for long, 1 for float Signed short 2
3 unused Offset for alignment Signed short 2
Syntax:
DB##ST[N]=N1,N2
where:
N is a handle of a specified VAC machine (2 bytes, signed short).
N1 is a stack pointer (2 bytes, signed short).
N2 is a new variable value (4 bytes, long or float).
In order to change a value of a local variable, DB##SS sets a new value to the relevant stack
entry for a specified VAC machine. The type of stack entry is set according to the type of
value that is sent.
SimplIQ Software Manual Program Development and Execution 6-33
MAN-SIMSW (Ver. 1.2)
Stack Pointer
Relative to
Base Pointer Meaning Remarks
BP-5 Saved previous BP BP is 0 for first called function
BP-4 Return address Program counter of next
program line after function call
BP-3 Index of current function in See section A.5.5.
Function Symbol table
BP-2 Number of input arguments
BP-1 Number of actual output arguments Number of left-hand values
during function call
The LINK command allocates place for local variables, inserting N entries at the top of
the stack and resetting them, where N is the number of local variables. Usually, LINK
is the first opcode of the function. If a local variable is accessed before the opcode
LINK is executed, the relevant stack entries will contain garbage.
SimplIQ Software Manual 7-1
MAN-SIMSW (Ver. 1.2)
To use the Wizard mode with the SimplIQ drive, enter the password TP[6]=1. In this mode,
the SimplIQ drive recognizes its full instruction set, including commands for simulation,
tuning experiments or factory software tests. To exit Wizard mode, enter TP[6]=0.
7.2 Simulation
You can use the extensive built-in simulation capabilities of the SimplIQ drive to:
Design and run motion reference signals without a connected motor.
Apply all digital inputs without connecting to any physical input device.
Override the hardware readouts of the digital inputs.
Apply a motor fault and verify the correct fault handling.
Apply a follower reference without connecting any encoder signals to the auxiliary
input.
Apply analog inputs for referencing speed or torque or any other purpose, without
connecting to any analog voltage source.
The setting is volatile and at the next power-up, the SimplIQ drive will revert to its under-
voltage protection.
SimplIQ Software Manual Development Aids 7-2
MAN-SIMSW (Ver. 1.2)
Once you have entered the password, you enter MO=1 to initiate “motor on” state, in which
you can run controller reference commands. Of no motor is connected to the SimplIQ drive,
the drive may refuse to accept MO=1, claiming that all Hall sensors read the same. In such a
case, you may use one of the following remedies:
Set CA[28]=1 to define a DC motor that does not require Hall sensors.
Change CA[1] so that one Hall sensor is software-inverted.
Define CA[20]=0, “No Halls are present.”
Notes:
To run simulation only, disconnect the power supply from the SimplIQ drive. If a
motor and a power supply are connected to the drive, the motor will run normally,
despite TW[34].
When TW[34]=0, an auto-phasing process will indicate success and continue to
MO=1 regardless of its actual success. Do not set TW[34]=0, CA[20]=0, MO=1 with
the motor and power supply connected because the auto-phasing process can fail
without being noticed, resulting in unstable feedback control.
The SimplIQ drive will abort the “motor on” (MO=1) state and the motor fault (MF) report
will be n.
The auxiliary encoder will read a simulated encoder signal with a speed of n counts/second.
The desired speed n may be positive or negative. The auxiliary encoder readout will connect
to the hardware again at the next power on or when you enter TW[35]=0.
Do not use TW[35]=n when the auxiliary encoder serves for feedback (UM=4) because
this result in control instability.
You may define a sequence of analog input readouts that run cyclically from a value that
you define. The readout values are in the ZX[N] array. MP[1] and P[2] define the lowest
and the highest N values to use. TW[38]=n starts the sequence running as analog input,
starting with index n (or from MP[1] if n is out of the range [MP[1]…MP[2]]).
The analog input readout will reconnect to the hardware at TW[38]=0, or at the next power
on.
A new ZX[N] sample is used every torque sampling time. Therefore, with UM=1, the analog
input for the previous sample sequence will be:
4,8,12,16, 4,8,12,16, 4,8,12,16 . . .
With UM=2, the analog input is averaged to yield a new reading every sampling time of the
speed controller, which is twice the sampling time of the torque controller.
With UM=3, 4, 5, the analog input is averaged to yield a new reading every sampling time of
the position controller, which is four times the sampling time of the torque controller. At the
position controller input, the following sequence will b seen:
10,10 . . . (10 is the mean of 4, 8, 12 and 16).
Do not use TW[38]=n when the analog input serves for feedback (CA[23]=5) because
this may result in control instability.
SimplIQ Software Manual Development Aids 7-4
MAN-SIMSW (Ver. 1.2)
The smaller the sampling time, the better the control performance. For mechanically ideal
plants, the achievable speed controller bandwidth (with reasonable gain and phase margins)
is approximately:
12000
BW =
TS
which is approximately 120 Hz for a sampling time of 100 microseconds, and 170 Hz for a
sampling time of 70 microseconds. The bandwidth increases slightly with the closure of the
position loop.
For a low sensor resolution (speed always below 10,000 counts/second) or for moderate
control performance requirements, a larger sampling time is tolerable. For extreme control
performance, decrease the sampling time.
A lower sampling time implies a higher RS-232 baud rate. The SimplIQ drive can always
operate at a baud rate of 57,600, while it can operate at a baud rate of 115,200 for TS=80 or
less. Lower sampling times also imply that a larger number of CAN messages can be sent to
the SimplIQ drive without loss. The maximum continuous CAN message acceptance rate is
one message per 4 TS (bursts of up to eight messages can be accepted at the full CAN bus
rate of 1 Mbaud/second). However, lower sampling times imply a greater CPU load, which
causes the interpreter and the user program to operate at a slower rate. The “interpreter”
includes the RS-232 interpreter, CAN SDO handling and CAN receive PDO (other than
CAN high-speed motion commands) handling.
The CPU load is not only a function of the sampling time. DC motors consume less CPU
load than brushless motors. UM=4 and 5 loads the CPU the most, while UM=2 loads it less
and UM=1 and 2 the least. The specific design of the controller and sensor filters also affects
the CPU load.
An extreme CPU load (not likely at TS-70 unless a very large control filter is being
implemented) can cause a real-time overflow in the SimplIQ drive; it can be corrected by
setting TS to a new value.
The WI[7] command tests for the CPU load and reports the percentage of CPU power
remaining for the interpreter and the user program. A value no smaller than 25 is
recommended for WI[7]. In order to use a smaller WI[7] value, the sampling time should be
increased.
SimplIQ Software Manual Development Aids 7-5
MAN-SIMSW (Ver. 1.2)
This section explains how to define the recorder parameters for the SimplIQ drive, how to
launch and trigger the recorder and how to fetch the recorded data. The details need not be
of interest to most SimplIQ drive users, because the Composer application normally operates
the recorder through a user-friendly interface.
The list of recordable signals supported by the SimplIQ drive is stored internally and can be
retrieved by the host. (Refer to the LS and LP commands in the SimplIQ Command Reference
Manual.) In addition, the SimplIQ drive can record user-program variables for tracing the
progress of user programs without interrupting them.
Command Description
BG, BT, IL[N] Begins motion using software or hardware command. Start of motion
may be used to trigger the recorder.
BH Uploads recorder results.
LS Loads a record from the serial flash memory, in order to retrieve the
list of recorder signals.
RC Defines which of mapped signals should be recorded.
RG Recorder gap: specifies sampling rate of the recorder.
RL Recorder length.
RP[N] Recorder parameters: defines which event will trigger the recorder,
and the trigger position. Also defines basic time quantum for recorder
(TS or four times TS) and data to be uploaded to host by next BH
command.
RR Launches recorder and reads back its status.
RV Signal mapping: maps the IDs of the recordable signals to logical IDs
that the recorder can reference.
SR Status register, which indicates the status of the recorder: idle, armed,
triggered and recording, or ready with data.
TS Sampling time, the basic resolution of recorder.
WI[21] Actual amount of recorded data.
Table 7-1: Commands Relevant to the Recorder
SimplIQ Software Manual Development Aids 7-6
MAN-SIMSW (Ver. 1.2)
To poll the status of the recorder, use the RR and SR commands. After the recorder data is
ready, use the BH command to upload the data.
After power on, the recorder can access the first 16 signals, as listed in Table 7-2. To access
other signals, the recorder must perform a process called “mapping” in order to make them
available. In the mapping process, the IDs of the desired signals are mapped to recorder
“cells” (logical IDs that can be directly referenced by the recorder) so that on power on, the
signals are mapped to the cells. The following table lists the additional signals that are
available to the SimplIQ drive recorder. The full list of signals may differ according to the
SimplIQ drive’s grades and released. The signals can be retrieved from the personality
partition of the serial flash memory.
Prior to being recorded, the signals listed in Table 7-3 must be mapped to the recorder. Up
to sixteen signals may be mapped to the recorder at any time. Up to eight signals can be
recorded simultaneously.
The RV[N]=x command maps a signal with the ID of x to the logical ID of N, N=1…16. RC is
a bit-field parameter (bit 0 to 15) that sends the actual required signal to the recorder. In this
case, bit N-1 of RC points to signal x.
Example:
RV[2]=1 maps the signal with the ID of 1 (main encoder speed) to the logical ID of 2. This
means that in order to record the main encoder speed, bit 1 of RC should be set (RC=2).
The default mapping, restored at boot, maps the signals of IDs 1 through 16 to the
corresponding logical IDs 1 through 16. Therefore, the signals with IDs 1 through 16 can be
recorded using corresponding logical IDs, without further programming.
Example:
The commands RV[1]=5; RV[2]=1; RC=3;
define that when launched, the recorder will record the main speed and position error.
RC may define a maximum of eight recorded signals, meaning that the binary
representation of RC may not include more than eight ones.
RG defines the sampling rate of the recorder, in terms of the time quantum:
RG=1 indicates that a new sample should be taken once per time quantum. If TS=70 and
RP[0]=0, the recorder will sample once per 280 microseconds.
RG=2 indicates that a new sample should be taken once per two time quanta. If TS=70
and RP[0]=1, the recorder will sample once per 140 microseconds.
Similarly, RG=N indicates the a new sample should be taken once per N time quanta.
SimplIQ Software Manual Development Aids 7-9
MAN-SIMSW (Ver. 1.2)
Note that RG specifies only the recorder sampling rate, not the trigger sampling rate. A
trigger event will cause the recorder to start within one time quantum (TS).
RL defines the maximum number of data items to collect. For example, if RL=11, TS=70,
RG=1 and RP[0]=0, then the 11 samples will be taken at the rate of 280 microseconds, lasting
(11-1) x 280 milliseconds = 2,800 microseconds.
The recorder memory is limited to a total of 4096 long variables. When more signals are
recorded, less memory is available for each recorded signal.
If RL > (recorder memory) / (number of signals), the recorder will fail to record the
specified RL samples and instead, will record up to its data volume.
The actual amount of recorded data can be polled using the WI[21] command.
0.6 Level 1
0.4
The trigger The trigger
0.2 occurs here if set occurs here if set
for negative slope for positive slope
0
The trigger
-0.2 occurs here if set
for window
-0.4
Level 2
-0.6
-0.8
-1
1 2 3 4 5 6 7
Digital signal: The SimplIQ drives will support this trigger option in the future.
SimplIQ Software Manual Development Aids 7-10
MAN-SIMSW (Ver. 1.2)
The trigger defines when the recorder is to start. The recorder can be programmed to start
before the trigger event, so that the trigger event can occur “in the middle of the action.” This
is possible because the recorder begins to record at the instant it is launched by the RR
command, so that when the trigger event occurs, the pre-trigger information is already
recorded.
Example:
The signal to be recorded is speed, and the trigger is set on BG. After launching the recorder
with RR=3, the following command sequence is given: JV=5000;BG.
5000
Speed C ommand
4500
4000
Triggered on BG with
0% pre-trigger delay
3500
3000
1500
1000
500
Time
0
0 2 4 6 8 10
In this example, the recorder works for 10 seconds. In such a case, a pre-trigger delay of 20%
requires 2 seconds, in order to acquire the pre-trigger data. A BG command set for less than 2
seconds after the RR=3 will be missed.
Trigger levels RP[4] and RP[5] can be entered as either integers or floating point numbers.
Note that the results of RR=1 and RR=2 can be achieved with RR=3 and the appropriate
RP[N] definitions. The RR=2 and RR=2 commands are used for easy interface with the most
common recorder actions.
The SR (status register) command details the status of the recorder. SR returns a bit field, in
which bits 16 and 17 may have the following values:
Parameter Description
RR If zero, indicates that the recorder is ready for data upload
WI[21] Indicates how much data is actually recorded
RP[8], RP[9] Defines the part of the signal to be uploaded next
BH Uploads recorded data command
Table 7-6: Parameters for Uploading Recorded Data
The BH command is used to upload to the host the values recorded by the SimplIQ drive
recorder. BH optimizes the data transfer, assuming that the host has the computing power
to analyze the SimplIQ drive message.
To execute a BH command, valid data must be stored in the recorder. If the data is valid, the
fields of the RC variable define the variables that have been recorded.
The BH=n command uploads the recorded variable defined by RC&n, where & is the bit-
wise AND operator. For example, if RC=7, the command BH=2 will transfer the variable to
be recorded by setting RC=2, because 7&2=2. If the binary representation of RC&BH
includes more than one “1”, the variable with the lowest value will be uploaded and BH will
not return an error.
Example:
If RC=7 and BH=3, BH will upload the recorder variable defined by RC=2. BH=16 will return
an error because BH&RC=0.
It is convenient to use hexadecimal notation for the BH command; for example, BH=0x4000
appears more understandable than BH=32768.
The BH command can load an entire recorded signal, or a part of one. If RP[8]=0 and
RP[9]=0, BH=n will upload an entire signal. Otherwise, BH will upload the recorded signal
from index RP[8] until index RP[9]. RP[9] must always be less than or equal to the length of
the recorded signal.
SimplIQ Software Manual Development Aids 7-13
MAN-SIMSW (Ver. 1.2)
The data is uploaded in hexadecimal form in order to minimize transmission time (relative
to ASCII formatted text), while adhering to the ASCII nature of transmissions. Each data
byte is parsed into two nibbles, and the ASCII code of the nibbles is sent from the controller
to the host. For example, the short integer number 43794 has the hexadecimal representation
AB12. It will be transmitted as “A” “B” “1” “2” with the most significant nibble first and the
least significant nibble last. The long integer number 1 will be sent as: “0” “0” “0” “0” “0”
“0” “0” “1”.
In order to analyze the BH record, it is important to understand that the internal
representation of quantities in the controller is not in user units. For example, while the user
relates to motor current in amperes, the controller represents current internally by the bits of
the A/D that measures the current. The BH record uploaded recorded currents (and other
variables as well) in their internal representation units, and also provides the scaling
multiplier to relate it to user units. This way, no multiplication inaccuracies are introduced
to the BH records, and the CPU load is minimized.
The recorded transmitted by the controller in response to a BH=n command is described in
the following table. The record includes 20 bytes of overhead, and numerical record data.
The variables in the table are translated into ASCII as described previously.
Byte
Number Description Value Type
0-1 Variable type for user. 0: Integer system parameter Byte
Field has no practical 1: Real system parameter
significance. 2: Integer user program
variable
3: Real user program variable
2-3 Data width: number of hex 4: Short integer Byte
character of single transmitted 8: Long integer
data item.
4-7 Data length: actual number of Word
transmitted data items.
8 - 11 Variable time multiplier: Depends on RP[0] value Word
number by which TS must be
multiplied to obtain basic
recording period.
12 - 19 Floating number factor, by 32-bit float
which every uploaded data item number in
is multiplied in order to convert IEEE
it to user units, such as amperes, format.
or counts/second.
20 - 20+ (Data length) * (Data width) -1: Words or
data items. Oldest record is long
transmitted first, and most integers,
recent record is transmitted last. according
to data
width.
Table 7-7: BH Record Structure
SimplIQ Software Manual Development Aids 7-14
MAN-SIMSW (Ver. 1.2)
BH record transmission time can be quite long. A record of 2000 long numbers is
approximately 8000 bytes, which take at least 4 second to transmit over RS-232 at a baud
rate of 19,200. During this time:
The user program continues to run normally.
CAN commands are accepted and processed normally.
RS-232 commands are accepted and executed normally, although the transmission of the
response to them is deferred until after the BH upload is complete.
Example:
A BH command may return the string:
0008000100013f80000000010000
Chapter 8: Commutation
Mathematically:
T = KeI * cos (θ)
where:
θ is the angle between the magnet and the field of the winding.
Ke is a parameter, proportional to the strength of the magnet.
T is the motor winding torque.
I is the motor current.
If the magnet is allowed to move, it will rotate until it is aligned with the winding field, and
will remain stationary there.
A motor is composed of a fixed magnet and several windings arranged so that each winding
generates a field of different direction. By powering the windings alternately, the direction
of the winding field moves, and so does the direction to which the rotor is attracted. This
process of alternating the powered winding is called commutation.
DC brush motors are equipped with a mechanical device that selects which winding to
power. In brushless motors, this selection mechanism is electronic. The “commutation
policy” has two major types: stepper and BLDC (Brushless DC).
Commutation parameters are normally set using the Composer Wizard application.
To tune commutation manually, thoroughly read the CA[N] documentation in the
SimplIQ Command Reference Manual.
CA[25], motor direction is set to 0 or 1 so that the motor will rotate in the desired
direction for positive torque commands.
The values of CA[16] and CA[25] must be coordinated; otherwise, the feedback direction will
be incorrect and the encoder will count negative displacement for positive torques. In
addition, the motor will immediately “run away” as soon as speed or position control is
attempted.
If you intend to use the SimplIQ drive with DC motors, the rest of this chapter is irrelevant.
Stepper commutation is simple and reliable. Its main drawback is that normally, |θ| << 90º;
therefore, large currents are required to generate a given torque. In its steady state, the
motor torque is zero and not affected by motor current. The sensitivity of motor torque to
deviation of the rotor angle is maximal. The great sensitivity of the torque to rotor angle
generates a fast, but oscillatory position feedback.
The advantage of BLDC commutation is its maximum torque per given motor current, and
its smooth, controllable torque. It is ideal for servo applications. BLDC involves a
considerable amount of real-time calculation and requires a rotor position sensor, which
decreases motor reliability. The torque is not sensitive to rotor angle.
When the rotor travels, the coils of the three-phased motor are powered in the sequence A-
B-C-A-B-C . . . and so on. The powered phases generate a magnetic field, which attracts the
permanent magnet of the moving part (rotor). When the phases are powered sequentially,
the magnetic field moves and the rotor follows continuously. When the rotor passes from a
location over the A coil to the next A coil, it covers an electrical cycle.
Several coil sets — with corresponding fixed-magnet pole pairs on the rotor — may be
located around a motor circumference. For example, a motor with three pole pairs complete
three electrical cycles in one mechanical shaft revolution.
SimplIQ Software Manual Commutation 8-3
MAN-SIMSW (Ver. 1.2)
You can read the electrical and mechanical angle of the motor using the following
commands:
Command Description
WS[20] Stator field angle, in 1024 counts/revolution units.
Stator field angle (degrees) = WS[20] x (360/1024).
WS[21] Commutation counter. WS[21] counts the main high-resolution
position sensor, modulo CA[18].
Hall A
Hall B
HallC
The following table describes the digital Hall sensor reading. The BLDC field angle is the
angle that produces maximum torque for this Hall sensor reading.
The crude division into six draws a rough torque from the motor, and requires hard
switching of the motor winding currents.
In many application digital Hall sensors are used together with higher-resolution position
sensors. The Hall sensors serve to initialize the field direction and add redundant position
sensing for increased reliability.
For commutation calculation, it is important to now how many bits the shaft sensor counts
per single electrical cycle. If this number is not an integer, after a certain amount of
movement, the calculated commutation angle may accumulate numerical errors and cause
the motor to lose torque. The numerical commutation error is not a serious issue with linear
motors, because the limited travel also limits the commutation calculation error. With rotary
motors, each mechanical shaft rotation involves an integer number of encoder counts, per an
integer number of electrical cycles. This means that the commutation can be kept as accurate
as:
p1 = mod (encoder, counts per shaft revolution)
and
Number of pole pairs Counts per shaft revolution
Electrical rotor angle = 360º * * mod (pl, )
Counts per shaft revolution Number of pole pairs
SimplIQ Software Manual Commutation 8-5
MAN-SIMSW (Ver. 1.2)
The digital Hall sensor readout defines a range in which the high-resolution calculated angle
should reside. Deviating from this range by more than a few degrees results in a
commutation error and automatic motor shutdown.
The allowed deviation is increased at higher speeds, because then the sensor and the
calculation delays contribute a significant matching error.
As shown in the table, change CA[25] switches the B and C phases. Actually, changing
CA[25] will reverse the direction in which the motor moves for a given torque command.
In addition, the switching lines in the figure are set at 30, 90, 150, 210, 270 and 330 degrees.
The even spacing of 60º is true for most motors, but many motors exhibit a significant origin
deviation. For example, with a 10º deviation, the digital Hall sensor switching points may be
at 40, 100, 160, 200, 280 and 340 degrees respectively. This error, although hardly noticeable
at low speed, causes the loss of significant motor torque at high speed.
If Hall sensors are not present, and if commutation is performed using an incremental
encoder, then upon starting the motor, the SimplIQ drive must first find the electrical
direction of the motor. If digital Hall sensors are not present (CA[20]=0), then at motor on, a
commutation search is performed (refer to section 8.4).
Parameter Description
CA[1] Polarity of digital Hall sensor A: 1 for active high; 0 for active low.
CA[2] Polarity of digital Hall sensor B: 1 for active high; 0 for active low.
CA[3] Polarity of digital Hall sensor C: 1 for active high; 0 for active low.
CA[4] Actual Hall sensor connected to A Hall connector pin:
1 for A, 2 for B and 3 for C.
CA[5] Actual Hall sensor connected to B Hall connector pin:
1 for A, 2 for B and 3 for C.
CA[6] Actual Hall sensor connected to C Hall connector pin:
1 for A, 2 for B and 3 for C.
CA[7] Offset of digital Hall sensors in encoder units. The range for this parameter
is [0…CA[18]-1]. This parameter compensates for deviations in the Hall
sensor switching point. If no encoder is present, set this parameter to zero.
CA[20] Digital Hall sensors present:
0: No digital Hall sensors connected
1: for Digital Hall sensors connected.
Table 8-2: Hall Sensor Parameters
SimplIQ Software Manual Commutation 8-7
MAN-SIMSW (Ver. 1.2)
Parameter Description
CA[17] Commutation sensor type: 1 for Main encoder.
CA[21] Position sensor present:
0: No high-resolution commutation sensor. Commutation will be based on
digital Hall sensors only.
1: Main position sensor will be used for commutation.
The encoder is normally used both for motion feedback and for commutation. As a motion
feedback counter, it must count up when the motor goes forward, in the application sense.
As a commutation counter, it must count up when the commutation angle increases. These
two requirements are not necessarily the same, so the following two parameters are needed:
Parameter Description
CA[16] Encoder direction: Set 0 or 1 so that the encoder will count forward in the
desired movement direction.
CA[25] Motor direction: Set 0 or 1 so that with positive torque, the motor will
rotate in the direction for which the encoder counts up.
The encoder measures the shaft angle. In order to commutate, the encoder count per
electrical revolution is needed. Normally, the number of encoder counts per motor
revolution is an integer (if not, commutation with an encoder may be incorrect). The number
of pole pairs per revolution is always an integer. By knowing the encoder counts per
mechanical revolution, along with how many pole pairs are in a revolution, the
commutation counter can infinitely update without accumulate errors.
For linear motors, the number of pole pairs CA[19] should be set to the largest number of
full electrical cycles possible for that motor. Enter the “encoder counts in revolution” CA[18]
parameter as the number of encoder counts for CA[19] electrical cycles.
Parameter Description
CA[18] Encoder bits per revolution, after resolution multiplication by 4, in the
24
range [6…2 =16,777,216]. For an incremental encoder with 1000 lines,
CA[18] will be 4000.
CA[19] Number of motor pole pairs: [1…50].
CA[23] Counts per meter (an positive integer):
0: Rotary motor
1: Counts per meter in linear motor
This parameter is not used directly by the drive; it is just stored there for
the convenience of the host.
Table 8-3: Encoder Parameters
SimplIQ Software Manual Commutation 8-8
MAN-SIMSW (Ver. 1.2)
The angle θs is known because the drive controls it directly. The angle θr is unknown.
If θs is rotated — that is, θs –2πf * t, where f is a frequency and t is the time — the result is
the following sinusoidal torque:
T = KT * I * sin(2πf * t - θr) (3)
For that torque, the motor shaft will move according to:
P(t) = A(f) * KT * I * sin (2πf * t - θr – φ(f)),
where:
P(t) is the motor shaft position.
A(f)ejφ(f) is the transfer function of the motor and its load at the frequency f.
By applying a torque of (3) and measuring the position, both A(f) and θ r can be identified.
Parameter Description
I The torque is selected by the parameter CA[26], which defines I as a
percentage of the continuous current rating CL[1]. For example, if
CA[26] = 50, then I = 0.5 CL[1].
f CA[15] controls the frequency of the sinusoidal motor torque. The basic
frequency (with CA[15] = 0) is such that a cycle is completed in 128 * TS
microseconds. For a SimplIQ drive with TS=80, this will be a cycle of 10,240
microseconds, which is about 100 Hz.
The frequency is 2CA[15] * basic frequency of CA[15] in the range [-4…4].
For example, with CA[15] = 2, the frequency is about 40 Hz, whereas with
CA[15] = -2, the frequency is about 640 Hz.
SimplIQ Software Manual Commutation 8-9
MAN-SIMSW (Ver. 1.2)
The Composer program normally selects the parameters I and f at the “Establishing
Commutation” stage of auto-tuning.
8.4.3 Protections
The method described here can work reliably in many practical situations, although it does
not match every application. If the parameters of the method are not tuned properly, or if
the method does not match the application, the motor starting process will fail.
After setting MO=1, the algorithm will attempt to rotate the motor back and forth and find
the commutation angle. If the results are not reliable, because the oscillation amplitude is
too small or because the load behavior is not inertial, MO will reset automatically to zero
and the motor will not start.
Parameter Description
CA[18] Encoder resolution and number of motor pole pairs.
CA[19] CA[18] must be greater than CA[19] * 256.
CA[20] Must be set to 0 to indicate that no Hall sensors are present.
CA[21] Must be set to 1 to indicate that an encoder is present.
CA[15] Set the oscillation frequency as explained previously.
CA[24] Set the minimum acceptable oscillation amplitude to 4.
CA[26] Set the excitation amplitude as a percentage of the continuous current.
CA[27] Set the maximum number of iterations for the auto-phasing process.
MO MO=1 sets the motor to on. If the motor starts to fail, MO resets to 0.
WS[15] Reads the actual oscillation amplitude.
WS[16] Flag if a non-inertial behavior has been observed.
The torque production is not very sensitive to εθ. Writing equation (1) as:
T = KT * I cos (εθ), it can be seen that a discrepancy of 5° can result in a loss of about 0.4% of
the torque. With a miss of 30°, 13.4% of the torque is lost, as illustrated in the following
figure:
100
80
60
40
Lost torque, %
20
0
-100 -50 0 50 100
Commutation miss angle, degrees
Two main methods — six-step commutation and continuous commutation — are used to
keep εθ near zero.
The crude six steps produce an approximately 13% ripple torque when used with sinusoidal
motors, and must less ripple torque when used with trapezoidal motors (refer to section
8.6). The main drawback of six-step commutation is the need to abruptly switch phase
currents, which imposes an extreme bandwidth demand on the current controller. If the
bandwidth of the current controller is less than satisfactory, noticeable “knocks” will occur
at commutation switching points.
SimplIQ drives also use six-step commutation immediately after motor on, and before the
first Hall sensor transition is encountered. Afterwards, the high-resolution commutation
sensor (encoder) can be homed, and commutation may proceed in the continuous mode.
The continuous commutation mode is native to the SimplIQ drive and is used most of the
time. This mode of commutation is much more complex than the six-step commutation. In
fact, it requires two independent current controllers for controlling both the amplitude and
the direction of the windings magnetic field.
Continuous commutation reduces the dynamic demands from the current controller,
because such demands are rarely switched abruptly.
In other words, the phase currents must be proportional to the corresponding commutation
function values. If (1) is satisfied, the magnetic field produced by the winding currents is
perpendicular to the rotor magnet.
SimplIQ Software Manual Commutation 8-13
MAN-SIMSW (Ver. 1.2)
Most motors are wound to sinusoidal or trapezoidal winding forms, but no motor can be
exactly sinusoidal or trapezoidal. Trapezoidal motors are normally chosen for six-step
commutation, whereas sinusoidal motors are normally chosen for continuous commutation.
0.4
0.3
0.2
0.1
h(theta)
-0.1
-0.2
-0.3
-0.4
0 50 100 150 200 250 300 350 400
Theta (degrees )
0.8
0.6
0.4
0.2
h(theta)
-0.2
-0.4
-0.6
-0.8
0 50 100 150 200 250 300 350 400
Theta (degrees)
In order to optimize the SimplIQ drive for as many motors as possible, the SimplIQ drive can
be programmed to any winding shape function. SimplIQ drives come from the factory
programmed, by default, for sinusoidal motors, but the motor waveform can be changed
using the Composer program.
SimplIQ Software Manual Commutation 8-14
MAN-SIMSW (Ver. 1.2)
Command Description
TS Current controller sampling time
KP[1] Proportional gain of current controller (nominal voltage)
HI[1] Integral gain of current controller (nominal voltage)
XP[4] Time constant for DC power bus filter
XP[5] Step limiter for torque command filter
XP[6] Time constant for torque command filter
MC Largest available drive current
PL[1] Application peak current limit
PL[2] Duration for peak current limit
CL[1] Continuous application current limit
Each of these commands is described fully in the SimplIQ Command Reference Manual.
This chapter deals with currents measured in amperes. The definition of ampere
used for three-phased motor current is explained in section 2.3of this manual.
SimplIQ drives energize all three motor terminals simultaneously. This means that it must
control two current components simultaneously, because the phase currents are linearly
dependent (the sum of all phase currents is zero). The SimplIQ drive’s vector current
controller directly controls the following two current components:
IQ: current component that produces a magnetic field in the desired direction
(normally perpendicular to the rotor fixed magnet field)
ID: current component that produces a magnetic field orthogonal to the desired
direction (normally parallel to the rotor fixed magnet field)
Peak/Continuous lim it
saturation
PW M output
Torque Q
com m and
Pre-filter Σ P+I controller
VQ Va
Output Vb
- Coordinate
Power bridge
Vc & m otor
transform
D VD
0 Σ P+I controller
Com m utation
-
angle
θ
IQ Ia
Input Ib
Coordinate
ID transform Ic
Current sensors
The input coordinate transform retrieves the IQ and ID (active and reactive) components
of the motor current.
For sinusoidal motors, h (θ) ≡ cos(θ) and g (θ) ≡ cos(θ) . The SimplIQ drive tabulates
both h (θ) and g (θ) .
You should program PL[1] to be smaller than MC if you do not wish to utilize the full
power of the drive; this may be the case if the drive is oversized with respect to your
application or because the line voltage is not enough to drive MC amperes into the
motor.
SimplIQ Software Manual The Current Controller 9-3
MAN-SIMSW (Ver. 1.2)
You should define a PL[1] small enough so that at peak current there is enough voltage to
drive current changes. Otherwise, at large currents, the drive speed of response will be
limited by voltage saturation.
The continuous current limit for your application is programmed by CL[1]. This
parameter cannot exceed MC/2, because greater continuous currents could cause drive
overheating.
As a recommendation, you should select PL[1] and CL[1] to be as great as the drive and
application permit. This will extend the linear range of the drive to its maximum and
thereby optimize the servo parameters.
The parameters PL[1] and CL[1] specify limits for the current demand. At
transients, the motor current may exceed PL[1] and CL[1] due to overshooting.
The decision to limit the motor current demand to CL[1] or to PL[1] is made by the drive
in real time. The LC flag reports the current limiting status. The decision mechanism is
depicted as follows:
Ia
Low Pass filter
RMS
Ib - RMS
I a2 + I 2b + I c2
Ic
When the current limit switches, the comparison threshold (named THOLD in Figure
9-2), changes slightly. This hysteresis prevents frequent switching of the current limit.
SimplIQ Software Manual The Current Controller 9-4
MAN-SIMSW (Ver. 1.2)
Slower time constants in the low-pass filter permit a peak current demand for longer
times, but also take more time to recover from a limitation to CL[1]. The time constant τ
of the low-pass filter is selected by PL[2] as follows:
− PL[2]
τ=
⎡ CL[1] ⎤
log ⎢1 −
⎣ MC ⎥⎦
With this selection, when PL[2] is set to MC, and after the current demand has been zero
for a long time, the drive will permit a maximum of PL[2] seconds of peak current, and
then switch to continuous current limiting.
For other settings of PL[1], the maximum time for which the peak current can be
maintained, after the current demand has been zero for a long time is:
⎡ CL[1] ⎤
- log ⎢1 − ⋅ τ seconds
⎣ PL[1] ⎥⎦
Example:
The following graph illustrates the signals related to the current command limiting
process for MC=6, PL[1]=6, PL[2] = 3 and CL[1] =3.
The motor current demand increases from zero to 6 amperes at the time of 0, and is then
decreased to 0 at the time of 5 seconds. The state of the low-pass filter increases until it
reaches the continuous current limit of 3 at the time of 3 seconds. Then, the LC flag is
raised and the motor current command is decreased to CL[1] = 3 amperes. After the
motor current command is set to zero, the state of the filter begins to drop. When it
reaches 2.7 amperes = 90% of 3 amperes, the LC flag is reset and the torque command
limit once again becomes 6 amperes.
3
F ilter state
1 LC current lim it
Indication
0
0 1 2 3 4 5 6 7 8 9
Bus voltage
VB
Proportional gain
Com m and
ε Saturation
Σ Kp[1]/VB
- Output
Σ
Integrator
Feedback
∑ εk KI[1]/VB
k
Integral gain
Anti wind up
The following table lists the roles of the inputs and outputs in the IQ and ID controllers:
The proportional and integral gains are divided by the DC voltage because the output of
the current controller is the PWM duty cycle.
The PWM duty cycle sets the corresponding motor terminal voltage to:
Motor terminal voltage = (PWM duty cycle) x (DC power voltage).
This equation shows that the uncertainty in the DC power voltage acts as a gain
uncertainty for the current controller.
SimplIQ Software Manual The Current Controller 9-6
MAN-SIMSW (Ver. 1.2)
The DC power voltage varies significantly: It decreases at high current due to the power
supply output impedance and increases when, upon braking, the motor acts as a
generator. The division of the bus voltage makes the output of the controller proportional
to the physical motor voltage, eliminating the uncertainty.
The bus voltage is filtered to avoid too rapid changes in current loop PI parameters. The
bus voltage filter is a simple low-pass filter, with a bandwidth of:
− 10 6 XP[4]
log Hz.
8π ⋅ TS 32768
The relation between XP[4] and the time constant of the filter is calculated in the table
below for several values of XP[4] and TS=50.
XP[4] is factor set to 30,720. Set it to a higher value if the output impedance of your
power supply is too high, causing an interplay between the filter gains and the DC motor
voltage. Set it to a lower value if you have a very low-impedance power supply, but a
high ripple voltage. In normal applications, it is recommended not to change the factor
setting of XP[4].
You may install an AUTO_ERR routine in your user program to automatically respond to
an exception shutdown.
SimplIQ Software Manual The Current Controller 9-7
MAN-SIMSW (Ver. 1.2)
MF
Protection Reports Reason
Over-voltage 0x5000 Voltage of the power supply is too high, or the servo
drive failed to absorb kinetic energy while braking a
load. A shunt resistor may be required. The over-voltage
threshold differs with the power stage model (refer to
product user manual). A probable reason for this
protection is an attempt to decelerate a motor that is
moving so fast that the drive fails to absorb the motor’s
kinetic energy. The solution to this is to decelerate more
slowly or to add a shunt resistor to the power supply.
Under-voltage 0x3000 The power supply has been shut down or its impedance
is too high. The under-voltage threshold differs with
power stage models; refer to the product user manual. A
probable reason is that PL[1] and CL[1] have been set too
high for the power supply.
Short circuit 0xb000 A large, fast current pulse has been detected. The motor
or its wiring may be defective or the drive may be faulty.
Over-temperature 0xd000 The power stage of the drive is too hot. An additional
heatsink or forced cooling is required.
Over-current 0x8 An unexpected, large current has exceeded 1.15 * MC.
The current loop or the winding shape function HV[N]
may need better tuning.
Table 9-3: Current Amplifier and Power Stage Protections
SimplIQ Software Manual 10-1
MAN-SIMSW (Ver. 1.2)
If position sensors are connected, the position and speed are evaluated so that the drive
will abort upon over-speed, as specified by parameters LL[2] and HL[2].
Enable if
RM==1
AS[1]
TC
The AS[1] parameter compensates for possible offsets in the driving equipment and
internally in the SimplIQ drive. If you do not use the analog input for the torque
command, set AG[1] = 0 or RM = 0 in order to avoid the noises and offset that affect the
drive torque command.
The combined (software and analog input) current demand is reported by DV[1].
The Stop Manager does not affect the reference generator: When the relevant switch is
released, the torque command value set by the reference generator is restored.
The reference to the speed controller is a sum of software commands and an auxiliary
speed command that is derived using the analog input, the auxiliary encoder input and
the ECAM table (details in Table 10-2).
The Stop digital input and the limit switches (RLS, FLS) can be used to stop or to limit the
direction of the motor (described in section 10.2.3). The drive will abort upon over-speed,
as specified by the parameters LL[2] and HL[2]. The speed control scheme can be
depicted as follows:
Enable if
RM==1
Speed command
(DV[2], cnt/sec) Torque command
(DV[1], Amp)
Auxiliary speed Stop Speed
command Σ manager Σ controller
DV[4]
-
DV[5]
Software speed
Smoother
command
Software speed
feedback
If you do not use the analog input for the torque command, set RM = 0, in order to avoid
noises and offset that affect the drive speed command. The DV[2] command reports the
combined (software and analog input) speed demand, after being further processed for
acceleration and speed limiting, and for the switch actions RLS, FLS and STOP.
DV[4] and DV[5] retrieve the external and software components of DV[2], respectively.
Command Description
AC Profiler acceleration limit, in counts/second2.
BG Begin command.
DC Profiler deceleration limit, in counts/second2.
JV Profiler final speed command, in counts/second.
PM PM=1: Normal acceleration limits form software speed command.
PM=0: AC and DC are ignored and SD is used instead. The Composer
setup program uses this mode when tuning the speed controller.
During regular operation, PM=1 is recommended.
SF Smooth factor: time, in milliseconds, required to develop the full
acceleration of AC and deceleration of DC.
VH[2] Maximum speed command, in counts/second.
VL[2] Minimum speed command (bound by speed command, negative
value), in counts/second.
HL[2] Maximum allowed speed, in counts/second. If feedback indicates a
higher value, the motion is automatically aborted.
LL[2] Minimum allowed speed, in counts/second. If feedback indicates a
lower value (high value in negative direction), motion is automatically
aborted.
IL[N] Map functions to digital inputs, which may function as hardware ST
or BG instructions.
Table 10-2: Software Speed Commands
The BG command enters a new desired speed value together with the acceleration and
deceleration limits. The AC acceleration is used to increase the absolute speed value,
while the DC deceleration is used to decrease the absolute speed value.
1. Has any new BG command been accepted by the software or hardware? If yes,
update the speed target to the value of JV, and also update the permitted
acceleration and deceleration to the values of AC and DC.
2. If the speed target and speed command are positive, and the speed target is greater
than the speed command, select AC for the acceleration limit. If the speed target and
speed command are negative, and the speed target is less than the speed command,
also select AC. Otherwise, select DC for the acceleration limit.
3. Advance the speed command towards the speed target as much as the selected
acceleration/deceleration permits. In a trivial case, in which the speed command
already equals the speed target, do nothing.
Example 1:
In order to demonstrate the concepts of target speed and the speed command — along
with AC and DC acceleration/deceleration limits — let:
MO=1; JV=4000; AC=100,000; DC=200,000; SD=106; PM=1; RM=0; SF=0; BG;
The following figure depicts how the speed command to the controller (DV[2]) tracks the
target speed specified by changing the JV parameter, followed by a BG.
1000
JV
DV [2]
500 DC
AC
AC
-500
-1000
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08
The speed reference to the controller may be changed any time, regardless of the
state of the profiler. In the previous figure, the required speed was changed at time
0.065, from -1000 to 0, before reaching the speed command of -1000.
SimplIQ Software Manual Unit Modes 10-5
MAN-SIMSW (Ver. 1.2)
Example 2:
This example demonstrates the smoothing filter and the smoothing factor SF:
MO=1; JV=4000; AC=100,000; DC=100,000; SD=1000000; PM=1; RM=0;BG
SF has three different values:
The SF=0 graph displays sharp corners, because smoothing is ignored, thereby
allowing non-continuity of acceleration.
The SF=10 graph takes 10 milliseconds more to stabilize the speed software
command; however, the speed reference profile is much smoother.
For the SF=50 graph, the smoothing is so strong with respect to total acceleration time
that the AC acceleration is never reached.
4000
3500
SF=0
3000 SF=10
Speed reference SF=50
(count/sec)
2500
2000
1500
1000
500
Time (sec)
0
0 0.02 0.04 0.06 0.08 0.1
The profiler smoothes the motion and decreases (and may also prevent) overshoots,
while introducing a delay in the controller response.
Parameters Description
AG[2] Analog input gain, counts/second/volt
AS[1] Analog offset
FR[2] Follower gain
KV[88]…KV[99] Filter for analog input
RM Reference mode:
1: Use auxiliary speed command
0: Null auxiliary speed command
Table 10-3: Auxiliary Speed Command Parameters
SimplIQ Software Manual Unit Modes 10-6
MAN-SIMSW (Ver. 1.2)
AS[1]
Speed
Auxiliary input FR[2]
estim ator
The analog input is must useful when the SimplIQ drive serves as an inner controller,
embedded in an external control loop. The auxiliary encoder speed input enables the
drive to issue speed commands relative to a conveyor or other moving object.
The filter is optional. You can design a linear arbitrary filter of an order up to 4, and use it
to filter the analog input for extra smoothness. The parameters of the filter are as follows:
Parameter Description
KV[88] 0: Do not use a filter (the filter is replaced by a unity gain).
100: Use the filter. KV[88]=100 synchronously enters all filter
parameters KV[89]…KV[99].
Parameters Description
SD Maximum motor acceleration/deceleration, in counts/second2
VL[2], VH[2] Speed command limit
IL[N] Input logic: defines digital inputs as hard stop or as direction limit
switches (RLS or FLS)
Table 10-4: Stop Manager Parameters
SimplIQ Software Manual Unit Modes 10-7
MAN-SIMSW (Ver. 1.2)
Stop condition
(Stop, RLS, FLS)
-
Com m and to
SD Speed Controller
Reference generator
Acceleration/Deceleration
output (software +
Lim iter
auxiliary)
LV[2],HV[2] speed lim iter
The stop manager prevents the speed controller command from changing abruptly by
limiting the rate of reference change to SD counts/second2. When the stop manager stops
the motor due to a switch action, the reference generator is replaced by a zero command
at the input to the stop manager. The stop manager uses the SD parameter to decelerate
the motor command from the output of the reference generator to a complete stop.
When the switch action terminates (a Stop switch is released, for example), the stop
manager uses the SD acceleration to recover the speed command to the output of the
reference generator. Stop manager operation includes the following factors:
The stop manager must limit the speed command to the range [VL[2]…VH[2]].
Although both the software speed command and the external speed command are
each limited to the legal range, their total value may be out of range.
When the stop manager stops the command to the speed controller, it does not affect
the reference generator, which continues to behave normally. When the switch action
is complete, the stop manager attempts to recover the speed controller command to
the output to the reference generator.
The stop manager limits the decelerations and accelerations due to abrupt changes of
the auxiliary reference. The SD parameter is the only acceleration limiter for the
auxiliary input. The AC and DC parameters are only relevant to software commands.
When AC and DC are greater than SD, they become irrelevant, because SD further
limits acceleration.
The IL[N] command can program a variety of stop options to an input pin. A pulse at
the pin can be directed to the stop manager (as in the following example), stop the
software reference generator, or both.
Example:
SD=100,000, MO=1, AC=10,000, DC=10,000, JV=5000, BG;
At the time of 0.2 seconds, a switch programmed as hard stop is activated, and released
at the time of 0.4 seconds. The following waveforms result:
SimplIQ Software Manual Unit Modes 10-8
MAN-SIMSW (Ver. 1.2)
5000
4500
3000
1500
1000
S top switc h
active
500
0
0 0.2 0.4 0.6 0.8 1
When the stop switch is applied, the speed command is brought to a complete stop,
decelerating at 100,000 counts/second2. When the switch is released, the acceleration of
100,000 counts/second2 is used to recover the output of the reference generator.
Specifying a higher motor current enables larger accelerations and decelerations, but also
causes a loss of more power in a steady state. In stepper mode, the stator field and rotor
magnet are nearly equal most of the time, and the motor efficiency is very low.
The SimplIQ drive uses stepper mode mainly for safe testing and controller tuning before
any feedback control is tuned. The SimplIQ drive can serve as an advanced micro-stepper
driver, with 1024 micro-steps per electrical revolution. The main limitation is that the
SimplIQ drive is a three-phase driver, while most stepper motors in the market are two-
phased.
SimplIQ Software Manual Unit Modes 10-9
MAN-SIMSW (Ver. 1.2)
Enable if
RM==1
Stepper angle
com m and
W S[20]
Auxiliary position Stop Current
com m and Σ m anager controller
1024 count
per electrical rev.
Software
position Sm oother
com m and
Torquecom m and
(DV[1], Am p)
Torque
com m and
The generation of the stepper angle command is similar to position command generation
in UM=5. The torque command is simply given by the TC command.
Acceleration
feed forward
d/dt FF[1]
Enable if
RM==1 d/dt FF[2] Speed
Error
Auxiliary
feedback
encoder
Generation of the position and speed commands is similar to the position and speed
command generation of UM=5 and is described in Chapter 12.
The speed command, multiplied by the gain FF[2], is fed as reference to the speed
controller in addition to position correction. Setting FF[2] exactly to the gear ratio
between the position sensor and the speed sensor prevents steady-state constant-speed
tracking errors.
The acceleration of the position command, multiplied by FF[1], can be injected directly as
a torque command. By default, FF[1]=0. The reference values to the position, speed and
torque controllers can be queried by DV[3], DV[2] and DV[1] respectively.
SimplIQ Software Manual Unit Modes 10-11
MAN-SIMSW (Ver. 1.2)
Enable if
RM==1 d/dt FF[2]
Speed
Error, for the
speed controller
Auxiliary position Stop Position
com m and Σ m anager Σ Controller Σ Σ
- -
DV[2]
DV[3]
Software Position
position Sm oother correction
com m and
The generation of the position and speed commands is described in Chapter 11.
The speed command, multiplied by the gain F[2], is fed as reference to the speed
controller, in addition to position correction. Setting FF[2] exactly to unity prevents
steady-state constant-speed tracking errors. The acceleration of the position command,
multiplied by FF[1], can be injected directly as a torque command. By default, FF[1]=0.
The reference values to the position, speed and torque controllers can be queried by
DV[3], DV[2] and DV[1] respectively.
SimplIQ Software Manual The Position Reference Generator 11-1
MAN-SIMSW (Ver. 1.2)
In order to initiate a software motion, its parameters must be initialized and a mode
command issued. The next BG (software, hardware or timed) will start the motion. The
following are the mode commands:
SimplIQ Software Manual The Position Reference Generator 11-2
MAN-SIMSW (Ver. 1.2)
Command Mode
ST Idle: ST stops any motion.
PA PTP: PA=n specifies a PTP motion, to absolute position n counts.
JV Jog: JV=n specifies a jog motion, at speed n counts/second.
PT PT: PT=n specifies a PT motion, beginning from the nth item in the PT
data table.
PV PVT: PV=n specifies a PVT motion, beginning from the nth item in the
PVT data table.
Table 11-1: Software Motion Mode Commands
PTP and jog motion commands can be sent anywhere, at any time. The drive will
calculate the path to be followed so that the desired speed or position is reached, subject
to the acceleration limits. PTP and jog motions can even be initiated during PVT or PT
motion. Care must be taken, however, if the smooth factor (SF) is nonzero. Upon
switching from interpolated motion to PTP or jogging, the PTP or jogging will start
unsmoothed, with smoothing gradually building up, until after SF milliseconds, the
motion is fully smoothed.
Care is also required when switching to tabulated (PT and PVT) motion modes. These
modes should be started only when the motor is at a complete stop (MS=0 or MS=1), at
the exact position specified as the first point for the PT or PVT. If the motor is not totally
stopped at the correct start position, the software reference will jump. The command to
the position controller will attempt to catch up with the PT or PVT motion, using the SD
acceleration (refer to section 11.3).
Feature PT PVT
Motion buffer length 1024 64
Position points in one CAN 2 1
message
Speed command calculation Automatic, by third-order Specified by user
interpolation
Acceleration command Automatic, by third-order Automatic, by third-order
interpolation interpolation
Time between user data Fixed multiple of the Specified by user
points 1 - 255 controller sampling independently for each
times. Cannot be changed motion interval, in msec.
on-the-fly. Range: [1…255] msec.
SimplIQ Software Manual The Position Reference Generator 11-3
MAN-SIMSW (Ver. 1.2)
Feature PT PVT
Cyclical motion support Yes Yes
On-the-fly motion Yes Yes
programming with
handshake host protocol
Table 11-2: Tabulated Motion Differences
Feature Preferred
Long preprogrammed motions PT
Ease of use PT
Variable command sampling time PVT
Motion design independent of controller sampling time PVT
Synchronized, multiple-axis motions PVT
Table 11-3: Tabulated Feature Preferences
Idle mode is the only mode in the parameters of the external reference generator can be
changed. This mode can be identified by the MS (motion status) variable, which can be
read as follows:
MS Value Description
0 Position reference generator is idle and motor position is stabilized
within target radius for a satisfactory length of time.
1 Position reference generator is idle or the motor is off (MO=0).
2 Position reference generator is active in one of the optional motion
profilers: PTP, jog, PT or PVT.
Table 11-4: Motion Status Indications
When MS is 1 or less, the parameters of the external reference generator can be switched.
The condition MS=0 implies that the motor position is indeed stabilized, meaning that
the motor position is within the target radius, for at least the target time. The target
radius is given by RS[1] counts, and the target time is TR[2] milliseconds.
SimplIQ Software Manual The Position Reference Generator 11-4
MAN-SIMSW (Ver. 1.2)
Example:
The concepts of target time and target radius are demonstrated in the following figure.
1400
1200
1000
Target
800
600
400
200
Time
0 0.011 0.012 0.046 0.050 0.074
In this figure, the motor position settles after overshooting the target of 1000 counts.
The target radius is 20. The motor position is within the target radius in the range of
[980…1020] counts.
Considering the dynamics of the example, it is reasonable to select the target time
TR[2]=30. If too low a value is selected for TR[2], false “on-target” decision may result.
For example, if the target time is set at 3 milliseconds, a final stabilization will be
concluded at the time of 0.049 seconds, because during the time interval [0.046…0.049],
the motor was within the allowed position error of [980…1020] counts.
The largest PTP motion available is (XM[2] - XM[1])/2, because with modulo calculation,
the PTP motion always goes the short way around. For example, if XM[1]=-500 and
XM[2]=500, the present position reference is 490 and the command PA= -490. When BG is
entered, the position reference increases and goes through 499 to -500, and then to -490.
The total length of the movement will be 20 counts.
SimplIQ Software Manual The Position Reference Generator 11-5
MAN-SIMSW (Ver. 1.2)
Parameter Action
AC Acceleration, in counts/second2
DC Deceleration, in counts/second2
SP Maximum speed, in counts/second
SF Smooth factor, in milliseconds
PR Relative position, in counts
PA Specifies that the next motion will be PTP, and the absolute target
position
Table 11-5: PTP Motion Parameters
The PA command plays more than one role. PA=n specifies that the next BG will start a
PTP motion. In addition, it specifies the target of the next PTP move.
PTP example:
The simplest point-to-point motion is from a stationary position to another stationary
position. The acceleration and final speed limits are:
AC=100,000, DC=200,000, SP=2000,
starting from PX=0 and PA=70; BG;
The following speed graph shows the acceleration, constant speed and deceleration in the
trajectory to the target.
SimplIQ Software Manual The Position Reference Generator 11-6
MAN-SIMSW (Ver. 1.2)
2000
C onstant speed
S peed (S P )
1000 A cceleration
(A C ) D eceleration
(D C )
0
0 0.01 0.02 0.03 0.04 0.05 0.06
100
P osition
50
0
0 0.01 0.02 0.03 0.04 0.05 0.06
With shorter movement, the deceleration begins before the speed limit is reached, so that the
SP speed limit is not effective. This situation is depicted in the following figure:
1000
S peed
500 DC
AC
0
Time (sec)
-500
0 0.01 0.02 0.03 0.04 0.05 0.06
10
P osition
5
Time (sec)
0
0 0.01 0.02 0.03 0.04 0.05 0.06
S tar t
S pe ed > S P ? Y es A p p ly D C
W ill s t e a d y
d e c e le r a t io n a t
No A p p ly D C
D C s to p m o tio n
b e f o r e ta rg e t ?
S pe ed = S P ? Y es M a in t a in S P
A p p ly A C
Note that in this example, the position reference overshoots the original position target of
100. This is because at the time that the position target was changed, the drive was
approaching the target using DC. When a new target is set, the drive exits the state of
final approach. Therefore, it uses the AC acceleration, which is smaller than DC in this
example. With the reduced acceleration, it cannot avoid the overshoot.
5000
AC DC
0 AC
-5000 DC
C ounts/sec
Time (S ec)
-10000
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
200
P osition reference
0
11.1.5 Jog
In a jogging motion, the motor receives a command to move at a fixed speed. The AC and
DC parameters indicate the acceleration or deceleration to the desire speed.
Jog motions may be initiated any time by using the JV command, and not necessarily
from a stationary state. The jog mode decisions, made every position control cycle, are
given in the following flowchart.
Start
JV > 0 and
Yes Apply DC
Speed > JV?
JV< 0 and
Yes Apply DC
Speed < JV?
Apply AC
All parameters in the flowchart — including AC, DC, JV and the position target — are
updated by a BG command or by its hardware equivalent (refer to the IL[N] command in
the SimplIQ Command Reference Manual).
Jog motions can continue indefinitely. The position reference jumps by XM[2] - XM[1]
when it reaches the modulo boundary, but the speed remains constant. The jog motion
parameters are summarized in the following table:
Parameter Action
AC Acceleration, in counts/second2
DC Deceleration, in counts/second2
SF Smooth factor, in milliseconds
JV Jog velocity
Table 11-6: Jog Motion Parameters
The JV command specifies that the next motion will be a jog, and also what speed the jog
will target.
SimplIQ Software Manual The Position Reference Generator 11-9
MAN-SIMSW (Ver. 1.2)
3000
JV =3000
DC
2000 AC
C ounts/sec
1000 JV =1500
Time (sec)
0
0 0.02 0.04 0.06 0.08
150
100
P osition reference
50
Time (sec)
0
0 0.02 0.04 0.06 0.08
A PTP motion begins, during which the drive brings the reference position to the position
target. At the time of 0.055 seconds (where the plot of the position target terminates in the
following figure), the command JV=-2000; BG; is entered. The drive uses the AC
acceleration to reach the desired speed. If, at the time of the BG, the speed of the position
reference is more negative than -2000 the drive will use the DC parameter instead of AC.
4000
C ounts/sec
2000
Time (sec)
-2000
0 0.1 0.2 0.3 0.4
100
0
P osition reference
C ounts
-200 Time (sec)
0 0.05 0.1 0.15 0.2 0.25
SimplIQ Software Manual The Position Reference Generator 11-10
MAN-SIMSW (Ver. 1.2)
The ability to relate PVT motions to absolute time makes them ideal for tightly-
synchronized multiple-axis motions. For an explanation of how to synchronize the
absolute time counters of multiple drives to the precision of a few microseconds, refer to
the Elmo CAN Implementation Manual.
Example 1:
The system should be at position 1000 and speed 100,000 counts/second at a given time,
and at position 1620 and speed 110,000 counts/seconds 6 milliseconds later.
The time is defined in milliseconds, not in drive sampling times. The drive interpolates
the motion specification in order to calculate the desired position and speed at the
sampling instances, when it needs the information.
PVT implements a third-order interpolation between the position - speed data provided
by the user. For each motion interval, the user specifies the boundary positions and
speeds. Mathematically, the user provides the following data:
Starting position and speed, denoted by P0 and V0, respectively
End position and speed, denoted by PT and VT, respectively
If t 0 denotes the starting time and T denotes the length of the time interval,
the position for t ∈ [t 0, t 0 + T] is given by the third-order interpolating polynomial:
P(t) = a(t – t 0)3 + b(t – t 0)2 + c(t – t 0) + c
The four parameters a, b, c and d are unknown and can be solved using the following
four linear equations:
P(t 0) = P0, namely, d = P0
V(t 0) = V0, namely, c = V0
P(t 0 + T) = PT, namely, PT = aT3 + bT2 + cT + d
V(t 0 + T) = VT, namely, VT = 3aT2 + 2bT + c
Example 2:
This example demonstrates how a very few points can accurately describe a smooth and
long motion path.
Two drives, driven synchronously, draw an ellipse. One drive drives the x-axis and the
other drives the y-axis. The long axis of the ellipse is 100,000 counts long and the short
axis of the ellipse is 50,000 counts long. The entire ellipse is to be traveled within 2.2
seconds.
A PVT motion is planned with a fixed inter-point time of 100 milliseconds. For the entire
ellipse, 23 points are sufficient, as depicted in the following figures. The motion is
planned so that the tangential speed is accelerated to a constant rate, and then
decelerated back to zero at the end of the ellipse. Near the starting point of the ellipse, the
speed is slow; therefore, the PVT points — which are equally spaced in time — are more
spatially dense in that area. The continuous line in the following figure depicts the true
ellipse along with the ellipse generated by the drive by interpolating the PVT points.
The original ellipse and the drive interpolation of the PVT points are so close that they
cannot be differentiated on the plot, as seen in the following depiction of the ellipse.
4
x 10
4
2
Nominal ellipse
1
-2
-3
-4
-4 -2 0 2 4
4
x 10
The following figure takes a closer look at the error between the true ellipse and the
drive-interpolated path.
SimplIQ Software Manual The Position Reference Generator 11-12
MAN-SIMSW (Ver. 1.2)
5 D ifference
(counts)
4
1
msec
0
0 500 1000 1500 2000 2500
It can be seen that with only 23 PVT points, the interpolated path never differs from the
original ellipse by more than 8 counts (remember that the ellipse axes are 100,000 and
50,000 counts respectively)! At the PVT points, the interpolation error is zero.
The next figure displays the interpolated trajectories generated by the drive for the x-axis
and for the y-axis.
4
x 10
6
X axis trajectory
4
-2
C ounts
Y axis trajectory
-4
msec
-6
0 500 1000 1500 2000 2500
Example 3:
The drive normally produces maximally smooth interpolating trajectories, which is why
the ellipse in the previous example could be interpolated using so few points. Accurate
corners, however, require non-smooth interpolation. Specifying zero speed for the corner
points generates hard corners. The following graph shows a 2-axis synchronized PVT
trajectory of an accurate rectangle.
SimplIQ Software Manual The Position Reference Generator 11-13
MAN-SIMSW (Ver. 1.2)
4
x 10
2
C ounts
1
0 Rectangle
-1
C ounts
-2
-3 -2 -1 0 1 2 3
5 4
x 10 x 10
2
C ounts/sec
1
-1 x speed
y speed
P VT points
-2
0 5 10 15 20 25
For the corner points both the x and y speeds are specified to zero. The interpolation
error for the entire rectangle is zero.
Example 4:
A PVT interpolation interval contains these values:
Starting position = 1000 counts
Starting speed = 100,000 counts/second
End position = 1200 counts
End speed = 190,000 counts/second
Time = 6 milliseconds
The interpolated path for the data of the table, for a controller with a sampling time of
160 milliseconds, is depicted in the following figure. The + symbols indicate the points at
integer multiples of the controller sampling time. At these points, the drive evaluates the
interpolated motion path.
The end point does not necessarily fall on a controller sampling time. Strange-looking
position commands may result if the speed choice is not consistent with the position and
time definitions. The position distance and the time between points imply an average
speed of (1200 - 1000)/0.006 = 33,000 counts/second. This average conflicts with the
boundary point speed specifications of 100,000 counts/second and 190,000 counts/sec,
respectively.
SimplIQ Software Manual The Position Reference Generator 11-14
MAN-SIMSW (Ver. 1.2)
1200
1180
1160
1140
1120 Position
1100
1080
1060
1040
1020
1000 Time
0 1 2 3 4 5 6
The table has 64 rows, enabling the specification of up to 63 consecutive PVT motion
segments (64 segments if the table is used cyclically). The cells of the table may be
accessed using the QP, QV and QT commands:
The QP[N] command sets/reads the nth row of the P column.
The QV[N] command sets/reads the nth row of the V column.
The QT[N] command sets/reads the nth row of the T column.
The first PVT point must be within the range XM[1]…XM[2]. the remaining PVT points
need not be within modulo range; but the difference between consecutive PVT position
points must be less than(XM[2] - XM[1])/2. For example, suppose that XM[1] = 0 and
XM[2] = 1000. If the PVT describes a trajectory beginning at 0 and ending at 10,000, the
motor will travel 10,000 counts, fully completing its position range 10 times.
SimplIQ Software Manual The Position Reference Generator 11-15
MAN-SIMSW (Ver. 1.2)
When the time period specified by QT[N] elapses, the N segment is complete, the drive
increments the read pointer to N+1, and then reads the N+2 PVT table row in order to
calculate the parameters of the next motion segment.
The entire PVT table need not be used for a given motion. Its use is defined by the
following parameters:
Parameter Use
MP[1] Lowest valid row of the PVT table
MP[2] Highest valid row of the PVT table
MP[3] A bit field:
Bit 0 is:
0: Stop motion if read pointer reaches MP[2]
1: Continue motion when read pointer reaches MP[2]. The next row of
the table is MP[1].
Bit 1 is:
0: PVT motion not expected to terminate. Issue an exception if it does.
1: PVT motion expected to terminate. When all data in PVT table has
been used, exit PVT mode to Idle mode without issuing an emergency
object.
Figure 11-4: PVT Motion Parameters
The following flowchart depicts the basic PVT mode. It assumes that the commands
PV=N; BG; were entered, with 1 < N < 64.
The command PV=N sets the read pointer of the table to N and specifies that the next BG
will start a PVT motion. BG then starts the motion.
The PVT table may be written online while PVT motion is being carried out. An infinite
non-periodic motion can be generated in cyclical mode (MP[3]=1) by programming the
PVT table on-the-fly.
2The PVT mode may be cyclical, according to MP[3]. In this case, N+1 must be interpreted in
the modulo sense.
SimplIQ Software Manual The Position Reference Generator 11-16
MAN-SIMSW (Ver. 1.2)
Initial
conditions:
PVT read
pointer equals
N
Motion
segment
completed
?
Yes
Yes
Interpolate
position
command
Go to
position
controller
The host must know how much free place is available in the PVT table in order to
continue programming an executing PVT motion. This is achieved most efficiently by
tracking the table read and write pointers. The host is aware of the write table status,
because it controls writing to the table. If there is a doubt, the host can query MP[6]. The
PV command is used to query the read pointer.
The read and write pointers can be mapped to a synchronous PDO, so that a CAN master
can efficiently and continuously stay informed about the status of multiple drives
running PVT in parallel in a network. Rather than polling the status of the PVT motion
continuously, the host can use the queue underflow CAN emergency object as a request
to refill the PVT table.
SimplIQ Software Manual The Position Reference Generator 11-17
MAN-SIMSW (Ver. 1.2)
An unused part of the PVT table may be programmed for the next motion while the
present motion is executing. An attempt to modify the data of an executing motion
segment generates an error.
With an RS-232 ASCII communication interface, a single PVT table row is programmed
with the following format:
QP[xx] = xxx,xxx,xxx; QV[xx] = x,xxx,xxx; QT[xx] = xxx;
Up to 40 characters may be required to program a single PVT table row. At a
communication rate of 19,200 baud, this may take 20 milliseconds. At a communication
rate of 115,200 baud, this may take 4 milliseconds.
The CAN communication option allows must faster PVT table programming, by packing
an entire PVT table row into one PDO communication packet. For easy synchronization
with the host, the drive may be programmed to send the PVT read and write pointers
continuously to the host as a synchronous PDO, or to send an emergency object
whenever the number of yet unexecuted motion segments falls below a given threshold.
The PDO does not specify the PVT table row to be programmed; instead, a write pointer
specifies the row. The parameter MP[6] initially sets the write pointer. A new PVT
CANopen message (object 0x2001) write the data to the table row indicated by MP[6] and
then automatically increments MP[6]. The CANopen auto-increment mode is described
in the following flowchart:
Initial
conditions:
PVT read
pointer equals
N
Motion
segment
completed
?
Yes
Exit PVT mode:
Read pointer == Set Stop motion,
Yes
Write pointer using the SD
deceleration
No
EMERGENCY:
QUEUE
UNDERFLOW
Set the read
Increment
pointer to
read pointer
No MP[1]
MP[4]>0 and
(Write pointer == EMERGENCY:
Yes
N+1 or QUEUE LOW
left time < MP[4])
No
Interpolate
position
command
Go to
position
controller
Set the QP[N], QV[N] and QT[N] array elements for at least the first two rows of the PVT
table. This is needed because PVT requires at least two time points for interpolating the
motion trajectory.
When object 0x2001 is used to feed PVT reference points to the drive while a PVT motion
is executing, the drive automatically enters Online Feed mode, in which the drive is
aware of the position written and takes the following precautions:
If the feed is too slow, so that the drive must fetch unprogrammed points, the motion
will abort with a “Queue underflow” emergency.
If the feed is too fast, so that points not yet used by the drive are overstruck, the drive
will reject the feed attempt with a “Queue overflow” emergency.
The Online Feed mode will continue until the end of the current PVT motion and will not
be applied to the next motion.
To stay informed about how the PVT motion is advancing, the read and write PVT table
pointers can be received continuously, mapped to a synchronous PDO, or the “Queue
low” emergency signal can be used to indicate the need for more data. The “Queue low”
emergency message includes the present location of the read pointer and the write
pointer. It is safe to send more PVT data PDOs until the write pointer is one location
before the read pointer specified by the “Queue low” emergency message.
The host is well aware of the location of the write pointer, because it can count its own
messages. However, a data message may be rejected because the queue is full, or because
a message has been lost. In such a case, the drive issues an emergency object to the host.
After receiving the object, the true location of the write pointer may be unclear. The host
may then set MP[6] to the possibly-rejected table row and continue writing from there.
SimplIQ Software Manual The Position Reference Generator 11-20
MAN-SIMSW (Ver. 1.2)
MP[5] (number of rows remaining for “Queue low” emergency) should not be set to too
high a value. For example, consider a slow-responding host that manages a 64-row PVT
queue in the drive. Suppose that the PVT row times are 10 milliseconds each and that
MP[5] = 55. The host receives a “Queue low” emergency object notifying it that there are
64 - 55+1 = 8 free programmable rows in the PVT table. Suppose that the host takes 50
milliseconds to respond, and 5 milliseconds to program each row. The 8 rows will have
been programmed after 90 milliseconds. In the meantime, 9 additional PVT table rows
will have been executed, and there are only 54 valid rows in the PVT table. Because 54 is
lower than MP[5], there will be no more “Queue low” emergency messages until the PVT
table is exhausted, and PVT mode is terminated. The situation can be remedied if the host
requests the drive for a PV (location of read pointer) after the PVT table writes are
complete. If PV < MP[5], the programming process has taken too much time, and the
writing must be continued.
Accurate timing with respect to the host is the essence of multiple-axis synchronized
motion. Such timing can be achieved by using the CAN SYNC signal and the CAN
synchronized BG service, as described in the Elmo CAN Implementation Manual.
Error Error
Code Code
(Hex) (Dec) Reason Data Field
0x56 86 Queue is low. Number of yet Field 1: Write pointer
unexecuted PVT table rows has Field 2: Read pointer
dropped below the value stated in
MP[4].
0x5b 91 Write pointer is out of physical range Value of MP[6]
([1…64]) of PVT table. Reason may be
an improper setting of MP[6].
0x5c 92 PDO 0x3xx is not mapped.
0x34 52 An attempt has been made to program Field 1: Index of PVT table
more PVT points than are available in entry that could not be
queue. programmed
0x7 7 Cannot initialize motion due to bad
setup data. The write pointer is outside
the range specified by the start and end
pointers.
0x8 8 Mode terminated and motor has been Data field 1: Write pointer
automatically stopped (in MO=1).
Data field 2:
1: End of trajectory in non-
cyclical mode
2: A zero or negative time
specified for a motion
interval
3: Read pointer reached
write pointer
0x9 9 A CAN message has been lost.
Figure 11-8: PVT CAN Emergency Messages
Let T = m * Ts
where:
Ts is the sampling time of the position controller. The parameter WS[28] reads Ts.
T is the sampling time of the PT trajectory.
m (system parameter MP[4]) is the integer parameter that relates Ts and T.
For m = 1, no interpolation is required. For m > 1, there are certain sampling instances of
the position controller for which the path command must be interpolated, using a third-
order polynomial interpolation.
These four requirements exactly suffice for solving the third-order interpolating
polynomial.
Example:
Consider the position controller reference signal P(t) - sin(2π * 10t)
where t is the time in seconds.
The controller sampling time is 200 microseconds and the path is programmed with a
data point once per MP[4] = 50 controller sampling times (10 milliseconds). The PT
reference points are depicted as circles in the following graph. The path interpolated by
the drive is shown as a solid line.
SimplIQ Software Manual The Position Reference Generator 11-23
MAN-SIMSW (Ver. 1.2)
1000
Interpolated path
800 PvtPlan output
600
400
200
0
Motion path in counts
-200
-400
-600
-800
Time (seconds)
-1000
0 0.02 0.04 0.06 0.08 0.1
The first PT point must be within the range XM[1]…XM[2]. The remaining PT points
need not be within modulo range; but the difference between consecutive PT position
points must be less than (XM[2] - XM[1])/2. For example, suppose that XM[1] = 0 and
XM[2] = 1000. If the PT describes a trajectory beginning at 0 and ending at 10,000, the
motor will travel 10,000 counts, completing its position range 10 times.
3The PT mode may be cyclical, according to [MP3]. In this case, N+1 must be interpreted in
the modulo sense.
SimplIQ Software Manual The Position Reference Generator 11-24
MAN-SIMSW (Ver. 1.2)
Initial
conditions:
PT read
pointer equals
N
Motion
segment
completed
?
Yes
Exit PT mode:
Set Stop motion,
N >= MP[2]-1 Yes MP[3]==1 No
using the SD
deceleration
Yes
Interpolate
position
command
Go to
position
controller
a. Mode Termination
The PT motion terminates when one of the following occurs:
The motor is shut down, either by programming MO=0 or by an exception.
Another mode of motion is set active; by programming PA=xxx; BG, for example. In
this case, the new motion command executes immediately, without having to
explicitly terminate the PT mode.
The PT motion manager runs out of data. This occurs when the read pointer reaches
MP[2] and MP[3] is zero. This may also occur in auto-increment mode (CAN
communications only) if the read pointer reaches the write pointer. In that case, the
PT motion is stopped immediately, using the SD deceleration. Note that if the last
programmed PT speed is zero, the PT motion terminates neatly.
The CAN communication option allows must faster PT programming, by packing two
position points into one PDO communication packet. For easy synchronization with the
host, the drive may be programmed to send the PT read and write pointers continuously
to the host as a synchronous PDO, or to send an emergency object whenever the number
of yet unexecuted motion segments falls below a given threshold.
The PDO does not specify the QP vector elements to be programmed; instead, a write
pointer specifies them. The parameter MP[6] sets the value of the write pointer, which
may be set once for the entire motion. The write pointer is incremented automatically by
two each time the drive receives a new PT motion-programming message. The CANopen
auto-increment mode is described in the following flowchart:
Initial
conditions:
PT read
pointer equals
N
Motion
segment
completed
?
Yes
Exit PT mode:
Read pointer == Set Stop motion,
Yes
Write pointer using the SD
deceleration
No
EMERGENCY:
QUEUE
UNDERFLOW
Set the read
Increment
pointer to
read pointer
No MP[1]
MP[4]>0 and
(Write pointer == EMERGENCY:
Yes
N+1 or QUEUE LOW
left time < MP[4])
No
Interpolate
position
command
Go to
position
controller
Set QP[N] for at least the first two points in the PT motion. This is needed because the PT
algorithm requires at least two time points for interpolating the motion trajectory. Set at
least three points if the speed at the second point is to be continuous.
When object 0x2002 is used to feed PT reference points to the drive while a PT motion is
executing, the drive automatically enters Online Feed mode, in which the drive is aware
of the position written and takes the following precautions:
If the feed is too slow, so that the drive must fetch unprogrammed points, the motion
will abort with a “Queue underflow” emergency.
If the feed is too fast, so that points not yet used by the drive are overstruck, the drive
will reject the feed attempt with a “Queue overflow” emergency.
The Online Feed mode will continue until the end of the current PT motion and will not
be applied to the next motion.
To stay informed about how the PT motion is advancing, the read and write PT table
pointers can be received continuously, mapped to a synchronous PDO, or the “Queue
low” emergency signal can be used to indicate the need for more data. The “Queue low”
emergency message includes the present location of the read pointer and the write
pointer. It is safe to send more PT data PDOs until the write pointer is one location before
the read pointer specified by the “Queue low” emergency message.
The host is well aware of the location of the write pointer, because it can count its own
messages. However, a data message may be rejected because the queue is full, or because
a message has been lost. In such a case, the drive issues an emergency object to the host.
After receiving the object, the true location of the write pointer may be unclear. The host
may then set MP[6] to the possibly-rejected table row and continue writing from there.
SimplIQ Software Manual The Position Reference Generator 11-28
MAN-SIMSW (Ver. 1.2)
Error Error
Code Code
(Hex) (Dec) Reason Data Field1
0x56 86 The time for the entire remaining valid PT Time (milliseconds)
program has dropped below the value remaining with valid
stated in MP[4]. motion program.
0x5b 91 Write pointer is out of physical range Value of MP[6]
([1…1024]) of QP vector. Reason may be
an improper setting of MP[6].
0x5c 92 PDO 0x3xx is not mapped.
0x34 52 An attempt was made to program more Index of PT table entry that
PT points than supported by queue. could not be programmed
0x7 7 Cannot initialize motion due to bad setup
data. The write pointer is outside the
range specified by the start pointer and
the end pointer.
0x8 8 Mode terminated and motor has been Read pointer.
automatically stopped (in MO=1).
Reasons:
End of trajectory in non-cyclical mode
(MP[3] = 0 ) [additional code 1]
A zero or negative time was specified
for a motion interval [additional code 2]
Read pointer reached write pointer
[additional code 3]
Figure 11-12: PVT CAN Emergency Messages
Auxiliary encoder
FR[3]
input
DV[6]
Auxiliary position
command
Parameter Action
FR[3] Scale the auxiliary encoder input. Applicable only if the auxiliary
encoder is not used for position feedback.
EM[1] Define whether the ECAM table transforms the external reference:
EM[1]=0: Do not use ECAM table.
EM[1]=1: Use linear ECAM table to transform external command.
EM[1]=2: Use cyclical ECAM table to transform external command.
RM Define whether an external reference is used:
RM=0: Do not use external reference.
RM=1: Use external reference.
DV[6] Reads the external position reference.
Table 11-9: Position Reference Parameters
11.2.1 Follower
In Follower mode (RM=1, EM[1]=0), the external speed command tracks the auxiliary
encoder speed at a ratio of FR[3], as depicted in Figure 11-14. In this figure, the auxiliary
encoder counts PY modulo in the range [0…500]. The derived external position reference
advances at the same rate as the auxiliary encoder while FR[3]=1. Jumps in PY due to the
modulo count are not reflected in auxiliary position reference DV[6]. When FR[3] changes
to 2, DV[6] advances at twice the speed of PY.
SimplIQ Software Manual The Position Reference Generator 11-31
MAN-SIMSW (Ver. 1.2)
1800
PY - Auxiliary Position
DV[6] - External Position Reference
1600
1400 FR[3]
changes
1200
1000
FR[3]=1 FR[3]=2
800
600
400
200
0
0 0.005 0.01 0.015 0.02 0.025 0.03
Time
Example:
This example illustrates how a moving object is handled by the application:
Moving conveyer
Circle to
draw
Y axis
10000
Cake
X axis
In this application, an x-y stage draws a chocolate picture on a cake while the cake travels
on a conveyor. The drawing must be accurate with respect to the cake.
In order to draw a circle of radius 10,000 encoder counts on the cake in one second, the
x-axis motor must follow the trajectory:
x(t) = 10,000 * cos(2πt) + c(t)
where c(t) is the position of the conveyor.
If the conveyor has an encoder, it can be used to compensate for its motion.
SimplIQ Software Manual The Position Reference Generator 11-32
MAN-SIMSW (Ver. 1.2)
Suppose that the resolution of the conveyor encoder is similar to the resolution of the
x-axis encoder. To draw an exact circle on the moving cake, the motion 10,000 * cos(2πt) is
programmed as PVT and RM=1, FR[3]=1.
4
x 10
4
x motor motion command
3
C onveyer position, as measured
by the auxiliary encoder input
2
0 x motion
relative to cake
Time (sec)
-1
0 0.2 0.4 0.6 0.8 1
11.2.2 ECAM
ECAM is an acronym for electronic CAM, in which the position reference to the drive is
not directly proportional to the total external inputs, but is rather a function of them.
Commands Action
EM[1] Indicates whether the ECAM function is active:
2: ECAM is cyclical.
1: ECAM is linear.
0: Direct external referencing.
Set EM[1] to synchronously activate the most recent settings of EM[2],
EM[3], EM[4], EM[5] and EM[7].
EM[2] Last valid index of ECAM table. Maximum for EM[2] is 1024.
The EM[2] setting goes into effect only at next setting of EM[1] or next
MO=1.
EM[3] Starting position: value of the input to the ECAM function for which
the output of the ECAM function will be ET[EM[5]] (ET of EM[5]).
If EM[3] is out of range for PY, it will be taken modulo PY.
EM[4] Table difference (see sections 11.2.2.1 and 11.2.2.2).
The EM[2] setting goes into effect at next setting of EM[4] or next
MO=1.
SimplIQ Software Manual The Position Reference Generator 11-33
MAN-SIMSW (Ver. 1.2)
Commands Action
EM[5] First valid index of ECAM table.
The EM[2] setting goes into effect at next setting of EM[5] or next
MO=1.
EM[6] Write pointer for fast loading of ECAM table via CAN bus (see section
11.2.4).
EM[7] Last interval shortening. EM[7] allows the ECAM table length (ECAM
cycle in the EM[1]=2 cyclical mode) not to be an integer multiple of
EM[4] (see sections 11.2.2.1 and 11.2.2.2).
EM[8] Reports present executing segment of ECAM table. Used to determine
if an action is executing or is complete.
Table 11-10: ECAM-related Commands
The input to the ECAM table (IET) is FR[3] * (auxiliary encoder - EM[3]).
The ECAM table defines the external position reference for IET values between 0 and
IETmax = (EM[2] - EM[5]) * EM[4] - EM[7].
The output of the ECAM table does not need to be in the range of the main position
sensor (refer to the XM[N] command section in the SimplIQ Command Reference Manual). If
the output of the ECAM table is out of the position sensor range, it is interpreted modulo
the position sensor range.
SimplIQ Software Manual The Position Reference Generator 11-34
MAN-SIMSW (Ver. 1.2)
Example 1:
The following figure illustrates the behavior of linear ECAM for EM[5]=1 and EM[2]=4.
External position com m and
ET[3]
ET[4]
ET[2]
EM[4]-EM[7]
EM[4]
ET[1]
EM[4]
0 IETmax
Example 2:
Consider an application in which a two-axis x-y servo system is used to plot chocolate
bears on birthday cakes:
Eyes
Head contour
Cake
moves
The cakes come from the oven on a conveyor. An incremental encoder measures the
position of the conveyor. Each time a new cake arrives, it activates the DIN#1 input of the
drive. In response to DIN#1, the x-y axes begin to contour the head of the bear, drawing
it with chocolate. The chocolate flow is stopped while the x-y axis travels towards the
start of the bear eyes. After the eyes are drawn, the x-y stage returns to its initial position,
ready for another cake.
Both drives that manage the x and y axes operate in ECAM mode. They get their position
reference as a function of the location of the conveyor, via the auxiliary encoder input.
The ECAM motion starts when a cake arrives at the plotting station and continues until
the conveyor travels 4000 counts.
SimplIQ Software Manual The Position Reference Generator 11-35
MAN-SIMSW (Ver. 1.2)
One of the drives uses a digital output to control the flow of the chocolate out of the
drawing nozzle.
In each master period (in which the master completes a travel of IETmax/FR[3] counts),
the slave advances by ET[EM[2]] - ET[EM[5]]. The following figure illustrates the
behavior of cyclical ECAM for EM[5]=1 and EM[2]=4.
SimplIQ Software Manual The Position Reference Generator 11-36
MAN-SIMSW (Ver. 1.2)
ET[EM[2]]-ET[EM[5]]
External position com m and
ET[3]
ET[4]
ET[2]
EM[4]-EM[7]
EM[4]
ET[1]
EM[4]
0 IETm ax 2 IETm ax
Note that the external position command is summed from the ECAM table outcome and
a cumulative offset, which is n x (ET[EM[2]] = ET[EM[5]]) with n being an integer.
When the cumulative offset is lost, and if the software reference generator is not running
an interpolated mode, the software reference is automatically adjusted by the same value
so that the motor will not jump (refer to section 11.2.5.1).
Example:
In the previous example of the chocolate bear, it was assumed that the bear drawing
could be programmed one time only. In many food applications, however, the products
to be worked on (the cake in the example) are not placed exactly on the conveyor or their
shapes may be irregular. A camera images the next coming product and the image is
analyzed to form the next motion path. The motion path for the analyzed image is
communicated to the drive by the system controller while the drive works on a
previously-programmed path, as depicted in the following figure:
CAN
Cam era
Assume that the drive at the x-y manipulator station runs ECAM table entries
ET[1]…ET[100]. In the meantime, the system controller programs the next shape to run
ET[101]…ET[200]. The preferred method to achieve this is to use the fast CAN ECAM
points protocol. While the x-y manipulator works on ECAM table entries
ET[101]…ET[2000], the system controller programs ET[1]…ET[100] again, and so on.
The AUTO_RLS program of the previous example is now slightly modified to:
function AUTO_I1 DIN#1 has operated an already-programmed HY
homing process to synchronize the following input.
EM[5]=1 + NextSegment * 100; EM[2]=100 * (1 + NextSegment);
EM[1]=1…OB[1]=1; FR=1;
The system controller manipulates the user program
variable NextSegment to signal which part of the table
to use next. The AUTO_I1 line selects the ECAM table
portion to use by NextSegment, and then sets EM[1]=1
to activate the new used portion, activating the follower
gain and the chocolate flow.
until (PY >= 2000) Wait until end of head contour.
… Continue as in previous example.
return
SimplIQ Software Manual The Position Reference Generator 11-38
MAN-SIMSW (Ver. 1.2)
The PDO writes the ET vector at the positions specified by EM[6]. After the PDO, EM[6]
increments automatically so that the next PDO will write consecutive places in the ET
vector. For example, if EM[6]=10, writing CAN object 0x2003 will fill data into ET[10] and
ET[11]. After writing, EM[6] will automatically update to 12.
Fast writes to the ECAM table are not protected against writing to the active part of
the ECAM table.
4 The other mapping options of this PDO write to the PT and PVT motion tables.
SimplIQ Software Manual The Position Reference Generator 11-39
MAN-SIMSW (Ver. 1.2)
To prevent the motor from jumping, the initial software reference is automatically set to
the present position of the motor, and the software command remains stationary until a
motion instruction is accepted. After setting MO=1, the motion mode is idle so that
sending a BG command without the prior specification of another motion mode will not
launch any motion.
Example 1:
Suppose that MO=0, RM=0 and PX=1000 (motor is off, no external reference, present
position is 1000 counts). Entering MO=1 will automatically set the software position
reference to 1000 counts, in Idle mode. The command sequence PA=0;BG will launch a
PTP motion from the position of 1000 counts to the zero position.
Example 2:
Suppose that MO=0, RM=1, FR[3]=1, PY=3000 and PX=1000 (motor is off, external
reference is generated by auxiliary encoder input with a unit follower ratio, the auxiliary
position is 3000 and the present position is 1000 counts). Entering MO=1 will
automatically set the software position reference so that the total position reference will
equal PX, Therefore, the initial, automatic software command will be:
PX - FR[3] * PY = 1000 - 1*3000 = -2000.
If the auxiliary encoder input is stable, the command sequence PA=0,BG will launch a PTP
motion from the position of 1000 counts to the position of 3000.
Parameter Description
FR[N] Follower ratio
EM[N] ECAM parameters
HY[N] Reading of auxiliary encoder
Figure 11-17: External Reference Parameters for On-the-fly Changes
SimplIQ Software Manual The Position Reference Generator 11-40
MAN-SIMSW (Ver. 1.2)
Example:
Consider a manipulator that works a conveyor. Whenever a box arrives, the roller prints
a label on the box. The roller turns continuously at the following line speed:
FR[3] = (counts per roller revolution) / (conveyor encoder counts/mm*2*π*r(mm)).
In order to print the label in the correct place, the roller position must be zero at the point
in which the sensor senses the next box. When a new box arrives, it homes the auxiliary
encoder to read zero.
Auxiliary
Am plifier
hom e
Painting roller
Auxiliary
encoder
input Motor
At the time of auxiliary homing (when a new box arrives at the sensor), the external
reference jumps by PY*FR. The software command to the roller jumps in parallel by
-PY*FR, so that the roller continues to turn normally.
Limits the magnitude of the controller command to the maximum allowed range.
This is necessary because even if the software command is generated within the
permitted limits and the external command is also within the permitted limits, their
total value may exceed the permitted limits.
The stop manager prevents the position reference generator from driving the motor to
undesired positions. It does not affect the reference generator.
Command Description
SD Maximum rate that the motor can accelerate/decelerate
IL[N] Input logic: define the functions associated with the digital inputs
VH[N], VL[N] Maximum allowed controller command
XM[N], YM[N] Modulo count for main and auxiliary sensors
Table 11-11: Stop Manager Commands
The clipping is necessary because, in some circumstances (explained previously), the sum
of the software command and the external command, or even the software command
alone, may exceed the command limits.
The rate and acceleration limiter block intervenes in the following situations:
The position command to the controller experiences an abrupt change; for example,
when a Hard Stop switch is sensed or when a Hard Stop switch is released.
The reference generator tries to control the motor in the permitted position range, but
at too great a speed.
The position command moves towards its permitted boundary (VL[3] or VH[3]) at a
speed greater than can be braked until the boundary with SD acceleration. For
example, near VH[3], the upper speed limit may be much lower than VH[2]. When
the position command equals VH[3], the maximum allowed speed command is zero.
Example:
The software reference generator generates a sine, using PVT.
The low position limit is VL[3]= -5000. The input to the stop manager and its output
(the position command to the controller) are depicted in the following figure:
SimplIQ Software Manual The Position Reference Generator 11-43
MAN-SIMSW (Ver. 1.2)
4
x 10
8
2
Counts
-2
-4
-6
-8
0 0.5 1 1.5 2 2.5 3
S ec
The input of the stop manager (the output of the position reference generator) is the red
solid line, and the output of the stop manager is the green dashed line. At the time of 0,
the PVT starts at position 17,000. The stop manager catches up with the sinusoidal
command, with an acceleration limit of SD. At the time of 1 second, a Hard Stop switch
becomes active and remains active until the time of 1.2 seconds. The stop manager
decelerates the position command to zero speed, using the SD deceleration. At the time
of 1.2 seconds, the stop manager begins to catch up again with the PVT reference, at SD
acceleration.
At the time of approximately 1.7 seconds, the PVT reference nears the limit of
VL[3]= -5000. Before the reference waveform actually reaches -5000, the stop manager
finds that the speed is too great for stopping at VL[3] with a deceleration of SD. It
therefore reduces the speed, coming to a complete stop at VL[3] with very small or no
overshoot.
At approximately 2.75 seconds, the stop manager finds that although the position
reference is not yet in range, it will be, in a short time. The stop manager begins to
accelerate the motor into the permitted range so that catching up when the reference
returns to range will be immediate, without the delay of acceleration.
SimplIQ Software Manual The Position Reference Generator 11-44
MAN-SIMSW (Ver. 1.2)
7
x 10
2
1.5
0.5
Counts/s ec
-0.5
-1
-1.5
-2
0 0.5 1 1.5 2 2.5 3
S ec
The most common examples of modulo counting are rotary pointing equipment such as
radar pedestals, camera pointers or rotary robot axes. In this type of equipment, the
position is normally counted modulo the mechanical rotation of the load. When the load
points in a given direction, the encoder readout is always the same, no matter how many
full rotations have been made.
The SimplIQ drive counts position cyclically; all software position modes handle cyclical
position counting. Point-to-point position motions always go the short way around.
Command Description
XM[N] Modulo count limits for main position counter. Main position
counting range is [XM[1]…XM[2]].
YM[N] Modulo count limits for auxiliary position counter. Auxiliary position
counting range is [YM[1]…YM[2]].
RM Reference mode. Must be 0 (do not use auxiliary reference generator) if
modulo counting is used. More details available in Chapter 12.
Table 12-1: Commands Relevant to Modulo Counting
If the modulo value is selected low and the sensor speed is high, more than one full
revolution of the position counter may elapse within a single sampling time. This
will cause the position counter to behave in an unpredictable manner.
Directional limit switches or software motion limits (HL[3], LL[3], VH[3] and VL[3])
should not be placed near the position folding point, as illustrated in the following
example:
UM=5, speed is 1000,000 counts/second, TS=75, XM[1]=0, XM[2]=1000, HL[3]=980
SimplIQ Software Manual Sensors, I/O and Events 12-2
MAN-SIMSW (Ver. 1.2)
The axis will travel 100,000 * (75 * 10-6 * 4) = 30 counts per one controller sampling time. If
the position is PX=975 at a certain sampling time, the position should be PX=1005 at the
next sampling time. PX=1005 is beyond XM[2]; therefore, the cyclical counting makes
PX=5. The condition PX > HL[3] is missed, although it did exist.
Example:
A motor rotates at a constant speed of 4000 counts/second, with
XM[1]=-1000, XM[2]=1000
The PX variable will behave as depicted in the following graph:
1000
500
0 Main
Position (P X )
-500
Time (sec)
-1000
0 0.5 1 1.5
The PY variable counts the distance traveled by the auxiliary encoder. It is counted in the
range [XM[1]…XM[2]-1], similarly to PX.
In order to identify an event, the event must be defined. From the events in the previous
list, only the Index is defined permanently. All other events are programmable. The
SimplIQ drive’s six digital connector pins can be routed, with direct or inverted polarity,
to functions such as general-purpose digital input or RLS. To learn how to route
connector pins to functions, refer to the IL[N] command section of the SimplIQ Command
Reference Manual.
5The Harmonica also identifies emergency events such as over-voltage, short-circuit or over-
current. The emergency events are explained in Chapter 13.
SimplIQ Software Manual Sensors, I/O and Events 12-4
MAN-SIMSW (Ver. 1.2)
Topic Comment
Capture probability High. An input pulse may slip away unnoticed only if the user
program is not running , the input is masked or the pulse is so
short that it does not pass through the input filters.
Deterministic delay Yes. Position logging and value setting are immediate and
yield accurate results regardless of speed. Position is flagged
within 100 microseconds. Motion management functions are
responded to at the next controller sampling time.
Use Homing (setting an absolute origin for the incremental
position sensors).
Motion management.
High-speed signaling.
Table 12-5: Real Time Properties
In the homing process, a trap is set for the event of reaching a desired position. The
motor travels until an expected event occurs. The event indicates that the motor is now in
a known absolute position, which, if set to the position counter at the time of the event,
makes the position reading of the drive absolute.
The expected event may be one of the limited switches (RLS or FLS), the home switch, the
encoder index or the digital inputs. However, the capture accuracy depends much more
on the homing event selection. If a Home or Index signal is selected as the captured
event, the captured position will not miss. If another digital input is selected, the sensing
delay for the switch is d=(0.004*TS+IF[N]) milliseconds, and VX*d/1000 counts may be
missed.
SimplIQ Software Manual Sensors, I/O and Events 12-6
MAN-SIMSW (Ver. 1.2)
Example:
TS = 80 Torque controller sampling time, in microseconds
IF[1] = 2 Input filter width for digital input #1, in milliseconds
VX = 20,000 Motor main speed, in counts/second
When homing on digital input #1, the expected misses are calculated as:
Refer to the HM[N] command section in the SimplIQ Command Reference Manual.
In jog motions, the position command is jumped according to the position feedback,
so that the motion is unaffected by the position counter update.
If the software position reference generator stops or has already stopped, the
software position command is corrected according to the position feedback. The
motion is unaffected by the position counter update.
In PVT or PT motions, an on-the-fly position counter update may lead to an
immediate high position error, and the motor may abort with an excessive position
tracking error exception.
With UM=5, if the auxiliary encoder counter is modified, and the following is true:
The motor tracks the auxiliary encoder with no ECAM table (RM=1, FR[3] is nonzero
and EM[1]=0)
The software position generator is idle, jogging or running PTP
the software position reference will be modified so that the motion is not affected. In PTP
mode, the PA parameter will change automatically to reflect the modification.
Example:
A PTP motion starts with PA=PX=0. After setting PA=1000;BG;, a motion 1000 counts
long is expected. If, at PX=500, the position has been reset to zero through homing, there
should be 1000 counts remaining immediately after the homing. The total length of the
motion becomes 1500.
The position setting is taken by the index, because in many applications, the index is
much more accurate than the Home switch, which is needed for resolving index
ambiguity (many index pulses may occur along the path of travel).
In normal operation, the FLS and RLS serve as emergency indicators, and the motor is
not expected to reach them. RLS is visited during the homing process, in order to know
in which direction to look for the Home switch.
SimplIQ Software Manual Sensors, I/O and Events 12-8
MAN-SIMSW (Ver. 1.2)
Note that this function uses MI to prevent RLS and Home from activating the AUTO_RLS
and AUTO_HM routines, respectively. Another possible approach would be to use IL[N]
to change the functionality of the switch to GPI (general-purpose input) and then home
on the GPI. However, with the latter approach, the programmer must know which
connector pin is programmed as RLS.
return
##ErrorOut
/* Error handler – just exit*/
return
In order to prevent compliance and timing errors, the position of the Home switch is
captured two times, with alternating movement directions. The two captured results are
averaged in order to cancel the error sources.
If PX=10,000 is in the middle of the Home switch, the homing formula is:
PX=PX+10,000 -0.5 * (PX at right home edge + PX at left home edge)
The following user program executes this routine, using the auxiliary functions of the
previous example:
function [int status] = homing1(int TimeOut)
/*
Homing routine.
Input:
TimeOut: Timeout for failure
Output:
status=1 if o.k., otherwise a negative error code
Assumptions:
RLS,FLS,HOME already programmed by IL[1],IL[2],IL[3] commands
*/
int OldMi,Pos1;
/* Go reverse until limit switch */
SimplIQ Software Manual Sensors, I/O and Events 12-10
MAN-SIMSW (Ver. 1.2)
12.5.6 Capture
Capture is a special case of homing, in which the event is programmed to register only
the counter values, without affecting motion and without updating the position counters.
It efficiently synchronizes the motion origin with objects in the working space.
The drive can capture two events defined by the HX and HY commands, and register
occurrences of PX and PY of each event. The capture function captures both the main and
auxiliary position counters simultaneously, which is useful for synchronizing the main
and auxiliary positions. When main capture mode (HM[1]) is required, HM[7] and HM[8]
capture PX and PY respectively. When auxiliary capture mode (HY[1]) is required, YM[7]
and YM[8] capture PX and PY respectively.
SimplIQ Software Manual 13-1
MAN-SIMSW (Ver. 1.2)
Protections prevent the motor from starting, or shut down an active motor due to
abnormal situations. For example:
Bad or inconsistent setup data prevents the motor from starting.
An unexpectedly high motor current can endanger the SimplIQ drive and the motor.
Such a high current is abnormal because the command to the current (torque)
amplifier is limited. If the current controller seems to be functioning poorly, the drive
is immediately shut down.
The drive is too hot.
When the drive shuts down due to a protection, the motor continues to run on its own
inertia unless brakes are used (see section 13.6). In order to avoid spurious motor
shutdowns, always:
Leave enough space between the limits and the protection. For example, HL[2]
specifies the over-speed limit. A protection is activated when VX > HL[2]. VH[2]
specifies the legal command to the speed controller. Speed commands over VH[2] are
clipped to VH[2]. The protection HL[2] must be greater than the limit VL[2].
Moreover, the distance HL[2] -VH[2] must leave enough space for the expected speed
overshoot.
When safety is a concern, always use brakes. SimplIQ drives can program one of their
digital outputs to activate a brake immediately upon motor shutdown.
If an exception stops the motor or prevents the motor from starting, the SimplIQ drive, in
most cases, can identify the cause of the event. If a real-time exception reaction is desired,
a #@AUTO_ER routine can be added to the user program (see section 5.8.9).
Command Description
BP[N] Brake parameters.
CD Dumps the process status of the SimplIQ drive and reports database
inconsistencies.
CL[N[ Continuous current limit and “Motor not moving” protection.
EC Error code describing why previous command returned an error.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-2
MAN-SIMSW (Ver. 1.2)
Command Description
ER[N] Tracking error exception limits for speed and position.
HL[N] Protection high limits for position and speed feedback.
IL[N] Input logic. Defines digital inputs as stop and limit switches.
LC Limit current indication that indicates whether peak limit is active.
LL[N] Protection low limits for position and speed feedback.
MF States reason for a motor automatic shutdown.
OL[N] Output logic. Programs digital outputs as brake activation or as drive
ready indication.
PL[N] Peak current limit.
PS Program status.
SR Status register. Gives SimplIQ drive status, including if motor is shut
down by exception or if a Stop switch has been hit.
VH[N] Command high limits for position and speed reference.
VL[N] Command low limits for position and speed reference.
Figure 13-1: Commands Relevant to Limits, Protection and Diagnosis
The current limiting process is dynamic: If the current has been close to its continuous
limit, the time allowed for the peak current is reduced. This process is determined as
follows:
The absolute value of the measured motor current (in vector servo drives, this is
I Q2 + I D2
) is applied to a first order low-pass filter. The state of the filter is compared
with two thresholds. When the state of the filter is higher than the upper threshold, the
continuous limit is activated. When the state of the filter is lower than the bottom
threshold, the peak limit is activated.
− PL[2]
The time constant of the low-pass filter is τ=
⎡ CL[1] ⎤
log ⎢1 −
⎣ MC ⎥⎦
where MC is the maximum servo drive current.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-3
MAN-SIMSW (Ver. 1.2)
The maximum time for which the peak current can be maintained after the current
demand has been zero for a long time is:
⎡ CL[1] ⎤
log ⎢1 − ⎥ ⋅ τ seconds.
⎣ PL[1] ⎦
If PL[1] = MC, the maximum time allowed for peak current is PL[2]. Otherwise, the servo
drive can provide the peak current for a longer time.
Generally, if a current demand of PL[1] has been placed after the current command is
stable at I1 < CL[1] for a long time, peak current PL[1] will be available for:
⎡ CL[1] − I1⎤
− log ⎢1 − ⋅ τ seconds.
⎣ PL[1] ⎥⎦
Example:
The following graph depicts the signals related to the current command limiting process
for MC=6, PL[1]=6, PL[2]=3 and CL[1]=3.
3
F ilter state
1 LC current lim it
Indication
0
0 1 2 3 4 5 6 7 8 9
The application motor current command increases from 0 to 6 amperes at the time of 0
seconds, and then decreases to 0 at the time of 5 seconds.
The state of the filter increases until it reaches the continuous current limit of 3 at the time of
3 seconds. At that time, the LC flag is raised and the motor current command decreases to
CL[1] -= amperes.
After the motor current command is set to zero, the state of the filter begins to drop.
When it drops to 2.7 amperes = 90% of 3 amperes, the LC flag is reset and the torque
command limiting returns to 6 amperes.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-4
MAN-SIMSW (Ver. 1.2)
In addition to the speed limiting, the SimplIQ drive provides two forms of speed
protection:
Speed-following error protection (ER[2])
Over-speed limit protection (HL[2]/LL[2])
The first protection detects an over-speed error. The ER[2] parameter specifies the limit
for the velocity error. If the absolute value of the speed tracking error VE exceeds ER[2],
the SimplIQ drive issues the exception MF=0x80 and the motor is shut down
automatically.
The second protection detects over-speed. If VX is greater than HL[2] or less than LL[2],
the SimplIQ drive issues the exception MF=0x20,000 and the motor is shut down
automatically.
The over-speed protection is active in all unit modes. The speed for over-speed detection
is always derived from the main position sensor; this means that in dual-loop systems
(UM=4), the motor speed (the inner loop) — and not the load speed (the outer loop) — is
over-speed protected.
The speed command and feedback limits are illustrated in the following figure. The drive
normally operates in the area marked “Within command and feedback limits.” However,
it may, momentarily, visit areas marked “Overshoot area” due to overshoot, and this is
acceptable. If the speed feedback reaches the “Abort area,” the drive will issue an over-
speed exception and the motor will be shut down automatically.
L L [2 ] H L [2 ]
0
Figure 13-2: Speed Command and Feedback Limits
Remember that when the drive shuts down due to an exception, the motor
continues to run on its own inertia unless brakes are used (refer to section
13.6).
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-5
MAN-SIMSW (Ver. 1.2)
The first protection detects an error of too large a position. The ER[3] parameter specifies
the limit for the position error. If the absolute value of the tracking error PE exceeds
ER[3], the SimplIQ drive issues the exception MF=0x100 and the motor is shut down
automatically.
The second protection detects a motor position that is out of range. If the position
feedback (PX in UM=4 and PY in UM=5) is greater than HL[3], or less than LL[3], the
SimplIQ drive issues the exception MF=0x400,000 and the motor is shut down
automatically.
Position reference and feedback limits should not be placed too close to position counter
limits because there, the relations “greater than” and “smaller than” are not well defined
(see section 12.1).
ER[3] is limited to the modulo counting range (described fully in the ER[3], XM[N]
and YM[N] command sections in the SimplIQ Command Reference Manual).
The following table lists the effects of the position limits on the different unit modes:
The position command and feedback limits are illustrated in the following figure.
The drive normally operates in the area marked “Within command and feedback limits.”
However, it may momentarily visit the areas marked “Overshoot area” due to an
overshoot, which is acceptable. If the position feedback reaches the “Abort area” the
drive will issue an out-of-position-range exception and automatically shut down.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-6
MAN-SIMSW (Ver. 1.2)
L L [3 ] H L [3 ]
Remember that when the drive shuts down due to an exception, the motor
will continue to run on its own inertia unless brakes are used (refer to
section 13.6).
When an Inhibit input is inactive, MO=1 will start the motor if the motor is off.
As a motion limiter, a digital input can stop the motion via the stop manager, stop the
reference generator or limit the motion to a single direction. In addition to stopping the
motion, the digital input can activate an automatic routine in the user program.
For more information about the functions associated with input pins, refer to the IL[N]
command section in the SimplIQ Command Reference Manual.
The brake activation must be synchronized to the motor-on / motor-off process because:
The motor may “run away” if the brake is engaged for too long a time after MO=0,
The position controller may integrate a position error that existed when the brake
was released after the motor was turned on. When the brake is completely released,
the motor may jump.
SimplIQ drives can program a digital output as a “brake” output (refer to the OL[N]
command section in the SimplIQ Command Reference Manual). The brake output must be
connected as follows:
Harmonica
Output Connector
opto-coupler pins
At the brake activation times (BP[2] milliseconds to disengage and BP[1] milliseconds to
engage), the motor is controlled to a complete stop.
The following physical conditions are checked before voltage is applied to the motor:
Power supply under-voltage
Power supply over-voltage
Drive temperature too high
Motor not connected to servo drive
An active limit switch is programmed to shut down the servo drive
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-9
MAN-SIMSW (Ver. 1.2)
The motor will not start if the voltage of the power supply is not within range, if the
servo drive temperature is too high, or if an active switch prevents motor on. The MO
command returns error code 65 or 66. The failure reason may be read through the status
(SR command) report. If the voltage is in range and the temperature is not excessive, the
drive will attempt to start the motor.
The MF variable may reveal the reason for motor shutdown even if the reason no longer
exists. For example, if the power supply has too large an impedance, its voltage may drop
in full load and the servo drive will be automatically shut down due to under-voltage.
When the motor is shut down, the under-voltage disappears. On the other hand, if an
over-voltage is generated due to an insufficient shunt, the over-voltage will disappear
when the motor is shut down.
The over- or under-voltage conditions that caused the fault are captured in the MF
variable.
Notes:
MF is reset automatically every “Motor enable” (MO=1) when the fault is no
longer valid.
The SR variable also reports motor faults, according to the current status of the
drive/motor. When the fault is no longer valid, the indication is removed. For
example, if an “Over-voltage” occurs, SP indicates the fault and MF latches the
fault indication. As soon as the over-voltage conditions end, the fault indication
is removed from SR. The “Fault latch” indication in the SR remains set (bit 6)
and MF indicates “Over-voltage” until the next MO=1.
When the drive shuts down by exception, the motor continues to run on its own
inertia unless brakes are used (refer to section 13.6).
For a full list of the exceptions that can cause automatic shutdown, refer to the MF
command section in the SimplIQ Command Reference Manual.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-10
MAN-SIMSW (Ver. 1.2)
13.9 Diagnosis
When a motor fault is detected, the MF command reports the exact reason for the fault;
when a run-time program fault is detected, the PS command reports -1. The reason for
the fault is reported by the Elmo Studio and by analyzing the DB_ES command.
For full explanations, refer to the relevant command section in the SimplIQ Command
Reference Manual and to Chapter 4 of the Composer for SimplIQ Servo Drive User Manual.
Loading the setup parameters form the flash memory rarely fails, because the parameters
are checked before allowing non-voltage storage. The only reason for failure is generally
a major firmware revision upgrade.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-11
MAN-SIMSW (Ver. 1.2)
Before enabling the motor, the drive tests all parameters to ensure that they are sensible.
For example, the variables CA[4], CA[5] and CA[6] define how the Hall sensors are
ordered. If CA[4] equals CA[5], two Hall sensors are assigned to the same position, which
is illogical. If CA[4] = CA[5], the command MO=1 will fail and will return the error code
54 to indicate a bad database. In order to determine the reason for this type of failure, use
the CD command, which will return:
Null address=0
Failure address=0
Called Handler=none
Database status:
CA[4], error code=37
The first lines establish that the CPU did not detect an exception (refer to following
section). The last line states that parameter CA[4] yielded the error code 37, meaning that
two Hall sensors are defined for the same place.
For this reason, SimplIQ drives use traps for CPU exceptions and stack overflow. When it
traps an exception, it:
Shuts off all controller activity and aborts any motion to freewheeling
Writes down the exact trap that was activated, along with the address in the firmware
that caused the exception
After the exception, the communication remains enabled so that the drive can be queried
about the event. The motor, however, cannot be set to work again until the drive is
rebooted.
A CPU exception is detected using the CD and SR commands. The SR command indicates
only that an exception occurred, while the CD (CPU dump) command provides the
details. The CD command provides the report as follows:
The CPU dump also returns the database status, as described previously.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-12
MAN-SIMSW (Ver. 1.2)
A stationary motor responding to a high torque command does not always indicate an
error. In certain applications, such as thread fastening, it is perfectly legitimate for the
motor to reach a mechanical motion limit.
The drive user should define whether a high-torque stopped motor is a fault or not. If the
parameter CL[2] is less than 2, a high torque that does not lead to motion is not
considered a fault. If the parameter CL[2] is 2 or more, a high-torque stopped motor,
detected for at least 3 continuous seconds, is considered a fault. The motor is set to off
(MO=0) and MF=0x200,000. The time constant of 3 seconds is used because almost every
motion system applies high torques for short acceleration periods while the speed is
slow.
CL[2] defines the tested torque level as a percentage of the continuous current limit
CL[1]. CL[3] states the absolute threshold main sensor speed under which the motor is
considered not moving. CL[3] should not be set to a very small number because when a
motor is stuck, a vibration may develop that will induce speed-reading. When an encoder
wire is damaged, the motor will run away with the encoder readout vibrating + bit. This
also creates speed-reading.
Example:
If CL[2]=50 and CL[3]=500, the drive will abort (reset to MO=0) if the torque level is kept
at at least 50% of the continuous current, while the shaft speed does not exceed 500
counts/second for a continuous 3 seconds.
SimplIQ Software Manual Limits, Protections, Faults and Diagnosis 13-13
MAN-SIMSW (Ver. 1.2)
Note that in extreme cases, where abs(Δθ) > 90º, the motor torque becomes reversed with
respect to what is expected by the current defined in the command.
The SimplIQ drive supports commutation failure identification through the use of
redundant encoder and digital Hall sensor data. The Hall sensors provide a rough, but
direct, estimate of the commutation angle. The encoder provides high-resolution data,
but it may accumulate errors if the drive setup data is set incorrectly or if it is faulty. If
the encoder’s cumulative commutation angle differs by more than 15 electrical degrees
from the closest value to match the Hall sensor reading, an error is issued. The motor is
shut down (MO=0) and MF is set to 0x4. An error is issued when there is a commutation
discrepancy of between 15 and 45 degrees.
After detection of a commutation fault, the motor must be shut down and a proper MF
code set to be active. The motor cannot be stopped under control, because the correlation
between the motor currents and the resulting torque is not known. At the next motor
startup attempt, the motor will again seek commutation.
SimplIQ Software Manual 14-1
MAN-SIMSW (Ver. 1.2)
All of these filters are parameterized the same way. Each filter is built by one or more
second-order links, connected in a series, as depicted in the following two-block example:
Out
1
10
I
-0.1
10
0
10 -0.2
10
n
-0.3
10
-1
10
-0.4
10
-0.5
-2
10
10
-0.6
10
-3 -0.7
10 10
-0.8
10
-4
10
1 2 3 4 5 1 2 3 4 5
10 10 10 10 10 10 10 10 10 10
In O
t
-1
10
-2
10
-3
10
-4
10
1 2 3 4 5
In the top frame, the first block in the series is a second-order low-pass filter; the next one is
a notch filter. The bottom frame contains a fourth-order filter resulting from applying the
notch filter in series with the low-pass filter.
A first-order filter link can be made by setting some of the second-order filter parameters to
zero. The filters are implemented in a normalized form, meaning that the DC gain of each
filter (and of the entire filter series) is 1.0.
Very high-order control filters can be used with the SimplIQ drive. However, when they are
used, the filter implementation increases the load on the CPU significantly and may require
an increase in the sampling time (TS) (see section 7.3).
The parameters of all filters are programmed into the vector KV[N], as follows:
SimplIQ Software Manual 13BFilters 14-2
MAN-SIMSW (Ver. 1.2)
The parameters k1, k2, k3 and k4 are stored inside the SimplIQ drive as integers. As a
result, when you read back these coefficients, they may have slightly different values
than those that you programmed.
The index k is the gain scheduler selector: It selects one set of (A, B, C, D, E) from the 63
possible selections [A(1), B(1), C(1), D(1), E(1)…A(63), B(63), C(63), D(63), E(63)].
Note that the frequency response of a discrete-time filter depends on the sampling time. In
the following examples, you should use sampling time T.
where:
8
2ω 2 −
a1 = T2
4 dω 4
+ 2 +ω2
T T
4 4 dω
2
+ω2 −
a2 = T T
4 dω 4
+ 2 +ω2
T T
4ω 2
b0 = a1 + a 2 + 1 =
4dω 4
+ 2 +ω2
T T
where:
p1 + c1 + 1 2(1 − p1 ) p − c1 + 1 p − c2 + 1
b0 = , b1 = , b2 = 1 , a2 = 2
q q q q
2(1 − p 2 )
a1 = b0 + b1 + b2 − a 2 − 1 =
q
assuming:
2d k 1
ck = , pk = , ( k = 1,2 )
⎛ ω kT ⎞ ⎛ ω T ⎞
2
tan⎜ ⎟ tan⎜ k ⎟
⎝ 2 ⎠ ⎝ 2 ⎠
q = p2 + c2 + 1
⎜ ⋅ ⎟
⎝a s+b⎠
The frequency a / (2π) [Hz] is the lead corner frequency. The frequency b / (2π) [Hz] isis the
lag corner frequency.
Order Parameter
1 k1 = (1 - β)2
2 k2 = Gβ · (Gβ + 2 · (1 - β))
3 k3 = - (Gβ)2
4 k 4 = β2
β is selected as β = e-bt.
b
G is selected by G = , with 0 < β < 1 and 1 < G < 3.
a
SimplIQ Software Manual 13BFilters 14-8
MAN-SIMSW (Ver. 1.2)
Order Parameter
1 k1 = 1 - β
2 ⎛1− β ⎞
k2 = ⎜ ⎟α
⎝1−α ⎠
3 k3 = 0
4 k4 = 0
s
parameters are α = 0, β = e
− pT
For a single pole, ⋅ .
s+ p
Example:
A filter consist of one second-order block and one first-order block. The second-order block
is a notch filter with a 300-Hz notch frequency and a damping of 0.14. The sample time is
360 microseconds. The discrete equivalent of the filter is parameterized by:
k1 = 0.3372, k2 = 0.4573, k3 = -0.7277 and k4 = 0.5222.
The second block is a simple pole with a 400-Hz frequency. It may be represented by:
k1 = 0.1341, k2 = 0, k3 = 0 and k4 = 0.
Be aware that the KV[N] manual programming is not required because the Composer
program performs it manually.
SimplIQ Software Manual 15-1
MAN-SIMSW (Ver. 1.2)
The type of controller used depends on the SimplIQ drive motion mode (see Chapter 10:):
At the basic level of the speed controller, the control algorithm is the traditional PI
(proportional - integral). At the basic level of the position controller, the control algorithm is
an internal PI speed loop and an external position loop using a simple gain for the
controller, a structure known as a cascaded loop.
As control requirements become more stringent, the algorithms can be extended to include:
A high-order filter that operates in series with the PI controller, with the following
blocks:
Notch filters for notching resonance
Low-pass filters for attenuating very high-frequency resonance and decreasing
sensor noise
A lead-lag element, which moderates the tradeoff of margins versus bandwidth
A continuous scheduling algorithm that modifies the PI algorithm and some of the
advanced filter parameters as a function of the closed loop operating point
An advanced user may tune the various filter blocks, which is a bit more complex than
tuning the PI and simple gain. The gain scheduling can programmed by the Composer
Wizard automatically or manually, using the Advanced Manual Tuning options (explained
in Chapter 4 of the Composer for SimplIQ Servo Drive User Manual).
SimplIQ Software Manual The Controller 15-2
MAN-SIMSW (Ver. 1.2)
The following table lists the parameters of the algorithms referred to in this chapter. Details
are available in the SimplIQ Command Reference Manual.
Parameter Description
UM Unit mode. Determines the type of control algorithm used:
speed, dual position or open loop.
KP[N] N=2: Inner speed loop proportional gain
N=3: Outer loop gain (UM=4 and UM=5)
KI[N] N=2: Inner speed loop integral gain, I.
KV[N] Coefficients for high-order filter. The parameter KV[0] asserts if these
filters are used: If KV[0] is zero, the advanced filter is not used.
GS[N] Gain scheduling parameters.
MC Maximum drive phase current.
PL[1] Maximum motor phase peak current.
WS[28] Sampling time of the controller, in microseconds.
Table 15-2: List of All Control Parameters
Notation:
Standard mathematics notation is used here:
The time derivative is denoted by the letter s.
The expression sx is equivalent to dx/dt.
The expression x/s is equivalent to ∫xdt, where t is the time and x(t) is any signal.
The operator z denotes a time advance of a single sampling time.
The gain scheduler can be used or the gains of the controller can be fixed using GS[2]=0. The
high-order filter can be used or not used; to avoid using the high-order filter, set KV[0]=0.
SimplIQ Software Manual The Controller 15-3
MAN-SIMSW (Ver. 1.2)
FF[1] d/dt
Autom atic
Fixed if
Controller
Selector GS[2]=0
0
DV[2]
Torquecom m and
Speed (DV[1], Am p)
High order
Speed com m and Σ controller:
filter Σ
KP,KI
-
Position sensor
Speed feedback Speed
Estim ator
Encoder pulse
tim er
When using the scheduler, KI and KP are functions of time. When not using the gain
scheduler, they are fixed.
The input to the PI element is the speed error eSPEED(t) [Internal speed units]:
eSPEED (t ) = SpeedCommand (t ) − SpeedFeedback (t )
KSPEED is the conversion factor from the D/A scale to current in amperes:
MC
K Speed = , MC _ VALUE _ BITS = 14000
MC _ VALUE _ BITS
1
32768 ∫
⎧0 if no encoder counts for GS[0] samples and eSPEED dt < GS[14]count
p(t ) = ⎨
⎩1 otherwise
The GS[0] parameter is used to stabilize the motion at very low speeds. It cuts the
proportional gain of the speed controller after enough controller sampling times have
elapsed without a change in the encoder readout.
Example:
For a speed reference of 200 counts/second, a new encoder count is available once per 5
milliseconds, which is about 25 sampling times of the speed controller. If a new encoder
pulse comes only once per 5 milliseconds, the speed readout is delayed by at least 2.5
milliseconds, which in turn may have a fatal effect on the control stability. Setting GS[0]=12,
the proportional gain of the controller is applied only for about half of the time, leading to a
practical reduction of the proportional gain to half at that speed. The reduced gain implies
reduced bandwidth and increased stability. The acceleration from complete rest is slow. To
avoid cutting the speed proportional gain, set GS[0] to its maximum value (refer to the GS
command section in the SimplIQ Command Reference Manual).
Parameter Description
KP[2] Proportional gain
KI[2] Integral gain
GS[0] Proportional gain duration
GS[2] Controller gain selection
GS[14] Speed reference integral threshold
FF[1] Torque feed forward
CL[1] Continuous torque limit
PL[1] Peak torque limit
KV[N] High-order filter parameters
Table 15-3: Non-scheduled Speed Controller Parameters
SimplIQ Software Manual The Controller 15-5
MAN-SIMSW (Ver. 1.2)
FF[2] d/dt
Fixed if
GS[2]=0 Autom atic
Controller
Selector
0
DV[3]
Speed com m and
Position (DV[2], Am p)
Position
com m and Σ Controller Σ
KP[3],GS[9]
ePos Com m andPi
-
Main Position
Position feedback sensor
UM=4
UM=5 Auxiliary Position
Sensor
The reference to the speed controller is composed of the derivative of the position command
(speed) and of the output of the auxiliary position controller. The derivative of the position
command is multiplied by the FF[2] factor in order to eliminate tracking errors at steady
speed.
The gain scheduler can be used or the gains of the controller can be fixed, setting GS[2]=0.
The high-order filter can be used or not. To avoid the use of the high-order filter, set
KV[0]=0.
The same controller is used for single-feedback mode (UM=5) and for the dual-feedback
mode (UM=4). Use the single feedback mode when there system includes only one sensor,
for commutation, speed and position sensing. Use dual-feedback mode when the load is
driven through a gear, and where a separate load sensor enables precise load positioning
despite backlash and gear compliance.
SimplIQ Software Manual The Controller 15-6
MAN-SIMSW (Ver. 1.2)
However, when the position error ePOS(t) is too large, the gain is modified to avoid
Out
instability and K P is replaced by:
min( K Out
P ⋅ abs( ePOS (t )), 2 ⋅ α ⋅ abs( ePOS (t )) ) ⋅ sign( ePOS (t )) .
where 2 ⋅ α = GS[9] .
This formula ensures that the speed controller is not required to decelerate beyond
counts/second2. GS[9] must be calculated with as 80% of the highest deceleration the
motor can produce with the current PL[1].
Parameter Description
KP[3] Proportional gain, K P .
Out
Only a subset of the controller parameters can be scheduled. The KG[N] parameters can
program sets of KP, KI gains, as well as one scheduled double-lead block at the high-order
filter. The other elements of the high-order filter cannot be gain scheduled.
The scheduling is automatic for GS[2]=64. GS[2]=0 selects the controller parameters of
KP[2], KI[2] and KP[3]. Other values of GS[2] directly select with of the available sets of
controller parameters is used.
Example:
If GS[2]=1, the proportional gain of the speed loop will be SpeedKpTable[1]. According to
Table 15-1, SpeedKpTable[1] = KG[64].
The gains are scheduled according to the reference speed. If the desired speed is high, the
encoder data is updated at a high rate so that the speed sensing delay is low. If the desired
speed is low, the encoder pulses are slow. For example, suppose that a speed of 200
counts/second is required. At this speed, there will be a new encoder count once per 5
milliseconds. The calculated speed will have an average 2.5-millisecond delay that may
adversely affect the stability of the control algorithm. For this reason, if the speed is low, the
controller bandwidth must be narrowed so that the extra sensing delay becomes tolerable.
The speed command is filtered so that the filtered value serves to fetch the relevant
controller scheduled parameters, KP, KI and some of the advanced filter parameters, from a
table. The filtering is required in order to avoid abrupt changes of controller parameters,
which can spoil the guaranteed stability of the gain-scheduled controller (assuming that
each selection set of speed controller parameters is a stable controller for its goal speed).
The speed range in which the scheduling is effective is approximately 0…10,000 counts/
second.