NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

smithd wrote:

If my customer's master polls the NI slave with a function code 22 - will it work?

Function 22/0x16 is supported on both sides. The Mask Write Holding Register VI will send function code 22 from the master side or perform equivalent behavior on the slave side (on the slave it directly modifies the data). However, you are correct, it makes more sense from the master where you can modify a single bit within a register. Without the latency of the network it doesn't make so much sense.

Thanks,

Daniel

Thanks

And a general thanks for this library. I was able to get it working (interactively deployed) on a cRIO-9074 - but I had to go to LV2013 (that was fun). But when I build it to run as startup - the target refuses to run my app. Guess I'll put in another support request.

This is a big impovment on the slave side. I was able to poll three groups of data

16 bytes in.out @ 50ms (modifiyng the data via your FBs @ 25ms)

240bytes out @ 1000ms

240bytes out. 36bytes in @ 3000ms.

CPU total jumps only about 8% when I start polling. The old library railed the cpu polling the small set at anything less that 300ms.

0 Kudos
Message 31 of 527
(6,368 Views)

Well...I'm sorry you're having trouble getting it running. Is it crashing as an rtexe in 2013, or just not running? You might make the exe debuggable and then connect to it.

Either way, I'm glad to hear that the performance is good, especially when CPU is still that low on a 9074. I would guess it probably idles at about 4 or 5%, so 8% is great

0 Kudos
Message 32 of 527
(6,368 Views)

Hi Daniel

I have implemented the basic functions and I am now working on adding the Diagnostics following your instructions - thanks for this I'll let you know how it goes.

I am seeing a lot of Error 56 at an unidentified location (LabVIEW:  The network operation exceeded the user-specified or system time limit.) messages. I thought this might be my implementation, so I have used your master api set up as a serial master to communicate with the Modbus PLC simulator (http://www.plcsimulator.org/) and I still get error 56, when using almost any function call, although data is transferred (I see the values in the Modbus simulator). My test tool code is the same - the data appears in the simulator and then the test tool displays an error 56. I have two USB to serial converters connected to a serial cable as my Modbus network. This works well with my test tool (master) to your slave (serial) API example, and your master/slave examples talk happily together over this cable at various baud settings. I have tried various USB ports in case there was some bizarre USB problem.

Hope this makes sense

Regards

Ray

0 Kudos
Message 33 of 527
(6,368 Views)

Hey Ray,

To make sure I am clear:
-The NI slave and master work fine togehter, and the slave responds correctly to your master

-Using the NI master with your (simulated) slave fails with error 56 (standard timeout)

First: What slave address are you setting. If it is 0 and you are receiving a timeout, there may be a bug with the code that prevents waiting on a response in that case (0 is broadcast with no response expected).

Second: Using the NI SPY (I/O Trace) application, can you post back here what data is going through VISA (if you can get it working, the code I provided you should do the same). It may be that the packet is not in an expected format, which could result in a timeout. This will also make sure the driver is working.

Third: I hate to point you towards the older library, but this is still beta(? alpha?) software and it wouldn't be right if we didn't make sure that the old library can communicate with your simulated device. If it can't, and the new one cannot (which arguably tries harder to follow the specification), then we can assume it is something to do with the simulator.

Thanks,

Daniel

0 Kudos
Message 34 of 527
(6,368 Views)

Hi Daniel

I found the issue - it was the bizarre USB error.. The problem was intermittent and I kept getting differing results when trying to recreate it. Eventually I changed the two USB to serial adapters for two identical adapters and the problem went away. Both the old adapters work fine individually, not sure what was going on there.

Sorry to waste your time,



Ray

0 Kudos
Message 35 of 527
(6,368 Views)

Glad you figured it out

0 Kudos
Message 36 of 527
(6,368 Views)

Hello, everyone.     I just created a document (https://decibel.ni.com/content/docs/DOC-31787) on how to communicate with ASCII modbus over RS232 serial COM ports.

I appreciate any feedbacks to make the example better.

Cheers,

m.wei

0 Kudos
Message 37 of 527
(6,368 Views)

Hi Daniel

I'm doing well - I have the slave diagnostics implemented as per your instructions - thanks!

I still have some queries around the error and exception handling. I have set up counters to monitor 538181 to 538184 (illegal function, address, data, server failure) and I monitor master bus messages by using the serial write queue. Please could you explain:

1. how I could monitor master exceptions - master sends request, slave sends response, slaves response is incorrect (incorrect function / data / address).

2. is the above related to the error codes 538170, 538172 and 538173? If not, what do these relate to - I had trouble understanding their function from the database description.

3. If there is a way of monitoring CRC errors?

Thanks again,

Ray

0 Kudos
Message 38 of 527
(6,368 Views)

Hello smithd,

I've been using LV for more than 4 years now, but this is the first project i'm trying to interface a modbus sensor with labview.

Can you provide me a starting point for the development of my project in LabVIEW? I know the modbus protocol though?

0 Kudos
Message 39 of 527
(6,368 Views)

Glad to hear it.

1/2) Yes, those error codes are the ones thrown by each read function in the event of bad data.

xx70 is a bad function code, xx72 is bad <whatever I decided was worth checking>--this is usually just whatever feedback I get from the slave. For example the master writes "set x03 to x55" and the slave responds with "set x03 to x22" or "set x55 to x03" then error xx72 is thrown. xx71 is a specific error related to the read dev id function. xx73 is a slave-only error, to the best of my knowledge. If that error is thrown locally by the connection handling daemon, it should return with a more generic modbus error for that function call.

3) No, but it possibly should. I'll pass the feedback along. The main challenge is that the way serial modbus works is that it polls the port for data and checks the CRC character by character. So you'd see a ton of "wrong crc" warnings on each readm, making that meaningless. It may be possible to at least split the error. Right now a failed CRC means we did not get a message in time, meaning we timed out (56). However, a true timeout should probably be the concept of getting no data at all, while the CRC error would say that we started to get some data back on the serial port, but it wasn't useful.

Thanks

Tarsel wrote:

Hi Daniel

I'm doing well - I have the slave diagnostics implemented as per your instructions - thanks!

I still have some queries around the error and exception handling. I have set up counters to monitor 538181 to 538184 (illegal function, address, data, server failure) and I monitor master bus messages by using the serial write queue. Please could you explain:

1. how I could monitor master exceptions - master sends request, slave sends response, slaves response is incorrect (incorrect function / data / address).

2. is the above related to the error codes 538170, 538172 and 538173? If not, what do these relate to - I had trouble understanding their function from the database description.

3. If there is a way of monitoring CRC errors?

Thanks again,

Ray

0 Kudos
Message 40 of 527
(6,368 Views)