06-20-2013 07:30 AM
Hello all,
I've been over the manuals/threads of using the Modbus library to communicate via serial. However, I'm not sure what exactly I'm doing wrong. If I use a program such as Modbus Poll and send 02 03 00 02 00 02 65 F8 I get a response back: 02 03 04 39 20 3F 90 D5 F9. Looking at the manual for the device I'm communicating with (a pressure transmitter), the request is in the following format:
02 - Address
03 - Function
00 - StAdd H
02 - StAdd L
00 - # Reg H
02 - # Reg L
65 - CRC16 L
F8 - CRC16 H
The response is in this format:
02 - Address
03 - Function
04 - # of Bytes
39 - Data H
20 - Data L
3F - Data H
90 - Data L
D5 - CRC16 L
F9 - CRC16 H
So, in LabVIEW this is how I have it setup:
I set the "Starting Address" at 1 because I read it has to be 1 less in LabVIEW than what the actual starting address is (n-1). I'm expecting the same response as above using Modbus Poll. In the block diagram above, I receive the following from the registers, beginning at index 0: 256, 661, 63490, 33538
Obviously the response isn't in Hex as above, but it's nowhere close to what it should be.
Thanks for the help!!!
Solved! Go to Solution.
06-20-2013 08:14 AM
I haven't done any Modbus for a while but from memory the address is not decremented so addr 2 = 2 etc. The -1 was for the port number on the old serial commands.
06-20-2013 08:16 AM
If I have the starting address at 2 I get a Timeout Error, code 6101.
06-20-2013 08:19 AM
What make/model transducer is it?
06-20-2013 08:24 AM
Attached is the communication protocol for it. Modbus specs start at page 9. Thanks for taking the time, ssk!
06-20-2013 08:54 AM
buickgn,
By default Visa Configure Serial Port.vi enables the termination character. You need to disable it.
06-20-2013 08:58 AM
Wayne,
I disabled it and still receive the same response if I use the starting address as 1. If I have the starting address as 2 I still receive a timeout error.
06-20-2013 08:59 AM
buickgn,
Suggest you use NI-Spy to monitor what is actually being transmitted and compare to your known good packet.
06-20-2013 09:20 AM
Wayne,
Great idea. I ran the trace and setting the starting address at 2 I see the correct request "02 03 00 02 00 02 65 F8". However, under the "VISA Write" that contains that request, there are about 2000 VISA Get Attribute/VISA Read.
06-20-2013 09:25 AM
buickgn,
All the get attributes are where the modbus vi is checking to see what has been received by the UART. What kind of hardware are you using for your COM port?