Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

scan channel list in NIDAQmx

Hi,

  I am using NIDAQmx 8.0 on Linux with NI PCI-6281 and 'C'.

I need to define the order in which channels are scanning.

I tried to follow advice form an article "Can I Sample One Channel Multiple Times Before Switching to the Next Channel In My DAQ Channel List?...

But I could get it right.

It seems I couldn't create global channels with

DAQmxCreateAIVoltageChan(taskHandle,physName,"Name1",...);

It also adds channel to the task.

What is then difference between global and virtual channel.

DAQmxCreateAIVoltageChan(taskHandle,physName,"Name2",...);

And When I tried DAQmxAddGlobalChansToTask(taskhandle,"Name1, Name2");

I got error 'Specified channel cannot be added to the task, because a channel with the same name is already in the task.'

Even when I added only Name2 I got the same message,

although I'd got from DAQmxGetReadChannelsToRead(taskHandle,..);

before that only "Name1".

 

Thanks,

  Andrew
 

0 Kudos
Message 1 of 6
(5,910 Views)

Hello AndreyCherepenko,

When you received that error text, did you also receive a specific error number? This could help us understand what is wrong.

This KnowledgeBase article “Sampling Different Channels at Different Overall Rates with NI-DAQmx” (http://digital.ni.com/public.nsf/allkb/96FD2F4685065C7686256F25006EE8DE) states that “Each local virtual channel must have a unique name because NI-DAQmx does not allow two virtual channels with the same name in the same task.”. You must give each channel a unique name, as specified in MAX (or per the steps in the DAQmx Base methods mentioned below) .

Global Virtual Channels are used by NI-DAQmx. Virtual Channels are used with the Traditional DAQ driver. My colleague Otis further clarifies the difference between a Task and a Channel in this forum post (http://forums.ni.com/ni/board/message?board.id=250&message.id=13446#M13446). I created both a Tdaq Virtual Channel and a NI-DAQmx Global Virtual Channel in MAX as seen here:

 

globalvirtual.png

 

From the help file for NI-DAQmx for Linux (http://ftp.ni.com/support/softlib/multifunction_daq/nidaqmx/8.0/Linux/Mandriva/readme.txt) “Persistent channels, tasks, and scales - Refer to the "NI-DAQmx Help" for how to programmatically create channels and tasks.” The NI-DAQmx Base Help (http://digital.ni.com/manuals.nsf/websearch/D549999ED75A41C38625748100719AE8) contains detailed information on the functionality you seek:

“DAQmxBase Create Virtual Channel VI
Creates a virtual channel or set of virtual channels and adds them to a task. The instances of this polymorphic VI correspond to the I/O type of the channel, such as analog input, digital output, or counter output; the measurement or generation to perform, such as temperature measurement, voltage generation, or event counting; and in some cases, the sensor to use, such as a thermocouple or RTD for temperature measurements.

You must call DAQmxBase Create Task before calling this VI. Alternately, you can use a DAQmxBase task control or constant to refer to a static task that was configured using the NI-DAQmx Base Task Configuration Utility.

Use the pull-down menu to select an instance of this VI.”

David G
Sales Engineer - SE Michigan & N Ohio
National Instruments
0 Kudos
Message 2 of 6
(5,881 Views)

Hello DJ Dave,
  Thank you for references.
  But most I'd seen before, None of them helped.

I try to clear up my question.
I need to have the same physical channel in scan list.
(Of course I use different names for virtual channels)

1 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name1",...);
2 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name2",...);

After first call task has already got "Name1"
as reported by  DAQmxGetReadChannelsToRead(taskHandle,..);
But after second call
DAQmxGetReadChannelsToRead(taskHandle,..); it still returns "Name1".
If in the second call physical chan were "/Dev1/ai1" it would return "Name1 Name2" and all work fine.

KnowledgeBase article "Can I Sample One Channel Multiple Times Before Switching to the Next Channel I\ n My DAQ Channel Li...  suggests that I should create global channels with
DAQmxCreateAIVoltageChan().
Is that possible ? What does taskHandle for ?
DAQmxAddGlobalChansToTask() refuses to add my virtual channels.
I think they aren't global.

Is it possible to do thaT on Linux with NIDAQmx 8.0 ?
I have neither LabView nor MAX nor even NIDAQmx BASE.

Thanks,
  Andrew

0 Kudos
Message 3 of 6
(5,853 Views)

Hi Andrew,

 

Since MAX is not an option, you can programmatically create your global channels as described in this discussion forum.  The LabVIEW commands they are referencing can be found in the DAQmx C Reference Help seen below.  The help file should be found in your National Instruments<<NI DAQ folder.  Also take a look at the C++ example from here to use as a starting point.  Looking up any of the functions in the Help should also provide an explanation of what is passed in and out of the function.  Hopefully this helps!

 

DAQmx C.jpg  

Regards,


h_baker
National Instruments
Applications Engineer
Message 4 of 6
(5,776 Views)
Hi,
  Thank you for suggestions.
  I've discovered my mistake.
That is what I actually did:
1 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name1",...);
 1a DAQmxSetAILowpassEnable(taskHandle, "/Dev1/ai0", -1);
2 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name2",...);
 
Without '1a' all work.
I think I needn't any global channel to make scan list.
 
Thanks,
  Andrew
 
 

AndreyCherepenko wrote:

I need to have the same physical channel in scan list.

1 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name1",...);
2 DAQmxCreateAIVoltageChan(taskHandle,"/Dev1/ai0","Name2",...);

After first call task has already got "Name1"
as reported by  DAQmxGetReadChannelsToRead(taskHandle,..);
But after second call
DAQmxGetReadChannelsToRead(taskHandle,..); it still returns "Name1".
If in the second call physical chan were "/Dev1/ai1" it would return "Name1 Name2" and all work fine.


0 Kudos
Message 5 of 6
(5,747 Views)

There is a simple solution that worked for me: String together multiple "Create Virtual Channel" VIs. The key here is to make sure to assign unique names for each channel. See attached image.

 

Does this work for you?

 

LabView-repeat-scanning.PNG

Message 6 of 6
(4,172 Views)