LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Serial and DAQ in Same While Loop

Solved!
Go to solution

Hi Everybody,

I have a while loop which has both a DAQ reading and a VISA serial reading. 

The DAQ readings are slowing down the while loop for serial com, and therefore the iterative nature of the serial measurements of constantly checking byte by byte (for the full line of code: 22 bytes) is not working. (it will check at 8 bytes, 24, .. etc because more bytes are being collected in buffer before it can run through loop again.) 

 

Is there a way to synchronize these two data acquision devices?

 

The speed of the DAQ is fast enough, so if there is a way to hold the serial bytes in a queue and only take the first 22 bytes for every while loop iteration?

 

Thank you for your help. I can not attach VI, but I can provide a reference picture. Capture.JPG

 

 

0 Kudos
Message 1 of 4
(3,597 Views)
Solution
Accepted by smat123

I recommend having the Serial Read and the DAQ loops seperate.  If you are just logging the latest value, the local variable is fine for sending the serial reading to the other loop for logging.



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 2 of 4
(3,584 Views)

Okay so the two while loops should be able ro un at the same time (local variables do not create data dependency right?), and the local variable will update each iteration?

 

Does it matter if one of the while loops (DAQ) is a producer in a consumer/producer relationship?

 

Thank you crossrulz!

0 Kudos
Message 3 of 4
(3,574 Views)

smat123 wrote:

Does it matter if one of the while loops (DAQ) is a producer in a consumer/producer relationship?


I'm not recommending a Producer/Consumer.  I'm just talking about two loops who just share data via a local variable.  A Producer/Consumer is more about streaming of data/commands.

 

But I would recommend just moving your serial port reading into another loop and leave the DAQ and logging in your other loop.



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 4
(3,550 Views)