10-07-2008 02:20 PM
I am having issues with the Modbus Serial Master Query VI in the NI Modbus 8_2 package. I am reading multiple registers of a device in one communication. The majority of the time it will work perfectly, but with 1 in approx. 20 reads I get a response of 5 registers. It does not return an error, just an array that is only 5 values instead of 6. Has anyone else had this problem or know a solution? I have implemented a simple vi to disregard the data if it is not correctly sized, but this results in missed data.
Thanks,
Dan
10-07-2008 02:42 PM
I have not seen this before. I can't think of a scenario of how this would happen. Unless the device you are communicating with (what is the device?) is not sending back a complete dataset.
Do the 5 values you get make any sense? Is it a case of the 5 are correct, but 1 is missing either from the end, the beginning, or the middle? Or by missing 1,do the 5 you get seem scrambled.
My first thought would be that you are missing some of the bytes on the serial read. But I don't think that could happen without the Modbus drivers generating an error. That is because there is a checksum going on for all the data received. The modbus frame is going to have some header, some data, and a checksum (you can look up the Modbus spec. at Modbus.org to see exactly what a Modbus frame would look like). If it was missing any data (which would be coming from the middle of the frame) the checksum would be invalid (though there would be a very, very slight chance it would still be good) and the Modbus drivers would generate an error.
So if a byte or two was missing, it would have to have been missing from the very beginning before the data was sent and the checksum calculated in the sending device in order for the sending device to still have sent a valid checksum.
10-07-2008 03:16 PM
The device that I am currently communicating with is an ADAM-4118 data acquisition module by Advantech. I have also tried communicating with a GE Fanuc PLC and I end up with the same scenario.
The 5 values that I get are valid. It is dropping off the 6th value.
10-07-2008 04:35 PM
10-13-2008 09:44 AM
10-13-2008 11:06 AM
Attached is some documentation. I created a simple VI for modbus master communication, when the GO button is pushed it sends 1 modbus request. A screenshot of the block diagram is attached.
Also attached is a screenshot of the front panel when the request is successful and when it is not successful. The main difference is the last byte of the received bytes.
See the next post for portmon screenshots.
10-13-2008 11:07 AM
10-13-2008 11:42 AM
10-13-2008 12:30 PM
The starting address at 0 has no effect, I can start at address 1 and I still get the same results every 20th time or so.
Attached are the screenshots of portmon w/ hex:
10-13-2008 01:08 PM
Could you post your vi as an llb file?? Seems like it should be waiting for more bytes to be received. Maybe the timeout value needs to be increased.
Download a demo of the kepware opc server with modbus drivers. Run this program with the quick client reading modbus data and watch the transfers with portmon.