NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Thanks

0 Kudos
Message 141 of 529
(1,767 Views)

dexterpoet wrote:

Hello smithd

Thanks a lot, I have opened the example code, but I have a few questions.

1. I am working with a serial device. From the example in the library, when I change the Modbus VI on the Connect case for the 'New TCP Master' to 'New Serial Master', I get a broken VI, with an error saying 'required input 'unit ID' and 'serial type' is not wired', and when the 'New TCP Slave' is changed to 'New Serial Slave', in addition to the warnings above, I get the error message 'required input 'VISA resource name' is not wired'. What do these mean and what data type is to be wired here?

2. If I want to access a register on the Slave from the Master, which of the VI's should be used?

3. Form your reply, could you please explain the underlined a bit further as I not quite clear. 'I would start simple with something like the example I provided or the simple state machine template and assign a button on the UI to each thing or register you want to access on the device.' Which UI are you refering to?

Thanks

Hi Dexter,

1. Thats correct, the example was designed with TCP in mind, but the nature of the API should make it easy to swap to serial--just create a control or constant for those inputs. Serial type is defined by your device (ASCII or RTU), as is unit ID (may be called something else--unit ID is the more modern terminology used by TCP and I stuck with that, but the old name was station address. And, in your case you'll want a master, as your device is going to be the slave.

2. Depends on the type of register. There is only one function for each operation, so you just need to know what operation you want to perform.

3. If you are using the example or writing your own simple test code, I am saying you can just put a button on the front panel, just like what I currently have in the example. In your case you can even simplify that and just use an event structure without the second loop, if you'd like--this would be similar to the simple state machine sample project.

0 Kudos
Message 142 of 529
(1,767 Views)

Hi Daniel,

First I tried to use one RS485 port as master and another RS485 port as slave, but I always got the Daemon error 56 when I run Modbus API slave example.vi.

Error 56 occurred at RTU Data Unit.lvclass:Read ADU Packet.vi:1

Possible reason(s):

LabVIEW:  The network operation exceeded the user-specified or system time limit.

May I know what it is.

Jason

0 Kudos
Message 143 of 529
(1,767 Views)

Hello smithd

Just a random question. What is the difference between NI VISA (used for instrument control) and the available Modbus library you provided?

0 Kudos
Message 144 of 529
(1,767 Views)

dexterpoet wrote:

Hello smithd

Just a random question. What is the difference between NI VISA (used for instrument control) and the available Modbus library you provided?

For this, I think the clarification actually needs to be on the VISA side. Specifically, from the wiki:
"The VISA standard[1] includes specifications for communication with resources (usually, but not always, instruments)"

That is, VISA defines an API. That API handles passing data to and from a hardware resource. That hardware resource could be an instrument that communicates using raw ASCII commands, like *idn?, or ir could be an instrument that communicates using modbus. Modbus, as a relatively high-level application protocol, just defines what you are sending with VISA and then what you are waiting on. It also can operate over TCP, in which case this library uses the labview TCP functions rather than VISA.

0 Kudos
Message 145 of 529
(1,767 Views)

Jason2010 wrote:

Hi Daniel,

First I tried to use one RS485 port as master and another RS485 port as slave, but I always got the Daemon error 56 when I run Modbus API slave example.vi.

Error 56 occurred at RTU Data Unit.lvclass:Read ADU Packet.vi:1

Possible reason(s):

LabVIEW:  The network operation exceeded the user-specified or system time limit.

May I know what it is.

Jason

I'm afraid I don't know how to help based on the information you've provided. Error 56 is, as it says, just a basic timeout error. The master sent a request and never got a response back. That could be because the two devices were not configured correctly, ports were selected wrong, physical connections are incorrect, or somebody tripped over the wire. Can you clarify what settings you are using and what your wiring looks like?

Thanks,

Daniel

0 Kudos
Message 146 of 529
(1,767 Views)

Hi Daniel,

This is actual a reply for the post number 119 at page 8. I change the Create Modbus Instance function from TCP to serial. I just use one master and one slave for the first test, so I set slave unit ID to 1, I also set unit ID of the master to 1. But every time when I run Modbus API slave example.vi, I just got the Deamon error 56. I am not sure whether it is normal, or I forget something. But today, I did a test, even I got that error when run slave example, I run Modbus API master example.vi and press "Connect" button. What I found that if I press "Set Coils" button in master example, I then press "Fetch Coils" in slave example, the coils value does transfer from master to slave, and I notice that LEDs at both RS485 port seem flash once. I also test to "Set basic objects", "Set discrete inputs" in slave example.vi, and "Fetch basic objects","Fetch discrete inputs" in master example.vi. It seems I could get the value, and LEDs in RS485 port flash. I wonder whether this means the two examples works, but why I got Deamon error 56?

For the exact hardware connection, I use the examples from that low level NI Modbus library download from ni.com, I use the same port setting, I am able to run that master and slave example successfully. I have receive and transmit LED at the RS485 port, I could see LEDs of master port and slave port blinking busily. From here, I think hardware connection or setting issue could be eliminated.

Jason

0 Kudos
Message 147 of 529
(1,767 Views)

Hey Jason,

Please correct me if I am wrong, but it sounds like you are able to access all of your data from the master, including the 5 main functions shown in the example, without issue. That is, it sounds like the modbus master never gets error 56, correct? It also sounds like the modbus slave is providing an error when you read the property node for daemon status, correct? That is, it looks something like this?

1.png

If so, this is completely expected behavior. The slave has a request timeout just like the master, so if you see this error it means that it was waiting for an incoming request and did not recieve one. Internally, the modbus library is latching every error that occurs in the daemon and storing it in a structure that the property node has access to. However, you'll also notice that the daemon status still says "running", rather than error. This is because error 56 is not a fatal error and does not put the daemon into an error state.

Hopefully this clarifies everything. Let me know if my understanding is wrong.

Thanks,
Daniel

0 Kudos
Message 148 of 529
(1,767 Views)

Hi Daniel,

That seems what exactly happened. For master modbus example, I did not see any error cluster, so I am not sure whether it gets error 56. It seems not. I'm going to try one master communicates with several slaves to see how it works. Thanks.

Jason

0 Kudos
Message 149 of 529
(1,767 Views)

Hi Daniel,

Error 56 scared me when I saw it at the first time. My perspective is that something seriously wrong with slave.

One question about this error. For my understanding, slave in Modbus communication setting should only response to master's request. Why does it need to wait for an incoming request. If there is no request, it will be fine, just waiting. Or is there any way to set this waiting timeout to -1 (infinity)?

Jason

0 Kudos
Message 150 of 529
(1,767 Views)