From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial port data parsing and ploting

Need help handling serial data from a Cypress PSoC in Labview. I'm able to read the data from the searial port, but I need help parsing it and deciding what characters to append to the ADC sample data for transmission. Currently each sample from the chip's ADC is sent as text to the serial port. Each data sample is appended with "h/r" to represent that the data sample is in hex format and "/r" for a carriage return. These appended characters were suggested from an example project. I'm using: rate=9600, data bits=8, parity=none,stop bits=1, flow control=none.

 

An example string from the serial port could look like this:  "0001h/r0002h/r0003h/r" and represents dec values of 1, 2, and 3.

 

My problems:

 

1. How do I parse the data correctly so that I can display and save it to a file?

2. How do I handle strings that have incomplete data samples as shown in the attached figure? For example, the string can begin and/or end with an incomplete sample:  "1h/r0002h/r0003h/r00".

3. Why is my data string ending and/or begining with incomplete data sample?

 

Attached are a screenshot and the VI.

Download All
0 Kudos
Message 1 of 5
(3,428 Views)

Hi,

 

For your first problem see the attached vi.For 2nd you can put some logic to find the incomplete data.for 3rd see if it is displaying some previous data initially or have you specified the number of bytes to read correctly.

 

Hope this helps you.

0 Kudos
Message 2 of 5
(3,413 Views)

I'm not able to open it. I think it's because i'm using Labview v2010 and this seems to be v2011. At least that what the error seems to be saying.

0 Kudos
Message 3 of 5
(3,398 Views)

Your error goes back to what you have programmed the serial device. What I am sure someone recomended is appending a \r - not a /r and the actual control code (x0D) not separate characters \ and r like you have now. You would then set the termination character to 0D for the VISA Configure Serial Port.

 

If you then set the number of bytes to read to 6, you would get a complete packet everytime except for the first read. You are reading asynchronously to the transmit so there is no way around that. Simply discard the read if the actual number of bytes is not correct.

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

Hi,

 

Here it is in lower version.Let us known does it solves your issue.

 

0 Kudos
Message 5 of 5
(3,366 Views)