LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fast serial read and live plotting data causes byte accumulation at port

Solved!
Go to solution

Dear All,

 

my aim was to send a string command via serial (LV) to my arduino, let the arduino create some signals (sine waves, rect signal etc.) and send the data with the correct delay back to the serial port and read out the data with LV. Further, whenever the data is being read by LV, I am creating a cluster adding a TimeStamp (since windows was started (dll running the getime command in c++)) so I can later check whether the read signal in LV has the correct timing (additionaly I am also checking this with an oscilloscop at the arduino analog output Pin). The Arduino sends the signal values with12Bit resolution (0.00 - 4095.00) with additional carriage return and line feed so it sends between  6 - 9 Bytes every 10ms.

 

So far I was able to do all the above. And the timing looks good (Bytes At Port don't accumulate and match the read count) and checking the TimeStamps also looks good. However, I was also planning to implement a preview window where the data is plotted in "real time" so I can check the signal course. But I was not able to implement the LivePreview without introducing a time delay (BytesAtPort accumulate) and the timing doesnt match anymore at the end.

I tried to implement a seperate while loop with an additional queue, then I tried to make use of Notifiers, then I tried to check the queue status and preview the last element, however all of these approaches introduced delays. 

 

Therefore I would like to know, whether you could help me implementing this LivePreview?

 

Attached are the LV Files. The main vi is called StimulusArduino.vi

0 Kudos
Message 1 of 3
(401 Views)
Solution
Accepted by topic author Kenai23

Your file IO needs to be in a completely different loop, not just in a different case as the serial read.  Read up more on the Producer/Consumer.

 

I actually doubt the need for the State Machine architecture here and even the Event Structure.  I think you could clean up this code a lot by letting the initialization happen before the loop and eliminating structures.

 

The attached code has some clean up done, but the main focus is showing the writing of the file in a separate loop.  I also changed your graph into a chart.


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 3
(370 Views)

Thank you very much crossrulz. Your suggestion was very helpful!

0 Kudos
Message 3 of 3
(293 Views)