LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus crc

Solved!
Go to solution

Hi All,

 

My query is regarding CRC in Modbus RTU.

 

I know Modbus library provided by NI calculates the CRC, but i want an event (boolean or int etc) when the CRC for transmitted and received does'nt match so that i can call it as a error. and not perform furhter operations.

 

Am i missing anything?

 

Regards,

 

Shrenik

0 Kudos
Message 1 of 4
(6,018 Views)

Hey shrekt,

the equal? fuction in the compare pallete can except most data types and outputs a boolean true if the values are the same. Could this not be used to help?

 

Regards,

 

Matt

Matthew Trott
Applications Engineer
National Instruments UK
www.ni.com/ask
0 Kudos
Message 2 of 4
(6,014 Views)
Solution
Accepted by topic author shrekt

Also, if you run the Modbus library CRC function on a string that already contains the CRC bytes, the CRC output of the function will return 0 if the CRC is correct, and something else if it is wrong.  So you can just take the string, put it into the CRC function, and do an =0 on the CRC output of the function to get your boolean true or false.

0 Kudos
Message 3 of 4
(6,006 Views)

If you're using this MODBUS Library there's a bug in the crc calculation, which is is fortunately trivial to fix. Change the data type of the Exception Code indicator from U8 to U16 in MB-CRC16.vi (check the comments on the library page for more info).

 

The bug is over 2 years old so I wouldn't wait for a fix from NI (I guess because the DSC module is the official way to use modbus, and that's an "example program").

Message 4 of 4
(5,994 Views)