Array [ ] is the array with the data – Yaskawa LEGEND-MC User Manual

Page 54

Advertising
background image

44

LEGEND-MC User’s Manual

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
handle number.

Modbus protocol has commands called function codes. The LEGEND-MC supports 10 major function
codes:

The LEGEND-MC provides three levels of Modbus communication. The first level allows the user to
create a raw packet and receive raw data. It uses the MBh command with a function code of -1. The
command 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
special 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 16 (P). 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
designate 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.)

Function Code

Definition

01

Read Coil Status (Read Bits)

02

Read Input Status (Read Bits)

03

Read Holding Registers (Read Words)

04

Read Input Registers (Read Words)

05

Force Single Coil (Write One Bit)

06

Preset Single Register (Write One Word)

07

Read Exception Status (Read Error Code)

15

Force Multiple Coils (Write Multiple Bits)

16

Preset Multiple Registers (Write Words)

17

Report Slave ID

Advertising