LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus+VISA

Hi,

I am working with a gas volume measurement device that communicates via Modbus RTU. (https://www.bluesens.com/fileadmin/user_upload/downloads-products/BlueVCount/Communication_Manual_Bl...)


Since my PC doesn't have a native RS485 port, I am using a USB to RS485 adapter
to connect the instrument to the computer.

Initially I had a simple LabVIEW application that continuously read the volume value
using Modbus Read Holding Registers and everything worked correctly.

However, after running for some time (usually around 20–40 minutes), the system stops
returning valid data. Instead of the expected counter value, the read operation starts
consistently returning 0.

If I stop and restart the VI (which reinitializes the VISA session), communication
immediately starts working again and the correct values are returned.

I tried implementing a self-recovery mechanism inside my While Loop using a Flat
Sequence to force a reconnection when invalid values are detected, but the issue still occurs
after some time.

- Modbus Close
- VISA Clear
- VISA Close
- Wait
- VISA Configure Serial Port
- Create New Serial Master

 

Has anyone experienced something similar when running continuous Modbus RTU polling
over USB-RS485 converters? Any recommendations on how to handle this more reliably?

Thanks in advance.

 

 

Download All
0 Kudos
Message 1 of 10
(338 Views)

Hey, 

you should check the Energy Settings for the USB Device in Windows Device Manager - often they will be powered down by the system.

Are you using Windows?

0 Kudos
Message 2 of 10
(315 Views)

No idea about the root cause, but your reconnect cannot work:

- the error is not cleared

- the modbus master output terminal is not wired

 

I think you can reduce the VI down to this:

 

modbus reconnectmodbus reconnect

Message 3 of 10
(288 Views)

@JC-Thk  ha escrito:

Hey, 

you should check the Energy Settings for the USB Device in Windows Device Manager - often they will be powered down by the system.

Are you using Windows?

Yes, I’m using Windows. However, I don’t think that’s the root of the problem, because I’m using other USB devices and none of them are shutting down. I suspect this is a limitation caused by the messy Modbus‑to‑USB conversion. Don’t you think?
 
Regards
0 Kudos
Message 4 of 10
(265 Views)

@cordm wrote:

No idea about the root cause, but your reconnect cannot work:

- the error is not cleared

- the modbus master output terminal is not wired

 

I think you can reduce the VI down to this:

 

modbus reconnectmodbus reconnect


I'm usually optimizing it even further by not executing the first Open function at all, but simply detecting if the communication resource is valid at all (if there is an easy way through Not a Refnum or similar, or trying to communicate with it with short timeout) and then in the error case trying to (re)open the resource.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 5 of 10
(243 Views)

@cordm  ha escrito:

No idea about the root cause, but your reconnect cannot work:

- the error is not cleared

- the modbus master output terminal is not wired

 

I think you can reduce the VI down to this:

 

modbus reconnectmodbus reconnect


Do you think I don’t need the VISA blocks?
I tried your example, but I didn’t receive any data. Could that be the issue, or am I talking nonsense?

I’ll look into it a bit more tomorrow.

Thanks.

0 Kudos
Message 6 of 10
(218 Views)

@Aros wrote:

@JC-Thk  ha escrito:

Hey, 

you should check the Energy Settings for the USB Device in Windows Device Manager - often they will be powered down by the system.

Are you using Windows?

Yes, I’m using Windows. However, I don’t think that’s the root of the problem, because I’m using other USB devices and none of them are shutting down. I suspect this is a limitation caused by the messy Modbus‑to‑USB conversion. Don’t you think?
 
Regards

"Other USB devices" can often handle power saving mode better than USB-to-serial devices because they are both not as dependent on an uninterrupted connection but also because a lot of USB-to-serial devices are very cheaply made and don't deal with power saving mode well.  You should still check this.

 

Also, what brand is your USB converter?  Or more specifically, what chipset?  If it's a "Prolific" chipset, I would recommend replacing it.  It might even be a counterfeit chipset.

 

Whatever brand it is, also look for newer drivers for it if you haven't.  It could be that any built-in Windows drivers for it have problems.

Message 7 of 10
(201 Views)

@Aros wrote:

@cordm  ha escrito:

No idea about the root cause, but your reconnect cannot work:

- the error is not cleared

- the modbus master output terminal is not wired

 

I think you can reduce the VI down to this:

 

modbus reconnectmodbus reconnect


Do you think I don’t need the VISA blocks?
I tried your example, but I didn’t receive any data. Could that be the issue, or am I talking nonsense?


Adding VISA blocks of your own in addition to the NI Modbus VIs is almost certainly going to mess with the implementation in the Modbus VIs unless you really know VERY VERY exactly what you are doing.

 

If you ask about implementing your own Modbus RTU protocol on top of VISA: That's certainly possible, but a major effort to do. I do not like everything about the NI Modbus implementation but use it anyhow in my applications when I need Modbus, since implementing my own is simply a lot more effort.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 8 of 10
(192 Views)

I have been using this BB-485USBTB-2W-A adaptor for years without issue

========================
=== Engineer Ambiguously ===
========================
Message 9 of 10
(173 Views)

@Kyle97330  ha escrito:

@Aros wrote:

@JC-Thk  ha escrito:

Hey, 

you should check the Energy Settings for the USB Device in Windows Device Manager - often they will be powered down by the system.

Are you using Windows?

Yes, I’m using Windows. However, I don’t think that’s the root of the problem, because I’m using other USB devices and none of them are shutting down. I suspect this is a limitation caused by the messy Modbus‑to‑USB conversion. Don’t you think?
 
Regards

"Other USB devices" can often handle power saving mode better than USB-to-serial devices because they are both not as dependent on an uninterrupted connection but also because a lot of USB-to-serial devices are very cheaply made and don't deal with power saving mode well.  You should still check this.

 

Also, what brand is your USB converter?  Or more specifically, what chipset?  If it's a "Prolific" chipset, I would recommend replacing it.  It might even be a counterfeit chipset.

 

Whatever brand it is, also look for newer drivers for it if you haven't.  It could be that any built-in Windows drivers for it have problems.


My USB Brand is USB-RS485-WE-1800-BT (FTDI).

I'll look into drivers updates and the power saving mode.

 

Thanks.

0 Kudos
Message 10 of 10
(105 Views)