12-17-2012 07:31 PM - edited 12-17-2012 07:32 PM
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 ). 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
12-17-2012 07:43 PM
12-17-2012 08:15 PM
Double check your parity and stop bit settings.
12-18-2012 05:38 AM
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,
12-18-2012 07:12 AM
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).
12-18-2012 07:16 AM
12-18-2012 01:54 PM
hello people.
thanks a lot for all your suggestions. im working right now on this.
will let you know anything
rgds
12-18-2012 02:09 PM
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!
12-18-2012 02:33 PM - edited 12-18-2012 02:40 PM
@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,0and 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.
12-18-2012 02:36 PM
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.