Calculating CRC 8 for MLX90614
Moderator: Benj
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Calculating CRC 8 for MLX90614
Hi
I am experimenting with the Melexis MLX90614 and have come to a point where i
need to change the I2c Address , in order to accomplish this I need to send the following data than 1 CRC Byte of All
data that has been sent .
Polynominal is : 100000111
0x00 - Address
0x2E - Address Register ( LSB Portion ONLY )
0x90 - LSB New Address Data
0x80 - MSB ( shuld be kept the same as it contains calibration values 0x80 is just an example )
0x?? - CRC 8 ( Result = 0x07 )
If i calculate the crc using the following websit it work fine ,but i wish to be able to calculate the
CRC Dynamically with flowcode .
Has anyone tried to accomplish something like this need some help
https://www.ghsi.de/CRC/index.php?Polyn ... e=002E9080
Thanks
I am experimenting with the Melexis MLX90614 and have come to a point where i
need to change the I2c Address , in order to accomplish this I need to send the following data than 1 CRC Byte of All
data that has been sent .
Polynominal is : 100000111
0x00 - Address
0x2E - Address Register ( LSB Portion ONLY )
0x90 - LSB New Address Data
0x80 - MSB ( shuld be kept the same as it contains calibration values 0x80 is just an example )
0x?? - CRC 8 ( Result = 0x07 )
If i calculate the crc using the following websit it work fine ,but i wish to be able to calculate the
CRC Dynamically with flowcode .
Has anyone tried to accomplish something like this need some help
https://www.ghsi.de/CRC/index.php?Polyn ... e=002E9080
Thanks
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi
Just find a very simple way around this , if i send a data whit wrong CRC the sensor will not acknowledge the CRC byte
so what have done is a counter from 0 to 255 converted to hex and send as CRC byte , sort of Brut forcing the CRC
when the sensor acknowledge the CRC byte i know that the right CRC byte is reached and the new Address is
successfully written
It definitely takes more time than it should but it Works
Just find a very simple way around this , if i send a data whit wrong CRC the sensor will not acknowledge the CRC byte
so what have done is a counter from 0 to 255 converted to hex and send as CRC byte , sort of Brut forcing the CRC
when the sensor acknowledge the CRC byte i know that the right CRC byte is reached and the new Address is
successfully written
It definitely takes more time than it should but it Works
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Alan,
That's a new CRC calculation on me. I've put together an example which seems to work, not promising this is the most elegant way of doing it or that it will work in all cases but seems to be working.
That's a new CRC calculation on me. I've put together an example which seems to work, not promising this is the most elegant way of doing it or that it will work in all cases but seems to be working.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
Just gave a try to the fcfx file but the output dose not seem to match whit that of the website when i change the input data
This may be more tricky than it seems .
I found the following code for Arduino but dont now how to convert it from the following website I am also attaching
a very informative PDF File .
http://stackoverflow.com/questions/2055 ... o-mlx90614
byte c8( byte x ){
for( byte i = 8; i--; ) {
x = ( x << 1 ) ^ ( x & 128 ? 7 : 0 );
}
return x;
Just gave a try to the fcfx file but the output dose not seem to match whit that of the website when i change the input data
This may be more tricky than it seems .
I found the following code for Arduino but dont now how to convert it from the following website I am also attaching
a very informative PDF File .
http://stackoverflow.com/questions/2055 ... o-mlx90614
byte c8( byte x ){
for( byte i = 8; i--; ) {
x = ( x << 1 ) ^ ( x & 128 ? 7 : 0 );
}
return x;
- Attachments
-
- 20_crc-8_firmware_implementations.pdf
- (58.9 KiB) Downloaded 297 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Calculating CRC 8 for MLX90614
This seems to work but again could be a fluke. Yep pretty sure it's not right as there is no summation of CRC from byte to byte.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
Yes you are right it dose not work but it's OK , I managed with the Brut force method
it works quit well .
Thanks for your time
Yes you are right it dose not work but it's OK , I managed with the Brut force method
it works quit well .
Thanks for your time
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Alan,
I think we are close, I just need to know how the CRC value is summed from byte to byte. Simply adding the output value together does not work. I'll have a quick hunt about and see if anything becomes clearer.
I think we are close, I just need to know how the CRC value is summed from byte to byte. Simply adding the output value together does not work. I'll have a quick hunt about and see if anything becomes clearer.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
In the calculator website it explains what happens to the process
So the polynomial defines the sum 100000111 = P(x) = x8+ x2+ x1+ x0
and with this data as input : 002E9080 the following bindery is somehow calculated
00000000 is the initial CRC value (hide details)
Next hex digit [0]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Next hex digit [0]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Next hex digit [2]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [1] results in 00000111
Shift in of [0] results in 00001110
Next hex digit [E]:
Shift in of [1] results in 00011011
Shift in of [1] results in 00110001
Shift in of [1] results in 01100101
Shift in of [0] results in 11001010
Next hex digit [9]:
Shift in of [1] results in 10010100
Shift in of [0] results in 00101111
Shift in of [0] results in 01011110
Shift in of [1] results in 10111011
Next hex digit [0]:
Shift in of [0] results in 01110001
Shift in of [0] results in 11100010
Shift in of [0] results in 11000011
Shift in of [0] results in 10000001
Next hex digit [8]:
Shift in of [1] results in 00000010
Shift in of [0] results in 00000100
Shift in of [0] results in 00001000
Shift in of [0] results in 00010000
Next hex digit [0]:
Shift in of [0] results in 00100000
Shift in of [0] results in 01000000
Shift in of [0] results in 10000000
Shift in of [0] results in 00000111
$ 7 (hexadecimal)
% 00000111 (binary)
! 7 (decimal)
https://www.ghsi.de/CRC/indexDetails.ph ... e=002E9080
In the calculator website it explains what happens to the process
So the polynomial defines the sum 100000111 = P(x) = x8+ x2+ x1+ x0
and with this data as input : 002E9080 the following bindery is somehow calculated
00000000 is the initial CRC value (hide details)
Next hex digit [0]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Next hex digit [0]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Next hex digit [2]:
Shift in of [0] results in 00000000
Shift in of [0] results in 00000000
Shift in of [1] results in 00000111
Shift in of [0] results in 00001110
Next hex digit [E]:
Shift in of [1] results in 00011011
Shift in of [1] results in 00110001
Shift in of [1] results in 01100101
Shift in of [0] results in 11001010
Next hex digit [9]:
Shift in of [1] results in 10010100
Shift in of [0] results in 00101111
Shift in of [0] results in 01011110
Shift in of [1] results in 10111011
Next hex digit [0]:
Shift in of [0] results in 01110001
Shift in of [0] results in 11100010
Shift in of [0] results in 11000011
Shift in of [0] results in 10000001
Next hex digit [8]:
Shift in of [1] results in 00000010
Shift in of [0] results in 00000100
Shift in of [0] results in 00001000
Shift in of [0] results in 00010000
Next hex digit [0]:
Shift in of [0] results in 00100000
Shift in of [0] results in 01000000
Shift in of [0] results in 10000000
Shift in of [0] results in 00000111
$ 7 (hexadecimal)
% 00000111 (binary)
! 7 (decimal)
https://www.ghsi.de/CRC/indexDetails.ph ... e=002E9080
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
If you succeed in calculating the CRC and you can make the polynominal as an input variable
well that could be a nice new component for flowcode CRC8 calculator .
If you succeed in calculating the CRC and you can make the polynominal as an input variable
well that could be a nice new component for flowcode CRC8 calculator .
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Alan,
I've cracked it, confirmed with a few series of values.
A component would be great but I would need to figure out a few more bits regarding the variable polynomial.
Anyway this code seems to work and should allow your code to function without resorting to brute force.
I've cracked it, confirmed with a few series of values.
A component would be great but I would need to figure out a few more bits regarding the variable polynomial.
Anyway this code seems to work and should allow your code to function without resorting to brute force.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
Yes that works 100% well done , this will be a lot faster than the brut force method
Thanks again , and keep up the good work
Yes that works 100% well done , this will be a lot faster than the brut force method
Thanks again , and keep up the good work
- Alan_37
- Posts: 179
- Joined: Sun May 01, 2016 8:36 pm
- Has thanked: 51 times
- Been thanked: 54 times
- Contact:
Re: Calculating CRC 8 for MLX90614
Hi Ben
I have modified your code a bit now the Macro can take a Hex String as an input Example "01220A"
Hex values in the input String must have 2 characters if they are lower than 0x10 a 0 must be added at the beginning .
The Macro will .Return the result as decimal
Maybe this will make it a bit more easy to create a component
Thanks .
I have modified your code a bit now the Macro can take a Hex String as an input Example "01220A"
Hex values in the input String must have 2 characters if they are lower than 0x10 a 0 must be added at the beginning .
The Macro will .Return the result as decimal
Maybe this will make it a bit more easy to create a component
Thanks .
- Attachments
-
- CRC_Calc_v2.fcfx
- (13.83 KiB) Downloaded 248 times