LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Analog Input DAQmx

Solved!
Go to solution

Hello,

 

I developed a state machine that would run parallel with a DAQmx analog input device that would be used for a PID controller. However, on the state 'Acquire' there is an error for 50103, and I believe that it is because I have two tasks in the code. Is there a possibility that I can run this in parallel? My hardware is an NI cRIO with a NI 9205 with DSUB.  Attached in my VI.

 

Thank you! 

Download All
0 Kudos
Message 1 of 12
(3,002 Views)
It will depend on the hardware, but usually all of the analog inputs must be read on the same task. Right now you have Mod1: ai0 and ai3 on one task, and ai4 on a separate task. Try combining all of them into a single task.
Hint: Right now you are using the "DAQmx Create Channel" VI with "task in" empty, which creates a new task. Once you create the task (for ai0 and ai3) wire that to the "task in" when adding ai4. I think for the timing you will have to set a single clock rate, so choose the fastest rate that any of your channels needs and then if you you can throw away samples later if you desire.
Message 2 of 12
(2,980 Views)

Hi Gregory,

Thank you for responding. I attempted combining them into a single tasks by adding the Mod1 ai4 on the physical channel constant, but to no avail. I am confused what do you mean by creating a new task for ai0 and ai3, and then adding ai4. The hardest part thinking about the architecture is where would the DAQmx read go if I were suppose to do this.

0 Kudos
Message 3 of 12
(2,963 Views)

It means add channel 4 to your task set up.  Like this.

 

0 Kudos
Message 4 of 12
(2,953 Views)

It looked like kepham wanted ai4 to be an RMS voltage measurement, so that's why I suggested using 2 "create virtual channel" VIs. When I use a simulated NI 9205 device though, it says RMS voltage is not supported. If all the channels are configured the same, then you can do it as RavensFan showed. If you need to configure them differently, you can chain the VIs together like so:

Capture.PNG

Note, this gives an error because it said Voltage RMS in the second function is not supported.

Message 5 of 12
(2,945 Views)

Hi Gregory,

 

Thanks for replying! Sorry the RMS Voltage is not supposed to be there! It is supposed to be AI Voltage, sorry about that! I have attempted to do what you did. But my question is, would I be able to still use the PID in parallel with the state hits "Acquire?" The goal is to use the PID constantly until the while loop ends, and won't stop when the state machine hits "Acquire." If I move the Read DAQmx outside of the for loop inside the case structure, won't it cause errors?

0 Kudos
Message 6 of 12
(2,940 Views)

You probably want your state machine in 1 loop, your "VFD PID Loop" in a 2nd loop, and your Analog read in a 3rd loop. Then your only problem is interloop (interprocess) data communication. This can be super simple, using a local variable if you only need the "latest" data. Or you could queues, channels, functional globals, and several other ways. 

 

I would just have the Analog read loop running very quickly, and depending on your data you might want to keep a running average of the last N samples and update a local variable.

0 Kudos
Message 7 of 12
(2,932 Views)

Hi Gregory,

 

I did some research and implemented our idea on using 3 loops with interloop communication. I chose to manipulate local variables in order to do this. However, when I execute the code, the while loop the is in the center (with DAQ channels Mod1:ai0 and ai3) are not executing. Could there be a reason why it is not executing? I thought there would be parallelism due to having 3 separate while loops.

0 Kudos
Message 8 of 12
(2,889 Views)

There sure is a reason. You have a wire which is an output from Loop 1 going to Loop 2. It doesn't matter what kind of wire this is (channel wires exempt), the second loop cannot run until the first loop stops and passes the data along. I recommend finding a different way to stop your loops. The simplest way is to have your boolean control on a "switch" mechanism and use local variables, but that will not provide the best user experience. An event structure would work well, you would have to wire a timeout to it at whatever period you want your loop to run at, 50 or 100ms for example.

 

capture.png

Message 9 of 12
(2,870 Views)

Hi, Would the event structure be triggered by a stop boolean or user interface? Or can I use the event structure to interact with the enum constant I used for the state machine? And would the smarter idea be to place the event structure within the state machine at the final state? 

0 Kudos
Message 10 of 12
(2,842 Views)