From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to set up multiple data inputs from analog and serial devices, each have different data rates

i think I figured it out, but I am not getting any updates visible on screen from the 1 sample/2 seconds case.  is it possible to limit a single while loop with a wait or will that slow the whole thing down.

 

If anyone knows where I went wrong with this or what I should do better please let me know. I plan to do some data processing in the display loop , and then have anotehr loop with a unique queue to write all this to a TDMS file. Thanks

0 Kudos
Message 11 of 33
(1,110 Views)

Easiest to do it as a type def.  Then you just see a front panel and you can edit the cluster however you want, including the element labels.  From the constant, you can right-click on the elements inside of the cluster and choose Visible->Label and edit from there.


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
Message 12 of 33
(1,101 Views)

I'm working on a similar problem of coordinating data acquisition/storage/analysis. I read Ben's nugget "Action Engines". It has the most kudos of all time, so go read it. 

https://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801

I'd like to know the opinion of some more experienced users.

 

What are the potential advantages to using an action engine here instead of just a queue? Alternatively why is an action engine unnecessary in this case?

Message 13 of 33
(1,087 Views)

The disadvantage of an AE here is that it is blocking, meaning your acquisition could be slowed down by waiting for the AE to be completed in another loop.

 

What I do in similar situations is put the queue in an AE.  This reduces the wiring needed and can help isolate who can manipulate the queue an how.  Ideally, the AE is a private VI in a library.  Then you have accessor VIs that are used to send the data on.


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
Message 14 of 33
(1,076 Views)

Tried to incorporate all of your suggestions, hopefully I got it right. But the speed of this is crazy fast, I'm guessing it is not possible to put a wait in one while loop and have that not affect the others in the VI.

0 Kudos
Message 15 of 33
(1,067 Views)

A few comments:

1. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (I might still need more emphasis).  The Bytes At Port can cause weird race conditions, especially if you do not wait to allow the device to respond.  Since it looks like you are dealing with ASCII communications and the termination character is turned on, just tell the VISA Reads to read more bytes than you ever expect in a message.  Something like 50 should work.

2. Have your acquisition loops decode the read data and make it an actual number.

3. You are reading 1 sample from every channel with the DAQmx Read.  Therefore, just use the Analog->Multiple Channels->Single Sample->1D DBL configuration.  Then you do not have to worry about wiring the 1 to the number of samples to read.  This will cause some slight changes to the rest of your code that depends on that, but the simplicity is nice.

4. You should have a Default case that is not tied to a valid group.  You can either throw an error or just do nothing in that case.


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
Message 16 of 33
(1,062 Views)

@crossrulz wrote:

A few comments:

1. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (I might still need more emphasis).  The Bytes At Port can cause weird race conditions, especially if you do not wait to allow the device to respond.  Since it looks like you are dealing with ASCII communications and the termination character is turned on, just tell the VISA Reads to read more bytes than you ever expect in a message.  Something like 50 should work.

2. Have your acquisition loops decode the read data and make it an actual number.

 

 

3. You are reading 1 sample from every channel with the DAQmx Read.  Therefore, just use the Analog->Multiple Channels->Single Sample->1D DBL configuration.  Then you do not have to worry about wiring the 1 to the number of samples to read.  This will cause some slight changes to the rest of your code that depends on that, but the simplicity is nice.

4. You should have a Default case that is not tied to a valid group.  You

can either throw an error or just do nothing in that case.


2. When you say decode do you mean run all of the string to number in each loop, and do all of my math and data processing in the acquisition loop, leaving the consumer just for display and trasnfer to data write?

4. What do you mean by this?

0 Kudos
Message 17 of 33
(1,054 Views)

@labview12110 wrote:

Tried to incorporate all of your suggestions, hopefully I got it right. But the speed of this is crazy fast, I'm guessing it is not possible to put a wait in one while loop and have that not affect the others in the VI.


Perhaps I missed something, but I thought the whole point of the independent while loops is that they can run at independent rates. Based on that I would say that you can wait as long as you like for taking data from the serial ports. I don't know about waiting on the DAQMX channel though. I run into "application can't keep up with hardware acquisition" errors when I mess with the timing there. 

0 Kudos
Message 18 of 33
(1,051 Views)

@labview12110 wrote:

i think I figured it out, but I am not getting any updates visible on screen from the 1 sample/2 seconds case.  is it possible to limit a single while loop with a wait or will that slow the whole thing down.

 

If anyone knows where I went wrong with this or what I should do better please let me know. I plan to do some data processing in the display loop , and then have anotehr loop with a unique queue to write all this to a TDMS file. Thanks


Each loop is independant, that's the whole point, so you can add a Wait to slow them down. The DAQ loop has hardware handled speed through the Sample rate and 1 sample read, but the Serial loops should have waits.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 19 of 33
(1,046 Views)

@labview12110 wrote:

2. When you say decode do you mean run all of the string to number in each loop, and do all of my math and data processing in the acquisition loop, leaving the consumer just for display and trasnfer to data write?

4. What do you mean by this?


2. Due to the fact that serial communications is just slow in the first place, a little math and string to number conversion will be a very small blip.  So, yes, convert from string and do the math in the producer and then let the consumer just display and/or log the data.

4. You currently have a case in your consumer loop that goes "Value",Default (don't have the code anymore, so I just threw in "Value").  Instead, that should be 2 cases: "Value" and Default.  The Default case should just ignore the message or throw an error since this case will be called when a value you did not define is sent to the consumer loop.


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 20 of 33
(1,044 Views)