LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Computing CRC

Highlighted

I found this VI in another thread in this forum. It is supposed to compute CRC:s for strings, but I'm not sure it works.

 

The lower indata, labeled "CRC16" is a constant set to zero. It is operated with something else that is essentially a constant. As far as I can see, much of the lower half of this VI could be replaced by a single constant. The CRC-polynomial is entered at a different place, further to the right.

Message 1 of 17
(5,903 Views)
Highlighted

The constant does change as it goes through the loop.  The shift registers allow the value to change and be passed to the next iteration.  Now, the CRC calculated in that VI is close to a CRC-CCITT, but I believe the initial value should be 0xFFFF and the author is using 0x0000.  But even if I specify 0xFFFF, his program doesn't appear to give the correct CRC-CCITT.

 

There are a multitude of CRC-16 methods, so you need to figure out which you have.  The attached ZIP file has the code I wrote 5 years ago for a CRC calculation for a customer.  I found only 1 place on the web that had a "correct" CRC algorithm that could calculate all the examples I found.  The code needs to be cleaned up some (I have controls on the inside of case statements), but it should get you started.  Below the case statement is some processor code the VI is based off of. You can use the selector to set a standard CRC or specify your own.

Message 2 of 17
(5,901 Views)
Highlighted
What does it mean to reflect the CRC?
0 Kudos
Message 3 of 17
(5,893 Views)
Highlighted
Basically, it's flips the bits (going from MSB to LSB).  So b10101010 would become b01010101 for an 8 bit reflection.
0 Kudos
Message 4 of 17
(5,890 Views)
Highlighted

I have this LLB in my tool box. Picked it up from internett some years ago. I have used the 8 bit CRC. And it works. I have not checked the 16 and 32 bit. If it is of some help use it ;).



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 5 of 17
(5,890 Views)
Highlighted

Do you know why it enters the polynomial in an array, sometimes with several values?

 

And by the way, in case anyone wonders, the one I'm looking for is the 16 bit CRC-CCITT.

0 Kudos
Message 6 of 17
(5,876 Views)
Highlighted
Try this one. I have it in my archive. BUT I have never used it or testet it. Source unknown. Some non warez site on the internettSmiley Very Happy so it should be safe


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 17
(5,867 Views)
Highlighted

Still, it leaves me with questions;

 

0*2^1 = 0

1000 0000 AND 0000 0000 = 0000 0000

 

This means the lower right corner could be replaced by a constant, zero, and that the second case structure is completely unnecessary, since the invalue will always be true. Should perhaps the for-index be involved somewhere here?

0 Kudos
Message 8 of 17
(5,847 Views)
Highlighted
All the examples I've seen so far goes through an eight cycle for loop. How is this coherent with a 16 bit polynomial?
0 Kudos
Message 9 of 17
(5,813 Views)
Highlighted
Matthew K: What is 'order' and 'Data array' in your VI?
0 Kudos
Message 10 of 17
(5,632 Views)