10-01-2015 03:46 PM
Greetings!
I've built an interface for a Sonotec bubble sensor.
There is a detail I have not been able to solve; calculating the CRC.
The manufacturer sent me a pair of examples in script based languages, Delphi and C for the CRC calculation. (see attached .txt files)
I've made an attempt at interpreting the two examples and creating LabVIEW code (See Calc Sonotec CRC.vi)
I've built a brute force method that increments the CRC from 0 - FF, while checking for any return bytes.
Some commands do not return a reply, so no clue as to when my "Guess the CRC" code works on these.
I thank anyone who takes interest in helping me out.
Mike
Solved! Go to Solution.
10-01-2015 09:08 PM
I'd ask for a VB6 script. Easier to understand.
10-02-2015 10:37 AM - edited 10-02-2015 10:37 AM
Hi Mike,
Have you tried importing the C code from the manufacturer as a DLL and running it in LabVIEW? More details on how to do so can be found here: http://zone.ni.com/reference/en-XX/help/371361F-01/TOC74.htm
Regards,
10-05-2015 12:52 PM
I'm using LabVIEW 2013 Service pack 1.
The CIN seems to have gone to be with the beep command
10-05-2015 01:09 PM
The C code doesn't look that hard to duplicate. I'm still on LabVIEW 2012; if you can save your VI back to that version, I'll take a look at making it match the C source.
10-05-2015 01:12 PM
Here it is in LV 2012
10-05-2015 01:24 PM
The two routines are confusing (to me), and don't seem to be saying the same thing. Maybe you can help. What is "the buffer" -- are you always given 3 bytes, of which the first is always FE, the second is something else, and the third will become the CRC? The Delphi code seems to suggest this, but the C code seems to have a fourth byte in there (but I'm unsure what PS means).
There are "standard" ways of computing CRCs -- do you know if one of these is being used?
Puzzled (a.k.a. BS)
10-05-2015 01:27 PM
This CRC is unlike any I've ever seen. It is proprietary to the sensor interface (Sonotec)
I've set up controls to allow for as few or as many bytes of data to be included, along with a reversed array.
I occasionally get a right answer (pure chance) for one message, but I never get the right CRC for more than one message
10-05-2015 01:31 PM
Four messages that I have working are as follows:
F1 00 06 32 00 1C (1C is the CRC)
F1 00 06 32 10 3C (3C = CRC)
F1 00 06 32 30 3C (3C = CRC)
F1 00 06 32 50 3C (3C = CRC)
10-05-2015 01:33 PM
The "Buffer" is the incoming array of bytes, a.k.a. the message