LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

checksum calulation

Solved!
Go to solution

Hi Everyone in the Forum,

 

I have an instrument hwich is used to measure some gas concentartion that outputs a serial message that looks like this

 

2007-03-12 11:37:14 MDT,0x00000001,NH3,0.46,0.00,ppmm,21%,5.0,11,0,0,0

 or

 

2007-03-12 11:37:22 MDT,0x00000001,NH3,0.41,0.00,ppmm,21%,5.0,11,0,0,0

 

I parse some of these characters, convert to numbers and plotthem in real time. For example the 21% is signal strength which I have to plot in real time using labview. Now sometime the instrumnet does not output the whole string completely, and maybe misses half the line. I would like to perfrom a position sensitive checksum on teh string to make sure it is complete and correct and of not reject that line. I tried to use CRC16 but everytime it gives me a 4 digits and characters such as e.g, F415 or soemtimes only digits e.g 7014, I DO NOT KNOW HOW TO INTERPRET THESE CHARACTERS. Appreciate if anybody can give me a hint or tell me how to use the checkum ( or which one) to reject imcomplete strings.

 

0 Kudos
Message 1 of 7
(3,300 Views)
Solution
Accepted by topic author Robert Mani

A CRC is only useful to verify a transmision was succesful.  It works just like a parity.  It needs to be added to the message by the sender and then verified by the receiver.  So in short, the CRC is not going to help you here.  It appears that the data is separated by commas.  Maybe you can count how many commas are in the message to verify you have all of the message parameters.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(3,296 Views)

Thanks. Counting commas may work. I will give it a try.

0 Kudos
Message 3 of 7
(3,291 Views)

I would look into why you are not getting the entire response.

 

Is there some handshaking problem?

 

Are you no allowing enought time for the instrument to respond?

 

etc. etc.

 

Anything else is a kludge which masks the real problem.

 

 

0 Kudos
Message 4 of 7
(3,278 Views)

I am afraid I have no control of how the instrument is outputting the serial string. There is a fixed integartion time and at that interval it outputs this string. Every once in a while ( maybe after every 10 to 20) at irregular intervals, an incomplete string comes out. Ideally I should send it back to he manufacturer but I am getting it ready for  field testing in near future and needed a  quick fix. I am positive the method of counting commas would work for now. Thanks for your thoughts anyways.. 

0 Kudos
Message 5 of 7
(3,275 Views)

I was thinking about this as well.  The counting of commas is really a kludge.  I was curious if the device has a termination character at the end of a message.  If it does, then you can setup the port to automatically look to that termination character.  The other simple option might be to simply wait a little bit longer.  Serial ports are slow after all.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 7
(3,268 Views)

Instead of counting commas use the spreadsheet string to array function with comma as separator. You can then do the validation on the resulting array size and if the size is correct use index array to get the value of interest.

 

Ben64

Message 7 of 7
(3,265 Views)