NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Hi I am trying to create a Modbus slave VI with multiple slave IDs, but I could dig deep enough to find out where the slave IDs are specified. I am using Modbus TCP/IP communication instance. How do you specify slave IDs that software such as Modscan can differentiate different IDs for each data model?

Aashish M
CEO
TransferFi
www.transferfi.com
0 Kudos
Message 501 of 527
(3,218 Views)

Hi 

I'm new to this Library and cutting my teeth with it. I have a few questions if anyone can help me with. Please correct me at any time if I am misinterpreting what I seeing.

 

Firstly, if I understand it correctly, I Create a Slave instance if I am writing an application where I am the Slave. I create a Master Instance for every communications link I intend to communicate with. Each of the Slaves you communicate with will have its unit ID assigned on the device and it must match with the Object at Creation. I'm very surprised I pass the declaration the COM port number but do not assign the Baudrate, flow Control ... at the time the declaration is made. Is this right?

 

I have an application where I'm communicating with 5 identical controllers (slaves) each on the same RS485 port and each with a different Modbus Address (Unit ID) starting at 2 and ending at 6. My understanding is that the master is supposed to be address 1. My question is do I Create and instance every time I need to communicate with a single controller and then shut it down at the end of the message stream? I'm retrieving temperature updates every second. Do I maintain 5 links each open while I'm retrieving temperature updates or do I Create & Shutdown each temperature update?

 

Thanks

Kevin

0 Kudos
Message 502 of 527
(3,068 Views)

Aashish:

 

Slave IDs are usually ignored in Modbus TCP. Your Modbus TCP slaves have a unique IP address and port number instead.

 

Slave IDs do become important though if you are communicating with a Modbus gateway that has Modbus serial devices attached to it. This way you can specify which slave to talk to.

0 Kudos
Message 503 of 527
(2,952 Views)

Kevin:

 

To communicate with 5 devices on the same RS-485 network with this library, you should create one Serial Master. Then before each read or write operation, use the property node "Unit ID" to specify the slave ID that you want to talk to.

 

If you want to know more about communicating with multiple slaves on a shared comm port, I suggest you check the section 8.5 of the manual for the Plasmionique Modbus Master library. This library was designed to offer more flexibility for such use cases: 

https://github.com/rfporter/Modbus-Master/blob/master/Documentation/MB_Master%20-%20User%20Guide.pdf

0 Kudos
Message 504 of 527
(2,946 Views)

Not sure if anyone is still monitoring this thread...

But I have discovered a bug in the Serial Slave, which causes the serial port to remain open after shutdown is called:

https://github.com/NISystemsEngineering/LabVIEW-Modbus-API/issues/11

0 Kudos
Message 505 of 527
(2,942 Views)

Hi. 

 

Has anyone tested the Modbus version 1.2.1.42 with LV version 2019?

I've tested the Modbus TCP Master example that comes with the library, trying to read input and holding registers from a sensor, and all i get is a timeout error (Error 56). Seems strange because if you connect the Master example with the slave example in the same localhost it works normally. I was able to trace back the error source to a "PDU not valid", but i couldn't go beyond since VIs are password protected. 

 

I've used Modbus Poll to connect with the sensor using Modbus TCP and it works just fine. So, seems to me like a problem to resolve the IP address or something? 

0 Kudos
Message 506 of 527
(2,863 Views)

 

I am using NI Modbus library on a cRIO, the cRIO is  Modbus TCP slave.

I have experienced  that in rare cases, the Modbus interface doesn't respond. So far it seems to be related to the deamon not running/not started when this occurs.

Any idea why the deamon sometimes fail?

I have verified that the application is running. The cRIO can be reached by ping and SFTP, so it is not related to network access. 

 

When the cRIO / Modbus deamon are in this state, it persists across multiple power cycles / reboots.

In the NI Modbus Library error log i see one occurence of this:

<nierror code="538175">
The slave daemon failed to launch.
</nierror>
<nierror code="538176">
The current Modbus Slave does not have a TCP daemon.
</nierror>
<nierror code="538177">

The error is only listed once, despite the cRIO has been in this state more than once...

 

Anyone else have experienced this behaviour?

 

Earlier, i did a Modbus shutdown and reinitialization if there was an error from any of the slave VI's in use. I have now expanded this to also occur if daemon state is anything else than "Running", hoping this will be sufficient to get the Modbus interface out of this state.

 

Any other suggestions?

 

 

0 Kudos
Message 507 of 527
(2,641 Views)

Hi SmithD,

 

I am new to Labview and Modbus. I have inherited this project that is used to communicate with a Siemens motor controller and I had it running in January. However, I cannot figure out what's wrong now. I thought I will just open it and it will run... I am sure there is a quick fix but cant figure out what.

 

I am using Windows 10 and Labview 2020 32 bit. 

Here are the errors I get:

 Capture.PNG

 

I get these disconected wires. I guess the Serial Master instance is not initialised properly, but not sure what to do about it.

Capture1.PNG

 

I have also attached the project.

 

Could you please look into it?

 

Regards,

Nandor

0 Kudos
Message 508 of 527
(2,123 Views)

Solved,

 

Needed to reinstall the NI Modbus Library in VI Package Manager.

0 Kudos
Message 509 of 527
(2,077 Views)

Hello, 

 

I'm having a bit of trouble with this library for a use-case that I haven't seen before, but is probably common to you all.

 

I'm working with a device that has provided its modbus registers to me, claiming that there is a management system (MS) that is a MASTER, and another system, called VGI, that is a slave. Both have assigned IP addresses. MS (Master) has R/W registers, VGI (slave), only read registers. The idea is that the MS writes to the VGI slave to get it to do something.

 

I'm confused - when I look at this library, there is no IP address option for the slave. Any idea how to get around this?

 

Second, when I went back to the manufacturer for clarification, they said that the application I was writing IS the MS itself, which confuses me again. If my application is the MS, or the master, how do I access the registers? My computer is not a modbus device.

 

I have a feeling I'm getting confused of the terminology. For example, I've been working with MODBUS for the last 6 years ... meters, inverters, all sorts of devices, and this library has worked fine. I've just opened up an instance of a TCP Modbus Master, entered the IP address, and everything worked. I'd really appreciate some help!

0 Kudos
Message 510 of 527
(1,760 Views)