LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus device not working with Labview, but works with Python.

Solved!
Go to solution

For this device with python I just request to read the register 0 and then I get back whatever is there. With labview I only get error. It connects but does not write neither read. I might be missing something very basic. By the way, I have been using Labview for 5 days till now, so I am sure the solution will come 😉.
On the windows firewall I allowed everything regarding labview, etc.

0 Kudos
Message 11 of 17
(266 Views)
Solution
Accepted by topic author henk1000

I have found a quick/temporary solution for my problem. Now just need some implementation. Since the Python code was working well, I just call the script inside Labview and get my numbers.
Still bothered by Labview Modbus library not working but for the moment it's fine.

0 Kudos
Message 12 of 17
(256 Views)

Hi,

 

Like Stockhouse said the ModBus address issue can be really a problem. 

Does your device starts at address 0 or 1

 

In the VI you used a loop. A read every 200msec. Can you device handle this ?

And you should use the 'ModBus master out' (right top output) of the read VI

 

Kees

0 Kudos
Message 13 of 17
(242 Views)

Hi Kess,

With the python code, I just read the registers (e.g 60, 61) and I get the value I need in hexadecimal.
In Labview I have tried different numbers for the quantity and initial address, but it did not work. I will try different configurations to see how it works. I am quite new to Labview (Started last Friday 😊) so I suppose I still have to figure out plenty of stuffs. Thankfully the community here is quite active and supportive.

Regarding the scan time of my device, I am not sure if it can handle the 200 ms. I will try longer time and post here the results.

 

Best,

Henrique

0 Kudos
Message 14 of 17
(232 Views)

Post your Python code as well, perhaps that will help us help you debug.

0 Kudos
Message 15 of 17
(229 Views)

Sure. Here is the python code for connecting to a modbus device.
"

from pymodbus.client import ModbusTcpClient
try:
    client = ModbusTcpClient('000.000.0.000', port=000)
    print("Modbus connected")
except ConnectionError as errorcom:
    print("Can not connect to PLC!")
    raise SystemExit from errorcom
v = client.read_holding_registers(60,13).registers
print(v)
client.close()
"
0 Kudos
Message 16 of 17
(207 Views)

I finally managed to connect to two other different devices with Labview !!! 😍
Still do not understand why two devices work with Labview (and python) and the other only with Python.

0 Kudos
Message 17 of 17
(202 Views)