LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am using the MODBUS library and can't receive data, however I can send it just fine?

Solved!
Go to solution

Hi,

 

I am using the Modbus Library to communicate with a VFD to control a fan. I am using the master write and read vi. I can write data to the VFD and get the fan to do what I want. The VFD is supposed to send a confirmation packet after I tell it to do something and I can also read its registers. When I debug the VI it shows the problem is the buffer always reads zero and the VI timesout. If I watch the lights of the USB to RS 485 adapter I am using to interface with the VFD, I see that the RX light flashs right after I send a message. So I should have something in the buffer. Does anyone have any suggestions?

 

Aaron

0 Kudos
Message 1 of 4
(3,227 Views)

Hi Aaron:

 

Recently I had a problem similar to yours in an application made to communicate LabVIEW with a Unitronics OPLC via Modbus TCP. When using the "MB Ethernet Master Query.vi" to read or write some registers, I always received the Timeout error after reading or writing. I found out that it was caused because I left the input "MBAP Header" unwired, and the default values of (0,0) in the cluster never worked for me. So, for testing purpuses I wired a (1,1) cluster, and It started to work.

 

Hope this helps.

 

Robst.



Robst - CLD

Using LabVIEW since version 7.0


Message 2 of 4
(3,216 Views)

Several possibilities. You could be trying to write to addresses that are read only. Could be using the wrong modbus command, wrong address ranges,...

Try using portmon or NI Spy to monitor the serial port hex code and post the data for what is transmitted and what is received from the device. Do you have an indicator wired to the error out terminals??

0 Kudos
Message 3 of 4
(3,191 Views)
Solution
Accepted by topic author WindNRG
Ok, heres what happened for anyone who has this problem. In the MB Serial Receive.vi The Bytes at Port property node was reading 0 even though there was something in the buffer. The program execution was then stuck in a loop till it timed out and never went on to read anything from the serial port buffer. I didn't spend too much time wondering why that VI didn't work and created my own. With an appropriate delay after writing to the serial port,  I used the same Bytes at Port property node and was able to get the right number of bytes to then feed the read VISA vi the number of bytes to read. I got the right response message and everything seemed good. But of course NOT! I then experimented with writing different speeds to the VFD to get the fan to run at different speeds. I found a small range of speeds where I would get no response from the VFD, either by it functioning or sending me a response packet. After quite some time, I found there is an error in the LRC-8 code in the MODBUS NI library. It does not mandate the LRC be a two character value. So if your LRC turns out to be a single character value such as F (which should be 0F)  you get an incomplete MODBUS message. This was easily fixed in the LRC8 vi by telling the 'number to hexidecimal string' vi to produce an output with a minimum width of two. Then everything worked great. Moral of the story is the MODBUS library is clunky.
0 Kudos
Message 4 of 4
(3,178 Views)