
Computer Interfacing Discussions about interfacing and electronics


URGENT HELP Rev. Engineering on crc polynomial
need to know CRC polynomial IEC standards used here

Author 
Message 
chetan.bitsgoa New User
Joined: 17 Nov 2011 Posts: 1

Nov 17, 2011 6:52 am 


Hi everyone i am Chetanya presently studying in last year, doing research in which the fieldbus device is used. I need to find the crc polynomial or algorithms related to it. Though the crc generator polynomial is given in data sheet but there is a separate algorithm attach with it
the CRC generator polynomial is G(x)=
X^16 + X^12 + X^11 + X^10 + X^8 + X^7 + X^6 + X^3 + X^2 + X^1 + 1
the L(x)=X^15 + X^14
+ X^13 + X^12 + … + X^2 + X^1 + 1
where K is number of data bits sent eg. 8 bits when 34 is sent
and nk is size of generator polynomial i.e 16 here
The FCS is F(X)= [L(X)(X^k + 1) + M(X)(X^(nk))]modulo (G(x)) // this is the algorithm attached as given in IEC 1158 standards
I am trying this for for past 1 month and the sample data is
[b]
1. 34h FCS of which is AF21 and it is coming out correct according to this algorithm
2. 01 10 FCS of which is 57 E0 which is also coming out correct according to this algorithm
3. 32 10 00 E3 FCS of which is 7E 82 and is not coming out correct according to this concept
4. 33 10 00 E3 FCS of which is 2A 0F and is again not coming out properly
5. 26 11 01 00 00 08 0A 10 has FCS 97 39 which i have not checked.[/b]
This fieldbus device follows IEC1158 standards
Please Help regarding the validity of this algorithm with respect to the data+FCS pairs given above.
Thank you 

Gammatester Guest

Nov 17, 2011 7:43 am 


I am not sure what your problem/question is. The polynomial X^16 + X^12 + X^11 + X^10 + X^8 + X^7 + X^6 + X^3 + X^2 + X^1 + 1 is written as a 16 bit integer hex value 1dcf; and your data
Code:  DATA CRC
321000E3 7E82
0110 57E0
2611010000080A10 9739
 is compatible with the Rocksoft parameter set found be SRP16 Code:  ===== Result parameter sets =====
CRC=$7e82 Poly=$1dcf init=$ffff xorout=$ffff refin=false refout=false
*** Second data set verified
*** Third data set verified
===== done =====



Guest

Nov 20, 2011 9:41 am 


Thank you very much
i am new to crc calculations and algebra
and i am developing new hardware for this algorithm
when i was trying to do it manually the crc of the first two was coming right but the three were incorrect.
Can yu please tell me what exactly init and xorout do and can u verify those two readings too.
btw what is the software you are using.
Thank you 

Gammatester Guest

Nov 20, 2011 12:24 pm 


The init and xorout values are used for pre and postconditioning the CRC calculation (see below). The definitive reference is the text by Ross Williams: A Painless Guide to CRC Error Detection Algorithms, where he defines the Rocksoft model, you should search the web and read it.
SRP16 is an opensource Pascal program to Search Rocksoft Parameters for 16 bit CRC. To get it search the web for SRP16 chksum_bin_20101219.
Here is a simple C program that implements the CRC16 calculation with the found parameters and reproduces the CRCs for your five test cases:
Code: 
//
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
static uint16_t CRC16_Unknown(uint8_t *data, size_t len) {
uint16_t crc = 0xFFFF; //init value
size_t j;
int i;
for (j=len; j>0; j) {
crc ^= (uint16_t)(*data++) << 8;
for (i=0; i<8; i++) {
if (crc & 0x8000) crc = (crc<<1) ^ 0x1DCF;
else crc <<= 1;
}
}
return (crc ^ 0xFFFF); //xorout value
}
int main() {
uint8_t test[9] = {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
uint8_t test1[] = {0x34};
uint8_t test2[] = {0x01,0x10};
uint8_t test3[] = {0x32,0x10,0x00,0xE3};
uint8_t test4[] = {0x33,0x10,0x00,0xE3};
uint8_t test5[] = {0x26,0x11,0x01,0x00,0x00,0x08,0x0A,0x10};
uint16_t crc;
crc = CRC16_Unknown(test, 9);
printf("Rocksoft check value: 0x%04X, test ", crc);
if (crc==0xA819) printf("passed.\n"); else printf("failed!\n");
crc = CRC16_Unknown(test1, sizeof(test1));
printf("CRC test 1: 0x%04X\n", crc);
crc = CRC16_Unknown(test2, sizeof(test2));
printf("CRC test 2: 0x%04X\n", crc);
crc = CRC16_Unknown(test3, sizeof(test3));
printf("CRC test 3: 0x%04X\n", crc);
crc = CRC16_Unknown(test4, sizeof(test4));
printf("CRC test 4: 0x%04X\n", crc);
crc = CRC16_Unknown(test5, sizeof(test5));
printf("CRC test 5: 0x%04X\n", crc);
return 0;
}
C:\TMP>gcc unk_crc.c o unk_crc.exe
C:\TMP>unk_crc
Rocksoft check value: 0xA819, test passed.
CRC test 1: 0xAF21
CRC test 2: 0x57E0
CRC test 3: 0x7E82
CRC test 4: 0x2A0F
CRC test 5: 0x9739



guest Guest

Nov 20, 2011 3:31 pm 


Thank you 

Running on php BB © 2001, 2009 php BB Group
