Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup to sample any two channels using DAQmx in .NET?

Solved!
Go to solution

Hi,

 

I am using NI 6210 and the maximum sampling rate is 250kHz. But if I sample 5 channels, each channel can have a rate of 50kHz. I am using DAQmx in .NET and I know I can set this using the following command:

myChannel = analogInTask.AIChannels.CreateVoltageChannel(
"Dev1/ai0:4", //The physical name of the channel
"myChannel_v1,myChannel_v2,myChannel_v3,myChannel_v4,myChannel_v5", //The name to associate with this channel

AITerminalConfiguration.Nrse,
0, //10v minimum
10, //10v maximum
AIVoltageUnits.Volts //Use volts
);
sampleRateInKHz = 30;
analogInTask.Timing.ConfigureSampleClock(
"", // external clock source line or use "" for internal clock
sampleRateInKHz*1000, // expected rate of external clock or actual rate of internal clock
SampleClockActiveEdge.Rising, // acquire on rising or falling edge of ticks
SampleQuantityMode.ContinuousSamples, // continuous or finite samples

500000 // number of finite samples to acquire or used for buffer size if continuous
);

 I can also choose single channel by replacing "Dev1/ai0:4" with "Dev1/ai0". However I can't find a way to select 2, 3 or 4 channels by choice, for example if I want to use only channels ai1 and ai3, then how do I set this in the code?


Thanks.

0 Kudos
Message 1 of 3
(3,362 Views)
Solution
Accepted by topic author Xichan

Hi Xichan,

 

To use channels ai1 and ai3, you can separate them by commas:

 

analogInTask.AIChannels.CreateVoltageChannel("Dev1/ai1,Dev1/ai3", ...)

 

or you can call CreateVoltageChannel() twice:

 

analogInTask.AIChannels.CreateVoltageChannel("Dev1/ai1", ...)

analogInTask.AIChannels.CreateVoltageChannel("Dev1/ai3", ...)

 

Calling the create channel function multiple times is helpful when you want the other parameters to be different on each channel.

 

Brad

---
Brad Keryan
NI R&D
Message 2 of 3
(3,344 Views)

Exactly what I needed, thanks.

0 Kudos
Message 3 of 3
(3,333 Views)