LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Real Time Data from the Serial Port

I have a device connected to the serial port in which i send a simple command to. The device returns 4 pair of hex bytes,(each pair of hex bytes is a 16 bit number)every .5 seconds. How can i get these values to be read from the serial port as they are returned every .5 seconds? Ultimately i want to view the returned results on a graph as they are returned.
0 Kudos
Message 1 of 3
(2,883 Views)
Use a loop with serial read inside it. Wire 8 into Bytes to read. Whenever 8 bytes arrive in the serial buffer the buffer will return with them. Use String to Byte Array to recieve an array with 8 values and you can bundle them into a chart or a graph.
You can use the example finder (Help>>Find Examples) to find examples for serial communication and for multiplot graphs.

To learn more, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here is one you can start with and here is another. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,872 Views)
To add to what tst said, since you are expecting two bytes to make a 16 bit number, you have to combine these two bytes to make the 16 bit number. Just wiring the byte array will produce 8 values of 8-bit numbers. You can use the join numbers function (Functions - Advanced - Data Manipulation - Join Numbers) to combine two bytes from the array into one 16-bit number. You would have to index the array to get bytes 1 and 2 to join, then bytes 3 and 4 to join, etc... Or you could use Type Cast on the incoming string to convert to an array of U16. See attached vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 3
(2,867 Views)