Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create multiple channels in DAQmx

Hello ,
 
I created an application based from this example program, MultiFunctionSyncAIAO_DigStart (from VCNet).
I added another input and output channels, which later on I plan to add trigger features between
the two signals ( could be both inputs, both outputs or a combination of I/O).  For now,
I am concentrating in the creation/ setup of multiple signals.
 
I desperately created multiple channels by converting the variables to array.  Obviously, this
is not a smart move.  Then, I saw this function DAQmxAddGlobalChansToTask which creates multiple channels.
Unfortunately, I do not know how to use it.  ( clueless )
Please send me a snippet of the function usage for further understanding. 
 
 Are there any other methods to create multiple channels based from the function/s used in the attachment? 
 
Thank you. 
A

 

Attachment DAQTestingDlg.cpp (14 kb)

0 Kudos
Message 1 of 6
(8,181 Views)

I am trying to get the hang of it.  So in my program, so far I am able to add channels but I find it a bit crude.

In OnInitDialog:

LoadStringVectorInComboBox(m_input1, CNiDAQmxSystem::GetPhysicalChannels(DAQmxPhysicalChannelTypeAI, DAQmxPhysicalChannelAccessExternal));

LoadStringVectorInComboBox(m_input2, CNiDAQmxSystem::GetPhysicalChannels(DAQmxPhysicalChannelTypeAI, DAQmxPhysicalChannelAccessExternal));

In the Startbutton function:

m_input1.GetWindowText(IN1);

m_input2.GetWindowText(IN2);

m_inputTask = std::auto_ptr<CNiDAQmxTask>(

new CNiDAQmxTask("inputTask"));

m_outputTask = std::auto_ptr<CNiDAQmxTask>(

new CNiDAQmxTask("outputTask"));

....

m_inputTask->AIChannels.CreateVoltageChannel(IN1, "", DAQmxAITerminalConfigurationDifferential, omin, omax, DAQmxAIVoltageUnitsVolts);

m_inputTask->AIChannels.CreateVoltageChannel(IN2, "", DAQmxAITerminalConfigurationDifferential, omin, omax, DAQmxAIVoltageUnitsVolts);

...

My parameters are the same for both inputs.  How do I combine them in one task?  I tried several methods to combine IN1 & IN2 but still failed.

I want to use the variables from the user selection in the combo box for flexibility.

 

super thanks!!!

 

 

 

 

 

.

 

 

 

 

0 Kudos
Message 2 of 6
(8,175 Views)

Hi A,

To clarify, I believe that you are trying to modify the SyncAIAO_DigStart example that ships with measurement studio for VC++ to use more than one AI and AO. Simply put, you will have one task for AI and one for AO. You will configure the timing on AO to correlate to the AI timing. You will also use the DAQmxAnalogMultiChannelReader/Writer functions rather than the single channel. Also, when you configure the channels, you were correct that you will use an array of channels.

I would suggest looking at other examples, specifically the ContAcqVoltageSamples_IntClk in the Analog Input folder and the corresponding example in Analog Output to take those implementations and apply them to your program. Also, check out these great online resources that can be found on our website (I put them in order of personal preference).

Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications
https://www.ni.com/en/support/documentation/supplemental/06/learn-10-functions-in-ni-daqmx-and-handl...
Using NI-DAQmx in Text Based Programming Environments
https://www.ni.com/en/support/documentation/supplemental/21/using-ni-daqmx-in-text-based-programming...
Getting Started with NI-DAQmx: Main Page
https://www.ni.com/en/support/documentation/supplemental/06/getting-started-with-ni-daqmx--main-page...

Also under Start Menu\All Programs\National Instruments\NI-DAQ\NI-DAQmx C Reference Help and the Measurment Studio Help documentation are filled with great information about the functions and what they do and what parameters they expect.

 
PBear
NI RF
0 Kudos
Message 3 of 6
(8,156 Views)
Thanks a bunch for the pointers, Patrick.
The functions are now updated in multiple channels.
I have another question.  The previously CNiReal64Vector is now CNiReal64Matrix.
Is there a function that is similar to the SineWave() ? I tried typecasting it but I didnt see any sine wave.
 
 
Thanks again,
Smiley Happy
 
 
0 Kudos
Message 4 of 6
(8,130 Views)
Hi PatrickSmiley Happy
 
To convert the code using multi I/Os, I included the multi reader/ writer header files.
Plus, those variables that require updating of data type are now in CNiReal64Matrix.
I also omitted the SineWave(), which i think I cannot use it with the CNiReal64Matrix data type.
But, I wonder why is that I have no significant output based from the amplitude.  I hooked it up
with the scope but saw nothing.  Aside from the changes that I mentioned, I didnt do anything
drastic.  To make the conversion fuss-free using the same example, i retained the UI and converted
the single functions to the multi functions.  I will add the control for additional I/Os later on. 
 
Please point it to me why the code has no output after the m_outputTask->Start(). I really can't get the output
portion working it. I browsed through the different voltage analog output for VC++ but all examples
use the single function. 
 
Btw, is there a way that i can use a sine wave or similar function to display a nicer waveform?
 
Thanks a bunch for all the help,
 
A
0 Kudos
Message 5 of 6
(8,115 Views)
Hi angelmcdoggie,

Make sure you are using the proper syntax when defining the channels. For example: Dev1/ai0:4 will use channels analog input 0 through 4. As far as the examples go, they are well documented and should be good at guiding you along. You can cross reference the DAQmx help documents for great detail about the different functions that are available to you. It appears you are using .NET and the screenshot shows you how to find the appropriate documentation (Start Menu\National Instruments\NI-DAQ)

Again, if none of these suggestions help, please look into the examples further and understand how they are coded and the functionality and flow of them. All of these can be found at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples.




Message Edited by Patrick_Ba on 02-29-2008 03:56 PM
PBear
NI RF
0 Kudos
Message 6 of 6
(8,082 Views)