LEGEND MC User Manual
LEGEND MC User Manual
LEGEND-MC
User’s Manual
Upon receipt of the product and prior to initial operation, read these instructions
thoroughly, and retain for future reference
LEGEND-MC User’s Manual
LEGEND-MC User’s Manual
WARNING
YASKAWA manufactures component parts that can be used in a wide
variety of industrial applications. The selection and application of
YASKAWA products remain the responsibility of the equipment
designer or end user. YASKAWA accepts no responsibility for the way
its products may be incorporated into the final system design.
TABLE OF CONTENTS
1 Introduction ............................................................................................................................... 1
Part Numbers .................................................................................................................... 2
Startup ............................................................................................................................... 3
Mounting the LEGEND-MC to the LEGEND Amplifier ......................................... 3
Mounting Orientation ............................................................................................ 3
Front Panel Description..................................................................................................... 4
Power/Connections Wiring - Single Phase ....................................................................... 5
Power/Connections Wiring - Three Phase ........................................................................ 6
Cable Shielding, Segregation and Noise Immunity ........................................................... 7
I/O Connections (50-pin CN5)........................................................................................... 8
Analog I/O ......................................................................................................................... 9
Analog Input ......................................................................................................... 9
Analog Output .................................................................................................... 10
Digital I/O ........................................................................................................................ 11
Digital Input ........................................................................................................ 11
Digital Output .................................................................................................... 12
Emergency Stop Chain ................................................................................................... 13
Serial Communication ..................................................................................................... 14
External Encoder Specifications ..................................................................................... 15
Dedicated Inputs ............................................................................................................. 16
Physical Specifications .................................................................................................... 17
Hardware Specifications ................................................................................................. 17
Cable Diagram and Dimensional Drawings .................................................................... 18
I/O Cable with Terminal Block JUSP-TA50P ..................................................... 18
2 Theory of Operation ................................................................................................................ 21
Overview ......................................................................................................................... 21
Level ................................................................................................................................ 22
Operation of Closed-Loop Systems ................................................................................ 24
System Modeling ............................................................................................................. 25
Controller ............................................................................................................ 25
Motor-Amplifier ................................................................................................... 25
Current Drive ...................................................................................................... 25
Velocity Loop ...................................................................................................... 26
Encoder .............................................................................................................. 27
DAC .................................................................................................................... 27
Digital Filter ........................................................................................................ 27
ZOH .................................................................................................................... 28
System Analysis ............................................................................................................................ 28
System Design and Compensation ................................................................................. 31
The Analytical Method ........................................................................................ 31
3 Communications ..................................................................................................................... 35
Introduction ..................................................................................................................... 35
Controller Response to Data .............................................................................. 35
RS232 Port ......................................................................................................... 35
Ethernet Configuration .................................................................................................... 36
Communication Protocols .................................................................................. 36
Addressing ......................................................................................................... 37
Ethernet Handles ............................................................................................... 37
Global vs Local Operation .................................................................................. 38
Configuring Operation for Distributed Control .................................................... 39
Operation of Distributed Control ......................................................................... 40
Accessing the I/O of the slaves .......................................................................... 40
Handling Communication Errors ........................................................................ 41
Modbus Support ................................................................................................. 41
LEGEND-MC User’s Manual
Subroutines .......................................................................................................278
Stack Manipulation ............................................................................................278
Auto Start Routine .............................................................................................278
Automatic Subroutines for Monitoring Conditions .............................................279
Mathematical and Functional Expressions ....................................................................282
Variables ........................................................................................................................284
Programmable Variables ..................................................................................284
Internal Variables & Keywords ..........................................................................286
Arrays............................................................................................................................. 288
Defining Arrays ................................................................................................. 288
Assignment of Array Entries .............................................................................288
Automatic Data Capture into Arrays ................................................................. 290
8 Input and Output of Data .......................................................................................................293
Sending Messages ........................................................................................................293
Input of Data ..................................................................................................... 295
Formatting Data ................................................................................................295
User Units ......................................................................................................... 297
9 Programmable I/O ..................................................................................................................299
Digital Outputs ...............................................................................................................299
Digital Inputs ..................................................................................................................300
Input Interrupt Function ..................................................................................................300
Analog Inputs .................................................................................................... 300
10 Example Applications ..........................................................................................................301
Instruction Set Examples ...............................................................................................301
Special Labels ...................................................................................................318
Wire Cutter ........................................................................................................322
Speed Control by Joystick ................................................................................323
Position Control by Joystick ..............................................................................324
Backlash Compensation by Dual-Loop .............................................................325
11 Troubleshooting ...................................................................................................................327
Overview ........................................................................................................................327
Installation ......................................................................................................................327
Communication ..............................................................................................................328
Stability ..........................................................................................................................328
Operation .......................................................................................................................328
LEGEND-MC User’s Manual
Introduction
The LEGEND-MC is a single axis Ethernet motion controller designed for use
exclusively with Yaskawa’s LEGEND Digital Torque Amplifier.
1
LEGEND-MC User’s Manual
Part Numbers
Description Part Number
SMC3010
b)
3.0m 50 Pin I/O Cable JZSP-CKI01-3 (A)
2
LEGEND-MC User’s Manual
Startup
Mounting the LEGEND-MC to the LEGEND Amplifier
1. Insert the lower two mounting notches of the LEGEND-MC into the mounting holes at the bottom of the right
side of the LEGEND.
2. Push the LEGEND-MC in the direction indicated by the arrow in the figure below, and insert the upper
mounting notches of the LEGEND-MC into the upper mounting holes on the right side of the LEGEND.
Mounting Orientation
Mount the LEGEND-MC and LEGEND vertically for proper cooling, as shown below. Allow a minimum spacing
of 10mm around the left and right sides and 30mm around the top and bottom of the LEGEND-MC/LEGEND
unit.
3
LEGEND-MC User’s Manual
(9)
4
LEGEND-MC User’s Manual
R T
1MCCB Control Control
Power Power
Noise Filter
ON OFF 1MC
2MC SUP
YASKAWA
C
N
6
LEGEND01
2MC CHARGE POWER
L1
L2 C
L3 N
5
1
2
1MC
L1C
L2C C R
B1 N S
B2 1 T
B3 C
N
U 4
V C
W F
N
G
2
Notes: The LEGEND-MC receives its power from the LEGEND amplifier through the side interface
connector, however, the digital I/O receives its power from pins 46, 47, 48, and 49 on the I/O connector.
For maximum noise immunity, connect the FG to a ground termnal on the sub panel or to the ground
terminal on the LEGEND.
5
LEGEND-MC User’s Manual
R S T
1MCCB Control Control
Power Power
Noise Filter
ON OFF 1MC
2MC SUP
YASKAWA
C
N
6
LEGEND01
2MC CHARGE POWER
L1
L2 C
L3 N
1 5
2
1MC
L1C
L2C C
B1 R
N S
B2 1 T
B3 C
N
U 4
V C
W F
N
2 G
Notes: The LEGEND-MC receives its power from the LEGEND amplifier through the side interface
connector, however, the digital I/O receives its power from pins 46, 47, 48, and 49 on the I/O connector.
For maximum noise immunity, connect the FG to a ground termnal on the sub panel or to the ground
terminal on the LEGEND.
6
LEGEND-MC User’s Manual
a)
PROPER
Shield connected across
terminal block.
b)
PROPER PROPER
Shield tied back at Shields of field
terminal block. cables grounded at
one point
Wrong
a)
WRONG
Shield grounded at
more than one point.
b)
WRONG
Shields of field
cables ungrounded
7
LEGEND-MC User’s Manual
8
LEGEND-MC User’s Manual
Analog I/O
Analog Input
Item Specifications
Input Voltage ± 10 V
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
DG403
MUX
1 Analog 1
2 Analog 2
5 +12V
-12V -12V 28
SMC Signal
Ground
9
LEGEND-MC User’s Manual
Analog Output
Item Specifications
D/A Output Resolution 16 bit over a ± 10 V range or 328 µV/bit
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
TL084CN
Analog External Device
26 Output -10 ~ 10 V
Signal L
28 Ground
10
LEGEND-MC User’s Manual
Digital I/O
Digital Input
Item Specifications
Number of Input Points 8
Input Format Sinking
Isolation Optical
Voltage 24 VDC ± 20%
Current Rating (ON) 5.3 mA to activate
Input Impedance 2.2k Ω
Operation Voltage Logic 0 <5V
Logic 1 >15V
OFF Current 0.9 mA or less
Response Time OFF to ON: <0.5 ms
ON to OFF: <1.5 ms
Latch response time Less than 25 µsec
Minimum latch width 9 µsec
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
24VDC
47
2.2k 49
18 Digital Input 1
(Main Latch)
17 Digital Input 2
(External Latch)
45 Digital Input 3
44 Digital Input 4
43 Digital Input 5
42 Digital Input 6
19 Digital Input 7
20 Digital Input 8
11
LEGEND-MC User’s Manual
Digital Output
Item Specifications
Number of Output Points 4
Output Format Sinking
Output Classification Transistor Output
Isolation Optical
Load Voltage 24 VDC ± 20%
Load Current 200 mA/Output (600 mA if activated individually)
Response Time OFF to ON <0.25 ms
ON to OFF <0.5 ms
External Common Power 24 VDC ± 20% 15 mA
Common User Fuse Rating 1A
Individual User Fuse Rating 200 mA recommended
Note: The ULN 2803 output chip is capable of 600 mA at a single output, or 800mA for the four outputs simultaneously.
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
24VDC
47 Fuse
49
4.7k
PS2505-4
ULN2803
24 Digital Output 1 L
23 Digital Output 2 L
10k
22 Digital Output 3 L
21 Digital Output 4 L
46
48
12
LEGEND-MC User’s Manual
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
VCC
U17
50 E STOP1
25 E STOP2
Q1
-EROUT 2N7002
1k
The LEGEND-MC closes the relay contact under normal operating conditions.
13
LEGEND-MC User’s Manual
Serial Communication
Item Specifications
Baud Rate 9600 or 19200 settable by jumper JP1, default is 19200
Data Bits 8
Parity None
Stop Bits 1
Legend-MC Serial
Internal Circuitry Port Connector CN6 Field Wiring
U7
VCC
C1+ V+
.1 UF .1 UF
C1-
.1 UF C2+
V-
C2- .1 UF
1 CTS Output
T1IN T1OUT
6 CTS Output
8 CTS Output
T2IN T2OUT
2 Transmit Output
3 Receive Input
A1OUT A1IN
7 RTS Input
4 RTS Input
A2OUT A2IN
MAX232A 9 N/C
5 Signal Ground
Note: Hardware handshaking must be used with the LEGEND-MC. If it is impossible to implement
hardware hndshaking, use a jumper between pins 1 and 4 in the connector.
14
LEGEND-MC User’s Manual
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
VCC
External Encoder
4.7k
4.7k
6.8k
6.8k
+5V or +12V
9 A+phase
3486
8 A-phase
34 0V
Digital 10 B-phase
3486 Ground
11 B+phase
34
Digital Shield
2.4k
2.4k
Ground
Frame
Ground
Standard voltage levels are TTL (0V to 5V), however, voltage levels up to 12V are acceptable. If using differential
12V signals, no modification is required. Single ended 12V signals require a bias voltage applied to the compli-
mentary input, i.e.; use two 10k resistors, one connected to +12V and the other connected to the LEGEND signal
ground to hold the /A phase and /B phase at 6VDC. Do not use a 24VDC encoder.
15
LEGEND-MC User’s Manual
Dedicated Inputs
Item Specifications
Number of Input Points Forward limit, Reverse limit, Home, Abort, Reset
Isolation Optical
Legend-MC I/O
Internal Circuitry Connector CN5 Field Wiring
24VDC
47
14 Home Input
12 Abort Input
16 Reset Input
16
LEGEND-MC User’s Manual
Physical Specifications
Description Specifications
Depth: 130mm (5.12 in)
Hardware Specifications
Description Specifications
CPU: 25 mHz Motorola
17
LEGEND-MC User’s Manual
CN5
+10%
Length of cable supplied: 19.69 (500) -0%
1.77 (45)
1 49
2 50
9.74 (247.5)
10.01 (254.2)
0.14 (3.5) 0.14 (3.5)
0.61 (15.5)
1.77 (45)
(29.5)
1.16
18
LEGEND-MC User’s Manual
MOUNTING CLIPS
LEGEND MOUNTING
CLIP
SIDE PIN CONNECTOR
(O.79)
20
(0.79)
20
(5.12)
130
ND MOUNTING
CLIP STATUS LED'S CLIP ATTACHMENT TO LEGEND AM
C
N
6
SERIAL PORT
(5.59)
C
142
N
5
I/O
MODEL NP
R
S
T RESET
ETHERNET LED'S C
N
4
ETHERNET F
G GROUND
DIMENSIONS: MM (IN)
19
LEGEND-MC User’s Manual
NOTES:
20
LEGEND-MC User’s Manual
2 Theory of Operation
Overview
The following discussion covers the operation of motion control systems. A typical motion control sys-
tem consists of the elements shown in the following illustration:
ENCODER MOTOR
The operation of such a system can be divided into three levels, as shown in the following illustration
Levels of Control Functions. The levels are:
21
LEGEND-MC User’s Manual
Level
LEVEL
MOTION
3 PROGRAMMING
MOTION
2 PROFILING
CLOSED-LOOP
1 CONTROL
The three levels of control may be viewed as different levels of management. The top manager, the
motion program, may specify the following instruction, for example.
PR 6000,4000
SP 20000,20000
AC 200000,300000
BG X
AD 2000
BG Y
EN
This program corresponds to the velocity profiles shown in the following illustration - Velocity and Position
Profiles. Note that the profiled positions show where the motors must be at any instant of time.
Finally, it remains up to the servo system to verify that the motor follows the profiled position by closing
the servo loop.
The operation of the servo system is done in two manners. First, it is explained qualitatively, in the fol-
lowing section. Later, the explanation is repeated using analytical tools for those who are more theoreti-
cally inclined.
22
LEGEND-MC User’s Manual
X VELOCITY
Y VELOCITY
X POSITION
Y POSITION
TIME
23
LEGEND-MC User’s Manual
24
LEGEND-MC User’s Manual
System Modeling
The elements of a servo system include the motor, driver, encoder and the controller. These elements are
shown in the following illustration. The mathematical model of the various components is given below:
Controller
CONTROLLER
R X DIGITAL Y V E
Σ FILTER
ZOH DAC AMP MOTOR
C
P
ENCODER
Motor-Amplifier
The motor amplifier may be configured in two modes:
1. Current Drive
2. Velocity Loop
Current Drive
The current drive generates a current I, which is proportional to the input voltage, V, with a gain of Ka, a
torque constant of Kt, and inertia J. The resulting transfer function in this case is:
P/V = Ka Kt / Js2
For example, a current amplifier with Ka = 2 A/V with the motor described by the previous example will
have the transfer function:
25
LEGEND-MC User’s Manual
Velocity Loop
The motor driver system may include a velocity loop where the motor velocity is sensed by a tachometer
and is fed back to the amplifier. Such a system is shown in the following illustration. Note that the trans-
fer function between the input voltage V and the velocity ω is:
V
Σ Ka Kt/Js
Kg
The functions derived above are shown in the following block diagram :
CURRENT SOURCE
V I W P
Kt 1
Ka
JS S
VELOCITY LOOP
V W P
1 1
Kg(ST 1+1) S
26
LEGEND-MC User’s Manual
Encoder
The encoder generates N pulses per revolution. It outputs two signals, Channel A and B, which are in
quadrature. Due to the quadrature relationship between the encoder channels, the position resolution is
increased to 4N quadrature counts/rev.
The model of the encoder can be represented by a gain of:
Kf = 4N/2π [count/rad]
For example, a 1000 lines/rev encoder is modeled as:
Kf = 638
DAC
The DAC or D-to-A converter converts a 14-bit number to an analog voltage. The input range of the
numbers is 16384 and the output voltage range is +/-10V or 20V. Therefore, the effective gain of the
DAC is:
Digital Filter
The digital filter has a transfer function of D(z) = K(z-A)/z + Cz/z-1 and a sampling time of T.
The filter parameters, K, A and C are selected by the instructions KP, KD, KI or by GN, ZR and KI,
respectively. The relationship between the filter coefficients and the instructions are:
K = KP + KD or K = GN
A = KD/(KP + KD) or A = ZR
C = KI/8
This filter includes a lead compensation and an integrator. It is equivalent to a continuous PID filter with
a transfer function G(s).
G(s) = P + sD + I/s
P = K(1-A) = KP
D = T.K.A = T.KD
I = C/T = KI/8T
For example, if the filter parameters are KP = 4:
KD = 36
KI = 2
T = 0.001 s
the digital filter coefficients are:
K = 40
A = 0.9
C = 0.25
and the equivalent continuous filter, G(s), is:
G(s) = 4 + 0.036s + 250/s
27
LEGEND-MC User’s Manual
ZOH
The ZOH, or zero-order-hold, represents the effect of the sampling process, where the motor command is
updated once per sampling period. The effect of the ZOH can be modeled by the transfer function
H(s) = 1/(1+sT/2)
If the sampling period is T = 0.001, for example, H(s) becomes:
H(s) = 2000/(s+2000)
However, in most applications, H(s) may be approximated as one.
This completes the modeling of the system elements. Next, we discuss the system analysis.
System Analysis
To analyze the system, we start with a block diagram model of the system elements. The analysis proce-
dure is illustrated in terms of the following example.
Consider a position control system with the LEGEND-MC controller and the following parameters:
KI = 0 No integrator
Motor:
DAC:
Kd = 0.0012 [V/count]
Encoder:
ZOH:
2000/(s+2000)
Digital Filter:
KP = 12.5, KD = 245, T = 0.001
28
LEGEND-MC User’s Manual
Therefore,:
D(z) = 12.5 + 245 (1-z-1)
Accordingly, the coefficients of the continuous filter are:
P = 12.5
D = 0.245
The filter equation may be written in the continuous equivalent form:
G(s) = 12.5 + 0.245s = 0.245(s+51)
2000 500
Σ 0.245(S+51) 0.0012 4
S+2000 S2
ENCODER
318
The open loop transfer function, A(s), is the product of all the elements in the loop:
A = 390,000 (s+51)/[s2(s+2000)]
29
LEGEND-MC User’s Manual
To analyze the system stability, determine the crossover frequency, ωc at which A(j ωc) equals one. This
can be done by the Bode plot of A(j ωc), as shown in the following illustration:
Magnitude
1
50 200 2000 W (rad/s)
0.1
For the given example, the crossover frequency was computed numerically resulting in 200 rad/s.
Next, we determine the phase of A(s) at the crossover frequency:
PM = 180° + α = 70°
As long as PM is positive, the system is stable. However, for a well damped system, PM should be
between 30 degrees and 45 degrees. The phase margin of 70 degrees given above indicated overdamped
response.
Next, we discuss the design of control systems.
30
LEGEND-MC User’s Manual
The DAC of the LEGEND-MC outputs +/-10V for a 14-bit command of +/-8192 counts.
The design objective is to select the filter parameters in order to close a position loop with a crossover
frequency of ωc = 500 rad/s and a phase margin of 45 degrees.
The first step is to develop a mathematical model of the system, as discussed in the previous system.
Motor:
Ka = 2 [Amp/V]
DAC
Kd = 10/8192:
Encoder:
Kf = 4N/2π = 636
ZOH:
H(s) = 2000/(s+2000)
Compensation Filter:
G(s) = P + sD
The next step is to combine all the system elements, with the exception of G(s), into one function, L(s):
31
LEGEND-MC User’s Manual
Now, determine the magnitude and phase of L(s) at the frequency ωc = 500:
|L(j500)| = 0.025
and a phase:
|A(j500)| = 1
Arg [A(j500)] = -135°
However, since:
A(s) = L(s) G(s)
then it follows that G(s) must have magnitude of:
|G(j500)| = |A(j500)/L(j500)| = 40
and a phase:
|G(j500)| = |P + (j500D)| = 40
and:
G = 20.6 + 0.0686s
The function G is equivalent to a digital filter of the form:
D(z) = KP + KD(1-z-1)
where:
KP = P
and:
KD = D/T
32
LEGEND-MC User’s Manual
Assuming a sampling period of T=1ms, the parameters of the digital filter are:
KP = 20.6
KD = 68.6
The LEGEND-MC can be programmed with the instruction:
KP 20.6
KD 68.6
In a similar manner, other filters can be programmed. The procedure is simplified by the following table,
which summarizes the relationship between the various filters.
KP, KD, KI K = KP + KD
A = KD/(KP+KD)
C = KI/8
GN, ZR, KI K = GN
A = ZR
C = KI/8
PID, T P = K(1-A) = KP
D = K.A.T = T.KD
I = C/T = KI/8T
33
LEGEND-MC User’s Manual
NOTES:
34
LEGEND-MC User’s Manual
3 Communications
Introduction
The LEGEND-MC has one RS232 port and one Ethernet port. The RS-232 port is the data set. The RS-
232 is a standard serial link with communication baud rates up to 19.2kbaud. The Ethernet port is a
10Base-T link.
RS232 Port
The LEGEND-MC has a single RS232 connection for sending and receiving commands from a PC or
other terminal. The pin connections for the RS232 connection are as follows.
Port 1 DATATERM
5 Ground
35
LEGEND-MC User’s Manual
Configuration
Although Yaskawa’s YTerm software automatically configures the port you may need to manually config-
ure the PC’s serial port if using third party software.
Configure your PC for 8-bit data, one start-bit, one stop-bit, full duplex and no parity. The baud rate for
the RS232 communication can be chosen by selecting the proper jumper configuration on the LEGEND-
MC according to the table below.
Handshaking Modes
The RS232 port is configured for hardware handshaking. In this mode, the RTS and CTS lines are used.
The CTS line will go high whenever the LEGEND-MC is not ready to receive additional characters. The
RTS line will inhibit the LEGEND-MC from sending additional characters.
Note: The RTS line goes high for inhibit. This handshake procedure ensures proper communication espe-
cially at higher baud rates.
If a device that is used in conjunction with the LEGEND-MC does not support hardware handshaking, sol-
der a jumper across the CTS and RTS lines. Remember that doing so may degrade communication reli-
ability.
Ethernet Configuration
Communication Protocols
The Ethernet is a local area network through which information is transferred in units known as packets.
Communication protocols are necessary to dictate how these packets are sent and received. The LEG-
END-MC supports two industry standard protocols, TCP/IP and UDP/IP. The controller will automati-
cally respond in the format in which it is contacted.
TCP/IP is a "connection" protocol. The master must be connected to the slave in order to begin communi-
cating. Each packet sent is acknowledged when received. If no acknowledgement is received, the infor-
mation is assumed lost and is resent.
Unlike TCP/IP, UDP/IP does not require a connection. This protocol is similar to communicating via
RS232. If information is lost, the controller does not return a colon or question mark. Because the proto-
col does not provide for lost information, the sender must re-send the packet.
Although UDP/IP is more efficient and simple, Yaskawa recommends using the TCP/IP protocol. TCP/IP
insures that if a packet is lost or destroyed while in transit, it will be resent.
Ethernet communication transfers information in ‘packets’. The packets must be limited to 470 data bytes
or less. Larger packets could cause the controller to lose communication.
NOTE: To avoid losing information in transit, Yaskawa recommends that the user wait for an acknowledge-
ment of receipt of a packet before sending the next packet.
NOTE: A command sent over an Ethernet Telnet session must reside in one packet. This means that a Telnet
emulator must not send a command such as MG_TPX<CR> until the carriage return is present; i.e., do not
send one character at a time as the user enters them.
36
LEGEND-MC User’s Manual
Addressing
There are three levels of addresses defining Ethernet devices. The first is the Ethernet or hardware
address- a unique and permanent 6 byte number, or MAC address. No other device has the same Ethernet
address. The LEGEND-MC Ethernet address is set by the factory and the last two bytes of the address are
the serial number of the controller.
The second level of addressing is the IP address. This is a 32-bit (or 4 byte) number. The IP address is
constrained by each local network and must be assigned locally. Assigning an IP address to the controller
can be done in a number of ways.
The first method is to use the BOOT-P utility via the Etherrnet connection (the LEGEND-MC must be
connected to the network and powered). For an explanation of BOOT-P see Third Party Software.
CAUTION: Be sure there is only one BOOT-P server running. If your network has DHCP or
BOOT-P running, it may automatically assign an IP address to the controller upon linking it to
the network. To ensure that the IP address is correct, please contact your system
administrator before connecting the controller to the Ethernet network.
PIC REQUIRED
The second method for setting an IP address is to send the IA command through the LEGEND-MC main
RS-232 port. The IP address you want to assign may be entered as a 4 byte number delimited by commas
(industry standard uses periods) or a signed 32 bit number. (Ex. IA 124,51,29,31 or IA 2083724575)
Type in BN to save the IP address to the controller's non-volatile memory.
NOTE: Yaskawa recommends that the IP address selected is not one that can be accessed across the Gate-
way. The Gateway is an application that controls communication between an internal network and the out-
side world.
The third level of Ethernet addressing is the UDP or TCP port number. The Yaskawa controller does not
require a specific port number. The port number is established by the master each time it connects to the
controller.
Ethernet Handles
An Ethernet handle is a communication resource within a device. The LEGEND-MC can have a maxi-
mum of 8 Ethernet handles open at any time. When using TCP/IP, each connection to a device; i.e., the
host computer, requires an individual Ethernet handle. In UDP/IP, one handle may be used for all the
masters, but each slave uses one. Pings and ARPS do not occupy handles. If all 8 handles are in use and
a 9th master tries to connect, it will be sent a “reset packet” that generates the appropriate error in its
native application.
37
LEGEND-MC User’s Manual
Ethernet or RS 232
Host Computer
LEGEND-MC LEGEND-MC
X Axis LEGEND-MC LEGEND-MC X Axis
X Axis X Axis
The LEGEND-MC supports Yaskawa’s control system. This allows up to four LEGEND-MC controllers
to be connected together as a single virtual axis controller. In this system, one of the controllers is desig-
nated as the master. The master can receive commands from the host computer that apply to all of the axes
in the system.
Here is a simple way to view Local and Global Operation; when the host communicates with a slave con-
troller, it considers the slave as a 1 axis controller. When the host communicates with a master, it considers
the master as a multi-axis controller. Similarly, an application program residing in a slave controller deals
only with 1 motor as A or X. An application program in a master deals with all motors referenced A
through H.
Global Operation
Host Computer
LEGEND-MC
X Axis
Ethernet
The controllers may operate under both Local and Global Mode. In general, operating in Global Mode
simplifies controlling the entire system. However, Local Mode operation is necessary in some situations;
using Local Mode for setup and testing is useful since this isolates the controller. Specific modes of
motion require operation in Local Mode. Also, each controller can have a program including the slave
controllers. When a slave controller has a program, this program would always operate in Local Mode.
38
LEGEND-MC User’s Manual
39
LEGEND-MC User’s Manual
Example
Bit 2 on the slave using handle E for the data record would be 502. The arguments for SB, CB, and OB use
this format as does the @IN[ ] function.
For byte and word-wide I/O, use the SA command such as: SAC=”OP6” to set the output port of handle C.
SAC=”TI” will return the input port on handle C and the operand, _SAC0 will contain the response from
the TI command.
40
LEGEND-MC User’s Manual
Example
Assume a system with one master and 2 slave LEGEND-MC controllers:
Instruction Interpretation
#SETUP Begin Program
QWC=20
EN
Modbus Support
The Modbus protocol supports communication between masters and slaves. The masters may be multiple
PC’s that send commands to the controller. The slaves are typically peripheral I/O devices that receive
commands from the controller.
Note: There are numerous ways to reset the controller; hardware reset (push reset button or power-down
controller) and software resets (through Ethernet or RS232 by entering RS). The only reset that will not
cause the controller to disconnect is a software reset via the Ethernet or RS232.
When the Yaskawa controller acts as the master, the IH command is used to assign handles and connect
to its slaves. The IP address may be entered as a 4 byte number separated with commas (industry standard
uses periods) or as a 32 bit number. A port may also be specified, but if not, it will default to 502. The
protocol (TCP/IP or UDP/IP) to use must also be designated at this time, otherwise, the controller will
not connect to the slave. (Ex. IHB=151,25,255,9<179>2 This will open handle #2 and connect to the I/P
address 151.25.255.9, port 179, using TCP/IP).
An additional protocol layer is available for speaking to I/O devices. Modbus is an RS-485 protocol that
packages information in binary packets that are sent as part of a TCP/IP packet. In this protocol, each
slave has a 1 byte slave address.The LEGEND-MC can use a specific slave address or default to the han-
dle number.
41
LEGEND-MC User’s Manual
Modbus protocol has commands called function codes. The LEGEND-MC supports 10 major function
codes:
17 Report Slave ID
The LEGEND-MC provides three levels of Modbus communication. The first level allows the user to cre-
ate a raw packet and receive raw data. It uses the MBh command with a function code of -1. The com-
mand format is:
MBh=-1,len, array[ ] where len is the number of bytes
array [ ] is the array with the data
The second level incorporates the Modbus structure. This is necessary for sending configuration and spe-
cial commands to an I/O device. The formats vary depending on the function code that is called. For more
information, refer to Command Reference
The third level of Modbus communication uses standard Yaskawa commands. Once the slave has been
configured, the commands that may be used are @IN[ ], @AN[ ], SB, CB, OB, and AO. For example, AO
2020,8.2 would tell I/O number 2020 to output 8.2 volts.
If a specific slave address is not necessary, the I/O number to be used can be calculated with the following:
I/O Number= (HandleNum*1000)+((Module-1)*4)+(BitNum)
Where HandleNum is the handle number from 1 (A) to 8 (H). Module is the position of the module in the
rack from 1 to 16. BitNum is the I/O point in the module from 1 to 4.
If an explicit slave address is to be used, the equation becomes:
I/O Number=(SlaveAddress*1000)+(HandleNum*1000)+((Module-1)*4)+(Bitnum-1)
Which devices receive what information from the controller depends on a number of things. If a device
queries the controller, it will receive the response unless it explicitly tells the controller to send it to
another device. If the command that generates a response is part of a downloaded program, the response
will route to whichever port is specified as the default (unless explicitly told to go to another port). To des-
ignate a specific destination for the information, add {Eh} to the end of the command. (Ex.
MG{EC}"Hello" will send the message "Hello" to handle #3. TP,,?{EF} will send the z axis position to
handle #6.)
42
LEGEND-MC User’s Manual
Multicasting
A multicast is only used in UDP/IP and is similar to a broadcast (everyone on the network gets the infor-
mation) but specific to a group. As such, all devices within a specified group will receive information
sent in a multicast. The many multicast groups on a network are differentiated by their multicast IP
address. To communicate with all devices in a specific multicast group, information can be sent to the
multicast IP address rather than to each device IP address. All LEGEND-MC controllers belong to a
default multicast address of 239.255.19.56. The controller's multicast IP address can be changed by using
the IA> u command.
43
LEGEND-MC User’s Manual
NOTES:
44
LEGEND-MC User’s Manual
4 Command Reference
AB (ABORT)
@ABS (ABSOLUTE VALUE)
AC (ACCELERATION)
@ACOS (ARC COSINE)
AD (AFTER DISTANCE)
AF (ANALOG FEEDBACK)
AI (AFTER INPUT)
AL (ARM LATCH)
AM (AFTER MOTION)
@AN (READ ANALOG)
AO (ANALOG OUTPUT)
AP (AFTER ABSOLUTE POSITION)
AR (AFTER RELATIVE DISTANCE)
AS (AT SPEED)
@ASIN (ARC SINE)
AT (AT TIME)
@ATAN (ARC TANGENT)
BG (BEGIN MOTION)
BL (REVERSE SOFTWARE LIMIT)
BN (BURN)
BP (BURN PROGRAM)
BV (BURN VARIABLES)
CB (CLEAR BIT)
CD (CONTOUR DATA)
CE (CONFIGURE ENCODER)
CF (CONFIGURE MESSAGES)
CH (CONNECT HANDLE)
CI (COMMUNICATION INTERRUPT)
CM (CONTOUR MODE)
CN (CONFIGURE LIMIT SWITCHES)
@COM (2’S COMPLEMENT)
@COS (COSINE)
CS (CLEAR SEQUENCE)
CW (COPYRIGHT INFORMATION / DATA ADJUSTMENT BIT ON/OFF)
DA (DE-ALLOCATE THE VARIABLES & ARRAYS)
DC (DECELERATION)
DE (DUAL (AUXILIARY) ENCODER POSITION)
DL (DOWNLOAD)
DM (DIMENSION)
DP (DEFINE POSITION)
DT (DELTA TIME)
45
LEGEND-MC User’s Manual
46
LEGEND-MC User’s Manual
LO (LOCKOUT)
LR (REVERSE LIMIT)
LS (LIST PROGRAM)
LV (LIST VARIABLES)
LZ (LEADING ZERO)
MB (MODBUS)
MC (MOTION COMPLETE - “IN POSITION”)
MF (FORWARD MOTION TO POSITION)
MG (MESSAGE)
MM (MASTER MODULUS)
MO (MOTOR OFF)
MR (REVERSE MOTION TO POSITION)
MT (MOTOR TYPE)
NA (NUMBER OF AXES)
NB (NOTCH BANDWIDTH)
NF (NOTCH FREQUENCY)
NO (NO OPERATION)
NZ (NOTCH ZERO)
OB (OUTPUT BIT)
OC (OUTPUT COMPARE)
OE (OFF ON ERROR)
OF (OFFSET)
OP (OUTPUT PORT)
@OUT (STATUS OF DIGITAL OUTPUT)
PA (POSITION ABSOLUTE)
PF (POSITION FORMAT)
PR (POSITION RELATIVE)
QD (DOWNLOAD ARRAY)
QR (DATA RECORD)
QU (UPLOAD ARRAY)
QW (SLAVE RECORD UPDATE RATE)
QZ (RETURN DATA RECORD INFORMATION)
RA (RECORD ARRAY)
RC (RECORD)
RD (RECORD DATA)
RE (RETURN FROM ERROR ROUTINE)
RI (RETURN FROM INTERRUPT ROUTINE)
RL (REPORT LATCHED POSITION)
@RND (ROUND)
RS (RESET)
<CONTROL>R <CONTROL>S (MASTER RESET)
<CONTROL>R <CONTROL>V (REVISION INFORMATION)
SA (SEND COMMAND)
SB (SET BIT)
SC (STOP CODE)
SH (SERVO HERE)
@SIN (SIN)
47
LEGEND-MC User’s Manual
SP (SPEED)
@SQR (SQUARE ROOT)
ST (STOP)
TB (TELL STATUS BYTE)
TC (TELL ERROR CODE)
TD (TELL DUAL ENCODER)
TE (TELL ERROR)
TI (TELL INPUTS)
TIME (TIME OPERAND KEYWORD))
TL (TORQUE LIMIT)
TM (TIME COMMAND)
TP (TELL POSITION)
TR (TRACE)
TS (TELL SWITCHES)
TT (TELL TORQUE)
TV (TELL VELOCITY)
TW (TIMEOUT FOR IN POSITION (MC))
UL (UPLOAD)
VA (VECTOR ACCELERATION)
VD (VECTOR DECELERATION)
VE (VECTOR SEQUENCE END)
VF (VARIABLE FORMAT)
VR (VECTOR SPEED RATIO)
VS (VECTOR SPEED)
VT (VECTOR TIME CONSTANT)
WC (WAIT FOR CONTOUR DATA)
WT (WAIT)
XQ (EXECUTE PROGRAM)
ZA (USER VARIABLES)
ZB (USER VARIABLES)
ZS (ZERO SUBROUTINE STACK)
48
LEGEND-MC User’s Manual
Command Description
Each executable instruction is listed in the following section in alphabetical order.
The two letter op-code for each instruction is placed in the upper left corner. Below the op-code is a
description of the command and required arguments. As arguments, some commands require actual val-
ues to be specified following the instruction. These commands are followed by lower case x, y, z, and w.
Values may be specified for any axis separately or any combination of axes. Axis values are separated by
commas. Examples of valid x ,y, z, w syntax are listed below. For the SMC-3010, the axis designators
a,b,c,d,e,f,g,h are used where x,y,z,w can be used interchangeably with a,b,c,d.
AC x Specify x only
AC ,y Specify y only
49
LEGEND-MC User’s Manual
50
LEGEND-MC User’s Manual
AB
FUNCTION:Abort [Motion]
DESCRIPTION:
AB (Abort) stops motion instantly without controlled deceleration by freezing the profiler. If there is a pro-
gram executing, AB also aborts the program unless a 1 argument is specified. The command, AB, will shut
off the motors (disable the amplifier) for any axis in which the off-on-error function is enabled (see com-
mand "OE"). AB aborts motion on all axes in motion and cannot stop individual axes. If a multi-axis sys-
tem is configured (distributed control) the AB command will abort all axes if issued to the master.
ARGUMENTS: AB n where
n = 0 aborts motion and program
n = 1 aborts motion without aborting program
USAGE:
While Moving Yes Default Value n/a
In a Program Yes Default Format n/a
Command Line Yes
OPERAND USAGE:
_AB returns the state of the Abort Input
RELATED COMMANDS:
"SH" Turns servos back on if they were shut-off by
Abort and OE1.
EXAMPLES:
OE 0,0,0,0 Disable OFF/ON error for all axes
AB Aborts motion unconditionally, motors remain
enabled
OE 1,1,1,1 Enable off-on-error
AB Shuts off amplifier enable and aborts motion
#A Label - Start of program
JG 20000 Specify jog speed on X-axis
BGX Begin jog on X-axis
WT 5000 Wait 5000 msec
AB1 Abort motion without aborting program
WT 5000 Wait 5000 milliseconds
SH Servo Here
JP #A Jump to Label A
EN End of the routine
Hint: Use parameter 1 following AB if you want the motion to be aborted or application program will be aborted.
51
LEGEND-MC User’s Manual
@ABS
FUNCTION: Absolute Value Function
DESCRIPTION:
@ABS returns the absolute value of a number or variable given in square brackets. Note that the @ABS
command is a function, which means that it does not follow the convention of the commands, and does not
require the underscore when used as an operand.
EXAMPLES:
OE 0,0,0,0 Program TEST
VAR1=45.6 Set a variable equal to -45.6
MG @ABS[VAR1] Display the absolute value of VAR1
VAR2=@ABS[VAR1]+100.404 Perform calculation
EN End of program
52
LEGEND-MC User’s Manual
AC
FUNCTION: Acceleration [Motion]
DESCRIPTION:
The Acceleration (AC) command sets the linear acceleration rate for independent moves, such as PR, PA
and JG moves. The parameters input will be rounded down to the nearest factor of 1024. The units of the
parameters are counts per second squared. The acceleration rate may be changed during motion. The DC
command is used to specify the deceleration rate.
ARGUMENTS: AC x, y, z, w or ACX=x or AC a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the acceleration value
USAGE:
While Moving Yes Minimum Value 1024
OPERAND USAGE:
RELATED COMMANDS:
"DC" Specifies deceleration rate.
EXAMPLES:
AC 150000 Set acceleration to 150000 counts/sec2
HINTS: Specify realistic acceleration rates based on your physical system such as motor torque rating, loads, and amplifier
current rating. Specifying an excessive acceleration will cause large following error during acceleration and the motor will
not follow the commanded profile. The acceleration feedforward command FA will help minimize error during accelera-
tion.
53
LEGEND-MC User’s Manual
@ACOS
FUNCTION: Arc Cosine Function
DESCRIPTION:
@ACOS returns the arc cosine, in degrees, of a number or variable which is inserted in square brackets.
Note that the @ACOS command is a function, which means that it does not follow the convention of
other commands and does not require the underscore when used as an operand.
ARGUMENTS: @ACOS [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -1
In a Program Yes Maximum n value 1
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=.707 Set a variable equal to .707
MG @ACOS[VAR1] Display the absolute value of VAR1
VAR2=@ACOS[VAR1]+100.404 Perform calculation
EN End of program
54
LEGEND-MC User’s Manual
AD
FUNCTION: After Distance [Trippoint]
DESCRIPTION:
The After Distance (AD) command is a trippoint used to control the timing of events. This command will
hold up the execution of the following command until one of the following conditions have been met:
1. The commanded motor position crosses the specified relative distance from the start of the
move.
2. The motion profiling on the axis is complete.
3. The commanded motion is in the direction which moves away from the specified position.
The units of the command are quadrature counts. The motion profiler must be on or the trippoint will auto-
matically be satisfied.
Note: AD will be affected when motion smoothing time constant, IT, is not 1. See IT command for more
information.
Used as an Operand No
RELATED COMMANDS:
"AR" After relative distance for sequential triggering
EXAMPLES:
#A;DP0 Begin Program
PR 10000 Specify position
BG Begin motion
AD 5000 Wait until profiler passes 5000 units from start
of move.
MG "Halfway" ;TP Send message
EN End Program
Hint: The AD command is accurate to the number of counts that occur in 2 msec. Multiply speed by 2 msec to obtain the
maximum position error in counts. Remember AD measures incremental distance from start of move on one axis.
55
LEGEND-MC User’s Manual
AF
FUNCTION: Analog Feedback [Configuration]
DESCRIPTION:
The Analog Feedback (AF) command is used to set an axis with analog feedback instead of digital feedback
(quadrature/pulse dir). As the analog feedback is decoded by a 12-bit A/D converter, an input voltage of 10
volts is decoded as a position of 2047 counts and a voltage of -10 volts corresponds to a position of -2048
counts.
ARGUMENTS: AF x,y,z,w or AFX=x or AF a,b,c,d,e,f,g,h where
x,y,z,w or a, b, c, d, e, f, g, h
1 = Enables analog feedback
0 = Disables analog feedback and switches to digital feedback
"?" returns a 0 or 1 which states whether analog feedback is enabled for the specified axes.
USAGE:
While Moving No Minimum Value 0
OPERAND USAGE:
_AFn returns the current feedback setting where n is an axis letter
RELATED COMMANDS:
"CE" Configure Encoder
EXAMPLES:
AF 1,0,0,1 Analog feedback on X and W axis
56
LEGEND-MC User’s Manual
AI
FUNCTION: After Input [Trippoint]
DESCRIPTION:
The AI command is used in motion programs to wait until after the specified input condition has occurred.
If n is positive, it waits for the input to go high. If n is negative, it waits for n to go low. To wait for a tran-
sition from high to low or low to high, put two AI commands together. AI is only available for local inputs.
ARGUMENTS: AI +/-n where
n is a signed integer
USAGE:
While Moving Yes Minimum Value 1
Used as an Operand No
RELATED COMMANDS:
@IN[n] Function to read digital input 1 through 8
EXAMPLES:
#A Begin Program
BG Begin motion
EN End Program
HINT: The AI command actually halts execution until specified input is at desired logic level. Use the conditional Jump
command (JP) or input interrupt (II) if you do not want the program sequence to halt.
57
LEGEND-MC User’s Manual
AL
FUNCTION: Arm Latch [Setting]
DESCRIPTION:
The AL command enables the latching function (high speed position capture) of the controller. When the
AL command is used to arm the position latch, the encoder position of the main encoder input will be cap-
tured upon a low going signal on Input 1. When interrogated or used in an operand the AL command will
return a 1 if the latch is armed or a zero after the latch has occurred. The command RL returns the captured
position value. The CN command will change the polarity of the latch.
ARGUMENTS: ALn where
n = XYZW or ABCDEFGH for the main encoder latch and
n = SX, SY, SZ, SW or SA, SB, SC, SD, SE, SF, SG, SH for the auxiliary encoder latch
USAGE:
While Moving Yes Minimum Value n/a
OPERAND USAGE:
_ALn or _ALSn contains the state of the latch where n is an axis letter. 0 = not armed, 1 = armed.
RELATED COMMANDS:
"RL" Report Latch
"CN" Configure
EXAMPLES:
#START Start program
JP #LOOP,_ALX=1
EN End of program
58
LEGEND-MC User’s Manual
AM
FUNCTION: After Move [Trippoint]
DESCRIPTION:
The AM command is a trippoint used to control timing of events. This command holds up execution of the
following commands until the current move on the specified axis or axes is completed. AM occurs when
the profiler is finished generating the last position command. However, the servo motor may not be in
final position. Use TE to verify position error for servos or use the MC trippoint to wait until final position
is reached by the servo.
ARGUMENTS: AM XYZWS or ABCDEFGH where
X, Y, Z, W or A, B, C, D, E, F, G, H are axis designators. S indicates an interpolation sequence. No argu-
ment specifies that motion on all axes is complete.
USAGE:
While Moving Yes Minimum Value n/a
RELATED COMMANDS:
"BG" _BG returns a 0 if motion complete
“MC” Actual Motion Complete
EXAMPLES:
#MOVE Start of program
PR 5000 Position relative move
BG Begin motion
AM Wait until motion is complete
EN End of Program
#F;DP 0 Program F
PR 5000 Position relative move
BG Begin motion
AM Wait until motion is complete
HINT: AM command controls the timing between multiple move sequences. If the motor is in the middle of a position rela-
tive move (PR), a position absolute move (PA, BG) cannot be made until the first move is complete. Use AM to pause the
program sequences until the first motion is complete. AM tests for profile completion. Another testing method is to query
the operand, _BG. This is equal to 1 during motion, and 0 when motion profiling is complete.
59
LEGEND-MC User’s Manual
@AN
FUNCTION: Read Analog Input
DESCRIPTION:
@AN returns the value of an analog input as a voltage (+/-10V). Note that the @AN command is a func-
tion, which means that it does not follow the convention of other commands, and does not require the
underscore when used as an operand. The resolution is 14 bit, or 1.2mV per bit. To read analog inputs
from a slave controller, use the SA command.
ARGUMENTS: @AN [n] where
n is an unsigned integer
USAGE:
While Moving Yes Minimum n Value 1
In a Program Yes Maximum n Value 2
Not in a Program Yes Default n Value n/a
Can be Interrogated No Default Format 10.4
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
MG @AN[2] Display the value of analog input #2 as a volt-
age
JGX=@AN[2]*10000 Set jog speed according to analog input
SAA=”MG”,”@AN”,”[2]” Sends command MG @AN[2] to slave on han-
dle A
Analog3=_SAA Returns slave response to SA command
BGX Begin Move
EN End of program
60
LEGEND-MC User’s Manual
AO
FUNCTION: Analog Out [I/O]
DESCRIPTION:
The AO command sets the analog output voltage of the local analog output or ModBus devices connected
via Ethernet.
ARGUMENTS:AO m, n where
m is either the local analog output voltage ranging from 9.9982 to -9.9982 or the I/O number calculated
using the following equations:
m = (SlaveAddress*1000) + (HandleNum*1000) + (Module-1)*4) + (Bitnum-1)
Slave Adrress is used when the ModBus device has slave devices connected to it and specified as
Addresses 0 to 225. Please note that the uses for ModBus are very rare and this number will usually be 0.
HandleNum is the handle specifier from A to H (1 - 8).
Module is the position of the module in the rack from 1 to 16.
BitNum is the I/O point in the module from 1 to 4.
n = the voltage which ranges from 9.9982 to –9.9982. If m is < 1000, n is omitted.
USAGE:
While Moving Yes Minimum n Value -9.9982
OPERAND USAGE: _AO returns the value of the local analog output in volts.
RELATED COMMANDS:
"SB" Set Bit
"MB" Modbus
EXAMPLES:
AO -3.4 Sets local analog output to -3.4V
AO 6016, 8.2 Sets analog output on modbus device on han-
dle F to 8.2V
SAA=”AO”,2.7 Set analog output of slave on handle A to 2.7V
SAA=”MG”,”_AO” Send command MG_AO to slave controller on
handle A
VAR1=_SAA Store the returned value to VAR1
61
LEGEND-MC User’s Manual
AP
FUNCTION: After Absolute Position [Trippoint]
DESCRIPTION:
The After Position (AP) command is a trippoint used to control the timing of events. This command will
hold up the execution of the following command until one of the following conditions have been met:
1. The commanded motor position crosses the specified absolute position.
2. The motion profiling on the axis is complete.
3. The commanded motion is moving away from the specified position.
The units of the command are quadrature counts. The motion profiler must be active or the trippoint will
automatically be satisfied.
ARGUMENTS: AP x, y, z, w or APX=x or AP a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
USAGE:
While Moving Yes Minimum Value -2147483648
In a Program Yes Maximum Value 2147483647
Used as an Operand No
RELATED COMMANDS:
"AR" Trippoint for relative distances
EXAMPLES:
#TEST Program B
BG Begin move
AP 2000 After passing position 2000
EN End of Program
HINT: The accuracy of the AP command is the number of counts that occur in 2 msec. Multiply the speed by 2 msec to
obtain the maximum error. AP tests for absolute position. Use the AD command to measure incremental distances.
62
LEGEND-MC User’s Manual
AR
FUNCTION: After Relative Distance [Trippoint]
DESCRIPTION:
The After Relative (AR) command is a trippoint used to control the timing of events. This command will
hold up the execution of the following command until one of the following conditions have been met:
1. The commanded motor position crosses the specified relative distance from either the start of
the move or the last AR or AD command.
2. The motion profiling on the axis is complete.
3. The commanded motion is in the direction which moves away from the specified position.
The units of the command are quadrature counts. The motion profiler must be active or the trippoint will
automatically be satisfied.
ARGUMENTS: AR x, y, z, w or ARX=x or AR a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
USAGE:
While Moving Yes Minimum Value 0
Used as an Operand No
RELATED COMMANDS:
"AP" Trippoint for after absolute position
EXAMPLES:
#A;DP 0 Begin Program
BG Begin motion
#B Label
JP #B Jump to Label #B
EN End Program
HINT: AR is used to specify incremental distance from last AR or AD command. Use AR if multiple position trippoints are
needed in a single motion sequence.
63
LEGEND-MC User’s Manual
AS
FUNCTION: At Speed [Trippoint]
DESCRIPTION:
The AS command is a trippoint that occurs when the generated motion profile has reached the specified
speed. This command will hold up execution of the following command until the speed is reached. The AS
command will operate after either accelerating or decelerating. If the commanded speed is not reached, the
trippoint will be triggered after the motion is stopped (after deceleration).
ARGUMENTS: AS XYZWS or ABCDEFGH where
X, Y, Z, W or A, B, C, D, E, F, G, H are axis designators. S indicates an interpolation sequence. No argument
specifies that motion on all axes is complete.
USAGE:
While Moving Yes Minimum Value n/a
Used as an Operand No
EXAMPLES:
#SPEED Program A
BG Begin motion
EN End of Program
WARNING: The AS command applies to a trapezoidal velocity profile only with linear acceleration. AS used with S-curve
profiling may be inaccurate.
64
LEGEND-MC User’s Manual
@ASIN
FUNCTION: Arc Sine Function
DESCRIPTION:
@ASIN returns the arc sine, in degrees, of a number or variable which is inserted in square brackets.
Note that the @ASIN command is a function, which means that it does not follow the convention of
other commands, and does not require the underscore when used as an operand.
ARGUMENTS: @ASIN [n] where
n is an unsigned integer
USAGE:
While Moving Yes Minimum n value -1
In a Program Yes Maximum n value 1
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
MG @ASIN[VAR1] Set variable
VAR1=.707 Display the arc sine of .707
VAR2=@ASIN[VAR1]+5 Perform calculation
EN End of program
65
LEGEND-MC User’s Manual
AT
FUNCTION: At Time [Trippoint]
DESCRIPTION:
The AT command is a trippoint which is used to hold up execution of the next command until after the spec-
ified time has elapsed. The time is measured with respect to a defined reference time. AT 0 establishes the
initial reference. AT n specifies n msec from the reference. AT -n specifies n msec from the reference and
establishes a new reference after the elapsed time period. This command is useful for waiting an accurate
amount of time duration while still being able to perform some other operations as long as they require less
time than the AT time.
ARGUMENTS: AT n where
n is a signed integer
n = 0 defines a reference time at current time
positive n waits n msec from reference
negative n waits n msec from reference and sets new reference after elapsed time period
(AT -n is equivalent to AT n; AT 0)
USAGE:
While Moving Yes Minimum Value -2147483647
Used as an Operand No
EXAMPLES:
The following commands are sent sequentially:
AT 0 Establishes reference time 0 as current time
66
LEGEND-MC User’s Manual
@ATAN
FUNCTION: Arc Tangent Function
DESCRIPTION:
@TAN returns the arc tangent, in degrees, of a number or variable which is inserted in square brackets.
Note that the @ATAN command is a function, which means that it does not follow the convention of
other commands, and does not require the underscore when used as an operand.
ARGUMENTS: @ATAN [n] where
n is an unsigned integer
USAGE:
While Moving Yes Minimum n value -1
In a Program Yes Maximum n value 1
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
MG @ATAN[VAR1] Set variable
VAR1=.707 Display the arc sine of .707
VAR2=@ATAN[VAR1]+5 Perform calculation
EN End of program
67
LEGEND-MC User’s Manual
BG
FUNCTION: Begin [Motion]
DESCRIPTION:
The BG command starts motion. When used as an operand, the BG command will return a 1 if there is a
commanded motion in progress, a 0 otherwise. The BG command will result in a command error if a move
is already in progress, the servo is not enabled or a limit switch is preventing motion.
ARGUMENTS: BG XYZWS or ABCDEFGH where
X, Y, Z, W, S or A, B, C, D, E, F, G, H specify the axis or sequence. No argument specifies that motion on all
axes is complete.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
OPERAND USAGE:
_BGn contains a ‘0’ if motion complete on the axis, otherwise contains a ‘1’ where n is an axis letter.
RELATED COMMANDS:
"AM" After motion complete
EXAMPLES:
PR 2000 Set up for a relative move
BG Begin motion
BG Begin motion
BG Begin motion
HINT: You cannot give another BG command until current BG motion has been completed. Use the AM trippoint to wait
for motion complete between moves. Another method for checking motion complete is to test for _BG being equal to 0.
68
LEGEND-MC User’s Manual
BL
FUNCTION: Reverse Software Limit [Setting]
DESCRIPTION:
The BL command sets the reverse software limit. If this limit is exceeded during a commanded motion, the
motion will decelerate to a stop. Reverse motion beyond this limit is not permitted. The reverse limit is
activated at position n-1 count. To disable the reverse limit, set n to -2147483648. The units are in quadra-
ture counts.
ARGUMENTS: BLx, y, z, w or BLX=x or BL a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
“?” returns the reverse software limit value
-2147483648 turns off the reverse limit.
USAGE:
While Moving Yes Minimum Value -2147483648
OPERAND USAGE:
_BLn contains the value of the reverse software limit where n is an axis letter.
RELATED COMMANDS:
EXAMPLES:
"FL" Forward Limit
BG Begin Motion
AM After Motion (soft limit occurred)
TP Tell Position
EN End Program
69
LEGEND-MC User’s Manual
BN
FUNCTION: Burn [General]
DESCRIPTION:
The BN command saves certain controller parameters in non-volatile EEPROM memory. This command
takes approximately one second to execute and must not be interrupted. If the burn is disrupted by power
failure, a memory checksum error will result. The controller returns a <:> when the Burn is complete.
AC EO KD PF
AF EP KI SB
BL ER KP SP
CB ET LZ TL
CE FA MM TM
CN FL MO (MOTOR OFF or ON) TR
CW GA MT VA
DC GR NA VD
DV IA OE VF
EA IL OF VS
EM IT OP VT
ARGUMENTS: None
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
70
LEGEND-MC User’s Manual
BP
FUNCTION: Burn Program [General]
DESCRIPTION:
The BP command saves the application program in non-volatile EEPROM memory. This command typi-
cally takes up to 10 seconds to execute and must not be interrupted. If the burn is disrupted by power fail-
ure, a memory checksum error will result. The controller returns a <: >when the Burn is complete.
ARGUMENTS: None
USAGE:
While Moving No Default Value ---
In a Program No
Can be Interrogated No
Used as an Operand No
71
LEGEND-MC User’s Manual
BV
FUNCTION: Burn Variables and Array [General]
DESCRIPTION:
The BV command saves the defined variables and arrays in non-volatile EEPROM memory. This command
typically takes up to 2 seconds to execute and must not be interrupted. If the burn is disrupted by power fail-
ure, a memory checksum error will result. The controller returns a <:> when the Burn variables are com-
plete.
ARGUMENTS: None
USAGE:
While Moving No Default Value ---
In a Program No
Can be Interrogated No
72
LEGEND-MC User’s Manual
CB
FUNCTION: Clear Bit [I/O]
DESCRIPTION:
The CB command clears a bit on the output port by setting it to logic zero. Slave controller or Modbus out-
puts can be cleared also.
ARGUMENTS: CB n where
n is an integer corresponding to a specific output on the controller to be cleared (set to 0). The first output
on the controller is denoted as output 1. A LEGEND-MC controller has 4 digital outputs plus applicable I/
O connected by Modbus.
DISTRIBUTED CONTROL:
MODBUS:
Note: When using Modbus devices, the I/O points of the modbus devices are calculated
using the following formula:
n = (SlaveAddress*1000) + (HandleNum*1000) + ((Module-1)*4) + (Bitnum-1)
Slave Address is used when the ModBus device has slave devices connected to it and specified as
Addresses 0 to 255. The use of slave devices for modbus are very rare and this number will usually be 0.
HandleNum is the handle specifier from A to H (1 - 8).
Module is the position of the module in the rack from 1 to 16.
BitNum is the I/O point in the module from 1 to 4.
USAGE:
While Moving Yes Default Value ---
In a Program Yes Default Format ---
Command Line Yes
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"SB" Set Bit
"OP" Define all outputs
EXAMPLES:
CB 1 Clear output bit 1
CB 2 Clear output bit 2
CB 3 Clear output bit 3
CB 602 Clear output 2 on slave controller on handle F
73
LEGEND-MC User’s Manual
CD
FUNCTION: Contour Data [Motion]
DESCRIPTION:
The CD command specifies the incremental position for an arbitrary motion profile. The units of the com-
mand are in quadrature counts. This command is only applicable in the Contour Mode (CM).
ARGUMENTS: CD x, y, z, w or CDX=x or CD a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
USAGE:
While Moving Yes Minimum Value -32767
Used as an Operand No
RELATED COMMANDS:
"CM" Contour Mode
EXAMPLES:
CM Specify Contour Mode
CD 0 Exit Mode
74
LEGEND-MC User’s Manual
CE
FUNCTION: Configure Encoder [Configuration]
DESCRIPTION:
The CE command configures the encoder inputs to the quadrature type or the pulse and direction type. It
also allows inverting the polarity. The configuration applies independently to the main axis encoder and the
auxiliary encoder inputs.
ARGUMENTS: CE x, y, z, w or CEX=x or CE a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
Each integer is the sum of two integers r and s which configure the main and the auxiliary encoders accord-
ing to the chart below.
“?” returns the encoder inputs
For example: CEX = 10 implies r = 2 and s = 8, both encoders are reversed quadrature.
USAGE:
While Moving Yes Minimum Value 0
In a Program Yes Maximum Value 10
OPERAND USAGE:
_CEn contains the value of encoder type for the main and auxiliary encoder where n is an axis letter.
RELATED COMMMANDS:
"MT" Specify motor type
EXAMPLES:
CE 0 Configure encoders
CE ? Interrogate configuration
V = _CE Assign configuration to a variable
75
LEGEND-MC User’s Manual
CF
FUNCTION: Configure Messages [Configuration]
DESCRIPTION:
Sets the controller’s default port for unsolicited messages. By default, the LEGEND-MC controller will
send unsolicited responses to the RS-232 serial port . An unsolicited message is one generated in the con-
troller, i.e.; a program fault message or a message resulting from the MG command with no port designation
specified.
ARGUMENTS: CF n where
n is A thru H for Ethernet handles 1 thru 8, S for serial port.
USAGE:
While Moving Yes Default Value 83 (“S”)
OPERAND USAGE:
_CF will return the current port selected for unsolicited responses from the controller. The _CF will return a
decimal value of the ASCII code.
EXAMPLES:
CFA Select Ethernet handle A to return unsolicited
responses.
76
LEGEND-MC User’s Manual
CH
FUNCTION: Connect Handle [General]
DESCRIPTION:
The CH command is used to associate master and slave controllers in a distributed control system. The
master controller must associate one Ethernet handle for sending commands to each slave, and one Ether-
net handle for receiving status information from each slave. Note that these handles must first be opened
before assigning them with this command, see the command IH.
RELATED COMMANDS:
EXAMPLE:
CHY=A,B Using one LEGEND-MC as a master and one LEGEND-MC as a slave
under TCP/IP. This command assigns a slave, identified by the Y axis
designator, with Handle A for commands and Handle B for status
returned from the slave.
77
LEGEND-MC User’s Manual
78
LEGEND-MC User’s Manual
CM
FUNCTION: Contouring Mode [Setting]
DESCRIPTION:
The Contour Mode is initiated by the instruction CM. This mode allows the generation of an arbitrary
motion trajectory. The CD command specifies the position increment, and the DT command specifies the
time interval.
The CM? or _CM commands can be used to check the status of the Contour Buffer. A value of 1 returned
indicates that the Contour Buffer is full. A value of 0 indicates that the Contour Buffer is empty.
ARGUMENTS: CM XYZW or ABCDEFGH
CM? Returns a 1 if the contour buffer is full, and 0 if the contour buffer is empty.
USAGE:
While Moving No Default Value ---
Can be Interrogated No
OPERAND USAGE:
_CM contains a ‘0’ if the contour buffer is empty, otherwise contains a ‘1’ meaning the buffer is
full.
RELATED COMMANDS:
"CD" Contour Data
EXAMPLES:
V=_CM;V= Return Contour Buffer Status
79
LEGEND-MC User’s Manual
CN
FUNCTION: Configure Limit Switches [Configuration]
DESCRIPTION:
The CN command configures the polarity of the limit switches, the home switch and the latch input.
ARGUMENTS: CN m,n,o where
m, n, o are integers .
n= 1 Home switch configured to drive motor in forward direction when input is high
upon initial HM execution. See HM and FE commands
-1 Home switch configured to drive motor in reverse direction when input is high
upon initial HM execution. See HM and FE commands
*
Note: The latch function will occur within 25usec only when used in active low mode, the opto iso
lator requires more time if active high .
USAGE:
While Moving Yes Default Value -1.-1.-1
Can be Interrogated No
OPERAND USAGE:
_CN0 Contains the limit switch configuration.
_CN1 Contains the home switch configuration.
_CN2 Contains the latch input configuration.
RELATED COMMANDS:
"MT" Motor Type
EXAMPLES:
CN 1,1 Sets limit and home switches to active high
80
LEGEND-MC User’s Manual
@COM
FUNCTION: 2’s Complement
DESCRIPTION:
@COM returns the complement of a number or variable which is inserted in square brackets. Note that
the @COM command is a function, which means that it does not follow the convention of other com-
mands, and does not require the underscore when used as an operand.
ARGUMENTS: @COM [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -2147483647.9999
In a Program Yes Maximum n value 2147483647.9999
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=1234 Set variable
MG @COM[VAR1] Display the complement of 1234
VAR2=@COM[VAR1]+99 Perform calculation
EN End of program
81
LEGEND-MC User’s Manual
@COS
FUNCTION: Cosine
DESCRIPTION:
@COS returns the cosine of a number or variable given in square brackets using units of degrees. Note
that the @COS command is a function, which means that it does not follow the convention of the com-
mands, and does not require the underscore when used as an operand.
ARGUMENTS: @COS [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -32768
In a Program Yes Maximum n value 32768
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=60 Set variable
MG @COS[VAR1] Display the value of the sine of VAR1
VAR2=@COS[VAR1]+9 Perform calculation
EN End of program
82
LEGEND-MC User’s Manual
CS
FUNCTION: Clear Sequence [General]
DESCRIPTION:
The CS command will remove VP or LI commands stored in a motion sequence. Please note that after a
sequence has been run, the CS command is not necessary to enter a new sequence. This command is use-
ful if you have correctly specified VP or LI commands.
When used as an operand, _CS returns the number of the segment in the sequence, starting at zero. The
instruction _CS is valid in the Linear Mode, LM, Vector Mode, VM and Contour Mode, CM .
ARGUMENTS: none
USAGE:
While Moving No Default Value ---
In a Program Yes Default Format ---
Not in a program Yes
Can be Interrogated No
EXAMPLES:
#CLEAR Label
VP 1000,2000 Vector position
VP 4000,8000 Vector position
CS Clear vectors
VP 1000,5000 New vector
VP 8000,9000 New vector
VE End sequence
BGS Begin motion sequence
EN End of program
83
LEGEND-MC User’s Manual
CW
FUNCTION: Copyright information / Data Adjustment Bit On/Off [General]
DESCRIPTION:
The CW command has a dual usage. The CW command will return the copyright information when the
argument, n is 0. Otherwise, the CW command is used as a communications enhancement. When CW = 1,
the communication enhancement sets the MSB of unsolicited, returned ASCII characters to 1. Unsolicited
ASCII characters are those characters which are returned from the controller without being directly queried
from an external source. This is the case when a program has a command that requires the controller to
return a value or string. The benefit of this is that two-way unsolicited messages can be filtered by an exter-
nal source to retrieve answers to strings that were sent by the external source.
ARGUMENTS: CW n,m where
n is a number, either 0,1 or 2:
0 Causes the controller to return the copyright information
1 Causes the controller to set the MSB of unsolicited returned characters to 1
2 Causes the controller to not set the MSB of unsolicited characters.
“?” returns the copyright information for the controller
m is 0 or 1 (optional)
0 Causes the controller to pause program execution when output FIFO is full until FIFO
no longer full.
1 Causes the controller to continue program execution when output FIFO is full - output
characters after FIFO is full will be lost.
USAGE:
While Moving Yes* Default Value n/a
Can be Interrogated No
OPERAND USAGE:
_CW contains the value of the data adjustment bit. 1 =on, 2 = off
*Note: The CW command can cause garbled characters to be returned by the controller. The
default state of the controller is to disable the CW command, however, the Yaskawa Y-Term soft-
ware may sometimes enable the CW command for internal usage. If the controller is reset while the
Yaskawa software is running, the CW command could be reset to the default value which would cre-
ate difficulty for the software. It may be necessary to re-enable the CW command. The CW com-
mand status can be stored in EEPROM.
84
LEGEND-MC User’s Manual
DA
FUNCTION: Deallocate Variables & Arrays [General]
DESCRIPTION:
The DA command frees array and/or variable memory space. With this command, more than one array or
variable can be specified for memory de-allocation. Different arrays and variables are separated by comma
when specified in one command. The * argument de-allocates all variables, and *[0] de-allocates all
arrays.
ARGUMENTS: DA c[0],d,etc. where
c[0] - Defined array name
d - Defined variable name
* - De-allocates all the variables
*[0] - De-allocates all the arrays
DA? Returns the number of arrays available on the controller.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_DA contains the total number of arrays available. For example, before any arrays have been defined, the
operand _DA is 14. If one array is defined, the operand _DA will return 13.
RELATED COMMANDS:
"DM" Dimension Array
EXAMPLES:
‘Cars’ and ‘Salesmen’ are arrays and ‘Total’ is a variable.
Cars[400],Salesmen[50] Dimension 2 arrays
NOTE: Since this command de-allocates the spaces and compacts the array spaces in the memory,
it is possible that execution of this command may take longer time than 2 ms.
85
LEGEND-MC User’s Manual
DC
FUNCTION: Deceleration [Motion]
DESCRIPTION:
The Deceleration command (DC) sets the linear deceleration rate for independent moves such as PR, PA and
JG moves. The parameters will be rounded down to the nearest factor of 1024 and have units of counts per
second squared.
ARGUMENTS: DC x, y, z, w or DCX=x or DC a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the deceleration value
USAGE:
While Moving Yes* Minimum Value 1024
OPERAND USAGE:
RELATED COMMANDS:
"AC" Acceleration
"PR" Position Relative
"SP" Speed
"JG" Jog
"BG" Begin
EXAMPLES:
PR 10000 Specify relative position
*NOTE: The DC command may be changed during the move in JG move, but not in PR or PA
move. For controlled deceleration in abort conditions, use the ST command.The deceleration rate
can be changed after ST.
86
LEGEND-MC User’s Manual
DE
FUNCTION: Dual (Auxiliary) Encoder Position [Motion]
DESCRIPTION:
The DE command defines the position of the auxiliary encoder.
USAGE:
While Moving Yes Minimum Value -2147483647
OPERAND USAGE:
_DEn returns the current position of the specified auxiliary encoder where n is an axis letter.
EXAMPLES:
:DE 0 Set the auxiliary encoder position to 0
HINT: Dual encoders are useful when you need an encoder on the motor and on the load. The encoder on the load is typi-
cally the auxiliary encoder and is used to verify the true load position. Any error in load position is used to correct the
motor position.
87
LEGEND-MC User’s Manual
DL
FUNCTION: Download [General]
DESCRIPTION:
The DL command prepares a controller to accept a data file from the host computer. Instructions in the file
will be accepted as a data stream without line numbers. The file is terminated using <control> Z, <control>
Q, <control> D, or \.
If no parameter is specified, downloading a data file will clear any programs in the LEGEND-MC RAM.
The data is entered beginning at line 0. If there are too many lines or too many characters per line, the LEG-
END-MC will return a “?”. To download a program after a label, specify the label name following DL. The
# argument may be used with DL to append a file at the end of the LEGEND-MC program in RAM.
ARGUMENTS: DL n
n = no argument Downloads program beginning at line 0 and erases programs in RAM.
n = #Label Begins download at line following #Label where label may be any valid program label.
n = #Begins download at end of program in RAM.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
OPERAND USAGE:
When used as an operand, _DL gives the number of available labels. The total number of labels is 126.
RELATED COMMANDS:
"UL" Upload
EN Data
88
LEGEND-MC User’s Manual
DM
FUNCTION: Dimension [General]
DESCRIPTION:
The DM command defines a single dimensional array with a name and total elements. The first element of
the defined array starts with element number 0 and the last element is at n-1.
ARGUMENTS: DM c[n] where
c is a name of up to eight alphanumeric characters, starting with an uppercase alphabetic character.
n is the number of entries from 1 to 8000.
DM? Returns the number of array elements available.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_DM contains the available array space. For example, before any arrays have been defined, the operand
_DM will return 8000. If an array of 100 elements is defined, the operand _DM will return 7900.
RELATED COMMANDS:
"DA" Deallocate Array
EXAMPLES:
DM Pets[5],Dogs[2],Cats[3] Define dimension of arrays, pets with 5 ele-
ments; Dogs with 2 elements; Cats with 3 ele-
ments
89
LEGEND-MC User’s Manual
DP
FUNCTION: Define Position [Setting]
DESCRIPTION:
The DP command sets the current motor position and current command positions to a user specified value.
The units are in quadrature counts. This command will set both the TP and RP values.
OPERAND USAGE:
_DPn reports the current position where n is an axis letter.
EXAMPLES:
:DP 0 Sets the current position of the X axis to 0
:DP ?
90
LEGEND-MC User’s Manual
DT
FUNCTION: Delta Time [Motion]
DESCRIPTION:
The DT command sets the time interval for Contouring Mode. Sending the DT command once will set the
time interval for all following contour data until a new DT command is sent. 2n samples is the time inter-
val. Sending DT0 followed by CD0 command terminates the Contour Mode.
ARGUMENTS: DT n where
n is an integer. 0 terminates the Contour Mode.
n=1 thru 8 specifies the time interval of 2n samples. By default the sample period is 1 msec (set by TM
command); with n=1, the time interval would be 2 msec.
DT? Returns the value for the time interval for contour mode.
USAGE:
While Moving Yes Minimum Value 0
OPERAND USAGE:
_DT contains the value for the time interval for Contour Mode
RELATED COMMANDS:
"CM" Contour Mode
EXAMPLES:
DT 4 Specifies time interval to be 16 msec
#CONTOUR Begin
WC Wait
EN End
91
LEGEND-MC User’s Manual
DV
FUNCTION: Dual Velocity (Dual Loop) [Setting]
DESCRIPTION:
The DV function changes the operation of the PID servo loop. It causes the KD (derivative) term to operate
on the dual encoder instead of the main encoder. This results in improved stability in the cases where there
is a backlash between the motor and the main encoder, and where the dual encoder is mounted on the motor.
See the example section.
ARGUMENTS: DV x, y, z, w or DVX=x or DV a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
n may be 0 or 1. 0 disables the function. 1 enables the dual loop.
“?” returns a 0 if dual velocity mode is disabled and 1 if enabled for the specified axis.
USAGE:
While Moving Yes Minimum Value 0
OPERAND USAGE:
_DVn contains the state of dual velocity mode where n is an axis letter and 0 = disabled, 1 = enabled.
RELATED COMMANDS:
"KD" Damping constant
EXAMPLES:
DV 1 Enables dual loop PID
DV 0 Disables DV
92
LEGEND-MC User’s Manual
EA
FUNCTION: ECAM master [Setting]
DESCRIPTION:
The EA command selects the master axis for the electronic cam mode.
ARGUMENTS: EA x where
X or SX
USAGE:
While Moving Yes Default Value n/a
RELATED COMMANDS:
"EB" Enable ECAM
EXAMPLES:
EASX Select auxiliary encoder as the master for ECAM
93
LEGEND-MC User’s Manual
EB
OPERAND USAGE:
_EB contains the state of Ecam mode. 0 = disabled, 1 = enabled
RELATED COMMANDS:
”EM“ Specify Ecam Cycle
EXAMPLES:
EB1 Starts ECAM mode
Note: See the example section for more detailed cam examples.
94
LEGEND-MC User’s Manual
EC
FUNCTION: ECAM Counter [Setting]
DESCRIPTION:
The EC function sets the index into the ECAM table. This command is only useful when entering ECAM
table values without index values and is most useful when sending commands in binary. See the com-
mand, ET.
ARGUMENTS: EC n where
n is an integer between 0 and 256.
n = ? Returns the current value of the index into the ECAM table.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_EC contains the current value of the index into the ECAM table.
RELATED COMMANDS:
"EA" Choose ECAM master
EXAMPLES:
EC0 Set ECAM index to 0
95
LEGEND-MC User’s Manual
ED
FUNCTION: Edit [General]
DESCRIPTION:
Using Yaskawa YTerm Software or any other terminal emulator: The ED command puts the controller into
the Edit subsystem. In the Edit subsystem, programs can be created, changed or destroyed. The commands
in the Edit subsystem are:
<cntrl>D Deletes a line
<cntrl>I Inserts a line before the current one
<cntrl>P Displays the previous line
<cntrl>Q Exits the Edit subsystem
<return> Saves a line
ARGUMENTS: ED n where
n specifies the line number to begin editing. The default line number is the last line of program space with
commands.
USAGE:
While Moving No Default Value n/a
Can be Interrogated No
OPERAND USAGE:
_ED contains the line number of the last line to have an error. Very useful in tracing problems in the field.
EXAMPLES:
000 #START
001 PR 2000
002 BG
004 EN
009 ST
010 ZS0
011 EN
HINT: Remember to quit the Edit Mode prior to executing or listing a program.
96
LEGEND-MC User’s Manual
EG
FUNCTION:ECAM Engage [Motion]
DESCRIPTION:
The EG command engages an ECAM operation at a specified position of the master encoder. If a value is
specified outside of the master’s range, the slave will engage immediately. Once a slave motor is engaged,
its position is redefined to fit within the cycle.
ARGUMENTS: EG n where
n is the master position at which the slave axis must be engaged.
“?” returns 1 if specified axis is engaged and 0 if disengaged
USAGE:
While Moving Yes Minimum value -2147483648
OPERAND USAGE:
_EGn contains ECAM status where n is an axis letter. 0 = axis is not engaged, 1 = axis is engaged.
RELATED COMMANDS:
“EB” Enable Ecam
EXAMPLES:
EG 700 Engages slave at master position 700.
NOTE: This command is not a trippoint. This command will not hold the execution of the pro-
gram flow. If the execution needs to be held until master position is reached, use MF or MR com-
mand.
97
LEGEND-MC User’s Manual
ELSE
FUNCTION: Else Function for use with IF Conditional Statement [Program Flow]
DESCRIPTION:
The ELSE command is an optional part of an IF conditional statement. The ELSE command must occur
after an IF command and it has no arguments. It allows for the execution of a command only when the argu-
ment of the IF command evaluates False. If the argument of the IF command evaluates false, the controller
will skip commands until the ELSE command. If the argument for the IF command evaluates true, the con-
troller will execute the commands between the IF and ELSE command.
ARGUMENTS: none
USAGE:
While Moving Yes Default Value ---
Command Line No
RELATED COMMANDS:
"ENDIF" End of IF conditional Statement
EXAMPLES:
IF (@IN[1]=0) IF conditional statement based on input 1
98
LEGEND-MC User’s Manual
EM
FUNCTION: ECam Cycle [Setting]
DESCRIPTION:
The EM command is part of the ECAM mode. It is used to define the change in position over one com-
plete cycle of the slave. If a slave will return to its original position at the end of the cycle, the change is
zero. If the change is negative, specify the absolute value.
ARGUMENTS: EM n where
n is the net change in the slave axis.
USAGE:
While Moving Yes Minimum n parameter -2147483648
OPERAND USAGE:
_EMn contains the cam cycle of the slave where n is an axis letter.
RELATED COMMANDS:
"EP" CAM table intervals & starting point
EXAMPLES:
EM 2000 Define the net change in the slave to be 2000.
99
LEGEND-MC User’s Manual
EN
FUNCTION: End [Program Flow]
DESCRIPTION:
The EN command is used to designate the end of a program or subroutine. If a subroutine was called by the
JS command, the EN command ends the subroutine and returns program flow to the point just after the JS
command.
The EN command is also used to end the automatic subroutines #MCTIME and #CMDERR.
ARGUMENTS: none
Note: Use the RE command to return from the interrupt handling subroutines #LIMSWI and
#POSERR. Use the RI command to return from the #ININT subroutine.
USAGE:
While Moving Yes Default Value n/a
Command Line No
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"RE" Return from error subroutine
EXAMPLES:
#A Program A
AMX Pause the program until the X axis completes the motion
EN End of Program
Note: Instead of EN, use the RE command to end the error subroutine and limit subroutine. Use
the RI command to end the input interrupt) subroutine.
100
LEGEND-MC User’s Manual
ENDIF
FUNCTION: End of IF Conditional Statement [Program Flow]
DESCRIPTION:
The ENDIF command is used to designate the end of an IF conditional statement. An IF conditional state-
ment is formed by the combination of an IF and ENDIF command. An ENDIF command must always be
executed for every IF command that has been executed. It is recommended that the user not include jump
commands inside IF conditional statements since this causes re-direction of command execution. In this
case, the command interpreter may not execute an ENDIF command.
ARGUMENTS: ENDIF
USAGE:
While Moving Yes Default Value n/a
Command Line No
RELATED COMMANDS:
"ELSE" Optional command to be used only after IF command
EXAMPLES:
IF (@IN[1]=0) IF conditional statement based on input 1
101
LEGEND-MC User’s Manual
EO
FUNCTION: Echo [Setting]
DESCRIPTION:
The EO command turns the echo on or off. If the echo is off, characters input to the serial port or Ethernet
will not be echoed back.
ARGUMENTS: EO n where
n=0 or 1. 0 turns echo off, 1 turns echo on.
USAGE:
While Moving Yes Default Value 1
Can be Interrogated No
Used as an Operand No
EXAMPLES:
EO 0 Turns echo off
EO 1 Turns echo on
102
LEGEND-MC User’s Manual
EP
FUNCTION: Cam Table Intervals and Starting Point [Setting]
DESCRIPTION:
The EP command defines the ECAM table intervals and offset. The offset is the master position where the
first ECAM table entry will synchronize. The interval is the difference of the master position between any
two consecutive table entries. This command effectively defines the size of the ECAM table. The param-
eter m is the interval and n is the starting point. Up to 257 points may be specified using the ET command.
ARGUMENTS: EP m,n where
m, n are signed integers
USAGE:
While Moving Yes Minimum m value 1
OPERAND USAGE:
_EP contains the value of the interval m.
RELATED COMMANDS:
"EB" Enable Ecam
EXAMPLES:
EP 20,100 Sets the cam master points to 100,120,140 . . .
103
LEGEND-MC User’s Manual
EQ
FUNCTION:ECAM Quit (disengage) [Motion]
DESCRIPTION:
The EQ command disengages an electronic cam slave axis at the specified master position. If a value is
specified outside of the master’s range, the slave will disengage immediately.
ARGUMENTS: EQ n where
n is the master position at which the axis is to be disengaged.
“?” contains a 1 if engage command issued and slave is waiting to engage, 2 if disengage command issued
and slave is waiting to disengage, and 0 if ECAM engaged or disengaged.
USAGE:
While Moving Yes Minimum value -2147483647
OPERAND USAGE:
_EQn contains 1 if engage command is issued and slave is waiting to engage, 2 if disengage command is
issued and slave is waiting to disengage, and 0 if ECAM engaged or disengaged.
RELATED COMMANDS:
"EB" Enable Ecam
EXAMPLES:
EQ 300 Disengages the motor at master position 300.
NOTE: This command is not a trippoint. This command will not hold the execution of the program
flow. If the execution needs to be held until master position is reached, use MF or MR command.
104
LEGEND-MC User’s Manual
ER
FUNCTION: Error Limit [Setting]
DESCRIPTION:
The ER command sets the magnitude of the position error that will trigger an error condition. When the
limit is exceeded, the Error LED will illuminate. If the Off-On-Error (OE1) command is active, the ampli-
fier will be disabled. The units of ER are quadrature counts.
ARGUMENTS: ER x, y, z, w or ERX=x or ER a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the Error limit.
USAGE:
While Moving Yes Minimum Value 1
OPERAND USAGE:
_ERn contains the value of the Error limit where n is an axis letter.
RELATED COMMANDS:
#POSERR Automatic Error Subroutine
EXAMPLES:
ER 200 Set the error limit to 200
ER ? Return value
00200
V1= Returns V1
00200
HINT: The error limit specified by ER should be high enough as not to be reached during normal operation. Examples of
exceeding the error limit would be a mechanical jam, or a fault in a system component such as encoder or amplifier.
105
LEGEND-MC User’s Manual
ET
FUNCTION:Electronic Cam Table [Setting]
DESCRIPTION:
The ET command sets the ECAM table entries for the slave axis. The values of the master are not required.
The slave entry (n) is the position of the slave when the master is at the point (n ∗ i) + o, where i is the inter-
val and o is the offset as determined by the EP command.
ARGUMENTS: ET [n] = m where
n is an integer.
m is an integer.
USAGE:
While Moving Yes Minimum n Value 0
RELATED COMMANDS:
"EB" Enable Ecam
EXAMPLES:
ET [7] = 1000 Specifies the position of the slave that must be
synchronized with the eighth increment of the
master.
106
LEGEND-MC User’s Manual
FA
FUNCTION: Acceleration Feedforward [Setting]
DESCRIPTION:
The FA command sets the acceleration feedforward coefficient, or returns the previously set value. This
coefficient, when scaled by the acceleration, adds a torque bias voltage during the acceleration phase and
subtracts the bias during the deceleration phase of a motion.
OPERAND USAGE:
_FAn contains the value of the feedforward acceleration coefficient where n is an axis letter.
RELATED COMMANDS:
"FV" Velocity feedforward
EXAMPLES:
AC 500000 Set acceleration
NOTE: If the feedforward coefficient is changed during a move, then the change will not take
effect until the next move.
107
LEGEND-MC User’s Manual
FE
FUNCTION: Find Edge [Motion]
DESCRIPTION:
The FE command moves a motor until a transition is seen on the homing input for the associated axis. The
direction of motion depends on the initial state of the homing input (use the CN command to configure the
polarity of the home input). Once the transition is detected, the motor decelerates to a stop.
This command is useful for creating your own homing sequences. See the example section.
ARGUMENTS: FE XYZW or ABCDEFGH
USAGE:
While Moving No Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"FI" Find Index
"HM" Home
"BG" Begin
EXAMPLES:
FE Set find edge mode
BG Begin
HINT: Find Edge only searches for a change in state on the Home Input. Use FI (Find Index) to search for the encoder
“C” channel. Remember to specify BG after each of these commands. Use HM (Home) to search for both the Home input
and the Index.
108
LEGEND-MC User’s Manual
FI
FUNCTION: Find Index [Motion]
DESCRIPTION:
The FI and BG commands move the motor until an encoder index pulse, or “C” channel, is detected. The
controller looks for a transition from low to high. When the transition is detected, motion stops and the
position is defined as zero. To improve accuracy, the speed during the search should be specified as 1000
counts/s or less. The FI command is useful in custom homing sequences. The direction of motion is spec-
ified by the sign of the JG command.
ARGUMENTS: FI XYZW or ABCDEFGH
USAGE:
While Moving No Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"FE" Find Edge
"HM" Home
"BG" Begin
EXAMPLES:
#HOME Home Routine
JG 500 Set speed and forward direction
FI Find index
BG Begin motion
AM After motion
MG "FOUND INDEX"
EN
HINT: Find Index only searches for a change in state on the Index. Use FE to search for the Home input. Use HM
(Home) to search for both the Home input and the Index. Remember to specify BG after each of these commands.
109
LEGEND-MC User’s Manual
FL
FUNCTION: Forward Software Limit [Setting]
DESCRIPTION:
The FL command sets the forward software position limit. If this limit is exceeded during commanded
motion, the motor will decelerate to a stop. Forward motion beyond this limit is not permitted. The forward
limit is activated at position n + 1. The forward limit is disabled at position 2147483647. The units are in
counts.
When the reverse software limit is activated, the automatic subroutine #LIMSWI will be executed if it is
included in the program and the program is executing. See section on Automatic Subroutines.
ARGUMENTS: FL x, y, z, w or FLX=x or FL a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned numbers
“?” returns the value of the forward limit switch
USAGE:
While Moving Yes Minimum Value -2147483648
In a Program Yes Maximum Value +2147483647
OPERAND USAGE:
_FLn contains the value of the forward software limit where n is an axis letter.
RELATED COMMANDS:
"BL" Reverse Limit
EXAMPLES:
#TEST Test Program
AC 1000000 Acceleration Rate
BGX Begin
AMX After Motion
110
LEGEND-MC User’s Manual
@FRAC
FUNCTION: Fraction
DESCRIPTION:
@FRAC returns only the fractional portion of a number or variable given in square brackets. Note that
the @FRAC command is a function, which means that it does not follow the convention of the com-
mands, and does not require the underscore when used as an operand.
ARGUMENTS: @FRAC [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -2147483647.9999
In a Program Yes Maximum n value 2147483647.9999
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=123.456 Set variable
MG @FRAC[VAR1] Display only the fractional portion of VAR1
VAR2=@FRAC[VAR1]+.5 Perform calculation
EN End of program
111
LEGEND-MC User’s Manual
FV
FUNCTION: Velocity Feedforward [Setting]
DESCRIPTION:
The FV command sets the velocity feedforward coefficient, or returns the previously set value. This coeffi-
cient generates an output bias signal in proportion to the commanded velocity.
OPERAND USAGE:
_FV contains the velocity feedforward coefficient where n is an axis letter.
RELATED COMMANDS:
EXAMPLES:
FV 10 Set feedforward coefficients to 10
010
112
LEGEND-MC User’s Manual
GA
FUNCTION: Master Axis for Gearing [Setting]
DESCRIPTION:
The GA command specifies the master axis for electronic gearing.
The master axis is the auxiliary encoder on the LEGEND-MC. The slave ratio is specified with the GR
command and gearing is turned off by the command GR0.
ARGUMENTS: GADX
USAGE:
While Moving No Default Value ---
RELATED COMMANDS:
"GR" Gear Ratio
EXAMPLES:
#GEAR Gear program
113
LEGEND-MC User’s Manual
GR
FUNCTION: Gear Ratio [Motion]
DESCRIPTION:
GR specifies the Gear Ratio for the slave axis in electronic gearing mode. The master axis for the LEG-
END-MC is specified with the GA command. Gear ratio may range between +/-127.9999. The slave axis
will be geared to the actual position of the master. The master can go in both directions. GR 0 disables
gearing. If a limit switch is hit during gearing, then gearing is automatically disabled.
ARGUMENTS: GR n where
n is a signed number.
0 disables gearing
“?” returns the value of the gear ratio
USAGE:
While Moving Yes Minimum Value -127.9999
OPERAND USAGE:
_GRn contains the value of the gear ratio where n is an axis letter.
EXAMPLES:
#GEAR
EN End program
114
LEGEND-MC User’s Manual
HM
FUNCTION: Home [Motion]
DESCRIPTION:
The HM command performs a three-stage homing sequence.
The first stage is the motor moving at the user programmed speed until detecting a transition on the Home
input. The direction for this first stage is determined by the initial state of the Home input. Once the Home
input changes, the motor decelerates to a stop. The state of the Home input can be configured using the CN
command.
The second stage consists of the motor changing directions and slowly approaching the transition again.
When the transition is detected, the motor is stopped instantaneously.
The third stage consists of the motor slowly moving forward until it detects an index pulse from the
encoder. It stops at this point and defines it as position 0.
Can be Interrogated No
OPERAND USAGE:
_HMn contains the state of the Home input. Regardless of the limit switch polarity, where n is an axis let-
ter, 0 always means the home input is active, 1 means inactive.
RELATED COMMANDS:
EXAMPLES:
HM Set Homing Mode
BG Begin Homing
HINT: You can customize homing sequence by using the FE (Find Home Sensor only) and FI (Find Index only) com-
mands.
115
LEGEND-MC User’s Manual
HX
FUNCTION: Halt Execution [Program Flow]
DESCRIPTION:
The HX command halts the execution of any of the programs that may be running independently via multi-
tasking. The parameter n specifies the program to be halted.
ARGUMENTS: HX n where
n is 0 or 1 to indicate the task number
USAGE:
While Moving Yes Default Value n/a
Can be Interrogated No
OPERAND USAGE:
When used as an operand, _HX n contains the running status of thread n with:
0 Thread not running
1 Thread is running
2 Thread has stopped at trippoint
RELATED COMMANDS:
116
LEGEND-MC User’s Manual
IA
FUNCTION: IP Address [Setting]
DESCRIPTION:
The IA command assigns the controller an IP address.
The IA command may also be used to specify the time out value. This is only applicable when using the
TCP/IP protocol.
The IA command can only be used via RS-232. Since it assigns an IP address to the controller, communi-
cation with the controller via internet cannot be accomplished until after the address has been assigned.
ARGUMENTS: IA ip0 ,ip1, ip2, ip3 or IA n or IA<t where
ip0, ip1, ip2, ip3 are 1 byte numbers separated by commas and represent the individual fields of the IP
address.
n is the IP address for the controller which is specified as an integer representing the signed 32 bit number
(two’s complement).
<t specifies the time in update samples between TCP retries.
>u specifies the multicast IP address where u is an integer between 0 and 63.
IA? will return the IP address of the controller
USAGE:
While Moving No Default Value n = 0, t=250
OPERAND USAGE:
_IA0contains the IP address representing a 32 bit signed number (Two’s complement)
_IA1contains the value for t (retry time)
_IA2contains the number of available handles
_IA3contains the number of the handle using this operand where the number is 0 to 7. 0 represents handle
A, 1 handle B, etc.
RELATED COMMANDS:
IH Internet Handle
EXAMPLES:
IA 151, 12, 53, 89 Assigns the controller with the address
151.12.53.89
117
LEGEND-MC User’s Manual
IF
FUNCTION: IF conditional statement [Program Flow]
DESCRIPTION:
The IF command is used in conjunction with an ENDIF command to form an IF conditional statement. The
arguments are one or more conditional statements. If the conditional statement(s) evaluates true, the com-
mand interpreter will continue executing commands which follow the IF command. If the conditional state-
ment evaluates false, the controller will ignore commands until the associated ENDIF command OR an
ELSE command occurs in the program. The conditional statements MUST be enclosed on parentheses for
the expression to be evaluated correctly. See the example below.
ARGUMENTS: IF condition where
Conditions are tested with the following logical operators:
USAGE:
While Moving Yes Default Value ---
Command Line No
RELATED COMMANDS:
"ELSE" Optional command used only after IF command
EXAMPLES:
IF (_TEX<1000) IF conditional statement based on X motor position
MG "Motor within 1000 counts of zero" Message to be executed if “IF” conditional state-
ment
IF ((TEMP=126) | (TEMP=123))
JS # RELEASE
JS # ASSIGN
JS # CONNECT
ENDIF
118
LEGEND-MC User’s Manual
IH
FUNCTION: Open Internet Handle [Setting]
DESCRIPTION:
The IH command is used when the LEGEND-MC is operated as a network master. This command opens a
handle and connects to a slave.
Each controller may have 8 handles open at any given time. They are designated by the letters A through
H. To open a handle, the user must specify:
The IP address of the slave
The type of session: TCP/IP or UDP/IP
The port number of the slave. This number isn’t necessary if the slave device doesn’t
require a specific port value. If not specified, the controller specifies the port value as
502.
ARGUMENTS: IHh= ip0, ip1, ip2, ip3 <p > q or IHh=n <p > q orIHh= >r where
h A H Internet handle
S=>C -1 (UDP) -2 (TCP) Close the handle that sent the command
T=>C -1 (UDP) -2 (TCP) Close handles except the one sending the
command
OPERAND USAGE:
_IHh0 contains the IP address as a 32 bit number
_IHh1 contains the slave port number
_IHh2 contains a 0 if the handle is free
contains a 1 if it is for a UDP slave
contains a 2 if it is for a TCP slave
contains a -1 if it is for a UDP master
contains a -2 if it is for a TCP master
contains a -5 if attempting to connect by UDP
contains a -6 if attempting to connect by TCP
_IHh3 contains a 0 if the ARP was successful
contains a 1 if it has failed or is still in progress.
119
LEGEND-MC User’s Manual
USAGE:
While Moving Yes Default Value ----
RELATED COMMANDS:
"IA" Internet Address
EXAMPLES:
IHA=251,29,51,1 Open handle A at IP address 251.29.51.1
Note: When the IH command is given, the controller initializes an ARP on the slave device before
opening a handle. This operation can cause a small time delay before the controller responds.
120
LEGEND-MC User’s Manual
II
FUNCTION: Input Interrupt [Configuration]
DESCRIPTION:
The II command enables the interrupt function for the specified inputs. This function triggers when the
controller sees a logic change from high to low on a specified input.
If the #ININT special label is included in the program and any of the specified inputs go low during pro-
gram execution, the program will jump to the subroutine with label #ININT. Any trippoints set by the pro-
gram will be cleared but can be re-enabled by the proper termination of the interrupt subroutine using RI.
To avoid returning to the main program on an interrupt, use the ZS command to zero the subroutine stack
and use the II command to re-enable the interrupt.
ARGUMENTS: II m,n,o,p are integers where
m 0 7 Zero disables the interrupts. The value of II 3 Input #3 will cause an interrupt
“m” specifies the lowest input number to when it goes low.
be used for the input interrupt.
n 2 7 Optional argument used with “m” to spec- II 2, 4 Input #2, Input #3, and Input #4
ify a range of inputs. When the “n” argu- are enabled for interrupt.
ment is omitted, only the input specified
by the “m” parameter will be enabled.
USAGE:
While Moving Yes Default Value n/a
Command Line No
RELATED COMMANDS:
"RI" Return from Interrupt
EXAMPLES:
#A Program A
121
LEGEND-MC User’s Manual
BG Begin motion
EN End Program
AM After stopped
BG Begin motion
122
LEGEND-MC User’s Manual
IL
FUNCTION: Integrator Limit [Tuning]
DESCRIPTION:
The IL command limits the effect of the integrator function in the filter to a certain voltage. For example,
IL 2 limits the output of the integrator to the +/-2 Volt range. This is very effective in allowing higher KI
values without adding instability.
A negative parameter also freezes the effect of the integrator during a move. For example, IL -3 limits the
integrator output to +/-3V. If, at the start of motion, the integrator output is 1.6 Volts, that level will be
maintained through the move. Note, however, that the KD and KP terms remain active in any case.
ARGUMENTS: IL x, y, z, w or ILX=x or IL a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the integrator limit
USAGE:
While Moving Yes Minimum Value -10
OPERAND USAGE:
_ILn contains the value of the integrator limit in volts where n is an axis letter.
RELATED COMMANDS:
"KI" Integrator
EXAMPLES:
KI 2 Integrator constants
IL 3 Integrator limits
3.0000
123
LEGEND-MC User’s Manual
IN
FUNCTION: Input Variable [General]
DESCRIPTION:
The IN command allows a variable to be input from the serial port or Ethernet. An optional prompt message
can be displayed. The variable value must be followed by a carriage return. The entered value is assigned
to the specified variable name.
The IN command holds up execution of following commands in the program thread until a carriage return or
semicolon is entered. If no value is given prior to a semicolon or carriage return, the previous variable value
is kept. Input Interrupts, Error Interrupts and Limit Switch Interrupts will still be active.
ARGUMENTS: IN{P1} ”m” , n {So} where
"m" is the prompt message. May be letters, numbers, or symbols up to maximum line length and must be
placed in quotations.
n is the name of variable to store the new value in.
{P1} specifies the port, if omitted, the default port is assumed.
{So} specifies string data where o is the number of characters from 1 to 6
USAGE:
While Moving Yes Default Value
Command Line No
Can be Interrogated No
Used as an Operand No
EXAMPLES: Operator specifies material length in inches and speed in inches/sec (2 pitch lead screw, 2000 counts/rev
encoder).
#A Program A
SP V3 Speed command
PR V4 Position command
EN End Program
124
LEGEND-MC User’s Manual
@IN
FUNCTION: Status of Digital Input [I/O]
DESCRIPTION:
@IN returns the status of the digital input number or variable given in square brackets. Note that the @IN
command is a function, which means that it does not follow the convention of the commands, and does
not require the underscore when used as an operand.
ARGUMENTS: @IN [n] where
n is an integer corresponding to a specific output on the controller to be cleared (set to 0). The first output
on the controller is denoted as output 1. A LEGEND-MC controller has 4 digital outputs plus applicable
I/O connected by Modbus.
DISTRIBUTED CONTROL:
MODBUS:
Note: With Modbus devices, I/O points of the devices are calculated usingthe following formula:
n = (SlaveAddress*1000) + (HandleNum*1000) + ((Module-1)*4) + (Bitnum-1)
Slave Address is used when ModBus device has slave devices connected to it and specified as Addresses
0 to 255. Note that the use of slave devices for modbus are very rare and this number will usually be 0.
HandleNum is the handle specifier from A to H (1 - 8).
Module is the position of the module in the rack from 1 to 16.
BitNum is the I/O point in the module from 1 to 4.
USAGE:
While Moving Yes Minimum n value 1
In a Program Yes Maximum n value 8
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=2 Set variable
MG @IN[VAR1] Display the status of digital input 2
VAR2=@IN[VAR1]+1 Perform calculation
EN End of program
IF(@IN[604])
MG”Slave input 4 is ON”
ELSE
MG”Slave input 4 is OFF”
ENDIF
125
LEGEND-MC User’s Manual
@INT
FUNCTION: Integer
DESCRIPTION:
@INT returns only the whole number part of a number or variable given in square brackets. Note that the
@INT command is a function, which means that it does not follow the convention of the commands, and
does not require the underscore when used as an operand.
ARGUMENTS: @INT [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -2147483648.9999
In a Program Yes Maximum n value 2147483648.9999
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=123.456 Set variable
MG @INT[VAR1] Display only the whole nimber portion of
VAR1
VAR2=@INT[VAR1]+25 Perform calculation
EN End of program
126
LEGEND-MC User’s Manual
IP
FUNCTION: Increment Position [Motion]
DESCRIPTION:
The IP command allows for an update in the commanded position while the motor is moving. This com-
mand does not require a BG. The command has three effects depending on the motion being executed.
The units of this command are quadrature counts.
Case 1: Motor is standing still
An IP n command is equivalent to a PR n and BG command. The motor will move to the specified position
at the requested slew speed and acceleration.
Case 2: Motor is moving towards specified position
An IP n command will cause the motor to move to a new position target, which is the old target plus n. n
must be in the same direction as the existing motion (final target cannot be closer).
Case 3: Motor is in Jog Mode
An IP n command will cause the motor to instantly try to servo to a position n from the present instanta-
neous position. The SP and AC parameters have no effect. This command is useful for making small cor-
rections when synchronizing 2 axes in which one of the axis' speed is indeterminate due to a variable
diameter pulley.
WARNING: When the motor is in jog mode, an IP will create an instantaneous position error. In this
mode, the IP should only be used to make small incremental position movements.
Used as an Operand No
EXAMPLES:
:IP 50 50 counts with set acceleration and speed
#CORRECT Label
127
LEGEND-MC User’s Manual
IT
FUNCTION: Independent Time Constant - Smoothing Function [Motion]
DESCRIPTION:
The IT command filters the acceleration and deceleration functions in independent moves of JG, PR, PA
type to produce a smooth velocity profile. The resulting profile, known as an S-curve, has continuous accel-
eration and results in reduced mechanical vibrations. IT sets the bandwidth of the filter where 1 means no
filtering and 0.004 means maximum filtering. Note that the filtering results in longer motion time.
The use of IT will not effect the trippoints AR and AD. The trippoints AR and AD monitor the profile prior
to the IT filter and therefore can be satisfied before the actual distance has been reached if IT is NOT 1.
ARGUMENTS: IT x, y, z, w or ITX=x or IT a ,b, c, d, e, f, g, h where
n is a positive number with a resolution of 1/256
“?” returns the value of the independent time constant.
USAGE:
While Moving Yes Minimum Value 0.004
OPERAND USAGE:
_ITn will return the value of the independent time constant where n is an axis letter.
EXAMPLES:
IT 0.8 Set independent time constants
0.8
128
LEGEND-MC User’s Manual
JG
FUNCTION: Jog [Motion]
DESCRIPTION:
The JG command sets a speed in jog mode. The parameters following the JG set the slew speed and direc-
tion of motion. Use of the question mark returns the previously entered value or default value. The units
of this are counts/second. The AC (acceleration) and DC (deceleration) commands work in this mode.
ARGUMENTS: JG x, y, z, w or JGX=x or JG a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
“?” returns the absolute value of the jog speed.
USAGE:
While Moving Yes Minimum Value -12,000,000
OPERAND USAGE:
_JGn will return the absolute value of the jog speed in counts per second where n is an axis letter.
RELATED COMMANDS:
"BG" Begin
"ST" Stop
"AC" Acceleration
"DC" Deceleration
EXAMPLES:
JG 100 Set for jog mode with a slew speed of 100
counts/sec
BG Begin Motion
129
LEGEND-MC User’s Manual
JP
FUNCTION: Jump to Program Location [Program Flow]
DESCRIPTION:
The JP command causes a jump to a program location on a specified condition (optional). The program
location may be any label. The condition is a conditional statement which uses a logical operator such as
equal to or less than. A jump is executed if the specified condition is true.
Multiple conditions can be used in a single jump statement. Conditional statements are combined in pairs
using operands “&” and “|”. The “&” operand between two conditions requires both statements to be true
for the combined statement to be true. The ”|” operand between two conditions requires that one statement
be true for the combined statement to be true.
Note: Each condition must be in parenthesis for controller evaluation as a boolean expression.
USAGE:
While Moving Yes Default Value n/a
Command Line No
Can be Interrogated No
Used as an Operand No
EXAMPLES:
JP #POS1,V1<5 Jump to label #POS1 if variable V1 is less than 5
HINT: JP is similar to an IF, THEN command. Text to the right of the comma is the condition that must be met for a jump
to occur. The destination is the specified label before the comma.
130
LEGEND-MC User’s Manual
JS
FUNCTION: Jump to Subroutine [Program Flow]
DESCRIPTION:
The JS command will change the sequential order of execution of commands in a program. If the jump is
executed, the program will continue at the label specified by the destination parameter. The line number of
the JS command is saved and after the next EN command is encountered (End of subroutine), program exe-
cution will continue with the instruction following the JS command. The JS command can be nested 16
deep.
Multiple conditions can be used in a single jump subroutine statement. The conditional statements are
combined in pairs using the operands “&” and “|”. The “&” operand between any two conditions requires
that both statements must be true for the combined statement to be true. The “|” operand between any two
conditions requires that only one statement be true for the combined statement to be true.
Note: Each condition must be placed in parenthesis for proper evaluation by the controller as a
boolean expression. Subroutines can be nested 16 deep in the standard controller.
USAGE:
While Moving Yes Default Value ---
In a Program Yes Default Format ---
Command Line No
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"EN" End
EXAMPLES:
JS #SQUARE,V1<5 Jump to subroutine #SQUARE if V1 is less than 5
JS #LOOP,V1<>0 Jump to #LOOP if V1 is not equal to 0
131
LEGEND-MC User’s Manual
KD
FUNCTION: Derivative Constant [Tuning]
DESCRIPTION:
KD designates the derivative constant in the controller filter. The filter transfer function is
⋅ ⋅
D(z) = 4 KP + 4 KD(z-1)/z + KIz/2 (z-1)
For further details on the filter see the section Theory of Operation.
ARGUMENTS: KD x, y, z, w or KDX=x or KD a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the derivative constant
USAGE:
While Moving Yes Minimum Value 0
OPERAND USAGE:
_KDn contains the value of the derivative constant where n is an axis letter.
RELATED COMMANDS:
"KP" Proportional Constant
"KI" Integral
EXAMPLES
KD 100 Specify KD
KD ? Return KD
0100.00
132
LEGEND-MC User’s Manual
KI
FUNCTION: Integrator [Tuning]
DESCRIPTION:
The KI command sets the integral gain of the control loop. It fits in the control equation as follows:
OPERAND USAGE:
_KIn contains the value of the integrator where n is an axis letter.
RELATED COMMANDS:
"KP" Proportional Gain
"KD" Derivative
EXAMPLES:
KI 12 Specify integral
KI ? Return value
0012
133
LEGEND-MC User’s Manual
KP
FUNCTION: Proportional Constant [Tuning]
DESCRIPTION:
KP designates the proportional constant in the controller filter. The filter transfer function is
⋅ ⋅
D(z) = 4 KP + 4 KD(z-1)/z + KI z/2(z-1)
For further details see the section Theory of Operation.
ARGUMENTS: KP x, y, z, w or KPX=x or KP a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the proportional constant
USAGE:
While Moving Yes Minimum Value 0
OPERAND USAGE:
_KPn contains the value of the proportional constant where n is an axis letter.
RELATED COMMANDS:
"KP" Proportional Gain
134
LEGEND-MC User’s Manual
LA
FUNCTION: List Arrays [General]
DESCRIPTION:
The LA command returns a list of all arrays in memory. The listing will be in alphabetical order. The size
of each array will be included next to each array name in square brackets.
ARGUMENTS: None
USAGE:
While Moving Yes Default Value -
RELATED COMMANDS:
"LL" List Labels
EXAMPLES:
: LA
CA [10]
LA [5]
NY [25]
VA [17]
135
LEGEND-MC User’s Manual
LE
FUNCTION: Linear Interpolation End [Motion]
DESCRIPTION: LE
Signifies the end of a linear interpolation sequence. It follow the last LI specification in a linear sequence.
The LE command signifies the controller issues commands to decelerate the motor to a stop.
ARGUMENTS:
n=? Returns the total vector move length in encoder counts for the coordinate system.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_LE contains the total vector move length in encoder counts.
RELATED COMMANDS:
"LI" Linear Distance
EXAMPLES:
LM XY Specify linear interpolation mode for X and Y
axes
136
LEGEND-MC User’s Manual
_LF*
FUNCTION: Forward Limit Switch Operand (Keyword) [Status]
DESCRIPTION: _LF XYZW or LF ABCDEFGH
The _LF operand contains the state of the forward limit switch. A value of zero always indicates that the
limit is active, no matter what configuration the CN command is set to.
EXAMPLES:
MG _LFX Display the status of the forward limit switch
137
LEGEND-MC User’s Manual
LI
FUNCTION: Linear Interpolation Distance [Motion]
DESCRIPTION:
The LI x, y command specifies the incremental distance of travel for each axis in the Linear Interpolation
(LM) mode. LI parameter are relative distances given with respect to the current axis positions. Up to 511
LI specifications may be given ahead of the Begin Sequence (BGS) command. Additional LI commands
may be sent during motion when the controller sequence buffer frees additional spaces for new vector seg-
ments. The Linear End (LE) command must be given after the last LI specification in a sequence. This com-
mand tells the controller to decelerate to a stop at the last LI command. It is the responsibility of the user to
keep enough LI segments in the controller’ sequence buffer to ensure continuous motion.
LM? returns the available spaces for LI segments that can be sent to the buffer. 511 returned means the
buffer is empty and 511 LI segments can be sent. A zero means the buffer is full and no additional segments
can be sent. It should be noted that the controller computes the vector speed based on the axes specified in
the LM mode. For example, LM XY designates linear interpolation for the X and Y axes. The speed of these
axes will be computed from VS2 =XS2+YS2 where XS and YS are the speed of the X and Y axes. The con-
troller always uses the axis specifications from LM, not LI, to compute the speed .The parameters o and p
are optional and can be used to define the vector speed that is attached to the motion segment.
Linear Interpolation is useful for making blended move profiles.
n -8388607 8388607 The incremental move dis- LI 500 500 encoder count move on the
tance. X axis.
o 0 12000000 Vector speed to be taken into LI 500 <40000 500 encoder count move on the
effect at the execution of this X axis. Change to a vector speed
segment. of 40000 counts per second.
p 0 12000000 Vector speed to be taken into LI 500 >40000 500 encoder count move on the
effect at the end of this seg- X axis. Change to a vector speed
ment. of 40000 counts per second at
the end of the segment.
USAGE:
While Moving Yes Default Value -
RELATED COMMANDS:
"LE" Linear End
138
LEGEND-MC User’s Manual
EXAMPLES:
LM XY Specify linear interpolation mode for X and Y
axes
139
LEGEND-MC User’s Manual
LL
FUNCTION: List Labels [General]
DESCRIPTION:
The LL command returns a listing of all of the program labels in memory. The listing will be in alphabetical
order.
ARGUMENTS: None
USAGE:
While Moving Yes Default Value ---
RELATED COMMANDS:
"LV" List Variables
EXAMPLES:
: LL
# FIVE
# FOUR
# ONE
# THREE
# TWO
140
LEGEND-MC User’s Manual
LM
FUNCTION: Linear Interpolation Mode [Setting]
DESCRIPTION:
The LM command specifies the linear interpolation mode and specifies the axes for linear interpolation. LI
commands are used to specify the travel distances for linear interpolation. The LE command specifies the
end of the linear interpolation sequence. Several LI commands may be given as long as the controller
sequence buffer has room for additional segments. Once the LM command has been given, it does not
need to be given again unless the VM command has been used.
It should be noted that the controller computes the vector speed based on the axes specified in the LM
mode. For example, LM XY designates linear interpolation for the X and Y axes. The speed of these axes
will be computed from VS2=XS2+YS2, where XS and YS are the speed of the X and Y axes. The control-
ler always uses the axis specifications from LM, not LI, to compute the speed.
ARGUMENTS: LM XYZW or ABCDEFGH
USAGE:
OPERAND USAGE:
_LMx contains the number of spaces available in the sequence buffer for the coordinate system.
RELATED COMMANDS:
EXAMPLES:
LM XY Specify linear interpolation mode
VS 10000; VA 100000;VD 1000000 Specify vector speed, acceleration and deceleration
141
LEGEND-MC User’s Manual
LO
FUNCTION: Lockout [Configuration]
DESCRIPTION:
The LO command is used to lock-out a particular handle or serial port with the master controller on a dis-
tributed control system. This function ignores all data received to the master on the specified communica-
tion channel.
OPERAND USAGE:
_LOh contains the state of the lockout for handle A - F or S.
RELATED COMMANDS:
EXAMPLES:
LOS Lockout information received from the serial port
142
LEGEND-MC User’s Manual
_LR*
FUNCTION: Reverse Limit Switch Operand (Keyword) [Status]
DESCRIPTION: _LR XYZW or ABCDEFGH
*The _LR operand contains the state of the reverse limit switch. A value of zero always indicates that the
limit is active no matter what the configuration of the CN command is.
EXAMPLES:
MG _LRX Display the status of the reverse limit switch
143
LEGEND-MC User’s Manual
LS
FUNCTION: List Program [General]
DESCRIPTION:
The LS command sends a listing of the program memory out of the port that issued the command. The list-
ing will start with the line pointed to by the first parameter, which can be either a line number or a label. If
no parameter is specified, it will start with line 0. The listing will end with the line pointed to by the second
parameter--again either a line number or label. If no parameter is specified, the listing will go to the last line
of the program.
ARGUMENTS: LS n,m where
n,m are valid numbers from 0 to 500, or labels. n is the first line to be listed, m is the last.
USAGE:
While Moving Yes Default Value 0,Last Line
Can be Interrogated No
Used as an Operand No
EXAMPLES:
:LS #A,6 List program starting at #A through line 6
002 #A
003 PR 500
004 BG
005 AM
006 WT 200
HINT: Remember to quit the Edit Mode <cntrl> Q prior to giving the LS command.
144
LEGEND-MC User’s Manual
LV
FUNCTION: List Variables [General]
DESCRIPTION:
The LV command returns a listing of all of the program labels in memory. The listing will be in alphabeti-
cal order.
ARGUMENTS: None
USAGE:
While Moving Yes Default Value n/a
Used as an Operand No
RELATED COMMANDS:
"LL" List Labels
EXAMPLES:
: LV
APPLE = 60.0000
BOY = 25.0000
ZEBRA = 37.0000
145
LEGEND-MC User’s Manual
LZ
FUNCTION: Inhibit Leading Zeros [Setting]
DESCRIPTION:
The LZ command is used for formatting the values returned from interrogation commands or interrogation
of variables and arrays. By enabling the LZ function, all leading zeros of returned values will be removed.
This will reduce transmission time and potentially ease formatting issues on connected devices.
ARGUMENTS: LZ n where
1 to remove leading zeros
0 to disable the leading zero removal
LZ? Returns the state of the LZ function.
USAGE:
While Moving Yes Default Value 0
EXAMPLES:
TE Tell error
0004
TE Tell error
146
LEGEND-MC User’s Manual
MB
FUNCTION: Modbus [I/O]
DESCRIPTION:
The MB command is used to communicate with I/O devices using the first two levels of the Modbus proto-
col.
The format of the command varies depending on each function code. The function code, -1, designates
that the first level of Modbus is used (creates raw packets and receives raw data). The other codes are the
10 major function codes of the second level that the LEGEND-MC supports.
Note: For those command formats that have “addr”, this is the slave address. The slave address
may be designated or defaulted to the device handle number.
Note: All formats contain an h parameter. This designates connection handle number (A thru H).
ARGUMENTS:
Function Meaning Example
-1 Raw Packets MBh = -1, y, array [ ]
g Register number
147
LEGEND-MC User’s Manual
USAGE:
While Moving Yes Default Value ---
EXAMPLES:
IHF=>-2 Disconnect handle
148
LEGEND-MC User’s Manual
MC
FUNCTION: Motion Complete - "In Position" [Trippoint]
DESCRIPTION:
The MC command is a trippoint used to control the timing of events. This command will hold up execu-
tion of the following commands until the current move is completed and the encoder reaches or passes the
specified target position. TW sets the timeout to declare an error if the encoder is not in position within a
specified time. If a timeout occurs, the trippoint will clear and the stopcode (SC command) will be set to
99. The application program will jump to the special label #MCTIME, if included in your program.
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"BG" Begin
"AM" After Move
"TW" Timeout
EXAMPLES:
#MOVE Program MOVE
EN End of Program
Hint: MC can be used to verify that the actual motion has been completed. In certain applications, that have very little KI
(integration), it is possible that the axis does not get to the exact position specified. This means the MC command will wait
the entire time of the TW command. Set the TW command to a realistic value.
149
LEGEND-MC User’s Manual
MF
FUNCTION: Forward Motion to Position [Trippoint]
DESCRIPTION:
The MF command is a trippoint used to control the timing of events. This command will hold up the exe-
cution of the following command until the specified motor moves forward and crosses the position speci-
fied. The units of the command are in quadrature counts. The MF command can also be used when the
encoder is the master and not under servo control, because the actual position is monitored.
ARGUMENTS: MFx, y, z, w or MFX=x or MFa ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
USAGE:
While Moving Yes Minimum Value -2147483648
Used as an Operand No
RELATED COMMANDS:
"AR" Trippoint for after Relative Distance
EXAMPLES:
#TEST Program B
HINT: The accuracy of the MF command is the number of counts that occur in 2 msec. Multiply the speed by 2 msec to
obtain the maximum error. MF tests for absolute position. The MF command can also be used when the specified motor is
driven independently by an external device.
150
LEGEND-MC User’s Manual
MG
FUNCTION: Message [General]
DESCRIPTION:
The MG command sends data out the specified port. This can be used to alert an operator, send instruc-
tions or return a variable value.
ARGUMENTS: MG {Ex} "m", {^n}, V {Fm.n or $m,n} {N} {Sn}
"m" is a text message including letters, numbers, symbols or <ctrl>G. Make sure that maximum line length
is not exceeded.
{^n} is an ASCII character specified by the value n in decimal.
V is a variable name or array element where the following specifiers can be used for formatting:
{Fm.n} Display variable in decimal format with m digits to left of decimal, and n to the right.
{$m,n} Display variable in hexadecimal format with m digits to left of decimal, and n to the right.
{Sn} Display variable as a string of length n where n is 1 thru 6
{N} Suppress carriage return line feed.
{Ex}For Ethernet and ‘x’ specifies the Ethernet handle (A,B,C,D,E,F or H).
Note: Multiple text, variables, and ASCII characters may be used, each must be separated by a
comma.
USAGE:
While Moving Yes Default Value -
Can be Interrogated No
Used as an Operand No
EXAMPLES:
Case 1: Message command displays ASCII strings
MG "Good Morning" Displays the string
Case 2: Message command displays variables or arrays
MG "The Answer is", Total {F4.2} Displays the string with the content of variable TOTAL in local format
of 4 digits before and 2 digits after the decimal point.
Case 3: Message command sends any ASCII characters to the port.
MG {^13}, {^30}, {^37}, {N} Sends carriage return, characters 0 and 7 followed by no carriage return
line feed command to the port.
151
LEGEND-MC User’s Manual
MM
FUNCTION: Master’s Modulus [Setting]
DESCRIPTION:
The MM command is part of the ECAM mode. The MM command replaces the master modulus setting of
the EM command. This allows camming with the auxiliary encoder as the master.
OPERAND USAGE:
_MMx contains the master modulus
RELATED COMMANDS:
"EA" Select master cam axis
EXAMPLES:
EADX Select Auxiliary X axis as Ecam master
152
LEGEND-MC User’s Manual
MO
FUNCTION: Motor Off [Setting]
DESCRIPTION:
The MO command shuts off the PID control algorithm and the servo enable signal. The controller will
continue to monitor the motor position. To turn the motor back on use the Servo Here command (SH). This
command is not allowed while the servo is commanded in motion. Use the ST command first in that case.
ARGUMENTS: MO XYZW or ABCDEFGH
“?” returns the state of the motor for the specified axis.
USAGE:
While Moving No Default Value 1
OPERAND USAGE:
_MOn will return the state of the motor where n is an axis letter, 0 = servo loop on and 1 = servo loop off.
RELATED COMMANDS:
"SH" Servo Here
EXAMPLES:
MO Turn off motor
SH Turn motor on
HINT: The MO command is useful for positioning the motors by hand. Turn them back on with the SH command.
153
LEGEND-MC User’s Manual
MR
FUNCTION: Reverse Motion to Position [Trippoint]
DESCRIPTION:
The MR command is a trippoint used to control the timing of events. This command will hold up the exe-
cution of the following command until the specified motor moves backward and crosses the position speci-
fied. The units of the command are in quadrature counts. The MR command can also be used when the
encoder is the master and not under servo control.
ARGUMENTS: MR x, y, z, w or MRX=x or MR a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
USAGE:
While Moving Yes Minimum Value -2147483648
Used as an Operand No
RELATED COMMANDS:
"AR" Trippoint for after Relative Distance
EXAMPLES:
#TEST Program B
DP0 Define zero
ST Stop
EN End of Program
HINT: MR command accuracy is the number of counts that occur in 2 msec. Multiply speed by 2 msec to obtain maximum
error. MR tests for absolute position. The MR command can also be used when the specified motor is driven externally.
154
LEGEND-MC User’s Manual
MT
FUNCTION: Motor Type [Configuration]
DESCRIPTION:
The MT command selects the type of the motor and the polarity of the drive signal. Motor types include
standard servo motors which require a voltage in the range of +/- 10 Volts. The polarity reversal inverts the
analog signals.
ARGUMENTS: MT x, y, z, w or MTX=x or MT a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h have one of the following values
1 Servo motor (rotary motor moves counterclockwise when viewing shaft end of motor)
-1 Servo motor reversed polarity
“?” returns the value of the motor type
USAGE:
While Moving Yes Default Value 1
OPERAND USAGE:
_MTn contains the value of the motor type where n is an axis letter.
EXAMPLES:
MT 1 Configure x as servo
155
LEGEND-MC User’s Manual
NA
FUNCTION: Number of Axes [Configuration]
DESCRIPTION:
NA defines the total number of axes used in a distributed network control system. This command is used on
the master controller. For example; using 3 LEGEND-MC controllers. The command NA3 would be given
to the master controller.
ARGUMENTS: NA n where
n is an integer. this number represents the number of axes in a distributed control system.
USAGE:
While Moving Yes Minimum Value 1
In a Program Yes Maximum Value 5
OPERAND USAGE:
_NA contains the contains the number of axes.
RELATED COMMANDS:
"CH" Connect to the internet handles for slave operation
EXAMPLES:
NA2 Command given to an LEGEND-MC acting as
a multi-axis network master with one slave.
156
LEGEND-MC User’s Manual
NB
FUNCTION: Notch Bandwidth [Tuning]
DESCRIPTION:
The NB command sets real part of the notch poles
ARGUMENTS: NB x, y, z, w or NBX=x or NB a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
USAGE:
While Moving Yes Minimum value 0
OPERAND USAGE:
_NBn contains the contains the value of the notch bandwidth where n is an axis letter.
RELATED COMMANDS:
"NF" Notch Filter
EXAMPLES:
NBX = 10 Sets the real part of the notch pole to 10/2 Hz
157
LEGEND-MC User’s Manual
NF
FUNCTION: Notch Frequency [Tuning]
DESCRIPTION:
The NF command sets the frequency of the notch filter, which is placed in series with the PID compensa-
tion.
ARGUMENTS: NF x, y, z, w or NFX=x or NF a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the Notch filter for the specified axis.
USAGE:
While Moving Yes Minimum value 0
OPERAND USAGE:
_NFn contains the value of notch filter for the specified axis where n is an axis letter.
RELATED COMMANDS:
"NB" Notch bandwidth
EXAMPLES:
NF, 20 Sets the notch frequency of Y axis to 20 Hz
158
LEGEND-MC User’s Manual
NO
FUNCTION: No Operation [General]
DESCRIPTION:
The NO command performs no action in a sequence, but can be used as a comment in a program. After the
NO, characters can be given to form a program comment up to the maximum line length. This helps to
document a program.
An apostrophe (‘ )may also be used instead of the NO to document a program.
ARGUMENTS: NO m where
m is any group of letters, numbers, symbols or <cntrl>G
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
EXAMPLES:
#A Program A
NO No Operation
NO Nothing No Operation
EN End of Program
159
LEGEND-MC User’s Manual
NZ
FUNCTION: Notch Zero [Tuning]
DESCRIPTION:
The NZ command sets the real part of the notch zero.
ARGUMENTS: NZ x, y, z, w or NZX=x or NZ a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the value of the Notch filter zero for the specified axis.
USAGE:
While Moving Yes Minimum value 0
Default Format
OPERAND USAGE:
_NZn contains the value of the Notch filter zero for the specified axis where n is an axis letter.
RELATED COMMANDS
"NB" Notch Bandwidth
EXAMPLES:
NZX = 10 Sets the real part of the notch pole to 10 Hz
160
LEGEND-MC User’s Manual
OB
FUNCTION: Output Bit [I/O]
DESCRIPTION:
The OB n, logical expression command defines output bit n = 1 through 4 as either 0 or 1 depending on the
result from the logical expression. Any non-zero value of the expression results in a one on the output.
ARGUMENTS: OB n, expression where
n is 1 through 4 denoting output bit
expression is any valid logical expression, variable or array element.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
EXAMPLES:
OB 1, POS 1 If POS 1 is non-zero, Bit 1 is high.
OB 2, @IN[1]&@IN[2] If Input 1 and Input 2 are both high, then Output 2 is set high
OB 3, COUNT[1] If the element 1 in the array is zero, clear bit 3, otherwise set bit 3
161
LEGEND-MC User’s Manual
OC
FUNCTION: Output Compare [I/O]
DESCRIPTION:
The OC command allows the generation of output pulses based on the main encoder positions. The output
is a low-going pulse with a duration of approximately 600 nanoseconds and is available at the output com-
pare signal.
The auxiliary encoder cannot be used while using this function.
Note: The OC function requires that the main encoder and auxiliary encoders be configured
exactly the same (see the command, CE). For example: CE 0, CE 10.
The output on pin 7 of the 5 CN connector is a TTL signal and requires JP3 to be installed.
ARGUMENTS: OCX = m, n where
m = Absolute position for first pulse. Integer between -2⋅ 109 and 2 ⋅ 109
n = Incremental distance between pulses. Integer between -65535 and 65535.
OCx = 0 will disable the Output Compare function.
The sign of the parameter, n, will designate the expected direction of motion for the output compare func-
tion. When moving in the opposite direction, output compare pulses will occur at the incremental distance
of 65536-|n| where |n| is the absolute value of n.
USAGE:
While Moving Yes Default Value -
Can be Interrogated No
OPERAND USAGE:
_OCx contains the state of the OC function
_OCx = 0 : OC function has been enabled but not generated any pulses.
_OCx = 1: OC function not enabled or has generated the first output pulse.
EXAMPLES:
OCX=300,100 Select X encoder as position sensor. First
pulse at 300. Following pulses at 400, 500…
162
LEGEND-MC User’s Manual
OE
FUNCTION: Off on Error [Setting]
DESCRIPTION:
The OE command causes the controller to shut off the motor command if the position error exceeds the
limit specified by the ER command or an abort occurs from either the abort input or an AB command.
OPERAND USAGE:
_OEn contains the status of the off-on-error function where n is an axis letter.
RELATED COMMANDS:
"ER" Error limit
EXAMPLES:
OE 1 Enable OE
OE 0 Disable OE
HINT: The OE command is useful for preventing system damage on excessive error.
163
LEGEND-MC User’s Manual
OF
FUNCTION: Offset [Tuning]
DESCRIPTION:
The OF command sets a bias voltage in the motor command output or returns a previously set value. This
can be used to counteract gravity or an offset in an amplifier. If the PID values are zero, then the output
voltage will be the OF value.
ARGUMENTS: OF x, y, z, w or OFX=x or OF a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
“?” returns the offset
USAGE:
While Moving Yes Minimum Value -9.9988
OPERAND USAGE:
_OFn contains the offset in volts where n is an axis letter.
EXAMPLES:
OF 1 Set offset to 1 volt
OF ? Return offset
1.0000
164
LEGEND-MC User’s Manual
OP
FUNCTION: Output Port [I/O]
DESCRIPTION:
The OP command sets 4 bits of data on the output port of the controller simultaneously.
The n parameter is used to specify the number of bits affected starting with the LSB. The other bits are
masked. For example, if n=2, only outputs 1 and 2 will be changed by OP m. If the n parameter is not
specified, all bits will be changed.
To set or read outputs on a slave controller use the SA command.
ARGUMENTS: OP m where
m is an integer
USAGE:
While Moving Yes Minimum m Value 0
OPERAND USAGE:
_OP contains the status of the outputs.
RELATED COMMANDS:
"SB" Set output bit
EXAMPLES:
OP 0 Clear Output Port -- all bits
165
LEGEND-MC User’s Manual
@OUT
FUNCTION: Status of Digital Output
DESCRIPTION:
@OUT returns the status of the digital output number or variable given in square brackets. Note that the
@OUT command is a function, which means that it does not follow the convention of the commands, and
does not require the underscore when used as an operand.
ARGUMENTS: @OUT [n] where
n is an integer corresponding to a specific output on the controller. The first output on the controller is
denoted as output 1. A LEGEND-MC controller has 4 digital outputs plus applicable I/O connected by
Modbus.
Note: When using Modbus devices, the I/O points of the modbus devices are calculated using the
following formula:
n = (SlaveAddress*1000) + (HandleNum*1000) + ((Module-1)*4) + (Bitnum-1)
Slave Address is used when the ModBus device has slave devices connected to it and specified as
Addresses 0 to 255. Please note that the use of slave devices for modbus are very rare and this number will
usually be 0.
HandleNum is the handle specifier from A to H (1 - 8).
Module is the position of the module in the rack from 1 to 16.
BitNum is the I/O point in the module from 1 to 4.
USAGE:
While Moving Yes Minimum n value 1
In a Program Yes Maximum n value 8
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=3 Set variable
MG @OUT[VAR1] Display only the whole number portion of
VAR1
EN End of program
166
LEGEND-MC User’s Manual
PA
FUNCTION: Position Absolute [Motion]
DESCRIPTION:
The PA command will set the absolute destination of the next move. The position is referenced to absolute
zero. If a ? is used, then the current destination (current commanded position if not moving, destination if
in a move) is returned. For each single move, the largest position move possible is +/- 2147483647. Units
are in quadrature counts.
ARGUMENTS: PA x, y, z, w or PAX=x or PA a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
USAGE:
While Moving No Minimum Value -2147483647
OPERAND USAGE:
_PAn contains current command position if not moving, start position if given during motion where n is an
axis letter.
RELATED COMMANDS:
"PR" Position relative
"SP" Speed
"AC" Acceleration
"DC" Deceleration
"BG" Begin
EXAMPLES:
:PA 400 X-axis will go to 400 counts
0000000
:BG
167
LEGEND-MC User’s Manual
PF
FUNCTION: Position Format [Setting]
DESCRIPTION:
The PF command allows the user to format the position numbers such as those returned by TP. The number
of digits of integers and the number of digits of fractions can be selected with this command. An extra digit
for sign and a digit for decimal point will be added to the total number of digits. If PF is minus, the format
will be hexadecimal and a dollar sign will precede the characters. Hex numbers are displayed as 2's comple-
ment with the first bit used to signify the sign.
If a number exceeds the format, the number will be displayed as the maximum possible positive or negative
number (i.e. 999.99, -999, $8000 or $7FF).
The PF command can be used to format values returned from the following commands:
BL ? PA ?
DE ? PR ?
DP ? TE
FL ?
IP ?
TP
Default n Value 0
OPERAND USAGE:
_PF contains the value of position format parameter.
EXAMPLES:
:TP Tell position
168
LEGEND-MC User’s Manual
00021.00
169
LEGEND-MC User’s Manual
PR
FUNCTION: Position Relative [Motion]
DESCRIPTION:
The PR command sets the incremental distance and direction of the next move. The move is referenced
with respect to the current position. If a ? is used, then the current incremental distance is returned (even if
it was set by a PA command). Units are in quadrature counts.
ARGUMENTS: PR x, y, z, w or PRX=x or PR a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
“?” returns the current incremental distance
USAGE:
While Moving No Minimum n Value -2147483648
OPERAND USAGE:
_PRn will return the current incremental distance where n is an axis letter.
RELATED COMMANDS:
"BG" Begin
"AC" Acceleration
"DC" Deceleration
"SP" Speed
"IP" Increment Position
EXAMPLES:
:PR 100 On the next move the X-axis will go 100
counts,
:BG
170
LEGEND-MC User’s Manual
QD
FUNCTION: Download Array [General]
DESCRIPTION:
The QD command transfers array data from the host computer to the LEGEND-MC. QD array[ ],start,end
requires that the array name be specified along with the first element of the array and last element of the
array. The array elements can be separated by a comma (,) or by <CR><LF>. The downloaded array is
terminated by a <control>Z, <control>Q, <control>D or \.
ARGUMENTS: QD array[ ], start, end where
“array[ ]” is a valid array name
“start” is the first element of the array (default=0)
“end” is the last element of the array (default=last element)
USAGE:
While Moving No Default Value 0
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"UL" Upload array
171
LEGEND-MC User’s Manual
QR
FUNCTION: Data Record [General]
DESCRIPTION:
The QR command causes the controller to return a record of information regarding controller status. This
status information includes 4 bytes of header information and specific blocks of information as specified by
the command arguments. The details of the status information is described in the communication chapter of
the user’s manual. This command is not designed to be used in the application program, it is designed for
data exchange with a computer.
ARGUMENTS: QR xx where
x is X,Y,Z,W,A,B,C,D,E,F,G,H or I or any combination to specify the axis, axes, or I/O status
I represents the status of the I/O
The Communication chapter of the users manual provides the definition of the data record information.
USAGE:
While Moving Yes Default Value -
RELATED COMMANDS:
"QZ" Return DMA / Data Record information
172
LEGEND-MC User’s Manual
QU
FUNCTION: Upload Array [General]
DESCRIPTION:
The QU command transfers array data from the LEGEND-MC to a host computer. QU requires that the
array name be specified along with the first element of the array and last element of the array. The
uploaded array will be followed by a <control>Z as an end of text marker.
ARGUMENTS: QU array[], start, end, delim where
“array[ ]” is a valid array name
“start” is the first element of the array (default=0)
“end” is the last element of the array (default=last element)
“delim” specifies the character used to delimit the array elements. If delim is 1, then the array elements
will be separated by a comma. Otherwise, the elements will be separated by a carriage return.
USAGE:
While Moving No Default Value 0
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"DL" Download array
173
LEGEND-MC User’s Manual
QW
FUNCTION: Slave Record Update Rate [Motion]
DESCRIPTION:
The PR command is given to the master controller of a distributed system. The value establishes the update
rate for data records to be sent from the slave controllers to the master controller. This command is executed
on the master controller.
ARGUMENTS: QWh=n where
h is the handle being used to send commands to the slave controller.
n = an even integer between 4 and 16000. this sets the period at which the slave controller updates the mas-
ter controller. the value of n represents the number of servo update cycles (default update cycle is 1 msec,
see the TM command). The slave controller will always wait for this period after a data record has been sent
before generating a new record.
USAGE:
While Moving Yes Default Value ---
RELATED COMMANDS:
"CH"
"NA"
"SR"
EXAMPLES:
CHC=A,B Using one LEGEND-MC as a master and one
LEGEND-MC as a slave. This command
assigns the slave, identified by the C axis des-
ignator, with Handle A for commands and
Handle B for status returned from the slave.
QWB=20 Sets the update rate for the slave controller to
20 msec (TM=1000).
174
LEGEND-MC User’s Manual
QZ
FUNCTION: Return Data Record Information [General]
DESCRIPTION:
The QZ command is an interrogation command that returns information regarding the Data Record. The
controller’s response to this command will be the return of 4 integers separated by commas. The four
fields represent the following:
First field returns the number of axes.
Second field returns the number of bytes to be transferred for general status
Third field returns the number bytes to be transferred for coordinated move status
Fourth field returns the number of bytes to be transferred for axis specific information
ARGUMENTS: QZ
USAGE:
While Moving Yes Default Value ---
RELATED COMMANDS:
“DR” DMA update rate
175
LEGEND-MC User’s Manual
RA
FUNCTION: Record Array [General]
DESCRIPTION:
The RA command selects up to four arrays for automatic data capture. The selected arrays must have been
dimensioned by the DM command. The data to be captured is specified by the RD command and time inter-
val by the RC command.
ARGUMENTS: RA n [ ],m [ ] where
n,m are dimensioned arrays as defined by DM command. The [ ] contain nothing.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"DM" Dimension Array
EXAMPLES:
#Record Label
EN End
HINT: The record array mode is useful for recording the real-time motor position during motion. The data is automatically
captured in the background and does not interrupt the program sequencer. The record mode can also be used for a teach or
learn of a motion path.
176
LEGEND-MC User’s Manual
RC
FUNCTION: Record [General]
DESCRIPTION:
The RC command begins recording for the Automatic Record Array Mode (RA). RC 0 stops recording.
ARGUMENTS: RC n,m where
OPERAND USAGE:
_RC contains status of recording '1' if recording, '0' if not recording.
RELATED COMMANDS:
"DM" Dimension Array
"RD" Record Data
EXAMPLES:
#RECORD Record
EN End program
177
LEGEND-MC User’s Manual
RD
FUNCTION: Record Data [General]
DESCRIPTION:
The RD command specifies the data type to be captured for the Record Array (RA) mode. The data types
include:
_TP Position
_TI Inputs
_OP Outputs
Can be Interrogated No
OPERAND USAGE:
_RD contains the address for the next array element for recording.
RELATED COMMANDS:
"RA" Record Array
178
LEGEND-MC User’s Manual
EXAMPLES:
DM ERRORX[50] Define array
179
LEGEND-MC User’s Manual
RE
FUNCTION: Return from Error Routine [Program Flow]
DESCRIPTION:
The RE command is used to end a position error handling subroutine or limit switch handling subroutine.
The error handling subroutine begins with the #POSERR label. The limit switch handling subroutine begins
with the #LIMSWI. An RE at the end of these routines causes a return to the main program. Care should be
taken to be sure the error or limit switch conditions no longer occur to avoid re-entering the subroutines. If
the program sequencer was waiting for a trippoint to occur, prior to the error interrupt, the trippoint condi-
tion is preserved on the return to the program if RE1 is used. RE0 clears the trippoint. To avoid returning to
the main program on an interrupt, use the ZS command to zero the subroutine stack. No RE is needed after
ZS. After using ZS, use a JP command to return to a key location in the main program.
ARGUMENTS: RE n where
0 clears the interrupted trippoint
1 restores state of trippoint
USAGE:
While Moving No Minimum n Value 0
Used as an Operand No
RELATED COMMANDS:
#POSERR Excessive Position Error Special Label
EXAMPLES:
#A;JP #A;EN Label for main program
Note: An application program must be executing for the #LIMSWI and #POSERR subroutines to
function.
180
LEGEND-MC User’s Manual
RI
FUNCTION: Return from Interrupt Routine [Program Flow]
DESCRIPTION:
The RI command is used to end the interrupt subroutine beginning with the label #ININT. An RI at the end
of this routine causes a return to the main program. The RI command also re-enables input interrupts. If
the program sequencer was interrupted while waiting for a trippoint, such as WT, RI1 restores the trippoint
upon return to the program. RI0 clears a trippoint. To avoid returning after an interrupt, use the ZS com-
mand to zero the subroutine stack. Check the example section for more details about using interrupts.
ARGUMENTS: RI n where
n = 0 or 1
0 clears interrupt trippoint
1 restores trippoint
USAGE:
While Moving No Minimum n Value 0
Used as an Operand No
RELATED COMMANDS:
#ININT Input interrupt subroutine
EXAMPLES:
#A;II1;JP #A;EN Program label
Note: An applications program must be executing for the #ININT subroutine to function.
181
LEGEND-MC User’s Manual
RL
FUNCTION: Report Latched Position [General]
DESCRIPTION:
The RL command will return the last position captured by the latch. The latch must first be armed by the
AL command. The armed state of the latch can be configured using the CN command.
ARGUMENTS: RLn where
n = XYZW or ABCDEFGH for the main encoder latch and
n = SX, SY, SZ, SW or SA, SB, SC, SD, SE, SF, SG, SH for the auxiliary encoder latch
USAGE:
While Moving Yes Default Value n/a
Can be Interrogated No
OPERAND USAGE:
_RLn or Sn contains the latched position where n is an axis letter.
RELATED COMMAND:
"AL" Arm Latch
EXAMPLES:
JG 5000 Set up to jog
BG Begin jog
10000
182
LEGEND-MC User’s Manual
@RND
FUNCTION: Round
DESCRIPTION:
@RND rounds a number or variable given in square brackets. Note that the @RND command is a func-
tion, which means that it does not follow the convention of the commands, and does not require the
underscore when used as an operand.
ARGUMENTS: @RND [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -2147483648.9999
In a Program Yes Maximum n value 2147483648.9999
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=123.456 Set variable
MG @RND[VAR1] Display the value of VAR1 rounded to the
nearest integer
VAR2=@RND[VAR1]+25 Perform calculation
EN End of program
183
LEGEND-MC User’s Manual
RS
FUNCTION: Reset [General]
DESCRIPTION:
The RS command resets the processor to its power-on condition. The previously saved (burned) state of the
controller, along with parameter values, and saved sequences are restored.
ARGUMENTS: RSn where
0 (or no parameter) restores burned parameters and clears application program
1 restores burned parameters only
2 clears application programs only
USAGE:
Can be Interrogated No
Used as an Operand No
EXAMPLES:
RS Reset the controller
184
LEGEND-MC User’s Manual
<control>R<control>S
FUNCTION: Master Reset [General]
DESCRIPTION:
The Master Reset command resets the LEGEND-MC to factory default settings and erases the EEPROM.
A master reset can also be performed by installing a jumper on the LEGEND-MC at the location labeled
JP1/MR. The controller must be removed from the amplifier to access the jumper. The controller must be
reattached to the amplifier and powered ON to perform the master reset. Remove the jumper after this pro-
cedure.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
185
LEGEND-MC User’s Manual
<control>R<control>V
FUNCTION: Revision [General]
DESCRIPTION:
The Revision command causes the controller to return the firmware revision information.
USAGE:
While Moving Yes Default Value -
Can be Interrogated No
Used as an Operand No
186
LEGEND-MC User’s Manual
SA
FUNCTION: Send Command [General]
DESCRIPTION:
SA sends a command from the master to the slave controller of a distributed control system. Any com-
mand can be sent to a slave controller and will be interpreted by the slave as a “local” command. Some
commands are only “local” commands and must be sent with the SA command. Refer to the discussion of
local vs global commands in this manual.
ARGUMENTS: SAh=arg or SAh= arg, arg, arg, arg, arg, arg, arg, arg where
h is the handle being used to send commands to the slave controller.
arg is a number, controller operand, variable, mathematical function, or string; the range for numeric values
is 4 bytes of integer (231) followed by two bytes of fraction (+/- 2,147,483,647.9999). The maximum num-
ber of characters for a string is 6. Strings are identified by quotations.
Typical usage would have the first argument as a string such as “KI” and the subsequent arguments as the
arguments to the command: Example SAF= “KI”,1,2 would send the command
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_SAhn gives the value of the response to the command sent with an SA command. The h value represents
the handle A thru F and the n value represents the specific field returned from the controller (1-8). If the
specific field is not used, the operand will be -2^31.
RELATED COMMAND:
"CH" Connect to Internet Handles for slaves
EXAMPLES:
CHY=A,B Use one LEGEND-MC as a master and one LEGEND-MC as a slave.
This command assigns the slave, identified by the Y axis designator, with
Handle A for commands and Handle B for status returned from the slave.
MG_SAA : 132 Display the content of the operand _SAA (first response to TE command
187
LEGEND-MC User’s Manual
SB
FUNCTION: Set Bit [I/O]
DESCRIPTION:
The SB command sets one of four bits on the output port, slave controller, or Modbus I/O.
ARGUMENTS: SB n where
n is an integer in the range 1 to 4 decimal or Modbus address. See chart below for setting outputs on slave
controllers.
DISTRIBUTED CONTROL:
MODBUS:
Note: When using Modbus devices, the I/O points of the modbus devices are calculated using the
following formula:
n = (SlaveAddress*1000) + (HandleNum*1000) + ((Module-1)*4) + (Bitnum-1)
Slave Address is used when the ModBus device has slave devices connected to it and specified as
Addresses 0 to 255. Please note that the use of slave devices for modbus are very rare and this number will
usually be 0.
HandleNum is the handle specifier from A to H (1 - 8).
Module is the position of the module in the rack from 1 to 16.
BitNum is the I/O point in the module from 1 to 4.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMAND:
"CB" Clear Bit
EXAMPLES:
SB 3 Set output line 3
188
LEGEND-MC User’s Manual
SC
FUNCTION: Stop Code [Status]
DESCRIPTION:
The SC command allows the user to determine why a motor stops. The controller responds with the stop
code as follows:
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
OPERAND USAGE:
_SCn contains the value of the stop code where n is an axis letter.
EXAMPLES:
Tom=_SCX Assign the Stop Code to variable Tom
189
LEGEND-MC User’s Manual
SH
FUNCTION: Servo Here [General]
DESCRIPTION:
The SH command tells the controller to use the current motor position as the commanded position and to
enable servo control here. PID control starts when this command is issued.
This command can be useful when the position of a motor has been manually adjusted following a motor off
(MO) command.
The SH command is integrated with the RUN output of the LEGEND amplifier. If the RUN output does not
come ON within 100 msec, the controller returns to MO status and issues a command error. If this occurs,
check the power on L1, L2, and L3.
ARGUMENTS: SH XYZW or ABCDEFGH
USAGE:
While Moving No Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"MO" Motor-off
EXAMPLES:
SH Servo motor
190
LEGEND-MC User’s Manual
@SIN
FUNCTION: Sin
DESCRIPTION:
@SIN returns the sin of a number or variable given in square brackets using units of degrees. Note that
the @SIN command is a function, which means that it does not follow the convention of the commands,
and does not require the underscore when used as an operand.
ARGUMENTS: @SIN [n] where
n is a number
USAGE:
While Moving Yes Minimum n value -32768
In a Program Yes Maximum n value 32768
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=60 Set variable
MG @SIN[VAR1] Display the value of the sine of VAR1
VAR2=@SIN[VAR1]+9 Perform calculation
EN End of program
191
LEGEND-MC User’s Manual
SP
FUNCTION: Speed [Motion]
DESCRIPTION:
This command sets the slew speed for independent moves. The parameters input will be rounded down to
the nearest factor of 2 and the units of the parameter are in counts per second.
OPERAND USAGE:
_SPn contains the current speed setting where n is an axis letter.
RELATED COMMANDS:
"AC" Acceleration
"DC" Deceleration
EXAMPLES:
PR 2000 Specify position relative move
SP 5000 Specify speeds
192
LEGEND-MC User’s Manual
@SQR
FUNCTION: Square Root
DESCRIPTION:
@SQR returns the square root of a number or variable given in square brackets. Note that the @SQR command is a
function, which means that it does not follow the convention of the commands, and does not require the underscore
when used as an operand. This function will treat negative numbers as positive numbers.
ARGUMENTS: @SIN [n] where
n is a number
USAGE:
While Moving Yes Minimum n value 0
In a Program Yes Maximum n value 2147483647.9999
Not in a program Yes Default Value ---
Can be Interrogated No Default Format ---
Used as an Operand Yes
EXAMPLES:
#TEST Program TEST
VAR1=60 Set variable
MG @SIN[VAR1] Display the value of the sine of VAR1
VAR2=@SIN[VAR1]+9 Perform calculation
EN End of program
193
LEGEND-MC User’s Manual
ST
FUNCTION: Stop [Motion]
DESCRIPTION:
The ST command stops commanded motion. The motor will come to a decelerated stop.
ARGUMENTS: ST XYZWS or ABCDEFGH where
XYZW or ABCDEFGH are axis designators. S indicates an interpolation sequence. No argument specifies
that motion on all axes is complete.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"BG" Begin Motion
EXAMPLES:
ST Stop motion
HINT: Use the after motion complete command, AM, to wait for motion to be stopped.
194
LEGEND-MC User’s Manual
TB
FUNCTION: Tell Status Byte [Status]
DESCRIPTION:
The TB command returns status information from the controller as a decimal number. Each bit of the sta-
tus byte denotes the following condition when the bit is set (high):
BIT STATUS
Bit 5 Contouring
Bit 1 0 (Reserved)
Bit 0 Echo on
ARGUMENTS: None
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_TB contains the status byte.
EXAMPLES:
TB Tell status information from the controller
195
LEGEND-MC User’s Manual
TC
FUNCTION: Tell Error Code [Status]
DESCRIPTION:
The TC command returns a number between 1 and 255. This number is a code that reflects why a command
was not accepted by the controller. This command is useful when the controller halts execution of a program
at a command or when the response to a command is a question mark. Entering the TC command will pro-
vide the user with a code as to the reason. After TC has been read, it is set to zero. TC 1 returns the text
message as well as the numeric code.
ARGUMENTS: TC n
n=0 returns code only
n=1 returns code and message
CODE EXPLANATION
1 Unrecognized command
4 Operand error
9 Variable error
196
LEGEND-MC User’s Manual
53 Error in {}
55 Missing [ or []
59 Mismatched parentheses
82 Undefined Array
197
LEGEND-MC User’s Manual
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_TC contains the value of the error code.
EXAMPLES:
:GF32 Bad command
198
LEGEND-MC User’s Manual
TD
FUNCTION: Tell Dual Encoder [Motion]
DESCRIPTION:
This command returns the current position of the dual (auxiliary) encoder.
Can be Interrogated No
OPERAND USAGE:
_TDn contains the dual encoder position where n is an axis letter.
RELATED COMMANDS:
"DE" Dual Encoder
EXAMPLES:
:PF 7 Position format of 7
0000200
199
LEGEND-MC User’s Manual
TE
FUNCTION: Tell Error [Status]
DESCRIPTION:
This command returns the current position error of the motor. It is up-dated every servo cycle.
ARGUMENTS: TE XYZW or ABCDEFGH
USAGE:
While Moving Yes Minimum Value -2147483648
OPERAND USAGE:
_TEn contains the value of the position error where n is an axis letter.
RELATED COMMANDS:
"ER" Error Limit
EXAMPLES:
TE Return position error
00005
HINT: Under normal operating conditions with servo control, the position error should be small. The position error is typi-
cally largest during acceleration.
200
LEGEND-MC User’s Manual
TI
FUNCTION: Tell Inputs [I/O]
DESCRIPTION:
This command returns the state of all 8 of the general digital inputs. Response is a decimal number which
when converted to binary represents the status of all 8 digital inputs.
BIT TI PIN
Bit 7 Input 8 20
Bit 6 Input 7 19
Bit 5 Input 6 42
Bit 4 Input 5 43
Bit 3 Input 4 44
Bit 2 Input 3 45
Bit 1 Input 2 17
Bit 0 Input 1 18
DISTRIBUTED CONTROL:
ARGUMENTS: TI
USAGE:
While Moving Yes Default Value ---
In a Program Yes Default Format 3.0
Command Line Yes
OPERAND USAGE:
_TI contains the status byte of the input block. This can be masked to return only specified bit information.
EXAMPLES:
TI
201
LEGEND-MC User’s Manual
TIME*
FUNCTION: Time Operand (Keyword) [General]
DESCRIPTION:
The TIME operand contains the value of the internal free running, real time clock. The returned value rep-
resents the number of servo loop updates and is based on the TM command. The default value for the TM
command is 1000. With this update rate, the operand TIME will increase by 1 count every update of
approximately 1000usec. Note that a value of 1000 for the update rate (TM command) will actually set an
update rate of 1/1024 seconds. Thus the value returned by the TIME operand will be off by 2.4% of the
actual time.
The clock is reset to 0 with a standard reset or a master reset.
The keyword, TIME, does not require an underscore (_) as with the other operands.
USAGE:
Used as an Operand Yes (without underscore) Minimum value 0
Format TIME
EXAMPLES:
MG TIME Display the value of the internal clock
202
LEGEND-MC User’s Manual
TL
FUNCTION: Torque Limit [Setting]
DESCRIPTION:
The TL command sets the limit on the motor command output. For example, TL of 5 limits the motor
command output to 5 volts. Maximum output of the motor command is 9.998 volts.
ARGUMENTS: TL x, y, z, w or TLX=x or TL a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are unsigned integers
“?” returns the limit value
USAGE:
While Moving Yes Minimum n Value 0
OPERAND USAGE:
_TLn contains the value of the torque limit where n is an axis letter.
EXAMPLES:
TL 1 Limit X-axis torque to 1volt
1.0000
203
LEGEND-MC User’s Manual
TM
FUNCTION: Time [Configuration]
DESCRIPTION:
The TM command sets the sampling period of the control loop. Changing the sampling period will uncali-
brate the speed and acceleration parameters. A negative number turns off the internal clock allowing for an
external source to be used as the time base. The units of this command are µsec. If a multi-axis system is
configured the TM value is set in all controllers if set in the master.
ARGUMENTS: TM n where
n is an integer in microseconds with a resolution of 125 microseconds.
“?” returns the value of the sample clock
USAGE:
While Moving Yes Minimum n Value 250
OPERAND USAGE:
_TM contains the value of the sample time.
EXAMPLES:
TM 250 Set sample rate to 250 µsec (This will multiply all
speeds by four and all acceleration by eight)
Note: Although this manual refers to times in msec, think in terms of servo cycles. This includes
everything from a WT command to SP commands.
204
LEGEND-MC User’s Manual
TP
FUNCTION: Tell Position [Status]
DESCRIPTION:
This command returns the current position of the motor in quadrature counts.This value is up-dated every
servo cycle.
ARGUMENTS: TP XYZW or ABCDEFGH
USAGE:
While Moving Yes Default Value n/a
Can be Interrogated No
OPERAND USAGE:
_TPn contains the current position value where n is an axis letter.
EXAMPLES:
:PF 7 Position format of 7
0000200
TP Return in hex
$0000C8
205
LEGEND-MC User’s Manual
TR
FUNCTION: Trace [Debug]
DESCRIPTION:
The TR command causes each instruction in a program to be sent out the communications port prior to exe-
cution. TR1 enables this function and TR0 disables it. The trace command is useful in debugging pro-
grams. It is not recommended to leave the TR command on for long durations (over 30 seconds) because it
takes much longer to output the data from the controller than to execute it, hence, program execution will be
affected. If no program lines are coming from the controller, issue “MG_XQn” or “MG_HXn” to see what
line the controller is on. If the controller is at a trippoint, no lines will be output. Another way to take advan-
tage of this command is to insert it in your program at a location previous to a suspected trouble spot (TR1)
and just after the trouble spot (TR0). This way the trace will only show program lines that pertain to the
debugging process.
ARGUMENTS: TR n where
n=0 or 1
0 disables function
1 enables function
USAGE:
While Moving Yes Default Value 0
Can be Interrogated No
206
LEGEND-MC User’s Manual
TS
FUNCTION: Tell Switches [Status]
DESCRIPTION:
TS returns the state of the Home switch, Forward and Reverse Limit switch, error conditions, motion con-
dition and motor state. The value returned by this command is decimal and represents an 8 bit value (deci-
mal value ranges from 0 to 255). Each bit represents the following status information.
Bit Status
Bit 7 Axis in motion if high
Bit 4 Undefined
Note: The value for bits 1, 2 and 3 depend on the limit switch and home switch configuration (see
CN command). For active low configuration (default), these bits are ‘1’ when the switch is inactive
and ‘0’ when active. For active high configuration, these bits are ‘0’ when the switch is inactive and
‘1’ when active.
OPERAND USAGE:
_TSX contains the current status of the switches.
207
LEGEND-MC User’s Manual
EXAMPLES:
Assigns value of TS to the variable V1
V1=
208
LEGEND-MC User’s Manual
TT
FUNCTION: Tell Torque [Status]
DESCRIPTION:
The TT command reports the value of the analog servo command output signal, which is a number
between -9.998 and 9.998 volts. This value is up-dated every servo cycle.
ARGUMENTS: TT XYZW or ABCDEFGH
USAGE:
While Moving Yes Minimum Value -9.9988
OPERAND USAGE:
_TTn contains the value of the torque where n is an axis letter.
RELATED COMMANDS:
"TL" Torque Limit
EXAMPLES:
V1=_TT Assigns value of TT to variable, V1
TT Report torque
209
LEGEND-MC User’s Manual
TV
FUNCTION: Tell Velocity [Status]
DESCRIPTION:
The TV command returns the actual velocity in units of quadrature count/s. The value returned includes the
sign. This value is averaged over 256 servo cycles.
ARGUMENTS: TV XYZW or ABCDEFGH
USAGE:
While Moving Yes Minimum Value -12,000,000
OPERAND USAGE:
_TVn contains the value for the velocity where n is an axis letter.
EXAMPLES:
VELX=_TV Assigns value of velocity to the variable VELX
0003420
210
LEGEND-MC User’s Manual
TW
FUNCTION: Timeout for IN-Position (MC) [Setting]
DESCRIPTION:
The TW n command sets the timeout in msec to declare an error if the MC command is active and the
motor is not at or beyond the actual position within n msec after the completion of the motion profile. If a
timeout occurs, then the MC trippoint will clear and the stopcode will be set to 99. An application pro-
gram will jump to the special label #MCTIME. If included, the RE command should be used to return
from the #MCTIME subroutine.
ARGUMENTS: TW x, y, z, w or TWX=x or TW a ,b, c, d, e, f, g, h where
x, y z, w, or a, b, c, d, e, f, g, h are signed integers
n specifies timeout in msec, -1 disables the timeout
“?” returns the timeout in msec for the MC command
USAGE:
While Moving Yes Minimum n Value -1
OPERAND USAGE:
_TW contains the timeout in msec for the MC command .
RELATED COMMANDS:
"MC" Motion Complete - "In Position"
211
LEGEND-MC User’s Manual
UL
FUNCTION: Upload [General]
DESCRIPTION:
The UL command transfers data from the LEGEND-MC to a host computer. Programs are sent without line
numbers. The Uploaded program will be followed by a <control>Z or a \ as an end of Text marker.
ARGUMENTS: None
USAGE:
While Moving Yes Default Value n/a
Can be Interrogated No
OPERAND USAGE:
When used as an operand, _UL gives the number of available variables. The total number of variables is
126.
RELATED COMMAND:
"DL" Download
EXAMPLES:
UL; Begin upload
#A Line 0
NO Program Line 2
EN Line 3
<cntrl>Z Terminator
212
LEGEND-MC User’s Manual
VA
FUNCTION: Vector Acceleration [Motion]
DESCRIPTION:
This command sets the acceleration rate of the vector in a coordinated motion sequence.
ARGUMENTS: VA n where
n is an unsigned integer. The parameter input will be rounded down to the nearest factor of 1024. The
units of the parameter is counts per second squared.
n = ? Returns the value of the vector acceleration for the coordinate plane.
USAGE:
While Moving Yes Minimum n Value 1024
OPERAND USAGE:
_VA contains the value of the vector acceleration.
RELATED COMMANDS:
"VS" Vector Speed
EXAMPLES:
VA 1024 Set vector acceleration to 1024 counts/sec2
VA ? Return vector acceleration
00001024
213
LEGEND-MC User’s Manual
VD
FUNCTION: Vector Deceleration [Motion]
DESCRIPTION:
This command sets the deceleration rate of the vector in a coordinated motion sequence.
ARGUMENTS: VD n where
n is an unsigned integer. The parameter input will be rounded down to the nearest factor of 1024. The units
of the parameter is counts per second squared.
n = ? Returns the value of the vector deceleration for the coordinate plane.
USAGE:
While Moving Yes Minimum n Value 1024
In a Program Yes Maximum n Value 67107840
Command Line Yes Default Value 256000
Can be Interrogated Yes Default Format Position Format
Used as an Operand Yes
OPERAND USAGE:
_VD contains the value of the vector deceleration.
RELATED COMMANDS:
"VA" Vector Acceleration
"VS" Vector Speed
"VP" Vector Position
"VE" Vector End
"VM" Vector Mode
"BGS" Begin Sequence
"VT" Smoothing constant - S-curve
EXAMPLES:
VE End Vector
214
LEGEND-MC User’s Manual
VE
FUNCTION: Vector Sequence End [Motion]
DESCRIPTION:
VE is required to specify the end segment of a coordinated move sequence. VE follows the final VP or CR
command in a sequence. VE is equivalent to the LE command. If a VE command is not issued before the
controller runs all the linear segments, motion will stop instantaneously.
ARGUMENTS: VE
n = ? Returns the length of the vector in counts.
USAGE:
While Moving Yes Default Value -
OPERAND USAGE:
_VE contains the length of the vector in counts.
RELATED COMMANDS:
"VM" Vector Mode
EXAMPLES:
VM XY Vector move in XY
VE End sequence
215
LEGEND-MC User’s Manual
VF
FUNCTION: Variable Format [General]
DESCRIPTION:
The VF command allows the variables and arrays to be formatted for number of digits before and after the
decimal point. When displayed, the value m represents the number of digits before the decimal point, and
the value n represents the number of digits after the decimal point. When in hexadecimal, the string will be
preceded by a $. Hex numbers are displayed as 2's complement with the first bit used to signify the sign.
If a number exceeds the format, the number will be displayed as the maximum possible positive or negative
number (i.e. 999.99, -999, $8000 or $7FF).
ARGUMENTS: VF m.n where
m and n are unsigned numbers. A negative m specifies hexadecimal format.
VF? returns the value of the format for variables and arrays.
USAGE:
While Moving Yes Minimum m Value -8
Default n Value 4
OPERAND USAGE:
_VF contains the value of the format for variables and arrays.
EXAMPLES:
VF 5.3 Sets 5 digits of integers and 3 digits after the
decimal point
216
LEGEND-MC User’s Manual
VR
FUNCTION: Vector Speed Ratio [Motion]
DESCRIPTION:
The VR sets a ratio to be used as a multiplier of the current vector speed. The vector speed can be set by
the command VS or the operators < and > used with CR, VP and LI commands. VR takes effect immedi-
ately and will ratio all the following vector speed commands. VR doesn't ratio acceleration or decelera-
tion, but the change in speed is accomplished by accelerating or decelerating at the rate specified by VA
and VD.
ARGUMENTS: VR n where
n is an integer with a resolution of .0001.
n = ? Returns the value of the vector speed ratio.
USAGE:
While Moving Yes Minimum n Value 0.0001
OPERAND USAGE:
_VR contains the vector speed ratio.
RELATED COMMANDS:
"VS" on page Vector Speed
EXAMPLES:
#A Vector Program
VMXY Vector Mode
VE End Sequence
VS 2000 Vector Speed
JP#SPEED Loop
XQ#A,0; XQ#SPEED,1 Execute task 0 and 1 simultaneously
Note: UseVR for feedrate override, when specifying the speed of individual segments using the
operator ‘<’.
217
LEGEND-MC User’s Manual
VS
FUNCTION: Vector Speed [Motion]
DESCRIPTION:
The VS command specifies the speed of the vector in a coordinated motion sequence in either the LM or
VM modes. VS may be changed during motion.
Vector Speed can be calculated by taking the square root of the sum of the squared values of speed for each
axis specified for vector or linear interpolated motion.
ARGUMENTS: VS n where
n is an unsigned even number. The units are counts per second.
n = ? Returns the value of the vector speed.
USAGE:
While Moving Yes Minimum n Value 2
OPERAND USAGE:
_VS contains the vector speed.
RELATED COMMANDS:
"VA" Vector Acceleration
EXAMPLES:
VS 2000 Define vector speed
002000
Hint: Vector speed can be attached to individual vector segments. For more information, see description of VP, CR, and LI
commands.
218
LEGEND-MC User’s Manual
VT
FUNCTION: Vector Time Constant - S curve [Motion]
DESCRIPTION:
The VT command filters the acceleration and deceleration functions in vector moves of VM, LM type to
produce a smooth velocity profile. The resulting profile, known as Smoothing, has continuous acceleration
and results in reduced mechanical vibrations. VT sets the bandwidth of the filter, where 1 means no filter-
ing and 0.004 means maximum filtering. Note that the filtering results in longer motion time.
ARGUMENTS: VT n where
n is an unsigned number with a resolution of 1/256.
n = ? Returns the value of the vector time constant.
USAGE:
While Moving Yes Minimum n Value 0.004
OPERAND USAGE:
_VT contains the vector time constant.
RELATED COMMANDS:
"IT" Independent Time Constant for smoothing
independent moves
EXAMPLES:
VT 0.8 Set vector time constant
0.8
219
LEGEND-MC User’s Manual
WC
FUNCTION: Wait for Contour Data [Program Flow]
DESCRIPTION:
The WC command acts as a flag in the Contour Mode. After this command is executed, the controller does
not receive any new data until the internal contour data buffer is ready to accept new commands. This com-
mand prevents the contour data from overwriting itself in the contour data buffer.
USAGE:
While Moving Yes Default Value ---
Can be Interrogated No
Used as an Operand No
RELATED COMMANDS:
"CM" Contour Mode
EXAMPLES:
CM Specify contour mode
CD 100
DT 0 Stop contour
CD 0 Exit mode
220
LEGEND-MC User’s Manual
WT
FUNCTION: Wait [Trippoint]
DESCRIPTION:
The WT command is a trippoint used to time events. After this command is executed, the controller will
wait for the number of samples specified before executing the next command. If the TM command has not
been used to change the sample rate from 1 msec, then the units of the Wait command are milliseconds.
ARGUMENTS: WT n where
n is an integer
USAGE:
While Moving Yes Minimum Value 0
Used as an Operand No
EXAMPLES:
Assume that 10 seconds after a move is over a relay must be closed.
#A Program A
SB 1 Turn on relay
EN End Program
221
LEGEND-MC User’s Manual
XQ
FUNCTION: Execute Program [General]
DESCRIPTION:
The XQ command begins execution of a program residing in the program memory of the controller. Execu-
tion will start at the label or line number specified. Two programs may be executed simultaneously to per-
form multitasking.
ARGUMENTS: XQ #A,n XQm,n where
A is a program label of up to seven characters
m is a line number
n is the thread number 0 or 1
NOTE: The arguments for the command, XQ, are optional. If no arguments are given, the first
program in memory will be executed as thread 0.
USAGE:
While Moving Yes Default Value n=0
Can be Interrogated No
OPERAND USAGE:
_XQ contains the current line number of execution for thread n, and -1 if thread n is not running.
RELATED COMMANDS:
"HX" on page Halt execution
EXAMPLES:
XQ #Apple,0 Start execution at label Apple, thread zero
222
LEGEND-MC User’s Manual
ZA
FUNCTION: User Variable [Configuration]
DESCRIPTION:
ZA sets the first user variable for use with a distributed control system. The user variable is automatically
sent as part of the status record from the slave controller to the master controller. This variable provides a
method for specific slave information to be passed to the master automatically.
ARGUMENTS: ZA n, n, n, n, n, n, n or ZAA=n where
n can be a number, controller operand, variable, mathematical function, or string. The range for numeric
values is 4 bytes of integer 2147483647 (231). The maximum number of characters for a string is 4 charac-
ters. Strings are identified by quotations.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_ZAa contains the user variable defined by the axis, a, set with a ZA command. a is any axis designator A,
B, C, D, ,E ,F ,G, and H.
RELATED COMMANDS:
"ZB" Set second variable
EXAMPLES:
CHB=A, B Use one LEGEND-MC as a master and one
LEGEND-MC as a slave. This command
assigns the slave, identified by the S axis des-
ignator, with handle A for commands and han-
dle B for status returned from the slave.
223
LEGEND-MC User’s Manual
ZB
FUNCTION: User Variable, ZB [Configuration]
DESCRIPTION:
ZA sets the “B” user variable for use with a distributed control system. The user variable is automatically
sent as part of the status record from the slave controller to the master controller. This variable provides a
method for specific slave information to be passed to the master automatically.
ARGUMENTS: ZB n, n, n, n, n, n, n or ZBA=n where
n can be a number, controller operand, variable, mathematical function, or string. The range for numeric val-
ues is 4 bytes of integer 2147483647 (231). The maximum number of characters for a string is 4 characters.
Strings are identified by quotations.
USAGE:
While Moving Yes Default Value ---
OPERAND USAGE:
_ZBa contains the user variable defined by the axis, a, set with a ZB command. a is any axis designator A,
B, C, D, ,E ,F ,G, and H.
RELATED COMMANDS:
"ZA" Set first variable
EXAMPLES:
CHB=A, B Use one LEGEND-MC as a master and one
LEGEND-MC as a slave. This command
assigns the slave, identified by the S axis des-
ignator, with handle A for commands and han-
dle B for status returned from the slave.
224
LEGEND-MC User’s Manual
ZS
FUNCTION: Zero Subroutine Stack [Program Flow]
DESCRIPTION:
The ZS command is only valid from within an application program and is used to avoid returning from an
interrupt (either input or error). ZS alone returns the stack to its original condition. ZS1 adjusts the stack
to eliminate one return. This turns the jump to subroutine into a jump.
ARGUMENTS: ZS n where
0 returns stack to original condition
1 eliminates one return on stack
USAGE:
While Moving Yes Minimum value 0
OPERAND USAGE:
_ZSn contains the stack level for the specified thread where n = 0 or 1. The response, an integer between
zero and seven, indicates zero for beginning condition and 15 for the deepest value.
EXAMPLES:
II1 Input Interrupt on 1
S= Print stack
ZS Zero stack
S= Print stack
EN End
225
LEGEND-MC User’s Manual
226
LEGEND-MC User’s Manual
227
LEGEND-MC User’s Manual
228
LEGEND-MC User’s Manual
5 Programming Basics
Introduction
The LEGEND-MC provides over 100 commands for specifying motion and machine parameters. Com-
mands are included to initiate action, interrogate status and configure the digital filter.
The LEGEND-MC instruction set is BASIC-like and easy to use. Instructions usually consist of two
uppercase letters that normally correspond phonetically with the appropriate function. For example, the
instruction BG begins motion, and ST stops motion.
Commands can be sent "live" for immediate execution by the LEGEND-MC, or an entire group of com-
mands (a program) can be downloaded into the LEGEND-MC memory for execution at a later time.
Combining commands into groups for later execution is referred to as Applications Programming and is
discussed in the following chapter.
This section describes the LEGEND-MC instruction set and syntax. A complete listing of all LEGEND-
MC instructions is included in the command reference section.
Program Maximums
Commands per line Until 80 characters
Labels among all threads 126
Lines among all threads 500
Subroutine nesting level 16
Threads 2
Command Syntax
LEGEND-MC instructions are represented by two ASCII upper case characters followed by applicable
arguments. A space may be inserted between the instruction and arguments. A semicolon or <enter> is
used to terminate the instruction for processing by the LEGEND-MC command interpreter.
229
LEGEND-MC User’s Manual
To view the current values for each command, specify the command followed by a ? for each axis
requested. The LEGEND-MC provides an alternative method for specifying data.
Here data is specified individually using a single axis specified such as X,Y,Z or W (or A,B,C,D,E,F,G or
H for the LEGEND-MC ). An equal sign is used to assign data to that axis. For example:
PRZ=1000 Sets the Z axis data as 1000
All axes data may be specified at once using the * symbol. This sets all axes to have the same data. For
example:
PR*=1000 Sets all axes to 1000
Instead of data, some commands request action to occur on an axis or group of axes. For example, ST XY
stops motion on both the X and Y axes. Commas are not required in this case since the particular axis is
specified by the appropriate letter X Y Z or W. If no parameters follow the instruction, action will take
place on all axes. The letter S is used to specify a coordinated motion sequence.
BG X Begin X only
BG Y Begin Y only
BG D Begin D only
230
LEGEND-MC User’s Manual
For example, if the command bg is sent in lower case, the LEGEND-MC will return a ?.
? LEGEND-MC returns a ?
The command Tell Code, TC1, will return the reason for the “?” received for the last invalid command.
There are several coded reasons for receiving a ?. Example codes include unrecognized command (such
as typographical entry or lower case), a command given at improper time, or a command out of range,
such as exceeding maximum speed. A complete listing of all codes is listed in the TC command in the
Command Reference section.
For interrogation instructions such as Tell Position (TP) or Tell Status (TS), the LEGEND-MC returns the
requested data on the next line followed by a carriage return and line feed. The data returned is in deci-
mal format.
The format of the returned data can be set using the Position Format (PF) and Variable Format (VF) com-
mand.
231
LEGEND-MC User’s Manual
Command Summary
Each LEGEND-MC command is described fully in the command reference section of this manual. A
summary of the commands follows.
The commands are grouped in this summary by the following functional categories:
• Motion
• Program Flow
• General Configuration
• Control Settings
• Status and Error/Limits
Motion commands are those to specify modes of motion such as Jog Mode or Linear Interpolation, and to
specify motion parameters such as speed, acceleration and deceleration, and distance.
Program flow commands are used in Application Programming to control the program sequencer. They
include the jump on condition command and event triggers such as after position and after elapsed time.
General configuration commands are used to set controller configurations such as setting and clearing out-
puts, formatting variables, and motor/encoder type.
The control setting commands include filter settings such as KP, KD, and KI and sample time.
Error/Limit commands are used to configure software limits and position error limits.
Motion
AB Abort Motion
AC Acceleration
BG Begin Motion
CD Contour Data
CM Contour Mode
DC Deceleration
ES Ellipse Scaling
FE Find Edge
232
LEGEND-MC User’s Manual
FI Find Index
GR Gear Ratio
HM Home
IP Increment Position
JG Jog Mode
LT Latch Target
PA Position Absolute
PR Position Relative
SP Speed
ST Stop
VA Vector acceleration
VD Vector Deceleration
VP Vector Position
VS Vector Speed
233
LEGEND-MC User’s Manual
Program Flow
AD After Distance
AI After Input
AS At Speed
AT After Time
EN End Program
HX Halt Task
IF IF Conditional Statement
IN Input Variable
II Input Interrupt
JS Jump To Subroutine
MG Message
NO No operation
WT Wait
XQ Execute Program
234
LEGEND-MC User’s Manual
General Configuration
AF Analog Feedback
AL Arm Latch
BN Burn
BP Burn Program
BV Burn Variables
CB Clear Bit
CE Configure Encoder
CN Configure Switches
DA De-Allocate Arrays
DL Download
DM Dimension Arrays
DP Define Position
EO Echo Off
LS List
MO Motor Off
MT Motor Type
OB Output Bit
OP Output Port
PF Position Format
QU Upload Array
QD Download Array
RA Record Array
RC Record
RD Record Data
RS Reset
SB Set Bit
UL Upload
VF Variable Format
235
LEGEND-MC User’s Manual
IL Integrator Limit
KD Derivative Constant
KI Integrator Constant
KP Proportional Constant
OF Offset
SH Servo Here
TL Torque Limit
TM Sample Time
236
LEGEND-MC User’s Manual
Status
RL Report Latch
SC Stop Code
TB Tell Status
TE Tell Error
TI Tell Input
TP Tell Position
TR Trace
TS Tell Switches
TT Tell Torque
TV Tell Velocity
ER Error Limit
OE Off on Error
237
LEGEND-MC User’s Manual
Arithmetic Functions
@COS Cosine
@RND Round
@SIN Sine
@TAN Tangent
+ Add
- Subtract
* Multiply
/ Divide
& And
| Or
() Parentheses
238
LEGEND-MC User’s Manual
6 Programming Motion
Overview
The LEGEND-MC provides several modes of motion, including independent positioning and jogging,
coordinated motion, electronic cam motion, and electronic gearing. Each one of these modes is discussed
in the following sections.
The LEGEND-MC is a single axis controller and uses X-axis motion only. The example applications
described below will help guide you to the appropriate mode of motion.
239
LEGEND-MC User’s Manual
240
LEGEND-MC User’s Manual
Note: The actual motor motion may not be complete when the profile has been completed, however, the next
motion command may be specified.
The Begin (BG) command can be issued for all axes either simultaneously or independently. X or Y axis
specifiers are required to select the axes for motion. When no axes are specified, this causes motion to
begin on all axes.
The speed (SP) and the acceleration (AC) can be changed at any time during motion, however, the decel-
eration (DC) and position (PR or PA) cannot be changed until motion is complete. Remember, motion is
complete (AM) when the profiler is finished, not when the actual motor is in position. The Stop com-
mand (ST) can be issued at any time to decelerate the motor to a stop before it reaches its final position.
An incremental position movement (IP) may be specified during motion as long as the additional move is
in the same direction. Here, the user specifies the desired position increment, n. The new target is equal
to the old target plus the increment, n. Upon receiving the IP command, a revised profile will be gener-
ated for motion towards the new end position. The IP command does not require a begin. Note: If the
motor is not moving, the IP command is equivalent to the PR and BG command combination.
Command Description
PR X,Y Specifies relative distance
The lower case specifiers (x,y) represent position values for each axis. The SC3010 also allows use of
single axis specifiers such as PRY=2000.
241
LEGEND-MC User’s Manual
The following illustration - Velocity Profiles of XY shows the velocity profiles for the X and Y axis.
Instruction Interpretation
#A Begin Program
PR 2000,100 Specify relative position movement of 2000 and 100 counts for the X
and Y axes.
WT 40 Wait 40 msec
EN End Program
VELOCITY
(COUNTS/SEC)
15000
Y axis velocity profile
10000
5000
TIME (ms)
0 20 40 60 80 100
Velocity Profiles of XY
Notes on Velocity Profiles of XY illustration: The X axis has a ‘trapezoidal’ velocity profile, while the Y axis has a
‘triangular’ velocity profile. The X axis accelerates to the specified speed, moves at this constant speed, and then
decelerates such that the final position agrees with the commanded position, PR. The Y axis accelerates, but before
the specified speed is achieved, must begin deceleration such that the axis will stop at the commanded position.
242
LEGEND-MC User’s Manual
Independent Jogging
The jog mode of motion is very flexible because speed, direction and acceleration can be changed during
motion. The user specifies the jog speed (JG), acceleration (AC), and the deceleration (DC) rate for each
axis. The direction of motion is specified by the sign of the JG parameters. When the begin command is
given (BG), the motor accelerates up to speed and continues to jog at that speed until a new speed or stop
(ST) command is issued. If the jog speed is changed during motion, the controller will make an acceler-
ated (or decelerated) change to the new speed.
An instant change to the motor position can be made with the use of the IP command. Upon receiving
this command, the controller commands the motor to a position which is equal to the specified increment
plus the current position. This command is useful when trying to synchronize the position of two motors
while they are moving.
Note that the controller operates as a closed-loop position controller while in the jog mode. The LEG-
END-MC converts the velocity profile into a position trajectory and a new position target is generated
every sample period. This method of control results in precise speed regulation with phase lock accu-
racy.
Command Description
BG XY Begins motion
ST XY Stops motion
Parameters can be set with individual axis specifiers such as JGY=2000 (set jog speed for Y axis to 2000)
or AC 400000, 400000 (set acceleration for X and Y axes to 400000).
243
LEGEND-MC User’s Manual
Additional Commands
The commands VS n, VA n, and VD n are used to specify the vector speed, acceleration, and deceleration.
The LEGEND-MC computes the vector speed based on the axes specified in the LM mode. For example,
LM XY designates linear interpolation for the X and Y axes. The vector speed for this example would be
computed using the equation:
244
LEGEND-MC User’s Manual
Instruction Interpretation
LI 4000,0 <4000 >1000 Specify first linear segment with a vector speed of 4000 and
end speed 1000
LI 1000,1000 < 4000 >1000 Specify second linear segment with a vector speed of 4000
and end speed 1000
LI 0,5000 < 4000 >1000 Specify third linear segment with a vector speed of 4000
and end speed 1000
EN Program end
Changing Feedrate:
The command VR n allows the feedrate, VS, to be scaled between 0 and 10 with a resolution of .0001.
This command takes effect immediately and causes VS to be scaled. VR also applies when the vector
speed is specified with the ‘<’ operator. This is a useful feature for feedrate override. VR does not ratio
the accelerations. For example, VR .5 results in the specification VS 2000 to be divided in half.
245
LEGEND-MC User’s Manual
Command Description
LI x,y < n Specify incremental distances relative to current position, and assign vector
speed n.
CS Clear sequence
To illustrate the ability to interrogate the motion status, consider the first motion segment of our example,
#LMOVE, where the X axis moves toward the point X=5000. Suppose that when X=3000, the controller
is interrogated using the command ‘MG _AV’. The returned value will be 3000. The value of _CS,
_VPX and _VPY will be zero.
Now suppose that the interrogation is repeated at the second segment when Y=2000. The value of _AV at
this point is 7000, _CS equals 1, _VPX=5000 and _VPY=0.
Note that the above program specifies the vector speed, VS, and not the actual axis speeds VX and VY.
The axis speeds are determined by the LEGEND-MC.
246
LEGEND-MC User’s Manual
30000
27000
POSITION Y
3000
FEEDRATE
VELOCITY
X-AXIS
TIME (sec)
VELOCITY
Y-AXIS
TIME (sec)
Linear Interpolation
247
LEGEND-MC User’s Manual
Note: This ‘internal’ definition of zero does not affect the absolute coordinate system or subsequent coordi-
nated motion sequences.
The command, VP x,y specifies the coordinates of the end points of the vector movement with respect to
the starting point.
Up to 511 VP segments may be specified in a single sequence and must be ended with the command VE.
The motion can be initiated with a Begin Sequence (BGS) command. Once motion starts, additional seg-
ments may be added.
The Clear Sequence (CS) command can be used to remove previous VP commands which were stored in
the buffer prior to the start of the motion. To stop the motion, use the instructions STS or AB1. ST stops
motion at the specified deceleration. AB1 aborts the motion instantaneously.
The Vector End (VE) command must be used to specify the end of the coordinated motion. This com-
mand tells the controller to decelerate to a stop following the last motion in the sequence. If a VE com-
mand is not given, an Abort (AB1) must be used to abort the coordinated motion sequence.
The user must keep enough motion segments in the LEGEND-MC sequence buffer to ensure continuous
motion. If the controller receives no additional motion segments and no VE command, the controller will
stop motion instantly at the last vector. There will be no controlled deceleration. LM? or _LM returns the
available spaces for motion segments that can be sent to the buffer. 511 returned means the buffer is
empty and 511 segments can be sent. A zero means the buffer is full and no additional segments can be
sent. As long as the buffer is not full, additional segments can be sent at the PCI bus speed.
The operand _CS can be used to determine the value of the segment counter.
Additional Commands
The commands VS n, VA n and VD n are used for specifying the vector speed, acceleration, and decelera-
tion.
VT is the motion smoothing constant used for coordinated motion.
248
LEGEND-MC User’s Manual
Changing Feedrate:
The command VR n allows the feedrate, VS, to be scaled from 0 and 10 times with a resolution of .0001.
This command takes effect immediately and causes VS scaled. VR also applies when the vector speed is
specified with the ‘<’ operator. This is a useful feature for feedrate override. VR does not ratio the accel-
erations. For example, VR .5 results in the specification VS 2000 act as VS 1000.
Trippoints:
The AV n command is the After Vector trippoint, which waits for the vector relative distance of n to occur
before executing the next command in a program.
Command Description
VM m,n Specifies the axes for planar motion where m and n represent the planar axes
and p is the tangent axis.
CS Clear sequence.
LM? Return number of available spaces for linear and circular segments in
LEGEND-MC sequence buffer. Zero means buffer is full. 512 means
buffer is empty.
249
LEGEND-MC User’s Manual
Operand Description
_VPM The absolute coordinate of the axes at the last intersection along the sequence.
_LM Number of available spaces for linear and circular segments in the LEGEND-
MC sequence buffer. Zero means buffer is full. 512 means buffer is empty.
_CS Segment counter - Number of the segment in the sequence, starting at zero.
When AV is used as an operand, _AV returns the distance traveled along the sequence.
The operands _VPX and _VPY can be used to return the coordinates of the last point specified along the
path.
250
LEGEND-MC User’s Manual
Electronic Gearing
With the LEGEND-MC, the master is always the auxiliary encoder. The master may rotate in both direc-
tions and the geared axis will follow at the specified gear ratio.
The GA command is unnecessary for the LEGEND-MC, as the auxiliary encoder is automatically used.
GR x,y specifies the gear ratios for the slaves where the ratio may be a number between +/-127.9999 with
a fractional resolution of .0001. GR 0,0 turns off gearing in both modes. A limit switch or ST command
disables gearing.
GR causes the specified axes to be geared to the actual position of the master.
Electronic gearing allows the geared motor to perform a second independent or coordinated move in
addition to the gearing. For example, when a geared motor follows a master at a ratio of 1:1, it may be
advanced an additional distance with PR, JG, VP, or LI commands.
Command Description
GA n Specifies master axes for gearing where n=DX for auxiliary encoder.
251
LEGEND-MC User’s Manual
Electronic Cam
The electronic cam is a motion control mode which enables the periodic synchronization of the servo
moter with an extenal device. The LEGEND-MC uses the auxiliary encoder as the master axis.
The electronic cam is a more detailed type of electronic gearing which allows a table-based relationship
between the axes. To illustrate the procedure of setting the cam mode, consider the cam relationship for
the slave axis X. Such a graphic relationship is shown in the following illustration - Electronic Cam Exam-
ple.
Step 2. Specify the master cycle and the change in the slave axis.
In the electronic cam mode, the position of the master is always expressed within one cycle. In this exam-
ple, the position of x is always expressed in the range between 0 and 6000. Similarly, the slave position is
also redefined such that it starts at zero and ends at 1500. At the end of a cycle when the master is 6000
and the slave is 1500, the positions of both x and y are redefined as zero. To specify the master cycle and
the slave cycle change, we use the instruction EM and MM.
EM x; MMx
where EMx specifies the cycle of the slave over one cycle and MMx specifies the cycle of the master.
The cycle of the master is limited to 8,388,607 whereas the slave change per cycle is limited to
2,147,483,647. If the change is a negative number, the absolute value is specified. For the given example,
the cycle of the master is 6000 counts and the change in the slave is 1500. Therefore, we use the instruc-
tions:
EM 1500; MM 6000
Step 3. Specify the master interval and starting point.
Next we need to construct the ECAM table. The table is specified at uniform intervals of master positions.
Up to 256 intervals are allowed. The size of the master interval and the starting point are specified by the
instruction:
EP m,n
where m is the interval width in counts, and n is the starting point.
For the given example, we can specify the table by specifying the position at the master points of 0, 2000,
4000 and 6000. We can specify that by
EP 2000,0
252
LEGEND-MC User’s Manual
The value, n, starts at zero and may go up to 256. The parameter x indicates the corresponding slave
position. For this example, the table may be specified by
ET[0]=0
ET[1]=3000
ET[2]=2250
ET[3]=1500
This specifies the ECAM table.
EB n
where n=1 enables ECAM mode and n=0 disables ECAM mode.
EQ x
where x is the master positions at which the corresponding slave axes are disengaged.
3000
2250
1500
253
LEGEND-MC User’s Manual
This disengages the slave axis at a specified master position. If the parameter is outside the master cycle,
the stopping is instantaneous.
To illustrate the complete process, consider the cam relationship described by
the equation:
The cam table can be constructed manually, point by point, or automatically by a program. The following
program includes the set-up.
The instruction EAX defines X as the master axis. The cycle of the master is
2000. Over that cycle, X varies by 1000. This leads to the instruction EM 2000,1000.
Suppose we want to define a table with 100 segments. This implies increments of 20 counts each. If the
master points are to start at zero, the required instruction is EP 20,0.
The following routine computes the table points. As the phase equals 0.18X and X varies in increments of
20, the phase varies by increments of 3.6°. The program then computes the values of SLAVE according to
the equation and assigns the values to the table with the instruction ET[N] = SLAVE.
Instruction Interpretation
#SETUP Label
N=0 Index
N = N+1
EN
Now suppose that the slave axis is engaged with a start signal, input 1, but that both the engagement and
disengagement points must be done at the center of the cycle: X = 1000 and Y = 500. This implies that Y
must be driven to that point to avoid a jump.
254
LEGEND-MC User’s Manual
Instruction Interpretation
#RUN Label
SP,5000 Y speed
AM After Y moved
EN End
255
LEGEND-MC User’s Manual
Contour Mode
The LEGEND-MC also provides a contouring mode. This mode allows any arbitrary position curve to be
prescribed for any motion axes. This is ideal for following computer generated paths such as parabolic,
spherical or user-defined profiles. The path is not limited to straight line and arc segments and the path
length may be infinite.
When the controller receives the command to generate a trajectory along these points, it interpolates lin-
early between the points. The resulting interpolated points include the position 12 at 1 msec, position 24
at 2 msec, etc.
The programmed commands to specify the above example are:
Instruction Description
#A Label
EN
256
LEGEND-MC User’s Manual
POSITION
(COUNTS)
336
288
240
192
96
48 TIME (ms)
0 4 8 12 16 20 24 28
SEGMENT 1 SEGMENT 2 SEGMENT 3
Additional Commands
The command, WC, is used as a trippoint "When Complete" or “Wait for Contour Data”. This allows the
LEGEND-MC to use the next increment only when it is finished with the previous one. Zero parameters
for DT followed by zero parameters for CD exit the contour mode.
If no new data record is found and the controller is still in the contour mode, the controller waits for new
data. No new motion commands are generated while waiting. If bad data is received, the controller
responds with a ?.
Command Description
CM X Specifies the X-axis for contouring mode. In a distributed control system, any
non-contouring axes may be operated in other modes.
WC Waits for previous time interval to be complete before next data record is
processed.
257
LEGEND-MC User’s Manual
Motion Smoothing
The LEGEND-MC controller allows the smoothing of the velocity profile to reduce mechanical vibrations
in the system.
Trapezoidal velocity profiles have acceleration rates which change abruptly from zero to maximum value.
The discontinuous acceleration results in jerk which causes vibration. The smoothing of the acceleration
profile leads to a continuous acceleration profile and reduces the mechanical shock and vibration.
Command Description
The command IT is used for smoothing independent moves of the type JG, PR, PA and the command VT
is used to smooth vector moves of the type VM and LM.
The smoothing parameters x,y and n are numbers between 0 and 1 and determine the degree of filtering.
The maximum value of 1 implies no filtering, resulting in trapezoidal velocity profiles. Smaller values of
the smoothing parameters imply heavier filtering and smoother moves.
Note that the smoothing process results in longer motion time.
258
LEGEND-MC User’s Manual
Homing
The Find Edge (FE) and Home (HM) instructions are used to home the motor to a mechanical reference.
This reference is connected to the Home input line. The HM command initializes the motor to the
encoder index pulse in addition to the Home input. The configure command (CN) defines polarity of the
home input.
The Find Edge (FE) instruction is useful for initializing the motor to a home switch. The home switch is
connected to the Home input. When the Find Edge command and Begin are used, the motor will acceler-
ate up to the slew speed and slew until a transition is detected on the homing line. The motor will then
decelerate to a stop. A high deceleration value must be input before the find edge command is issued for
the motor to decelerate rapidly after sensing the home switch. The velocity profile generated is shown in
the following illustration - Motion intervals in the Home sequence.
The Home (HM) command can be used to position the motor on the index pulse after the home switch is
detected. This allows for finer positioning on initialization. The command sequence HM and BG causes
the following sequence of events to occur.
1. Upon beginning, the motor accelerates to the slew speed. The direction of its motion is deter-
mined by the homing input. A zero (GND) will cause the motor to start in the forward direction;
+5V will cause it to start in the reverse direction. The CN command defines the polarity of the
home input.
2. Upon detecting a change in state on the home input, the motor begins decelerating to a stop.
3. The motor then traverses very slowly back until the home switch toggles again.
4. The motor then traverses forward until the encoder index pulse is detected.
5. The LEGEND-MC defines the home position as the position at which the index was detected
and sets the encoder reading at this position to zero.
MOTION BEGINS
TOWARD HOME
DIRECTION
POSITION
MOTION REVERSE
TOWARD HOME
DIRECTION
POSITION
POSITION
INDEX PULSES
POSITION
HOME SWITCH
POSITION
259
LEGEND-MC User’s Manual
Note: To insure a position capture within 25 microseconds, the input signal must be a transition from high to
low.
The LEGEND-MC software commands AL and RL are used to arm the latch and report the latched posi-
tion. The steps to use the latch are as follows:
1. Give the AL X command to arm the latch for the main (LEGEND) encoder.
2. Test to see if the latch has occurred by using the _ALX command. Example, V1=_ALX returns
the state of the X latch to the variable V1. V1 is 1 if the latch has not occurred.
3. After the latch has occurred, read the captured position with the RLX command or _RLX.
To capture the position of the auxiliary encoder, use the command ALSX. The input must be wired to gen-
eral input 2. _RLSX holds the captured position.
260
LEGEND-MC User’s Manual
7 Application Programming
Introduction
The LEGEND-MC programming language is a powerful language that allows users to customize a pro-
gram to handle their application. Complex programs can be downloaded into the LEGEND-MC memory
for later execution. Utilizing the LEGEND-MC to execute sophisticated programs frees the host com-
puter for other tasks. The host computer can still send commands to the controller any time, even while a
program is being executed.
In addition to standard motion commands, the LEGEND-MC provides commands that allow the LEG-
END-MC to make its own decisions. These commands include conditional jumps, event triggers, and
subroutines. For example, the command JP#LOOP, N<10 causes a jump to the label #LOOP if the vari-
able N is less than 10.
For flexibility, the LEGEND-MC provides 254 user-defined variables, arrays and arithmetic functions,
i.e.; length in a cut-to-length operation can be specified as a variable in a program and assigned by an
operator.
The following sections in this chapter discuss all aspects of creating applications programs.
Program Format
A LEGEND-MC program consists of several LEGEND-MC instructions combined to solve a machine
control application. Action instructions, such as starting and stopping motion, are combined with Pro-
gram Flow instructions to form the complete program. Program Flow instructions evaluate real-time
conditions, such as elapsed time or motion complete, and alter program flow accordingly.
A delimiter must separate each LEGEND-MC instruction in a program. Valid delimiters are the semico-
lon (;) or carriage return. The semicolon is used to separate multiple instructions on a single program
line. A carriage return enters the final command on a program line.
All LEGEND-MC programs must begin with a label and end with an End (EN) statement. Labels start
with the pound (#) sign followed by a maximum of seven characters. The first character must be a letter;
after that, numbers are permitted. Spaces are not permitted.
#BEGIN
#SQUARE
#X1
#BEGIN1
Invalid labels
#1Square
#123
261
LEGEND-MC User’s Manual
Special Labels
There are also some special labels, which are used to define input interrupt subroutines, limit switch sub-
routines, error handling subroutines, and command error subroutines. Special labels provide the applica-
tion program a method of handling situations that would otherwise be difficult to program.
Example Program:
SH Turn motors on
EN End of Program
The above program will execute automatically at power up and move X and Y 10000 and 20000 units.
After the motion is complete, the motors rest for 2 seconds. The cycle repeats indefinitely until the stop
command is issued. Automatic execution assumes that the program has been burned in using the BP com-
mand.
262
LEGEND-MC User’s Manual
1. Only the main thread may use the input command, IN.
2. In a case of interrupts, due to inputs, limit switches, position errors or command errors, it is thread 0
which jumps to those subroutines.
The execution of the various programs is done with the instruction:
XQ #A, n
Where n indicates the thread number. To halt the execution of any thread, use the instruction
HX n
where n is the thread number.
Note that both the XQ and HX functions can be performed by an executing program.
Multitasking is useful for executing independent operations such as PLC functions that occur indepen-
dently of motion. The example below produces a waveform on Output 1 independent of a move.
The program above is executed with the instruction XQ #TASK2,0 which designates TASK2 as the main
thread. #TASK1 is executed within TASK2.
263
LEGEND-MC User’s Manual
Debugging Programs
The LEGEND-MC provides trace and error code commands which are used for debugging programs. The
trace command may be activated using the command, TR1. This command causes each line in a program
to be sent out to the communications port immediately prior to execution. The TR1 command is useful for
debugging programs. TR0 disables the trace function. The TR command may also be included as part of a
program.
If there is a program error, the LEGEND-MC will halt program execution at the line number at which an
error occurs and display the line. The user can obtain information about the type of error condition that
occurred by using the command, TC1. This command reports back a number and error condition as fol-
lows:
Error Codes:
1 Unrecognized command
2 Command only valid from program
3 Command not valid in program
4 Operand error
5 Input buffer full
6 Number out of range
7 Command not valid while running
8 Command not valid while not running
9 Variable error
10 Empty program line or undefined label
11 Invalid label or line number
12 Subroutine more than 16 deep
13 JG only valid when running in jog mode
14 EEPROM check sum error
15 EEPROM write error
16 IP incorrect sign during position move or IP given during forced deceleration
17 ED, BN and DL not valid while program running
18 Command not valid when contouring
19 Application program/strand already executed
20 Begin not valid with motor off
21 Begin not valid while running
22 Begin not possible due to Limit Switch
24 Begin not valid because no sequence defined
25 Variable not given in IN command
28 S operand not valid
29 Not valid during coordinated move
30 Sequence segment too short
31 Total move distance in a sequence > 2 billion
41 Contouring record range error
42 Contour data being sent too slowly
46 Gear axis both master and follower
264
LEGEND-MC User’s Manual
265
LEGEND-MC User’s Manual
JP Conditional Jump
JS Conditional Jump to Subroutine
MC Trigger "In position" trigger (TW x,y,z,w sets timeout for in-position)
MF Trigger Forward motion
266
LEGEND-MC User’s Manual
Command Function
267
LEGEND-MC User’s Manual
#TWOMOVE Label
EN End program
In the above example, the AM trippoint is used to separate the two PR moves. If AM is not used, the con-
troller returns a ? for the second PR command because a new PR cannot be given until motion is complete.
268
LEGEND-MC User’s Manual
#SETBIT Label
EN End program
The above example sets output bit 1 after a distance of 1000 counts from the start of the move. The accu-
racy of the trippoint is the speed multiplied by the sample period.
#TRIP Label
STX Stop
EN End
269
LEGEND-MC User’s Manual
EN End program
#VECTOR Label
VMXY;VS 5000 Coordinated path
VE End vector
270
LEGEND-MC User’s Manual
#MOVES Label
PR 12000 Distance
SP 20000 Speed
AC 100000 Acceleration
EN End
#LOOP Loop
JP #LOOP Loop
EN
271
LEGEND-MC User’s Manual
Conditional Jumps
The LEGEND-MC provides Conditional Jump (JP) and Conditional Jump to Subroutine (JS) instructions
for branching to a new program location based on a specified condition. Unlike event triggers, the condi-
tional jump instruction does not halt the program sequence. Instead, it tests to see if a condition is satis-
fied and then branches to a new location or subroutine. (A subroutine is a group of commands defined by
a label and EN command. After all the commands in the subroutine are executed, a return is made to the
main program). If the condition is not satisfied, the program sequence continues to the next program line.
The JP and JS instructions have the following format:
Format: Meaning
JS destination, logical condition Jump to subroutine if logical condition is satisfied
The destination is a program line number or label. The destination is where the program sequencer jumps
to if the specified condition is satisfied. The comma designates "IF". The logical condition tests two oper-
ands with logical operators. The operands can be any valid LEGEND-MC numeric operand, including
variables, array elements, numeric values, functions, keywords, and arithmetic expressions.
Logical operators:
Operands:
Type Examples
Number V1=6
Numeric Expression V1=V7*6
@ABS[V1]>10
I/O V1>@AN[2]
@IN[1]=0
272
LEGEND-MC User’s Manual
Conditional Meaning
JP#A Jump to #A
Conditional jumps are useful for testing events in real-time. They allow the LEGEND-MC to make deci-
sions without a host computer. For example, the LEGEND-MC can decide between two motion profiles
based on the state of an input line. Or, the LEGEND-MC can keep track of how many times a motion
profile is executed.
Example:
Move the X motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec between
moves.
EN End Program
273
LEGEND-MC User’s Manual
NOTE: Each condition must be placed in parentheses for proper evaluation by the controller. In addition,
the LEGEND-MC executes operations from left to right.
Examples
If the condition for the JP command is satisfied, the controller branches to the specified label or line num-
ber and continues executing commands from this point. If the condition is not satisfied, the controller
continues to execute the next commands in sequence.
Format Meaning
JP #Loop, COUNT<10 Jump to #Loop if the variable, COUNT, is
less than 10
JS #MOVE2,@IN[1]=1 Jump to subroutine #MOVE2 if input 1 is
logic level high. After thesubroutine
MOVE2 is executed, the program sequencer
returns to the main program location where
the subroutine was called.
JP #BLUE,@ABS[V2]>2 Jump to #BLUE if the absolute value of vari-
able, V2, is greater than 2
JP#A Jump to #A
274
LEGEND-MC User’s Manual
Example:
Move the A motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec between
moves.
PA 0 Position absolute 0
EN End Program
275
LEGEND-MC User’s Manual
276
LEGEND-MC User’s Manual
Format: Meaning
Example:
277
LEGEND-MC User’s Manual
Subroutines
A subroutine is a group of instructions beginning with a label and ending with an END (EN). Subroutines
are called from the main program with the jump subroutine instruction JS, followed by a label or line num-
ber, and conditional statement. Up to 16 subroutines can be nested. After the subroutine is executed, the
program sequencer returns to the program location where the subroutine was called unless the subroutine
stack is manipulated as described in the following section.
Example:
An example of a subroutine to draw a square 500 counts per side is given below. The square is drawn at
vector position 1000,1000.
EN End subroutine
EN End subroutine
Stack Manipulation
It is possible to manipulate the subroutine stack by using the ZS command. Every time a JS instruction,
interrupt or automatic routine (such as #POSERR or #LIMSWI) is executed, the subroutine stack is incre-
mented by 1. Normally the stack is restored with an EN instruction. Occasionally it is desirable not to
return back to the program line where the subroutine or interrupt was called. The ZS1 command clears 1
level of the stack. This allows the program sequencer to continue to the next line. The ZS0 command
resets the stack to its initial value. For example, if a limit occurs and the #LIMSWI routine is executed, it
is often desirable to restart the program sequence instead of returning to the location where the limit
occurred. To do this, give a ZS command at the end of the #LIMSWI routine.
278
LEGEND-MC User’s Manual
For example, the #POSERR subroutine will automatically be executed when any axis exceeds its position
error limit. The commands in the #POSERR subroutine could decode which axis is in error and take the
appropriate action. In another example, the #ININT label could be used to designate an input interrupt
subroutine. When the specified input occurs, the program will be executed automatically.
Now, when a forward limit switch occurs on the X axis, the #LIMSWI subroutine will be executed.
Note: The #LIMSWI will continue to be executed until the limit switch is cleared (goes high).
279
LEGEND-MC User’s Manual
JP #LOOP;EN Loop
If the position error on the X axis exceeds that specified by the ER command, the #POSERR routine will
execute.
Note: The #POSERR routine will continue to be executed until the position error is cleared (is less than the
ER limit).
#A Label
JG 30000,,,60000 Jog
#LOOP;JP#LOOP;EN Loop
EN
280
LEGEND-MC User’s Manual
JP #BEGIN Repeat
EN End program
The above program prompts the operator to enter a jog speed. If a number is entered out of range (greater
than 8 million), the #CMDERR routine will be executed prompting the operator to enter a new number.
281
LEGEND-MC User’s Manual
Operator Function
+ Addition
- Subtraction
* Multiplication
/ Division
| Logical Or (On some computers, a solid vertical line appears as a broken line)
( ) Parenthesis
The numeric range for addition, subtraction and multiplication operations is +/-2,147,483,647.9999. The
precision for division is 1/65,000.
Mathematical operations are executed from left to right. Parentheses can be used and nested four deep.
Calculations within a parentheses have precedence.
Examples:
282
LEGEND-MC User’s Manual
@COS[n] Cosine
@FRAC[n] Fraction
@INT[n] Integer
@SIN[n] Sine
@TAN[n] Tangent
Functions may be combined with mathematical expressions. The order of execution is from left to right.
The units of the SIN and COS functions are in degrees with resolution of 1/128 degrees. The values can
be up to +/-2 billion degrees.
Example:
V1=@ABS[V7] The variable, V1, is equal to the absolute value of variable V7.
V2=5*@SIN[POS] The variable, V2, is equal to five times the sine of the variable,
POS.
V4=@AN[5] The variable, V4, is equal to the digital value of analog input 5.
283
LEGEND-MC User’s Manual
Variables
Many motion applications include parameters that are variable. For example, a cut-to-length application
often requires that the cut length be variable. The motion process is the same, however the length is
changing.
To accommodate these applications, the LEGEND-MC provides for the use of both numeric and string
variables. A program can be written in which certain parameters, such as position or speed, are defined as
variables. The variables can later be assigned by the operator or determined by the program calculations.
Example:
Programmable Variables
The LEGEND-MC allows the user to create up to 254 variables. Each variable is defined by a name
which can be up to eight characters. The name must start with an alphabetic character, however, numbers
are permitted in the rest of the name. Spaces are not permitted. Examples of valid and invalid variable
names are:
Valid Variable Names
POSX
POS1
SPEEDZ
Invalid Variable Names
1POS
123
SPEED Z
It is recommended that variable names not be the same as LEGEND-MC instructions. For example, PR is
not a good choice for a variable name.
The range for numeric variable values is 4 bytes of integer followed by two bytes of fraction (+/-
2,147,483,647.9999).
String variables can contain up to six characters which must be in quotation. Example: VAR="STRING".
Numeric values can be assigned to programmable variables using the equal sign. Assigned values can be
numbers, internal variables and keywords, and functions. String values can be assigned to variables using
quotations.
Any valid LEGEND-MC function can be used to return a value such as V1=@ABS[V2] or V2=@IN[1].
Arithmetic operations are also permitted.
284
LEGEND-MC User’s Manual
Example:
Variable values may be assigned to controller parameters such as GN or PR. Here, an equal is not used.
For example:
PR V1 Assign V1 to PR command
SP VS*2000 Assign VS*2000 to SP command
#JOYSTICK Label
#LOOP Loop
JP#LOOP Repeat
EN End
285
LEGEND-MC User’s Manual
Examples:
Internal variables can be used in an expression and assigned to a programmable variable, but they cannot
be assigned a value. For example: _KDX=2 is invalid.
The LEGEND-MC also provides a few keywords which give access to internal variables that are not
accessible by standard LEGEND-MC commands.
Keyword Function
_BGX or _BGY or _BGW Motion Done if 1. Moving if 0.
_LFX or _LFY or _LFZ or_LFW Forward Limit (equals 0 or 1)
Examples:
V1=_LFX Assign V1 the logical state of the Forward Limit Switch on the X-axis
286
LEGEND-MC User’s Manual
Example Program:
#TIMER Timer
#END Exit
287
LEGEND-MC User’s Manual
Arrays
For storing and collecting numerical data, the LEGEND-MC provides array space for 8000 elements in up
to 14 arrays. Arrays can be used to capture real-time data, such as position, torque and analog input val-
ues. In the contouring mode, arrays are convenient for learning a position trajectory and later playing it
back.
Defining Arrays
An array is defined by a name and number of entries using the DM command. The name can contain up to
eight characters, starting with an uppercase alphabetic character.
The number of entries in the defined array is enclosed in [ ].
Up to 14 different arrays may be defined. The arrays are one dimensional.
Example:
Each array element has a numeric range of 4 bytes of integer (231)followed by two bytes of fraction (+/-
2,147,483,647.9999).
Array space may be de-allocated using the DA command followed by the array name. DA*[0] de-allo-
cates all the arrays.
NOTE: Remember to define arrays using the DM command before assigning entry values.
Example:
SPEED[1]=7650.2 Assigns the first element of the array, SPEED the value
7650.2
POSX[10]=_TPX Assigns the 10th element of the array POSX the returned
value from the tell position command.
CON[2]=@COS[POS]*2 Assigns the second element of the array CON the cosine of
the variable POS multiplied by 2.
TIMER[1]=TIME Assigns the first element of the array timer the returned
value of the TIME keyword.
288
LEGEND-MC User’s Manual
An array element number can also be a variable. This allows array entries to be assigned sequentially
using a counter.
Example:
#A Begin Program
WT 10 Wait 10 msec
EN End Program
The above example records 10 position values at a rate of one value per 10 msec. The values are stored
in an array named POS. The variable, COUNT, is used to increment the array element counter. The
above example can also be executed with the automatic data capture feature described as follows.
Arrays may be uploaded and downloaded using the QU and QD commands.
QU array[ ],start,end,comma
QD array[ ],start,end
where array is an array name such as A[ ].
Start is the first element of array (default=0)
End is the last element of array (default=last element)
Comma -- if comma is a 1, then the array elements are separated by a comma. If not a 1, then the ele-
ments are separated by a carriage return.
The file is terminated using <control>Z, <control>Q, <control>D or \.
289
LEGEND-MC User’s Manual
RA n[ ],m[ ],o[ ],p[ ] Selects up to four arrays for data capture. The arrays must be
defined with the DM command.
RD_TI,_TPX,_SCZ,_TSY Selects the type of data to be recorded. See the table below
for the various types of data. The order of data type is
important and corresponds with the order of n,m,o,p arrays in
the RA command. In this example, the _TI input data is
stored in the first array selected by the RA command.
_TI Inputs
_OP Output
Note: X may be replaced by Y,Z or W for capturing data on other axes, or A,B,C,D,E,F,G,H for LEGEND-
MC.
290
LEGEND-MC User’s Manual
N= Print Counter
X POS[N]= Print X position
#DONE Done
291
LEGEND-MC User’s Manual
NOTES:
292
LEGEND-MC User’s Manual
Sending Messages
Messages may be sent to the bus using the message command, MG. This command sends specified text
and numerical or string data from variables or arrays to the screen.
Text strings are specified in quotes and variable or array data is designated by the name of the variable or
array. For formatting string variables, the {Sn} specifier is required where n is the number of characters,
1 through 6. Example:
MG STR {S3}
The above statement returns 3 characters of the string variable named STR.
Numeric data may be formatted using the {Fn.m} expression following the completed MG statement.
{$n.m} formats data in HEX instead of decimal. Example:
Example:
#A Label
MG "counts/sec" Message
EN End Program
When #A is executed, the above example will appear on the screen as:
293
LEGEND-MC User’s Manual
Example:
MG {^07} {^255}
sends the ASCII characters represented by 7 and 255 to the bus.
MG Message command
Variables may also be sent to the screen using the variable= format. Variable Name= returns the variable
value. For example, V1= , returns the value of the variable V1.
#DISPLAY Label
BGX Begin
V1= Print V1
294
LEGEND-MC User’s Manual
Input of Data
The IN command is used to prompt the user to input numeric or string data. The input data is assigned to
the specified variable or array element.
A message prompt may be sent to the user by specifying the message characters in quotes.
Example:
#A
IN "Enter Length", LENX
EN
This program sends the message:
Enter Length
to the PC screen and waits for the operator to enter a value. The operator enters the numeric value which
is assigned to the variable, LENX. String variables with up to six characters may also be input using the
{S} specifier. For example, IN "Enter X,Y or Z", V{S} specifies a string variable to be input.
Formatting Data
Returned numeric values may be formatted in decimal or hexadecimal* with a specified number of digits
to the right and left of the decimal point using the PF command.
The Position Format (PF) command formats motion values such as those returned by the Tell Position
(TP), Speed? (SP?) and Tell Error (TE) commands.
Position Format is specified by:
PF m.n
where m is the number of digits to the left of the decimal point (0 through 10) and n is the number of dig-
its to the right of the decimal point (0 through 4) A negative sign for m specifies hexadecimal format.
Hex values are returned preceded by a $ and in 2's complement. Hex values should be input as signed 2's
complement, where negative numbers have a negative sign. The default format is PF 10.0.
Examples:
295
LEGEND-MC User’s Manual
DP
ER
PA
PR
TE
TP
If the number of decimal places specified by PF is less than the actual value, a nine appears in all the dec-
imal places.
Example:
The Variable Format (VF) command is used to format variables and array elements. The VF command is
specified by:
VF m.n
where m is the number of digits to the left of the decimal point (0 through 10) and n is the number of digits
to the right of the decimal point (0 through 4).
A negative sign for m specifies hexadecimal format. The default format for VF is VF 10.4
Hex values are returned preceded by a $ and in 2's complement.
:V1=10 Assign V1
:V1= Return V1
:V1= Return V1
:V1= Return V1
:V1= Return V1
9 Overflow
296
LEGEND-MC User’s Manual
The variable format also affects returned values from internal variables such as _GNX.
PF and VF commands are global format commands. Parameters may also be formatted locally by using
the {Fn.m} or {$n.m} specification following the variable = . For example:
F specifies decimal and $ specifies hexadecimal. n is the number of digits to the left of the decimal, and
m is the number of digits to the right of the decimal. The local format is used with the MG* command.
Examples:
:V1=10 Assign V1
:V1= Return V1
ALPH
User Units
Variables and arithmetic operations make it easy to input data in desired user units i.e.; inches or RPM.
For example, an operator can be prompted to input a number in revolutions. The input number is con-
verted into counts by multiplying it by the number of counts/revolution.
The LEGEND-MC position parameters such as PR, PA and VP have units of quadrature counts. Speed
parameters such as SP, JG and VS have units of counts/sec. Acceleration parameters such as AC, DC,
VA and VD have units of counts/sec2. All input parameters must be converted into these units.
Example:
#RUN Label
BG Begin motion
EN End program
297
LEGEND-MC User’s Manual
NOTES:
298
LEGEND-MC User’s Manual
9 Programmable I/O
Digital Outputs
Each bit on the output port may be set and cleared with the software instructions SB (Set Bit) and
CB(Clear Bit), or OB (define output bit).
Example:
Instruction Function
SB3 Sets bit 3 of output port
The Output Bit (OB) instruction is useful for setting or clearing outputs depending on the value of a vari-
able, array, input or expression. Any non-zero value results in a set bit.
Instruction Function
OB1, POS Set Output 1 if the variable POS is non-zero. Clear Output 1 if
POS equals 0.
OB 2, @IN [1] Set Output 2 if Input 1 is high. If Input 1 is low, clear Output 2.
OB 3, @IN [1]&@IN [2] Set Output 3 only if Input 1 and Input 2 are high.
The output port may also be written to as an 8-bit word using the instruction
OP (Output Port). This instruction allows a single command to define the state of the entire 8-bit output
port, where 20 is output 1, 21 is output 2 and so on. A 1 designates that output is on.
Example:
Instruction Function
OP6 Sets outputs 2 and 3 of output port to high. All other bits are 0.
(21 + 22 = 6)
The output port is useful for firing relays or controlling external switches and events during a motion
sequence.
299
LEGEND-MC User’s Manual
#OUTPUT Label
BG Begin
AM After move
EN End
Digital Inputs
The LEGEND-MC has eight digital inputs for controlling motion by local switches. The @IN[n] function
returns the logic level of the specified input 1 through 8. For example, a Jump on Condition instruction
can be used to execute a sequence if a high condition is noted on an input 3. To halt program execution,
the After Input (AI) instruction waits until the specified input has occurred.
Example:
Important: Use the RI instruction (not EN) to return from the #ININT subroutine.
Analog Inputs
The LEGEND-MC provides two analog inputs. The value of these inputs in volts may be read using the
@AN[n] function where n is the analog input 1 or 2. The resolution of the Analog-to-Digital conversion is
14 bits. Analog inputs are useful for reading special sensors such as temperature, tension or pressure.
The examples in Section 10, Example Applications, show programs which cause the motor to follow an
analog signal. The first example is a point-to-point move. The second shows a continuous move.
300
LEGEND-MC User’s Manual
10 Example Applications
301
LEGEND-MC User’s Manual
Instruction Interpretation
#A Label
BG X Begin X motion
BG Z Begin Z motion
EN
Instruction Interpretation
#HOME Label
AC 1000000 Acceleration Rate
HM X Home X
BG X Begin Motion
AM X After Complete
#EDGE Label
AC 2000000 Acceleration rate
SP 8000 Speed
FE Y Find edge command
BG Y Begin motion
AM Y After complete
EN End
302
LEGEND-MC User’s Manual
MOTION BEGINS
TOWARD HOME
DIRECTION
POSITION
MOTION REVERSE
TOWARD HOME
DIRECTION
POSITION
POSITION
INDEX PULSES
POSITION
HOME SWITCH
POSITION
303
LEGEND-MC User’s Manual
Instruction Interpretation
#TEST
SPX=10000
ACX=1000000
DCX=1000000
CN,1
TRUE=1
FALSE=0
HOMING=FALSE
SHX; WT 2000
#HOMING
MG “Attempting to find
home” {N}
MG “(normal direction)”
FLX
BLX
HOMING=TRUE
JGX=8192;
FEX;BGX;AMX
HOMING=FALSE
JG*=500; FIX; BGX; (MCX because the controller will automatically define the position
MCX as zero when the index is found)
MG “Homed O.K!” EN
#BACKUP
MG “home input..”
304
LEGEND-MC User’s Manual
CN,-1
CN,1
JP #HOMING
EN
#REALPRB
MG “Limit Hit”
RE1
AB1; ZS
MG “Error”{N};TCI{N}
MG”on line”,_ED{F3.0}
MG”Program halted!”
AB
EN
305
LEGEND-MC User’s Manual
Instruction Interpretation
#A Label #A
#B Label #B
TP AB Report A and B axes positions
EN End of program
306
LEGEND-MC User’s Manual
Instruction Interpretation
#POINTS Label
SP 7000 Speed
#LOOP Label
JP #LOOP Repeat
EN End
Instruction Interpretation
#CONT Label
AC 80000;DC 80000 Acceleration rate
EN End
307
LEGEND-MC User’s Manual
BG XY Begin motion
Instruction Interpretation
PR 20000 Position
AC 100000 Acceleration
DC 100000 Deceleration
SP 5000 Speed
BG X Begin
ACCELERATION
VELOCITY
ACCELERATION
VELOCITY
308
LEGEND-MC User’s Manual
Cut-to-Length Example
In this example, a length of material is to be advanced a specified distance. When the motion is com-
plete, a cutting head is activated to cut the material. The length is variable, and the operator is prompted
to input it in inches. Motion starts with a start button which is connected to input 1.
The load is coupled with a 2 pitch lead screw. A 2000 count/rev encoder is on the motor, resulting in a
resolution of 4000 counts/inch. The program below uses the variable LEN, to length. The IN command
is used to prompt the operator to enter the length, and the entered value is assigned to the variable LEN.
#BEGIN Label
AC 800000 Acceleration
DC 800000 Deceleration
SP 5000 Speed
LEN=3.4 Initial length in inches
Instruction Interpretation
#Latch Latch program
JG5000 Jog X
Result=_RLX Set value of variable ‘Result’ equal to the report position of X axis
EN End
309
LEGEND-MC User’s Manual
Now suppose the gear ratio of the X-axis is to change on-the-fly to 2. This can be achieved by command-
ing:
Instruction Interpretation
DM DIF[15]
T=0 T is time in ms
#A
V1=50*T
T=T+8
C=C+1
JP #A,C<16
310
LEGEND-MC User’s Manual
C=0
#C
D=C+1
C=C+1
JP #C,C<15
C=0
#E
C=C+1
JP #E, C<15
DT0
Instruction Interpretation
LM XY Specify axes for linear interpolation
311
LEGEND-MC User’s Manual
Instruction Interpretation
#LOOP LOOP
#A Label
EN End program
312
LEGEND-MC User’s Manual
Instruction Interpretation
#LMOVE Label
In this example, the XY system is required to perform a 90° turn. In order to slow the speed around the
corner, we use the AV 4000 trippoint, which slows the speed to 1000 count/s. Once the motors reach the
corner, the speed is increased back to 4000 cts / s.
313
LEGEND-MC User’s Manual
Note: ω is the angular velocity; X is the position; and T is the variable, time, in milliseconds.
In the given example, A=6000 and B=120, the position and velocity profiles are:
ω = 50 [1 - cos 2π T/120]
The 300 can compute trigonometric functions. However, the argument must be expressed in degrees.
Using our example, the equation for X is written as:
314
LEGEND-MC User’s Manual
Instruction Interpretation
#RECORD Begin Program
DM XPOS[501] Dimension array with 501 elements
#COMPUTE Compute DX
DM DX[500] Dimension Array for DX
D=C+1
#B Loop counter
CD XPOS[I];WC Specify contour data I=I+1 Increment array counter JP #B,I<500 Loop until
done
315
LEGEND-MC User’s Manual
This specifies relative position movement on the X axis. The movement is separated by 40 msec.
The following illustration - Velocity Profiles of XY shows the velocity profiles for the X and Y axis.
Instruction Interpretation
#A Begin Program
PR 2000,100 Specify relative position movement of 2000 and 100 counts for the X
and Y axes.
VELOCITY
(COUNTS/SEC)
15000
Y axis velocity profile
10000
5000
TIME (ms)
0 20 40 60 80 100
Velocity Profiles of XY
Notes on Velocity Profiles of XY illustration: The X axis has a ‘trapezoidal’ velocity profile, while the Y axis has a
‘triangular’ velocity profile. The X axis accelerates to the specified speed, moves at this constant speed, and then
decelerates such that the final position agrees with the commanded position, PR. The Y axis accelerates, but before
the specified speed is achieved, must begin deceleration such that the axis will stop at the commanded position.
316
LEGEND-MC User’s Manual
Instruction Interpretation
EN;
#A Label #A
#B Label #B
JP #B Jump to #B
EN End of program
317
LEGEND-MC User’s Manual
Special Labels
This program demonstrates five of the SPECIAL LABELS as part of a LEGEND-MC application pro-
gram. #AUTO is usually the first line of a program. When this program is burned into the LEGEND-MC
using the BP command, the program will begin executing when the power is turned ON or after the RS
command is given, or the RESET button on the front is pressed.
Instruction
#AUTO
SHX WT 500
#BUSY
JGX=@AN[1]*10000
BGX
MG “BUSY...”
WT500
JP#BUSY
EN
#POSERR-- This special label is used to handle a situation in which a servo is not able to remain in posi-
tion. The special label works with the ER command. When the value of the ER command is exceeded,
thread zero automatically jumps to the #POSERR label. In this program example, ERX=150 counts. If
there are low gains or if using a small motor, it is possible to cause more than 150 counts of error by hand,
causing the #POSERR label to execute. In the following example, the program displays a message and
waits for input #1 to go low (falling edge). The servo is then re-energized.
There are three ways to return from a special label like this. The example below uses RE1; i.e., to return
from the error routine to the line in thread zero that was being executed when the #POSERR occurred.
The “1” means to restore a trip point if one was in progress, such as WT, AI, AM, AT, etc.
The second method is to do an RE, meaning that any trip points that were in progress are cleared. If thread
zero was waiting for an AM command, it would continue as if the profiler had completed the path.
The third method is to use the ZS command, which clears the subroutine stack, and the LEGEND forgets
it is in the middle of an error routine. After the ZS is given, it is possible to do a JP anywhere in the
program. Typically, there would be a jump back to a main loop where manual jogging can take place.
Instruction
#POSERR
SB1
AI1; AI-1
RE1
318
LEGEND-MC User’s Manual
The following is the special label that is automatically executed when there is a programming error, a
command given where it cannot be used, or a number out of range for a command. The example below
includes a jump to the #LIMSWI label if the _TC code is 22, which is “Begin not valid due to limit
switch.” This is considered a command error, but is easier to treat as a limit switch error. Similar condi-
tions could be handled by checking other _TC codes and reacting accordingly. If the error is anything
other than 22, motion is aborted without aborting the program (AB1), then a message is prompted indi-
cating the type of error and the line number on which it occurred. _ED reports the last line that had an
error. The #CMDERR routine can be finished just like the #POSERR special label, but it is not recom-
mended because usually there is very little reason to continue execution of the program if there are seri-
ous errors in it. This routine is very useful in two ways:
First, during program design when there will be many programming mistakes, it is convenient to have the
program display the error and line number automatically.
Second, it is safer to abort motion if there is a program fault. Without the AB1command, the motors will
continue doing whatever they were doing before the fault. For example, if they were jogging, they will
continue jogging.
Instruction
#CMDERR
JP#LIMSWI,_TC=22
AB1
MG “Error”{N};TCI{N}
MG “on line”,_ED{F3.0}
MG “Program halted!”
AB
EN
319
LEGEND-MC User’s Manual
The following is the #LIMSWI special label for handling situations where limit switches ar hit during
motion. This label automatically executes if an axis is in motion and a limit switch in the direction of
motion is hit, or a software limit is exceeded. Without this special label, if a limit switch is hit during
motion, such as a position absolute move, the motor will decelerate to a stop with NO ERROR. if an AM
command is used, it will be cleared. The example as shown does not recover from the limit switch error,
but a recovery method that woks well is the use of a status flag variable. For example if the machine was
in a manual jog operation, a variable could be used to indicate that it was in jog mode (JOGMODE=1).
The first line in the #LIMSWI could jump to #PROBLEM if JOGMODE <>1, otherwise return from the
error. The two commented lines below demonstrate this. (The JOGMODE variable can be set to “1” in the
jog routine and set back to “0” at the end of the jog routine.)
Instruction
Limit= “+”
Limit=“-”
ZS
EN
320
LEGEND-MC User’s Manual
The following is the special label to handle input interrupts. Inputs 1 - 8 can be used as interrupts. this
example uses the input to tell the LEGEND that the system is under an E-STOP condition. This input
may come from a contact that also removes power from the amplifiers. Notice that the interrupt com-
mand II is used at the beginning of the program to designate input #3 as an interrupt. When this input
goes low, thread zero automatically jumps to #ININT if it is included in the program. Notice that if the
example assumes that if an E-STOP occurs, the current operation has been scrapped. The ZS (Zero Sub-
routine Stack) command is used which allows the program to jump anywhere. Usually it is easiest to
jump back to a main loop which handles the different modes of operation of the machine. Also note that
if ZS is used, the interrupt must be enabled for next time.
Instruction Interpretation
#ININT
SB3
MG “ESTOPPED”
MG “RE-ENABLED..”
SHX
WT2000
ZS
EN
321
LEGEND-MC User’s Manual
Wire Cutter
Activate the start switch. The motor will advance the wire a distance of 10". When motion stops, the con-
troller generates an output signal activating the cutter. Allow 100 ms for cutting to complete the cycle.
Suppose the motor drives the wire by a roller with a 2" diameter and the encoder resolution is 1000 lines
per revolution. Since the circumference of the roller equals 2π inches, and it corresponds to 4000 quadra-
ture, one inch of travel equals: 4000/2π = 637 count/inch
A distance of 10 inches equals 6370 counts, and a slew speed of 5 inches / second equals 3185 count/sec.
The input signal may be applied to I1, and the output signal as output 1. Motor velocity profile and related
input and output signals are in the following illustration - Motor Velocity and Associated Input/Output signals.
The program starts at a state that we define as #A. Here the controller waits for the input pulse on I1. As
soon as the pulse is given, the controller starts the forward motion.
Upon completion of the forward move, the controller outputs a pulse for 20 ms and then waits an addi-
tional 80 ms before returning to #A for a new cycle.
Instruction Function
#A Label
AI1 Wait for input 1
PR 6370 Distance
SP 3185 Speed
WT 20 Wait 20 ms
CB1 Clear output bit 1
WT 80 Wait 80 ms
START PULSE I1
MOTOR VELOCITY
OUTPUT PULSE
output
TIME INTERVALS
move wait ready move
322
LEGEND-MC User’s Manual
Instruction Function
#A Label
#B Label
EN End
323
LEGEND-MC User’s Manual
Instruction Function
#A Label
BGX Start
#B
EN End
324
LEGEND-MC User’s Manual
325
LEGEND-MC User’s Manual
Instruction Function
#A Label
LINPOS=0
#B
WT 50 Wait 50 msec
PR ER Command correction
BGX
#C
EN
326
LEGEND-MC User’s Manual
11 Troubleshooting
Overview
The following discussion may help you get your system running if a problem is encountered.
Potential problems have been divided into groups as follows:
1. Installation
2. Communication
3. Stability and Compensation
4. Operation
The various symptoms along with the cause and the remedy are described in the following tables.
Installation
Motor runs away when connected to Amplifier offset Adjust amplifier offset
amplifier with no additional inputs. too large.
Controller does not read changes in encoder Wrong encoder Check encoder wiring.
position. connections.
327
LEGEND-MC User’s Manual
Communication
LEGEND-MC cannot Plug and Play installation Check first that LEGEND-
communicate with the did not proceed properly MC.INF was used to install
controller. the controller. Next check
the controller registry to see
if the controller was
automatically added and an
address selected.
Stability
Motor runs away when Wrong feedback polarity. Invert the polarity of the loop by
the loop is closed. (Positive Feedback) inverting the motor leads (brush
type) or the encoder (channel A+,
B+ if single ended; channel A+,
A- and B+, B- if differential)
Motor oscillates. Too high gain or too little Decrease KI and KP. Increase
damping. KD.
Operation
Motor does not start or Noise on limit switches To check the cause,
complete a move. stops the motor. Noise on interrogate the stop code
the abort line aborts the (SC). If caused by limit
motion. switch or abort line noise,
reduce noise.
328
LEGEND-MC User’s Manual