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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to generate multiple analog outputs simultaneously using PCI 6723

HI,
 
   As I am using PCI 6723 for generation of Analog Outputs LabWindows 7.1.
 
   I would like to create multiple outputs(PCI 6723) simultaneously using Thread Concepts , I am not able to generate multple signals simultaneously so please send me any example code that is  compatible with labwindows as early as possible.
 
Regards
krishna
0 Kudos
Message 1 of 14
(6,687 Views)

Hello krishna,

I would recommend looking for examples in the Example Finder.  To do this in LabWindows/CVI, go to Help >> Find Examples.  You will want to  look in the Hardware Input and Output >> DAQmx >> Analog Generation folder.  You modify any of these examples so that they meet your needs. 

There are additional examples posted in the example code library of the Developer Zone section of ni.com.   If you search for "analog output cvi daqmx" you get a very relevant hit:

NI-DAQmx: Continuous Multi-Channel Analog Output Example in CVI

Hope this helps you get started!
Laura
0 Kudos
Message 2 of 14
(6,658 Views)

HI Laura

 Thanks for your valuable response.

 One more issuse please reply for the same.   

 We had NI PCI-6723 card and we are not able to generate analog outputs signals simultaneously for different channels with different data.

  As per your example we can select one channel at a time and we can see the respective output, one possible is that I can change the code and send the channels one by one . In this case also  after completion of one channel then only I can able to see the next channel.
 
The sequence I am using is like this :-
 
1.DAQmxCreateTask("",taskHandle);
2.DAQmxCreateAOVoltageChan(*taskHandle,chan,"",min,max,DAQmx_Val_Volts,NULL);
3.DAQmxCfgSampClkTiming(*taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
4.DAQmxCfgSampClkTiming(*taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
5.DAQmxWriteAnalogF64(taskHandle,bufferSize,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL);
6.DAQmxStartTask(taskHandle);
7.DAQmxIsTaskDone(taskHandle,done);
8.DAQmxStopTask(taskHandle); 
9.DAQmxClearTask(taskHandle); 
 
In the above sequence CreateTask can be done once if we are driving all channels with the same data like below
 
DAQmxCreateAOVoltageChan(*taskHandle,Dev1/ao0:4,"",min,max,DAQmx_Val_Volts,NULL);
DAQmxWriteAnalogF64(taskHandle,bufferSize,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL);
DAQmxStartTask(taskHandle);
 
The above sequence will drive 0 to 4 channels simultaneously with the same data.
 
My requirement is I would like to see the two channels driving different data at the same time i.e simultaneously
 
I hope I will get the resonse as early as possible.
 
Regards
krishna
 
0 Kudos
Message 3 of 14
(6,640 Views)

Hello Krishna,

I believe I have found a more relevant example for what you are trying to do here.  It generates a different waveform for each channel.  The thing to be aware of is that you need to assemble your data array carefully so that each channel gets the waveform you need it to.  The example that I linked to uses "non-interleaving" to prioritize the samples in the array.  So if you have 4 channels and a buffer size of 1000 points, each channel gets 250 of those points.  To learn more about this look under the DAQmxWriteAnalogF64 function in the NI-DAQmx C Reference Help.  I have quoted your options here:

Interleaved samples prioritize samples before channels, such that the array lists the first sample from every channel in the task, then the second sample from every channel, up to the last sample from every channel.

Channel 0—Sample 1
Channel 1—Sample 1
Channel 2—Sample 1
Channel 0—Sample 2
Channel 1—Sample 2
Channel 2—Sample 2
...
Channel 0—Sample N
Channel 1—Sample N
Channel 2—Sample N

Non-interleaved samples prioritize channels before samples, such that the array lists all samples from the first channel in the task, then all samples from the second channel, up to all samples from the last channel.

Channel 0—Sample 1
Channel 0—Sample 2
...
Channel 0—Sample N
Channel 1—Sample 1
Channel 1—Sample 2
...
Channel 1—Sample N
Channel 2—Sample 1
Channel 2—Sample 2
...
Channel 2—Sample N

Hope this helps!
Laura
Message 4 of 14
(6,592 Views)

Hello Laura F.

Once again Thanks for your valuable reaponse.

Now I solved my problem completely by arranging my data array for different channels.

One more problem is that My data array is like this :-

Float64 data[100];

For the first channel Dev1/ao0 my data is

for(i=0;i<50;i++)

 data[i] = 10;

For the Second channel Dev1/ao1 my data is

for(i=0;i<50;i++)

 data[i] = 20;

Now my Execution Sequence is like below :-

1.DAQmxCreateTask("",taskHandle);
2.DAQmxCreateAOVoltageChan(*taskHandle,"Dev1/ao0 : Dev1/ao1","",min,max,DAQmx_Val_Volts,NULL);
3.DAQmxCfgSampClkTiming(*taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
4.DAQmxCfgSampClkTiming(*taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
5.DAQmxWriteAnalogF64(taskHandle,bufferSize,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL);
6.DAQmxStartTask(taskHandle);
7.DAQmxIsTaskDone(taskHandle,done);
  
From the above steps it is possible to drive Analog outputs of different channels with different data.
 
But if Data Array is updated again for both the channels in this case I have to follow 8 and 9 steps like below :-
 
8.DAQmxStopTask(taskHandle); 
9.DAQmxClearTask(taskHandle); 
 
and then again I have to repeat the steps 1 to 7 so that the step 5 will drive the updated data. Again if the data array changes follow steps 8 and 9 and repeat 1 to 7.
 
Can You tell me is there anyway with out stopping and clearing the task can I drive my  Updated data array so that it will be continuous matches my timing requirements.
 
Waiting for your response.
 
Regards
krishna

 

 

Message Edited by krishna_ak on 01-11-2006 10:29 AM

0 Kudos
Message 5 of 14
(6,555 Views)

Hello krishna,

Did you try using the DAQmxWrite while the task is running once you need to update your array data? 

By default, analog output tasks are setup to allow regeneration, which means that you write data to your buffer, start your task, and then the device will continuously output this data from the buffer.  It will loop back to the beginning of the buffer once you reach the end of the buffer.  However, if you use the DAQmxWrite function after the task has been started you will put new data into the buffer.  You need to be aware that glitching may occur.  Please see the NI-DAQmx Help file for more information on glitching considerations.  Once you have put the new data in the buffer, it will continuously generate that data until you update the buffer again.  If, instead, you would prefer never to allow the data to regenerate, you can use the function DAQmxSetRegenMode.  This way, you will have to continuously send data into the buffer to be outputted. 

Using either of these methods, you can avoid having to start the task again. 

Please read the sections about regeneration and glitching in the NI-DAQmx Help (Start >> Programs >> National Instruments >> NI-DAQ).

Also, just for your information, if you do not use the ClearTask and only the StopTask, you would only need to use DAQmxWrite and then StartTask to start outputting data again, because the task information will still be in memory.  You can avoid the other configuration steps. 

Hope this helps!

Laura

Message 6 of 14
(6,533 Views)

HI Laura,

Thanks for your valuable response and my application is working after implementing ur suggestions.

One more question

  As you see windows applications when it ask for a password ?
 
  if we press capslock key it shows capslock is on ..
 
  In Labwindows how to identify capslock key and how to show a warning msg to user exactly like windows....
 
  I hope  u understand my question..
 
  Please reply as early as possible
 
Regards
krishna

 

 

0 Kudos
Message 7 of 14
(6,488 Views)
Hello krishna,
 
You will have to use Windows SDK functions to get this kind of information. In particular you should take a look at the GetKeyState function as described in the following forum post:How to Detect Status of the NUM LOCK and CAPS LOCK Keys?
 
Hope that helps.
0 Kudos
Message 8 of 14
(6,461 Views)
Hi Everybody,

I'm trying to use the same card to generate multiple analog outputs waveforms with user controlable frequency.
I was able to do this fine with Labview, but I when i'm trying to port this over to ANSI C, i'm having problems.

With Labview Simulate Signal Express VI, can I can set it so it creates a Interger Number of Cycles.  I have to do this so that the waveform is continuous when it is regenerated.
When I change the freqency, the sample rate is contant, however; number of samples changes to accordingly  to create the interger cycles.

With ANSI C, how do I arrange the data for multiple channels when the data points per channel may vary with frequency?  ie,  It seems like  when running the function  DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,10000);  All the channels expect 10000 data points? 

Thanks in Advance!

Francis
0 Kudos
Message 9 of 14
(5,968 Views)

Hi Francis,

It sounds like what you are looking for is a way to determine the correct number of samples to read to ensure that you are getting integer number of cycles.

Here is an example of these calculations:

Say you are planning on generating two waveforms with frequencies of 20 kHz and 30 kHz at a sampling rate of 100 kHz.

You will need 5 samples to get a single cycle for the 20 kHz waveform and 3.33 samples to get a single cycle for the 30 kHz waveform.

Alternatively you could take 10 samples and get an integer number of waveforms for both waveforms.

If you apply this algorithm to your output frequencies you should be able to determine the proper number to use for the number of samples.

Best regards,

Jordan D
Applications Engineering
National Instruments
0 Kudos
Message 10 of 14
(5,933 Views)