LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How many DAQ tasks per loop?

Hi to everybody, I hope anybody can help me with the next case:

 

I am working on a system in which I have to read signals of 5 different sensors which have different ways to communicate (4 - 20 mA, voltage, RS-232, ModBUS, etc.) with the DAQ Device (cDAQ in my case), at same time when I am reading the variables I must check for the state of several digital inputs to verify connections and if any is interrupt I must stop the Data Acquisition.

 

My question is if is recommendable to put all the tasks in a single loop with the logic shown in the attached image.

 

DAQ Idea 1.PNG

 

 

Or if I should divide the tasks in a multiple loop architecture.

 

If the answer is the second, my next question is: How many DAQ tasks per loop is OK?, my doubt is based on the number of variables that I am going to read

and the different ways to get the measures, specially which are by protocols (ModBUS, RS-232), all this by the response time.

 

Thanks in advance, all suggestions are welcome!

0 Kudos
Message 1 of 10
(3,157 Views)

Hi AYanez,

 

while you could put all "tasks" into just one loop I would recommend to separate them in several parallel loops. I would create 3 loops: DAQmx, RS232, and MODBUS…

That way you can easily handle all those different samplerates and response times!

 


my doubt is based on the number of variables that I am going to read


 

Which "variables" are you referring to?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(3,133 Views)

RS-232 and Modbus should definately be in separate loops.  For the DAQmx, it really depends on how often you need to read each task.  I prefer having a separate loop for each type of taks (analog input, digital I/O, counter input, etc).


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 3 of 10
(3,110 Views)

Hi GerdW, the measured variables by the sensors, those I am referring, thanks for the help!

 

By the way, when I divide the tasks, which is the best way to control the acquisition, I am studying the possibility of using an Event Structure with Programattic Events, of this way for example with the ModBUS loop I could send the commands like Read Coils or Write Coils to change the configuration and I would use the Timeout Event to retrieve values of the sensor.

 

I thought this alternative but I don´t know if this is the best way or if use Queues would be better.

 

Best regards to both and thanks for their valuable time and help!!

0 Kudos
Message 4 of 10
(3,101 Views)

I would recommend using a loop just for control and UI events.  It should only have an event structure.  Don't use the timeout case, since that just turns the system into a polling.  Use Queues to send data from the controller loop to your other loops and User Events to send data back to the controller looop.


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 5 of 10
(3,081 Views)

I understand your point crossrulz, but I was referring to use an Event Structure with the next approach:

 

ES Slave.PNG

 

My approach consists in delegate a DAQ Task to an Event Structure, which is normally sleep and with an User Event I could configure some actions like:

 

Start DAQ Task, Stop DAQ Task or Read values with the help of Timeout Event which will activate the polling in the loop when I send the Enum Item Read.

 

I see 2 advantages with this idea:

 

The loop has delay itself with the Timeout Event.

The loop does not waste CPU while we dont need of this.

 

I know that Queues are useful but my doubt is if this way of using Event Structure is OK even when it is not so common, if is not I appreciate if someone tell me his opinion about which would be the best way to separate the DAQ Tasks in several loops.

 

Thanks for the answers, I really appreciate the help more even when is for learning some new.

0 Kudos
Message 6 of 10
(3,059 Views)

User Events to queue up DAQ tasks?  That certainly sounds like a Queue to me.  And the queue has a timeout if you want to use it.  Using a queue is a little more straight forward and easier to read, IMHO.


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 7 of 10
(3,043 Views)

So the correct approach for many DAQ Tasks in paralell would be to use a Queue State Machine per loop to manage the task, what would happen if I if I wanted to save the data to a TDMS file?.

 

I really would appreciate a VI example with 2 DAQ Tasks in parallel that sends data to 1 graph using your approach.

 

I apologize for being so annoying but I really want to learn to deal with these cases correctly, as it is widely used in real cases.

 

Thanks!

0 Kudos
Message 8 of 10
(3,017 Views)

Hi, 

I have similar problem. 

 

I have cDAQ NI9174 and modules NI 9205 for Voltage input measurement and NI 9219 for RTD input. I would like to measure the voltage and temperature simultaneously to have temp and voltage data per one time sample. Shall I use the DAQ mxRead VI twice in one while loop (for voltage and temp) or shall I implement two separate loops and synchronize the timing ???

0 Kudos
Message 9 of 10
(2,909 Views)

In my case in the end I put the acquisition in just one loop because the objective of this is to observe the behavior of a phenomenon so it makes no sense having different Read Rates, because the client wants have the readings in 1 sample on demand synchronized as possible.

 

If in your application is intended to have the posibility of changing the Frequencies of Reading, the best is having 2 loops with Queues like crossrulz said.

 

0 Kudos
Message 10 of 10
(2,887 Views)