HMS-EN2SE-R Serial Linking device code examples

HMS Team,
I am not familiar with Modbus and have to set up an interface with a Rockwell controller to act as a master device to control a machine using Modbus. I would like to get with a product expert to help me get kick-started

Hi @Sabrevt1100,

I can have someone who is familiar with this device reach out to you. I would highly recommend acquainting yourself with Modbus prior to setting this up. It is a very simple protocol compared to others, like Ethernet/IP or CANopen, for example. I find the website simplymodbus.ca is a great resource!

There is a step-by-step example in Chapter 3 of the User Manual as well.

Here are some examples of how to do a read and write with the HMS-EN2SE-R or Anybus Communicator:

Example reading the Holding Registers:

You can read the first 4 registers using one command or 4 commands. In the example we’ll read all 4. Open the Anybus Configuration Manager (don’t use Wizard).

Change the Fieldbus type to the appropriate protocol and enter your network settings if necessary (you don’t need to change this on the EN2SE-R as it requires Ethernet/IP):

image

Under ‘Communicator RS232/422/485’ the Protocol is already set to ‘Master Mode’ which is what we want for Modbus, so you don’t need to make any changes.

Under ‘Subnetwork’ just update your serial settings to match the slave(s).

Right click on ‘New Node’ (you can rename this to whatever you’d like and change the node address by left clicking on it) and select ‘Add Command’ than ‘Read Holding Registers’.

Under ‘Query’:

Leave ‘Starting Address’ as 0x0000 (This is the first byte address in the input registers 40xxx).

Change ‘Quantity of Registers’ to 4 (Please note that these values are in hexadecimal, if you delete the ‘0x’ it will automatically convert decimal to hex)

Under ‘Response’:

Change ‘Byte Count’ to 8 (4 registers = 8 bytes; this is the memory area in the Anybus that the response will be stored to)

Under ‘Register Value’ change ‘Data length’ to 8 bytes and leave ‘Data location’ as 0x0000 (This is the first 8 bytes in the Anybus. If you create another read command, make sure to start at 0x0008, the 9th byte.

(Please note that I didn’t mention the Slave Address, Function, or Checksum fields because those don’t need to be changed in this case)

By Default, this will be a cyclic command with an update time of 1000 ms. You can change it to be updated on a trigger byte (or to update when the data changes) by Clicking on Query:

image

I won’t get into the trigger byte too much right now, but you will have to put it in a memory location that your controller can write to (0x0200 – 0x03FF).

Example Writing to Input Register:

Again, we could write to a single register (FC6) or multiple registers (FC16), but in this example we’ll just write to one, Register 40001.

Right click on the node > Add Command > 0x06 Write Single Register.

Under ‘Query’:

The Address will be 0x0000 (the first byte in the Input Registers 40xxx)

Under ‘Register Value’ this is where we are putting the data that we are going to write.

The length will be 2 bytes, and the Data location will be 0x0200 (the first address in our Output Area, these two bytes will be mapped to the PLC)

Under ‘Response’:

This is where you will store the response. Usually the slave just echos back the write command. You can store this in 0x0000 – 0x01FF in the next free spot. In our case this will be 0x0008 because our read data is stored in 0x0000 – 0x0007 (8 bytes). You really only have to update the ‘Register Value’ field.

Right click on ‘Subnetwork’ and click on ‘Subnetwork Monitor’ to see the data size. You will need to enter this as the I/O size in RSLogix (this is automatically handled by the software when using the HMS-EN2SE-R with the add-on profile).

image

Please let me know if you have any questions!

Kyle

Kyle,

thank you for the information. I will take some time to work with the HMS-EN2SE-R Add-on profile and get an overview of the functions. I’ll send you a note after, and if needed maybe arrange to speak with a product specialist that can help me finalize my initial installation.
thanks again

Sounds good. A Field Application Engineer should be reaching out to so you, but feel free to ask any questions you have on the forum.

Kyle