LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

send a long integer in RS-232

Dear,
 
I am writing a code for motion controller and I am trying to send a 3D coordinate to the controller by RS-232.
The data type of a axis(totally 3) is long integer and I need to send it in "binary mode" after reversing bytes.(e.g. number=1/2/3/4byte->4/3/2/1byte)
 
Could you please check my code (see attachment) if there is a mistake?
Should I send the long integer by each bytes separately? (with 3*4=12 writing VISA)
(There is a checksum in the type of 2's comlement)
 
As my another question, how to calculate the checksum value if there is ".txt" file uploading, not definite data type?
 
Thank you in advance.
 
 

메시지가 10-18-2005 01:27 AM에 labmaster에 의해 편집되었음

메시지가 10-18-2005 01:28 AM에 labmaster에 의해 편집되었음

0 Kudos
Message 1 of 5
(9,040 Views)
The use of "byte array to string" is definitely incorrect, because the input is an array of U32. Each U32 would be reduced to a U8. Use typecast instead.
0 Kudos
Message 2 of 5
(9,025 Views)
Do you mean I should send the bytes separately or manipulate the long integer to U8?
Could you please how to manipulate it?
if not, How can I send the other bytes (2/3/4)?
 
Thank you.
0 Kudos
Message 3 of 5
(9,021 Views)
Looks like this
 
0 Kudos
Message 4 of 5
(9,007 Views)

After converting to U32, you need to reverse the bytes for each number. There are many ways to do this, one possibility is attached (LabVIEW 7.0). After that, you simply need to cast it to a string.

The attached example shows how to convert your input to a big or little endian string of 12 bytes. You probably want the little endian (LSB first), but please verify. LabVIEW is always big-endian, even on intel (which is typically little-endian).

0 Kudos
Message 5 of 5
(8,994 Views)