LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS-232 binary operation

Dear all,
 
I am a researcher with commercial instrument.
After communication with my technician, I got to know I have to do binary operation in RS-232.
But I am not familiar with the binary operation.
Could you please give me some guidance to write codes in  LabView 6 or 7?
 
I attah a part of the manual.
 
*)please let me explain the meaning of the parameters.
Host → Ecotec II: 5(start the communication), 5(length of the command, 5 bits),
3 (RS-232 functional command), 0(parameter of the command), 13(checksum, 5+5+3+0).
 
Very thank you for your attention.
Any comments will be very helpful to me.
 
0 Kudos
Message 1 of 5
(4,335 Views)

In binary representation, each number between 0 and 255 (a byte) gets a character assigned to it. You can send these characters as a string through the serial port. The conversion from numbers to a string is shown in the attached image. These VIs can be found in the String, Numeric and Array palletes.

One important point is that numbers consisting of more than one byte have a specific order in which the bytes are split (In this case, the low byte is first). You can use the Split Number VI from the Advanced>>Data Manipulation palette to get the high and low bytes.

Also, please don't save images as bitmaps. If you saved it as a GIF or JPG, it would taken no more than a few KB.


___________________
Try to take over the world!
0 Kudos
Message 2 of 5
(4,319 Views)

 

Thanks, tst

I have more questions about binary operation.

I was told there is no a termination character in binary opeartion.

1. How identify the instrument the termination of a command?

2. What is the size of the buffer I've read in this case?, I mean "5 5 0 3 13" for the replied message from the instrument.

3. In order to identify the meaning of the replied message, should I  use "String to Byte array"?

   -> In this case, it need to use some CASE routine to match the numerical value to the meaningful status of the instrument.

   -> Is there some convenient or simple idea for these complicated cases?

 Thank you for your attention again.

Lee

*)How to remove my question I posted incorrectly?.

0 Kudos
Message 3 of 5
(4,294 Views)

1. How identify the instrument the termination of a command?
I'm not sure, but if you have an opening character, followed by the length of the message, you can read a single byte and once it arrives, read the next one to know how many are left.


2. What is the size of the buffer I've read in this case?, I mean "5 5 0 3 13" for the replied message from the instrument.

The size is 5 bytes (the second number) because 13 is also a single character. It's important to remember that 5 is the number 5 (ASCII value 5) and not the character "5" (ASCII value 53 decimal).


3. In order to identify the meaning of the replied message, should I  use "String to Byte array"?

Yes. Then, like you said, you will need to use the data to decide how to proceed. The decision should be made based on the protocol. For example, if the opening number is always 5, you have to wait until receiving it before continuing. If you want to verify the command, you need to do the checksum on the data you received and if it doesn't match the sent checksum, ignore it.


*)How to remove my question I posted incorrectly?.

There is no need to.


___________________
Try to take over the world!
Message 4 of 5
(4,276 Views)

Very thank you, tst.

I will post if I have more problem.

Thank again.

Lee

0 Kudos
Message 5 of 5
(4,264 Views)