Jump to content

CRC 8 bit


malkowki

Recommended Posts

Dear I would like to translate my HW (see picture) into labview code.

It is in fact a CRC check based on the polynomial x^8+x^2+x+1.

I need to calculate the CRC 8 bits for a 56 bit word, so my total word to be send via an SPI will be 64 bits long.

I don't have any C code since I am not familiar with this language, I would like rather a LV solution.

Is there anybody familiar with the CRC generation via LV?

Any help will be welcome so I can solve my issue. :(

thanks in advance dears!

Regards, ;)

Link to comment

QUOTE(malkowki @ Feb 12 2008, 10:26 AM)

Dear I would like to translate my HW (see picture) into labview code.

It is in fact a CRC check based on the polynomial x^8+x^2+x+1.

I need to calculate the CRC 8 bits for a 56 bit word, so my total word to be send via an SPI will be 64 bits long.

I don't have any C code since I am not familiar with this language, I would like rather a LV solution.

Is there anybody familiar with the CRC generation via LV?

Any help will be welcome so I can solve my issue. :(

thanks in advance dears!

Regards, ;)

Hi malkowki,

The VI in attachment would help to solve your issue... :)

It calculate the CRC-16 x.25 standard CRC, but you can modify it to calculate any other CRC simply changing the loops and the binary word inside the inner loop.

The actual binary word (0001000000100001) stands for x^16+x^12+x^5+1... in your case the binary will be 00000111.

Don't forget to change the dimension from U16 to U8.

The VI can be used also to verify the CRC.

Best Regards ;)

Osvaldo

  • Like 1
Link to comment

QUOTE(osvaldo @ Feb 13 2008, 11:16 AM)

Hi malkowki,

The VI in attachment would help to solve your issue... :)

It calculate the CRC-16 x.25 standard CRC, but you can modify it to calculate any other CRC simply changing the loops and the binary word inside the inner loop.

The actual binary word (0001000000100001) stands for x^16+x^12+x^5+1... in your case the binary will be 00000111.

Don't forget to change the dimension from U16 to U8.

The VI can be used also to verify the CRC.

Best Regards ;)

Osvaldo

Thanks for your help.what do you mean by changing the loops?can you explain in more details?

best regards,

Link to comment
Link to comment

QUOTE(osvaldo @ Feb 13 2008, 03:02 PM)

Ok... a bit more in detail...

The VI get in input a string which is converted in an array of byte and than in a stream of byte by the outmost for loop.

The inner for loop take a byte a time from the stream and convert it in a stream of bit using the "Rotate left with carry" function.

The other code in the inner loop implements the function performed by the logic circuit shown from your first post: the bits in the accumulator are shifted and XOr-ed with he polynomial only when the MSB is "1"; this code is the software version of your diagram (note the logic XOr on the bit corresponding to the power of x where the coefficient is 1 in the polynomial).

To calculate the 8-bit CRC, the costant "0" that initialize the accumulator shift register must be an U8 type (now is U16), and the costant in the inner for loop must be a byte (now a word) with the binary costant 00000111, that is your polynomial.

Of course, the result will be a byte, therefore only 1 byte must concatenated to the input and to the output strings.

The initial value of the U8 costant that initialize the shift register can be different from 0; in some cases, it is equal to FF. This affect the result and you must verify which is the correct value in your application.

For more informations you can try on http://en.wikipedia.org/wiki/Cyclic_redundancy_check.

Regards

Osvaldo

Osvaldo,

thanks to have taken your time to help me.The CRC check was for me unclear unless you have explained me how it works.

I could implement this Vi in my application and it works! :beer:

:thumbup:

Best regards,

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.