LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change the Modbus Address of a Modbus IO Server programatically?

Solved!
Go to solution

Hi experts,

I am using a cRIO 9076 that is configured as a Modbus slave IO server for Modbus TCP communication. I have always used the same Modbus address to configure the IO server and there was never a need to change it until now. So I am wondering whether there is a way to change the Modbus address of the IO server programmatically after it has been initially configured? 

Thanks,

Volker

 

0 Kudos
Message 1 of 6
(5,964 Views)

follow up. seems to me that the Modbus address as configured in the Modbus IO server setup window is not really used in Modbus TCP as the slave's address is its IP address. Is this correct? 

0 Kudos
Message 2 of 6
(5,952 Views)
Solution
Accepted by topic author volker_sbk

Hi Volker,

 

There is an Express VI that lets you create or modify existing Modbus I/O servers programmatically called Create and Configure IO Server. Once you configure it as Modbus, you will be able to provide the address programmatically.

 

In terms of the addressing - you are correct in that the Modbus address configured in the server setup is not really used with Modbus Ethernet. According to the Modbus specifications, the address is used when connecting a Modbus Ethernet network to a Modbus serial sub-network via a bridge or gateway. The specs do say that the address 0xFF should be used on an Ethernet network. For more information on this, please see page 23.

 

Hope that helps!

 

Best Regards,

Matthew B.
Offering Manager
NI
0 Kudos
Message 3 of 6
(5,929 Views)

Matthew,

thanks for your post. Unfortunately, the Express VI that you recommended is only available within the DSC module, which I don't have. So far I have implemented the Modbus server interactively by taking advantage of the options offered by LV RT.

 

As pointed out in the Modbus TCP guidelines, I might not need to worry about the Modbus Unit ID in almost all cases. However, if I would have to change it programmatically, would I be able to do so by implementing Modbus via the Modbus library rather than using the Modbus IO server? 

 

Volker

0 Kudos
Message 4 of 6
(5,911 Views)

Hi Volker,

 

Sorry about that - I didn't think to ask if you had the LabVIEW DSC module!

 

I haven't found a way to change the address if you create the I/O server in the project. If you want to use the LabVIEW Modbus API on NI Labs, there only place you can specify an address is using the Serial VIs when you create a Serial Slave. As far as I can tell from the documentation, none of the TCP versions of the VIs allow you to specify the address.

 

I suspect changing the address of a slave programmatically is a very rare use case since the addresses are usually defined at edit time, so this change might not be possible using the Modbus I/O Server functionality provided by the LabVIEW Real-Time Module or the LabVIEW Modbus API.

 

Best Regards,

Matthew B.
Offering Manager
NI
0 Kudos
Message 5 of 6
(5,896 Views)

Matthew,

My cRIO always has its own IP address and runs one Modbus IO server. as you pointed out, in this case the Unit ID becomes redundant and there is no need to change it. I did set the server address to 255 per convention.

 

Thinking about the case of connecting a Modbus Ethernet network to a Modbus serial sub-network via a bridge or gateway; I would think that the gateway strips the IP address from the Modbus frame and passes the remaining data including Unit ID to the serial Modbus network. In that case, all the slaves on the network would be serial devices. So I think that the Modbus API has all the bases covered. 

 

Thanks for your help.

Volker 

0 Kudos
Message 6 of 6
(5,888 Views)