LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial data read not working properly

Hello,

 

I try to read serial data from Psoc 4. while i reading the data, some data is missing in between (data is decreasing or increasing randomly). I tried by changing the configurations (baud rate, data bits etc..) still it doesn't work properly. But the serial read is working exactly in Putty or Hyperterminal, but when trying to read in labview it doesn't work. Please help me with this issue.

 

I am attaching a waveform which shows the serial read data which is increasing or decreasing in between randomly.

 

Thanks

Download All
0 Kudos
Message 1 of 17
(5,201 Views)

Instead of that case structure, I think you want a While Loop around the VISA Read and parsing code.  And if you are using the Run Continuously button, STOP IT.  That is for debug purposes only, not for normal running of your code.

 

So my thoughts here is that you are reconfiguring your serial port for each reading.  If your instrument is just constantly streaming data, it is quite likely that you got only part of your message.  By having the read in a loop, it can stay synchonized to the message based on the termination character.


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
0 Kudos
Message 2 of 17
(5,198 Views)

Hello,

I have tried as u have said, but still it not working properly. For some period of time it seems woriking perfectly but later the count is increasing enormously for some time and then coming back to the normal count later. i am attaching the  vi with the modifications you have proposed  and the waveform which i got by serial read. Please provide me a solution to get rid of those extra counts.

 

Thanks

Download All
0 Kudos
Message 3 of 17
(5,146 Views)

liviya wrote:  I have tried as u have said...

No you didn't.  You put a loop around the entire code.  I told you to put the loop around only the read and parse section of the code.  The idea is that you only initialize the port once at the beginning and then close it once at the end.


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
0 Kudos
Message 4 of 17
(5,135 Views)

hello,

 In my project i want to count the values per second. If i try to use the wait(ms) the vi doesn't working properly. The read string is counting the values very slowly (3 to 4 sec) even if i give the wait as 1000ms. So, the delay between the counts in my Led display and labview is too high. The count/sec i am reading are not constant (varies 1count/sec to 500count/sec). So please provide me a way to count the values per second.

 

Note: In the 1st VI i provided to you, the wait(ms) used to work properly but coutns are not exact, but after i changed the while loop  around only the read and parse section of the code The wait(ms) is not working at all

 

 

Thank you

0 Kudos
Message 5 of 17
(5,083 Views)

Due to the termination character, you do not need a wait in your loop.  If you want to get the ms/message, use the Tick Count (ms) and subtract from the previous tick count (use a shift register or feedback node).  You can do the math from there to get your messages/second.


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
0 Kudos
Message 6 of 17
(5,074 Views)

Hello, 

 

i want read string to read the serial data per second (read/sec). Previously i did it by using wait (ms) in loop. Now as you said "Due to the termination character, you do not need a wait in your loop" . How can i read serial data per every second. I had tried something with the tick count but it didn't worked for me. Please tell me is there any that i can read the serial data (using read string) per every second.

 

Thank you

0 Kudos
Message 7 of 17
(4,999 Views)
You have to read as often as the device sends. If that's once per second, fine. If it's faster, then decimate the data in whatever way you want. Taking the mean every second of an array is one method.
0 Kudos
Message 8 of 17
(4,993 Views)

@liviya wrote:

Hello, 

 

i want read string to read the serial data per second (read/sec). Previously i did it by using wait (ms) in loop. Now as you said "Due to the termination character, you do not need a wait in your loop" . How can i read serial data per every second. I had tried something with the tick count but it didn't worked for me. Please tell me is there any that i can read the serial data (using read string) per every second.

 

Thank you


Perhaps it would be better to explain why you need to read the serial port every second.  You didn't, so I will assume that it is because of a requirement to take data every second.

 

Read the data as it becomes available, then parse the data the way you need to to arrive at your requirement of 1 second intervals.

 

Or you can query the instrument every second, which actually means sending a read command and then reading the results - once every second - if your equipment allows you to do that.

 

So many questions in the forums about how to take data in LabVIEW are really questions about autotesting test methodology in general...

 

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.
0 Kudos
Message 9 of 17
(4,984 Views)

Perhaps it would be better to explain why you need to read the serial port every second.


 In my project i want to produce the countrate(counts/sec). So i want the counts to be read every second, so that i can get the count rate by subtracting present count with the previous count every time using feedback loop.

 

 


Read the data as it becomes available, then parse the data the way you need to to arrive at your requirement of 1 second intervals.

 


 

I tried to read the data as it comes, but the data is too fast and i am not able to read the data exactly (even i can't see the numbers  on indicator) . The data fluctuates and it keeps on decreasing every time in between (the data is supposed to increase only). If i read every second, then it works properly as i did earlier (check the 1st VI i have posted). But in that Vi still the data is not reading properly so i posted here. 

 

Note: if i read a data which reads/sec it works fine but my actual reading varies (ex:100counts/sec to 2counts/sec).

 

i am posting my actula VI . Please correct me if i did anything wrong.

 

Thank You 

 

0 Kudos
Message 10 of 17
(4,960 Views)