Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple channels

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 Smiley Sad )
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
0 Kudos
Message 1 of 7
(4,196 Views)

Hi Angel,

As I understand the issue, you are using the code from the example MultiFunctionSyncAIAO_DigStart. This code only reads and writes on one input channel and one output channel but you would like to add another channel to each task. Is this correct?

I do not think that you will need to use the DAQmxAddGlobalChansToTask function. In this example, you will only need to make one change. In the code, m_reader and m_writer currently use the SingleChannelReader or Writer instance. This will need to be changed to allow multiple channels; the function can be found in the help file.

After this change is made, when the program runs and the user interface appears, you can enter a string representing multiple channels into the physical channels text box. The string format will be along the lines of “Dev1/ai0:1”, but for the proper syntax, you can look in the NI-DAQmx C Reference Help Document under NI-DAQmx Key Concepts>> Channels and Tasks in NI-DAQmx>>Channels, Physical verses Virtual>> Physical Channel Syntax.

Hope this helps, Mallori M.

Mallori M
National Instruments
Sr Group Manager, Education Services

ni.com/training
0 Kudos
Message 2 of 7
(4,177 Views)
Hello Mallori Smiley Happy
 
Yes, that is the example where I am expanding/changing the features.
 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 3 of 7
(4,135 Views)

Hi Angel,

I am having some trouble locating the problem with this code. I will really dig into it and post back with an update early next week.

Regards, Mallori M.

Mallori M
National Instruments
Sr Group Manager, Education Services

ni.com/training
0 Kudos
Message 4 of 7
(4,092 Views)
Hello M,
 
This time i changed my base program to ContGenVoltageWfm_IntClkDlg.
I performed the ffg to convert this to multiple output.
1.  replaced the "NiDAQmxAnalogSingleChannelWriter.h" with "NiDAQmxAnalogMultiChannelWriter.h".
2.  I used all my output channels, cDAQ1Mod2/ao0:3 in the CreateVoltageChannel().
3. The m_writer is now configured using this, CNiDAQmxAnalogMultiChannelWriter.
4. The2nd parameter of this function has now a CNiReal64Matrix data type.
           output[0] = CNiReal64Matrix(4, 2, 6.5);
  
  m_writer->WriteMultiSample(false, output[0]);
0 Kudos
Message 5 of 7
(4,035 Views)
Hello M,
 
This time i changed my base program to ContGenVoltageWfm_IntClkDlg.
I performed the ffg to convert this to multiple output.
1.  replaced the "NiDAQmxAnalogSingleChannelWriter.h" with "NiDAQmxAnalogMultiChannelWriter.h".
2.  I used all my output channels, cDAQ1Mod2/ao0:3 in the CreateVoltageChannel().
3. The m_writer is now configured using this, CNiDAQmxAnalogMultiChannelWriter.
4. The2nd parameter of this function has now a CNiReal64Matrix data type.
            output[0] = CNiReal64Matrix(4, 2, 6.5);
  
  m_writer->WriteMultiSample(false, output[0]);
0 Kudos
Message 6 of 7
(4,035 Views)

continuation....

i am unsure of the changes that I made even though that I have an output on the scope.

The output was quite vague and I am still debugging. 

By the way, how do I display a sinewave from the matrix?

Thanks2x.

Regards,

A

 

 

0 Kudos
Message 7 of 7
(4,028 Views)