This widget could not be displayed.
This widget could not be displayed.

LabVIEW

This widget could not be displayed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Checksum (4 characters)

Solved!
Go to solution

Hello everyone,

I have a serial device with a message-based communication, where it's used 4-characters checksum at the end of message (command).

 

For example command: "START " (space is included at the end),

in ASCII: "83 84 65 82 84 32",

so the sum is: "430",

this decimal in hexadecimal (4-characters) is: "01AE",

and the desired message is: "START 01AE".

 

So I tryed this with String To Byte Array and Add Array Elements, but result is only "AE" and I didn't find any solution for fix it.

 

Thanks in advance for your help.

 

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
0 Kudos
Message 1 of 9
(5,981 Views)

Hi,

Convert your decimal number to an array of bytes, then use the "Byte array to string" function.

Regards

 

 

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Message 2 of 9
(5,973 Views)

You should cast the byte numbers to a 16bit number before adding them.

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Message 3 of 9
(5,972 Views)

checksum.png

 

convert to U16 , sum, split number, add to array    and finally convert to string and send to VISA 🙂

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Message 4 of 9
(5,958 Views)

Meanwhile, I came to this solution.

 

progress.png

 

As with your solution, I still get: "START  ®" But we are close. Smiley Wink

The correct output should be this string: "START 01AE". Any idea how to prevent conversion checksum from HEX to ASCII at Concatenate Strings?

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
0 Kudos
Message 5 of 9
(5,939 Views)

Using the format into string 🙂

 

 

 

checksum2.png

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Message 6 of 9
(5,933 Views)

Great, you are really fast. Thanks a lot! Smiley Happy Last think is Use minimum field width (for checksum part) with 4 characters pad with zeros on left.

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
0 Kudos
Message 7 of 9
(5,924 Views)

You have been to fast 😉 I had edited my solution

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
0 Kudos
Message 8 of 9
(5,921 Views)

Thank you again, this completely solve my problem. Have a nice day.

 

Greeatings from Czech Republic,

Martin Wolker

This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
0 Kudos
Message 9 of 9
(5,913 Views)