Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus CRC16 generation question

Solved!
Go to solution

Dear guys

        I have a problem in the edit the CRC16 code,i can't get the CRC16 checksum is same as the correct command list showing.pls help to have a look about my Vi,if have a bug or no attention point,thanks a lot.attached my vi,fyi.

0 Kudos
Message 1 of 6
(1,261 Views)

I want to send the string"01 03 00 00 00 08",then generate a CRC "0C 44",but the result is not my attention.

0 Kudos
Message 2 of 6
(1,257 Views)

Hi,

 

To start with your second post. The ModBus CRC of the command you give is not 0x0C44 but it is 0x440C

 

In you program you convert a string into a byte array. If you convert the slave address '01' as a string into a byte array you will get two bytes 0x30 and 0x31. The are ascii character and what you need is a single byte with the value of 0x01.

 

If change your VI.

 

Kees

0 Kudos
Message 3 of 6
(1,245 Views)
Solution
Accepted by xiaozhao

Dear Kees,

        Thanks a lot.i got it.i use labview 13.0 version,i can't open you VI,but i have change my vi,now it can meet the result when swap the low 8bit and high 8bit,thanks a lot again.i'm misguided by the meter communication spec.

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

To be complete. Here is the LV 2013 version.

 

Kees

0 Kudos
Message 5 of 6
(1,196 Views)
Highlighted

(*bump*) I have attached your code with the incorporated byte swap for version 2018. Kees' version appended two zero-value bytes that made the Modbus CRC calculation invalid, and your approach seemed more straightforward.

Message 6 of 6
(352 Views)