LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NIMODBUS: Where can i connect the CRC code?

I download the NIMODBUS from NI website, I add the MB serial Master Query.VI on the block diagram,but I can not insert the CRC code into the Modbus Command Cluster Input. This input has Fuction Code, Starting Address, Quantity, Data and Discrete but has not CRC code terminal.
 
Where can i connect the CRC code? Who can tell me how to add the CRC code?
0 Kudos
Message 1 of 13
(4,299 Views)
You don't need to calculate the CRC. This is a Modbus implementation so it does it internally. If you go into the Transmit and Receive VIs you should find an MB-CRC-16 VI which does this.

___________________
Try to take over the world!
0 Kudos
Message 2 of 13
(4,289 Views)

I set up the elements accordint with the manual,please see the attached picture.

Function 03 Read Holding Registers

Request Data Frame:

Slave address     Function     Starting address Hi    Starting address Lo   No. of Word Hi     No. of Word Lo   CRC Lo   CRC Hi

         01H                  03H                 00H                           00H                           00H                            02H           C4H          0BH

When I combine above commands to a string and send the string to serial port, then I can recieve the data. But if I use NIMODBUS and conduct the program then a error occured.

Can you help me to solve this problem?

0 Kudos
Message 3 of 13
(4,270 Views)

As far as I can see, your settings seem to be OK (assuming that you are really using RTU and that the slave is really 01).

I'm not a Modbus expert, but a quick search shows that Modbus exception 3 is an invalid data value. This doesn't seem reasonable in this case, since you are asking for a value, but I suggest that you try searching more on that and ask the manufacterer of your device.

Also, you can try using another program which can call Modbus to determine where the problem is. Try searching for "Modbus Scanner", for example.


___________________
Try to take over the world!
0 Kudos
Message 4 of 13
(4,264 Views)
Check your comm settings. Modbus usually uses 8 data bits, 1 stop bit, and even parity.
0 Kudos
Message 5 of 13
(4,256 Views)

If I change the Comm settings there is not anything return.

I don't understand why I succeed with string mode but non-succeed with NIMODBUS mode.

0 Kudos
Message 6 of 13
(4,244 Views)


@青风细雨楼 wrote:

I don't understand why I succeed with string mode but non-succeed with NIMODBUS mode.


What do you mean by "string mode"? Does your device use Modbus ASCII or RTU?

If it is ASCII, then you need to change the input from RTU to ASCII.


___________________
Try to take over the world!
0 Kudos
Message 7 of 13
(4,232 Views)

I would suggest using portmon to watch the data transmitted by the serial port in both modes. Save this info and post it, so we can see what is happening.

http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/Portmon.mspx

 

Also try the llb file I put in reply 4 of this thread.

http://forums.ni.com/ni/board/message?board.id=170&message.id=144504&requireLogin=False

0 Kudos
Message 8 of 13
(4,226 Views)
If I combine the commands in a array and write it(in Hex) to the serial port(please see the attached pic.), then I can recieve the correct data. If I use NIMODBUS there is not any data feedback. the reason may be the checksum. 
0 Kudos
Message 9 of 13
(4,216 Views)

Your latest example has 2 stop bits configured. The Modbus library sets a single stop bit by default. Could this be the reason?

If you run just the VI that generates the actual Modbus string (MB Serial Modbus Data Unit to String) you will see that it does generate the same checksum.


___________________
Try to take over the world!
0 Kudos
Message 10 of 13
(4,201 Views)