LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial read, queue store and continuous time-evenly processing, but data is mixed now

Solved!
Go to solution

Hello, all,

 

I send the data from AVR MCU to PC via serial interface, 16bytes each time at 50ms interval,  if i donot use queue, the data readed from VISA is same as sended. But the read and processing in turn within a while loop is not time efficiently as multi-loop with queue.

 

I have a byte(0x55) as the first byte of the data transmited, with multi-loop with queue, but now the position of  0x55 is changed all the time, and more likely present at the 8th byte of the data.

 

Thanks for all help.

 

Ted

,,,,
0 Kudos
Message 1 of 8
(5,205 Views)

Hi Ted,

 

your "received buffer" is only connected to an indicator, so no new data will arrive the queue...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(5,200 Views)

Ted,

 

i reordered the elements in the writing loop using the clean up diagram tool and made a screenshot:

 

MakesSense.png

 

Maybe you can explain me the sense of the loop's content.

 

thanks,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 3 of 8
(5,198 Views)

And to add some important information:

You implemented an endless loop by connecting the FALSE constant to the loop condition terminal. This is very bad! You have to change it.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 8
(5,182 Views)

Many thanks to Norbert and others,

 

The data received with VISA read is unstable even no connection to other part, as the screenshot displayed. If the Received Data Buffer connect to following part,  the result is the same.

 

 

I wonder why the received data can be influnced by queue application.

 

 

Attaced is another vi file with no queue applied, it has no problem with VISA read, but there is only one while loop.

 

 

I am a new user for LabVIEW, but have take much time in LabVIEW, also thanks for your suggestion about the stop condion setting of while loop, all this is valueable.

 

 

 

With best wishes,

 

Ted

,,,,
0 Kudos
Message 5 of 8
(5,167 Views)

Hi Ted,

 

you're kidding, right?

check.png

Ever heard of using left-to-right-wiring?

Ever heard of using subVIs to bundle common tasks?

 

More specific questions:

Why do you do the data processing in each iteration instead of only for new data? It's just a matter of size of the case structure Smiley Wink

The string parsing could be made more compact using a single ScanFromString... The same applies for the string formatting for file writing when using FormatIntoString!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(5,151 Views)
Solution
Accepted by houde_dai

 


@houde_dai wrote:
[...]

The data received with VISA read is unstable even no connection to other part, as the screenshot displayed.[...]

With best wishes,

 

Ted


 

Ted,

 

what do you understand with "unstable"? And i saw that in your single loop VI, you are always flushing the buffer after each read, which you do not in the multiple loop VI. Maybe this is causing the issue.

 

Nevertheless, IF it is the flushing, the root cause is not the VI, but your connection (or the counterpart of your program). Since VISA Read does already remove the read amount of data from the buffer, the data has to be resent/captured again in the buffer.....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 8
(5,140 Views)

Dear GerdW,

 

Thanks for your replay.

 

I am serious for the questions.  Now I have 6 channels to process at the same time, and with 50ms interval every time. And I will carry out with sub VI, or case loop wiht these 6 channels  in turn.

 

ScanFromString may be useful, I will try.

 

Because I just beginn with LabVIEW, and so grateful to get the suggestions from all of you.

 

The reason why i donot do the data processing in each iteration instead of only for new data, because I donnot know when get the new data. Now I flush the I/O buffer after each reading, and I think the next reading is new, I donnot know whether it is ok. But the data obtain is in order now.

 

 

Thanks to all!

 

Ted

,,,,
0 Kudos
Message 8 of 8
(5,132 Views)