LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

corrupted serial data when reading

Hello Friends

 

Im working on a project that read a string through the serial port from a flow meter.

 

the string that the flow meter sends has this pattern. its a comma separated string:


0021,00029504,00032622,0115,0,0,00000000,00000006,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:48,12/04/12,2110,00000000,0


 

i already proccesed the data with this VI (please fell free to give me any suggestions Smiley Happy ). Please see 1.jpg

 

I am having the following issue. when receving data from serial, several strings show up corrupted. please see good.jpg and bad.jpg. i have tried to read the serial data on hyperterminal, and all strings show up ok.

 

i will appreciate any suggestions and advises on how to fix this!

 

thanks in advance

 

 

 

Download All
0 Kudos
Message 1 of 17
(3,648 Views)
Don't have the VISA Initialize Serial Port inside the loop. It is also not a good idea to use the VISA Bytes at Serial Port when you configure the serial port to use a termination character on the read. The wait served no purpose. Just request some large byte count.
0 Kudos
Message 2 of 17
(3,641 Views)

Double check your parity and stop bit settings.

0 Kudos
Message 3 of 17
(3,639 Views)

Hi moreins1,

                                 Friend this is serial communication. you can't parallely read & close the VISA. If the number of byte to be read from serial communication is fixed than close the VISA after each read operation & repeat the while loop in 1 or 2 sec delay. In while loop open read & later close. this will work perfectly.

 


Thats why your data is corrupted.

 

Thanks,

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 17
(3,625 Views)

As others have said, initialize your serial port once before your main loop.  You should then close the port once the main loop is complete (which you are already doing).

 

When I've seen this kind of corruption, it is usually a bad baud rate.  Reinitializing your port each loop could be causing that issue.

 

It doesn't look like you really have a termination character, so turn that off (part of the serial port setup VI).


GCentral
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
Message 5 of 17
(3,613 Views)
Ranjeet,

You must be looking at a different VI since the posted one does not read and close in parallel. The wait you mention is not based on any knowledge of the serial device and is probably not required if the device sends a termination chaeacter. And, do NOT open and close inside the loop.
0 Kudos
Message 6 of 17
(3,611 Views)

hello people.

 

thanks a lot for all your suggestions. im working right now on this.

will let you know anything

 

rgds

0 Kudos
Message 7 of 17
(3,581 Views)

hello

 

actually, i have one more question.

 

this is the data viewer i have on my vi. it shows each data string that my serial device is sending. this string will change 10 times in a second. this is OK. right now, its showing 1 string at a time:

 

 


0021,00029504,00030816,0110,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2173,00000000,0


 

 

 

 

what i want now is to actually append all this data in the viewer so i can copy and pasted it to notepad. i would like it to show like this:

 


0021,00029504,00030816,0110,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2173,00000000,0
0021,00029504,00031123,0107,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2174,00000000,0
0021,00029504,00030948,0104,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2175,00000000,0
0021,00029504,00030866,0103,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2176,00000000,0
0021,00029504,00030903,0105,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2177,00000000,0
0021,00029504,00030888,0105,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2178,00000000,0
0021,00029504,00030836,0104,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2179,00000000,0
0021,00029504,00030545,0095,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2180,00000000,0

and so on.........


 

 

Can you please advise on how to do this without actually monkeying around with the VISA inicialize?

 

thanks!

0 Kudos
Message 8 of 17
(3,580 Views)

@moreins1 wrote:

hello

 

actually, i have one more question.

 

this is the data viewer i have on my vi. it shows each data string that my serial device is sending. this string will change 10 times in a second. this is OK. right now, its showing 1 string at a time:

 

 


0021,00029504,00030816,0110,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2173,00000000,0


 

 

 

 

what i want now is to actually append all this data in the viewer so i can copy and pasted it to notepad. i would like it to show like this:

 


0021,00029504,00030816,0110,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2173,00000000,0
0021,00029504,00031123,0107,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2174,00000000,0
0021,00029504,00030948,0104,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:54,12/04/12,2175,00000000,0
0021,00029504,00030866,0103,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2176,00000000,0
0021,00029504,00030903,0105,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2177,00000000,0
0021,00029504,00030888,0105,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2178,00000000,0
0021,00029504,00030836,0104,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2179,00000000,0
0021,00029504,00030545,0095,0,0,00000000,00000009,0000,00000000,00000000,0000,0,0,00000000,00000000,18:14:55,12/04/12,2180,00000000,0

and so on.........


 

 

Can you please advise on how to do this without actually monkeying around with the VISA inicialize?

 

thanks!


You're gonna have to put that string into a shift register to bring it back around.  Then you'll have to concatenate it with the current string (add a return so they end up on different lines) and take the output to your indicator.  Be careful what you wish for... if it's updating 10 times a second, it will eat up memory like crazy.

 

[edit]

 

Didn't realize you wanted to cut n paste to notepad... why not just take the original output to a file instead of an indicator?  Cross beat me to it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 17
(3,569 Views)

You could just create a file and write a new line to it each time you get a new message or a button press.  Close the file when the program exits.


GCentral
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
Message 10 of 17
(3,555 Views)