LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transceiving long numbers using RS232

Solved!
Go to solution

I'm trying to learn labview. I have been able to do serial communication based on basic read write example. I can send single byte. Actually I'm only reading from serial port within labview. What I need to do is receiving 4 bytes and combine them as a single 32 bit integer. I'm setting read buffer as 4. I have basically 2 problems:

1- Since the sender and the receiver(labview) does not begin communication at the same time there is a sync problem. The incoming bytes are not in order (LSB and MSBs may not be in the right place)

2- I should interpret the coming characters as numbers and combine 4 of them into a single number and do it in the right order, and then do it continuously and then store them in an array.

 

Can you give me some tips. Is there an easy way to do this?

 

Note:I'll also send the same integer back in the future. Sending a 32 bit number to the port idea is also appreciated.

 

Thanks.

0 Kudos
Message 1 of 4
(2,787 Views)

What device are you communicating with? Can you be a bit more specific with the your hardware?

0 Kudos
Message 2 of 4
(2,776 Views)

Hi, I'm using an mcu to send the data to the pc(labview). I can modify the sent data if required.

0 Kudos
Message 3 of 4
(2,762 Views)
Solution
Accepted by topic author kartuba

Since you have control of the protocol, you can handle this however you want.  I would recommend using a command/response type of communication.  You send a command to the microcontroller and the microcontroller sends the data back.  If you need to stream data, then have a Start Stream command and a Stop Stream command.  This way you can make sure the serial buffers are clear and you can read the data properly.

 

Now the serial drivers (I assume you are using VISA) send strings.  So what you will want to do is use the Flatten To String and Unflatten From String to convert the data type back an forth.



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 4 of 4
(2,755 Views)