Showing results for 
Search instead for 
Did you mean: 

CRC-16 calculation in VB script

Go to solution


I am trying to implement a CRC-16 calculation in LabVIEW (2015) for which I have been given some VB code as a text file (but have very little knowledge of VB or CRC).

My reference manual says the CRC algorithm is similar to (but not identical to) the CRC16-CCITT. I cant tell from the code what the difference is, so if anyone can tell me how to either modify an existing VI that will work for me or how to run the VB code directly in LabVIEW that would really help! (its beyond my skill to even get the attached code running in VB).

example string (in DEC) is 001100000001 and CRC1 result should be 240 and CRC2 should be 240.

Many thanks!


0 Kudos
Message 1 of 4
Accepted by topic author g_james

I think we are going to need a bit more.  First the calculation you are trying to do has probably been done already and a quick search found this post that likely has the CRC16-CCITT.  But the problem is your input and output don't make sense to me.  We need to calculate the CRC of an array of bytes.  If your input is 0d1100000001, then are you saying the hex equivalent is 0x4190AB01?  If so then then using the CRC from that link the result is 0x277B.  Is this the answer you are looking for?  Show the LabVIEW code you've started with.  BTW I am not a VB master someone else might be able to help more there.  Also I'd recommend trying out several online CRC calculators to see if any of them get you the result you want, and then see if you can replicate it in LabVIEW.

0 Kudos
Message 2 of 4

many thanks. I've had a look at a number of the posts with implemented Vis already but not had any luck. turns out the post you linked to work when I changed the starting number outside the for loop from xFFFF to x0000.

I will try this when I next connect to my equipment to make sure its correct, but seems to work based on some of the example commands I have with the CRC already calculated for them.

0 Kudos
Message 3 of 4

@g_james wrote:

turns out the post you linked to work when I changed the starting number outside the for loop from xFFFF to x0000.

You should probably give that linked post a Kudo since it was so helpful.Smiley Wink

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4