From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

PXIe-6738 trouble writing separate data to multiple physical channels

Solved!
Go to solution

Summary

 

How do I address and funnel data through a certain physical channel? 

 

Background

 

I am working on transmitting the I and Q waveforms of a certain signal through two channels and I am having issues understanding how to effectively pass data to a certain physical channel. I have created a

 

 

TaskHandle 

 

 

and configured my channels as follows. 

 

 

TaskHandle  taskHandle1 = 0;
DAQmxErrChk(DAQmxCreateTask("quadrature output channels", &taskHandle1));
DAQmxErrChk(DAQmxCreateAOVoltageChan(taskHandle1, "Dev1/ao0:1", "I channel, Q channel", channel_neg, channel_pos, DAQmx_Val_Volts, NULL));
DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle1, "OnboardClock", samples_per_second_per_channel, DAQmx_Val_Rising, DAQmx_Val_ContSamps, sampsPerChanToAcquire));
DAQmxErrChk(DAQmxRegisterDoneEvent(taskHandle1, 0, DoneCallback, NULL));

 

 

 

I would like to be able to address and funnel data to a channel by name. However, I am using the following functions which seem to use the TaskHandle to determine the channel. This does not make sense because I created a TaskHandle with two channels which I should be able to address individually. 

 

 

 

wcscat(out, L" Writing samples to channels. \n\n ");
wcscat(out, L" \r");
AppendText(hOut, out);
wcscpy(out, L"");
DAQmxErrChk(DAQmxWriteBinaryI16(taskHandle1, samples_per_channel, 0, timeout, DAQmx_Val_GroupByChannel, I_chan_buffer, NULL, NULL));
/*********************************************/
// DAQmx Start Code
/*********************************************/
wcscat(out, L" Starting playback. \n\n ");
wcscat(out, L" \r");
AppendText(hOut, out);
wcscpy(out, L"");
DAQmxErrChk(DAQmxStartTask(taskHandle1));

 

 

 

So why is it that I can create a TaskHandle with two physical channels, and then I cannot specifically address one channel's output? I would like to pass I_chan_buffer and Q_chan_buffer to separate physical channels. 

 

Thank you

 

Mark 

0 Kudos
Message 1 of 6
(941 Views)

That is how DAQmx works, when you create a Task with multiple channels, it will ALWAYS expect you to provide data for ALL CHANNELS in the TASK. Nothing you can do about that.

 

If you want, you can create individual tasks but based on actual HW it may or may not run at the same time - some HW supports more than one simultaneous task but most don't.

 

Why don't you combine the I&Q data using array operations before passing it to DAQmx write?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 6
(920 Views)

Why don't you combine the I&Q data using array operations before passing it to DAQmx write?

 

The project requires that I produce two output signals. One for I and one for Q. So I am looking to produce two waveforms using two separate physical channels. Are you saying that I can only produce one set of samples on a given TaskHandle? If so, what is the process of declaring another TaskHandle object? The NIDAQ C API example gave the following. 

 

TaskHandle  taskHandle1 = 0;

but attempting to declaring another TaskHandle variable using the next integer

TaskHandle  taskHandle1 = 0;
TaskHandle taskHandle2 = 1;

results in this error. 

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2440	'initializing': cannot convert from 'int' to 'TaskHandle'	NIDAQ6738_PlayTSD	C:\PlayTSD_v1.0.0\GUI.cpp	56	

so how can I declare another TaskHandle then to use for a separate waveform? 

 

Thanks

0 Kudos
Message 3 of 6
(908 Views)

Let me clarify my comment about tasks,

 

A task can contain 1 or more channels, consider them like an array that can have 1 or more elements.

 

When writing data to a task, you've to write data for all the channels in the task. In your case, let us assume you're using ao0 for I and ao1 for Q. Now, you've created a task containing the channels ao0, ao1.

 

Whenever you write data to the task, you've to provide data for both ao0 and ao1, you cannot provide them separately. If you want to provide a 1D array of double data for ao0 and ao1, you've to combine them into a 2D array and pass it to DAQmx write.

 

I am sorry, I cannot help you with C APIs, I am a LabVIEW guy.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 6
(905 Views)

Santhosh, 

 

Thank for your thoughtful answer. The issue seems to be with my interpretation of the API documentation. The help page for `DAQmxWriteBinaryI16` defines the `writeArray[]` input as `int16 []`. So I don't see how this could accept an arbitrarily sized array. 

 

Instead, I'm going to interleave the data and provide those data to `DAQmxWriteBinaryI16` as a single interleaved array. 

 

 

 

0 Kudos
Message 5 of 6
(883 Views)
Solution
Accepted by musilmark25

Somewhere I have read about different data structuring for C APIs

 

This article might be helpful - https://www.ni.com/en-us/support/documentation/supplemental/21/using-ni-daqmx-in-text-based-programm...

 

santo_13_0-1631717718351.png

 

BTW, why are you writing as Binary I16? do you not need scaling? I would recommend any Floating point equivalent function so that you don't need to worry about scaling the DAC codes to Voltage

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 6
(871 Views)