beautypg.com

Sah=”command string, Accessing the i/o of the slaves, Example – Yaskawa LEGEND-MC User Manual

Page 53: Handling communication errors, Modbus support, Handling communication errors modbus support

background image

43

LEGEND-MC User’s Manual

would be TE. The position operand for the F axis would be _TPF.

Some commands are inherently sent to all controllers. These include commands such as AB (Abort), CN
and TM.

Certain commands need to be launched specifically. For this purpose there is the SA command. In its
simplest form the SA command is:

SAh=”command string”

Here “command string” will be sent to handle h. For example, the SA command is the means for sending
an XQ command to a slave. A more flexible form of the command is:

SAh=field1,field2,field3,field4...field8 Where each field can be a string in quotes or a variable.

When the master sends an SA command to a slave, it is possible for the master to determine the status of
the command. The response _IHh4 will return the number 1 to 4. One means waiting for the
acknowledgement from the slave. Two means a colon (command accepted) has been received. Three
means a question mark (command rejected) has been received. Four means the command timed out.

If a command generates responses (such as the TE command), the values will be stored in _SAh0 through
_SAh7. If a field is unused its _SA value will be -2^31.

Accessing the I/O of the slaves

The I/O of the slaves are settable and readable from the master. The bit numbers are adjusted by the
handle number of the data record. Each handle adds 100 to the bit number. Handle A is 100 and Handle F
is 600.

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.

Handling Communication Errors

If a controller has an application program running and the TCP communication is lost, the #TCPERR
routine will automatically execute. See the Special Label Example program in the Example Applications

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