Communication Toolbox General CRC Generator

4 次查看(过去 30 天)
Hello,
I would like to use the General CRC Generator block to generate a CRC16 ANSI.
  1. It appears that the block is expecting binary input for the message but I am working with messages assembled from uint8 (1 byte). I did not think that binary is a data type in Simulink. How would I manage this?
  2. How do I set the block for CRC16 ANSI? Anything else other than specifying the polynomial: ?
Any guidance would be appreciated.
Thank you.

回答(2 个)

Ajay Pattassery
Ajay Pattassery 2019-8-5
Since your data is an array of integers and the General CRC Generator block expects binary, you could use an integer to bit converter block. You can refer to the following link: Integer to bit
You can set the generator polynomial parameter field to CRC 16 by any of these following ways.
  1. As a polynomial character vector as z^16 + z^15 + z^2 + 1 as you specified.
  2. As a binary row vector containing the coefficients in descending order of powers.For example, for a polynomialx3+x2+ 1 is represents as [1 1 0 1]
  3. As an integer row vector containing the powers of nonzero terms in the polynomial, in descending order. For example, [3 2 0] represents the polynomial x3 + x2 + 1

Wess Gates
Wess Gates 2019-8-5
Hi Ajay,
Thank you for the response. I understand the polynomial part of the block.
  1. I am unclear on the other options i.e. is entering the polynomial alone sufficient for CRC ANSI16 or do the other block options need setting?
  2. Is there a reference for the various types of CRC and their link to the block options such as "Reflect Input Bytes" or "Reflect Checksums..."? The Matlab documentation describes these in general but not specifcially to any CRC type.
  3. What is the workflow for calculating CRC on types other than integers? For example I need my inputs to be "float" types as part of the final message that I am sending to my actuator. Seems like the "integer to bit convertor" is strictly "integer"....
Thank you.
  1 个评论
Ajay Pattassery
Ajay Pattassery 2019-8-6
Hello Wess,
  1. Yes. Just defining the corresponding polynomial is enough for setting CRC ANSI16.
  2. https://www.mathworks.com/help/comm/ref/comm.crcgenerator-system-object.html you could refer the MATLAB implementation for more details.
  3. Unfortunately, there is no built-in block to convert from float to binary in Simulink as of now. You have to create a custom block to accomplish the same. You could refer to the following link for a similar implementation.https://www.mathworks.com/matlabcentral/fileexchange/39113-floating-point-number-conversion (Please keep in mind that this is a 3rd party implementation and may not be tested for all the cases.)

请先登录,再进行评论。

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by