ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding multiple global virtual channels

Solved!
Go to solution

Hi,

 

 

I had a very simple function written in CVI that adds multiple global virtual channel

DAQmxErrChk (DAQmxAddGlobalChansToTask(g_TaskHandle, linesName)); //linesName consists 2 global virtual channels seperated by ",". E.g. "Power, Com" where Power = port1/line0 & Com = port1/line2

 There is AddGlobalFunction in MEasurement Studio too but it allows adding single channel only:

Task localTask = new Task();
localTask.AddGlobalChannel(linesName); //Get Expetion here = -200486, Specified Channel not in the task. When I give a single channel name..it works
DigitalSingleChannelWriter doWriter = new DigitalSingleChannelWriter(localTask.Stream);
doWriter.WriteSingleSampleMultiLine(true, states); //atates is the array of type bool which consists of value for each channel

 Is it not possible any more to add multiple Global Channels to a task??

 

We have recently acquired Measurement Studio license and are trying to port/compile/write our old libraries (written in CVI) in it.

- Is there any online help that compares CVI C functions with respective .NET functions of DAQmx?

 

Thanks in advance!

 

Ciao

Ricky

0 Kudos
Message 1 of 5
(7,219 Views)

Have been trying this for last 2 days, have also searched number of NI forum messages but have not got solution.

 

Anyone with slightest of hint?

0 Kudos
Message 2 of 5
(7,171 Views)

Have been trying this for last 2 days, have also searched number of NI forum messages but have not got solution.

 

Anyone with slightest of hint?

 

Meanwhile I have gathered some more Information:

 

- Adding multiple Global channels in LabWindows/CVI is possible using DAQmxAddGlobalChansToTask function where channels are , (comma) seperated

- Also adding multiple Global channels in LabView  where channels are , (comma) seperated.

 

May be I am wrong but has NI forgotten to implement the same in MeasurementStudio ? Or am I missing something?

0 Kudos
Message 3 of 5
(7,160 Views)
Solution
Accepted by dotNet_to_LabW

Hi,

 

it seems like you are correct. The definition of the method specifies that it only adds one channel:

 

public NationalInstruments.DAQmx.Channel AddGlobalChannel(string channelName)
    Member of NationalInstruments.DAQmx.Task

Summary:
Adds a preconfigured, global channel to the task.

Parameters:
channelName: The name of the global channel to add to the task.

Returns:
The global Channel.

Exceptions:
NationalInstruments.DAQmx.DaqException: The NI-DAQmx driver returned an error.

 

This could be explained by the fact the function returnes the appropriate instance of the channel object related to the global virtual channel you created. 

 

I tried to check the code reading 2 Global Virtual Channel using the DAQ Assistant in Measurment Studio but I was not able to get much of it (the generated code makes two consecutive calls of the "CreateVoltageChannel" method.

 

What happen if you call AddGlobalChannel twice?

 

Task localTask = new Task();
localTask.AddGlobalChannel("Power");
localTask.AddGlobalChannel("Com");

 

I did not have time to try this so far, but from my understanding of the help file, I assume it could work.

 

Best regards

______________
Florian Abry
Inside Sales Engineer, NI Germany
Message 4 of 5
(7,121 Views)

It worked!

 

Sorry, I did not even think about calling the function with different channels multiple times.

 

Thanks for your help!!

0 Kudos
Message 5 of 5
(7,098 Views)