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.
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.
04-08-2015 03:37 PM
I am developing a 16 channel data acquistion application using a cDaq9184 with a 9205 module. So far, I have one DaqTask set up in my .NET project along with one DaqComponent on the form for setting up the first AI channel. Each channel will have its own Waveform Graph on the form (form has a tab control for each WFG). I need to be able to log data from each of the channels selected by the user. All channels selected, their data will be logged to a single TDMS file. My question lies in the number of tasks that I require. For this application, should I use a single task with all the channels included in it or should I set up an individual task for each individual channel. If using individual tasks for each channel, is it going to be difficult or a pain to log all channels data to the single TDMS file?
Thank you
Solved! Go to Solution.
04-08-2015 04:07 PM
04-09-2015 08:33 AM
Okay, so if I use only one task for my 16 channels (DaqTask1 auto generates code and configures all 16 channels in the following sub. This is in the DaqTask1.vb and not the DaqTask1.User.vb
Public Overridable Sub Configure()
AIChannels.CreateVoltageChannel("cDAQ9184-1A2B748Mod1/ai0", "Voltage_0", AITerminalConfiguration.Differential, 0, 400, "MyScale")
AIChannels.CreateVoltageChannel("cDAQ9184-1A2B748Mod1/ai1", "Voltage_1", AITerminalConfiguration.Differential, 0, 400, "MyScale")
''
''
etc..for the remaining channels
End Sub
How do I configure the WFG so that it only plots one wafeform plot (ai0) and not all 16 channels? I need to set up 15 more WFG's the same with each channel plotted to its own WFG. Obviously, I can omit all lines of code other than the first line in the above configuration sub so that only ai0 plots on the WFG but I'm pretty sure that's not the answer, since I would be ommiting all the other channels from the task. Opening up the WFG on my form and editing the plots isn't it either since it only shows one plot, yet when I run the program all 16 channels are plotted on the WFG. I'm hazy on what's going on here and what I need to do to remedy.
Thank you
04-09-2015 08:57 AM
04-09-2015 09:20 AM
It is a Windows Forms Application. Technically, when I created the project, I selected "NI Windows Forms Application" under Measurement Studio templates.
The graph is getting its data from the auto generated code when I selected the option to auto generate a UI (wafeform Graph) and Measurement Studio auto generates the code for it. See attached - the code that is added to my Main Windows form. MS creates the task code (DaqTask1.vb) also but I have not altered that or the code generated in the Main Form (attached jpg).
04-09-2015 10:23 AM
It appears to be reading all channels from the DaqTaskComponent1 when the switch on the UI is high.
If Switch1.Value Then
DaqTask1Component1.StartRead()
Else
DaqTask1Component1.StopRead()
End If
I'm trying to modify that code so to only read one channel (ai0), but I can't seem to find the solution. Is there a way/method to modify this exhisting code so that when the StartRead() method is called, it is called for a specific channel in the task and not all of them?
04-09-2015 10:31 AM
As a possible work around to my problem, would it be possible to create a single task with DaqTaskComponent for each individual channel for the purpose of simply reading each plot to its own WFG? Then add yet another task to the project for reading and writing all channels to the TDMS file?
04-09-2015 11:37 AM
Hi DM@Means,
To solve your multiple waveform graph problem, you will need to modify the DaqTaskComponent1_DataReady
event handler. Please see the following pseudo-code which would represent the modification you might make:
System.Threading.Monitor.Enter(DaqTask1Component1) Dim acquiredData() As NationalInstruments.AnalogWaveform(Of Double) = e.GetData 'Plot the 0th waveform on WaveformGraph1 WaveformGraph1.PlotWaveform(acquiredData(0)) 'Plot the 1st waveform on WaveformGraph2 WaveformGraph2.PlotWaveform(acquiredData(1)) '... 'Plot the (n-1)th waveform on WaveformGraphn 'WavformGraphn.PlotWaveform(acquiredData(n-1)) System.Threading.Monitor.Exit(DaqTask1Component1)
This way, when you're data are ready, you can just plot them on the graphs you have prepared on your UI.
04-09-2015 12:15 PM
Thank you. It appears that its working like I want now. I modified the code to just read the first channel (0) and it is working. I have yet to try it with additional WFG's and their channels but it looks like this will work.
Thanks again.
04-09-2015 02:12 PM
I have accepted the solution posted, however I have run into a problem and before I start another thread, I will post to this one first. I tried reading multiple channels to separate WFGs and it appears to be working. However......I can only run one of the WFG's at a time and not multiple at the same time or I get a Daq error ("The Specified Resource is Reserved"). My online search reveals that it doesn't like that the program is reading from the same task before it's been released?
I dropped another DaqComponent onto my form (DaqTask1Component2) and pointed it to the same task since that is where the channels are that I want to read from. So I have two DaqComponents referencing the same task but they can't reference the task at the same time.
I copied the code generated by MS for my other DaqComponent and just changed the names accordingly to all objects. This is the code generated in the MainForm. (See attached).
Is there a work around for this issue or am I dead in the water? I really need to be able to run any of my WFG's at any time, and simulaneously. Am I going to have to create individual tasks for each channel and DaqComponents?
Thank you