{}

Our Brands

Impact-Company-Logo-English Black-01-177x54

Welcome to the Schneider Electric Website

Welcome to our website.
Search FAQs
Using the DATA_EXCH block to issue a function code 6 (write single register) from a M340 Ethernet interface.

Goals and Symptoms

To use the DATA_EXCH FB in Unity Pro is issue a modbus function code 6 from a Ethernet interface in a M340 PLC system.

Facts and Changes

A minimum version of Unity Pro v4.0 and a M340 CPU or NOE v2.0 must be used for the DATA_EXCH to work properly.

Causes and Fixes


First open the Project Settings form the tools menu in Unity Pro.



Under the Language Extensions tab check off directly represent array variables, Allow dynamic arrays, and disable array size compatibility check.
Then press OK.



Next open the variable editor and create e variables for the DATA_EXCH block



In this example a value of 16#1234 will be written to %MW1876 of slave device connected via MB TCP/IP. This information is shown above in the bytes of the EMIS_PARA variable.
Note: 1876 in decimal is 754 in hex. All values shown in the DATA_EXCH block are in Hex.

Explanation of the EMIS_PARA variable

To understand the setup of this array you must take each byte of each word separately.
In the first word (16#0706) the 2 bytes are 07 (high byte) and 06 (low byte). The low byte (06) is the MB function code. The high byte (07) is the first part of the starting address in the slave device.
In the second word (16#1254) the low byte (54) is the rest of the starting address in the slave and the high byte (12) is the start of the data to be sent.
The last word is only shows the low byte (34) and this is the remaining data to be sent.

If you look at the 5 bytes (in Hex) individually you get: 06 07 54 12 34

06 = MB function code 6
0754 = 1876 decimal (%MW1876)
1234 = Data to be sent

The last thing to mention here is that the forth word of the management parameter (Manage_PARA) is equal to the size in bytes of the transmitted data. In this case 5.


Now create a new FBD section in Unity Pro and press OK.



Add a ADDM and DATA_EXCH block and link the parameters as follows.



Note: In a M340 the TYP parameter is always a 1
The string input for the ADDM block must be chosen to meet the requirements of your network. An explanation of the syntax of this input can be found in the Unity help files.
In this example %M0 is used to trigger the function code 6 and the slave device is located at 192.168.40.45.

Build and download to the M340.

Open a animation table and trigger %M0. You should see the RECP parameter (RECIEVE_DATA) values go from all 0's to the same as the EMIS parameter. This is because the slave device echoes the data back to the master is the transmission was a success. Also the first word of the Management parameter should also be changing while the block is enabled. This indicates successful transmissions.





Schneider Electric Thailand

Related products for Schneider Electric Thailand
Range:
Articles that might be helpful Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.
Related products for Schneider Electric Thailand
Range: