11-24-2009 05:08 PM
I'm attempting to read Multiple channles at the same time in C# using this
try
{
C1Driver.AIChannels.CreateVoltageChannel("CARD_01/ai0", "", AITerminalConfiguration.Differential, -VScale[1], VScale[1], AIVoltageUnits.Volts);
C2Driver.AIChannels.CreateVoltageChannel("CARD_01/ai1", "", AITerminalConfiguration.Differential, -VScale[2], VScale[2], AIVoltageUnits.Volts);
C3Driver.AIChannels.CreateVoltageChannel("CARD_01/ai2", "", AITerminalConfiguration.Differential, -VScale[3], VScale[3], AIVoltageUnits.Volts);
C4Driver.AIChannels.CreateVoltageChannel("CARD_01/ai3", "", AITerminalConfiguration.Differential, -VScale[4], VScale[4], AIVoltageUnits.Volts);
C1Driver.Timing.ConfigureSampleClock("", Rate[1], SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Count[1]);
C2Driver.Timing.ConfigureSampleClock("", Rate[2], SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Count[2]);
C3Driver.Timing.ConfigureSampleClock("", Rate[3], SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Count[3]);
C4Driver.Timing.ConfigureSampleClock("", Rate[4], SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Count[4]);
C1Driver.Control(TaskAction.Verify);
C2Driver.Control(TaskAction.Verify);
C3Driver.Control(TaskAction.Verify);
C4Driver.Control(TaskAction.Verify);
C1AReader = new AnalogMultiChannelReader(C1Driver.Stream);
C2AReader = new AnalogMultiChannelReader(C2Driver.Stream);
C3AReader = new AnalogMultiChannelReader(C3Driver.Stream);
C4AReader = new AnalogMultiChannelReader(C4Driver.Stream);
V1Data = QST_SetupDAQ.C1AReader.ReadMultiSample(Count[1]);
V2Data = QST_SetupDAQ.C1AReader.ReadMultiSample(Count[2]);
V3Data = QST_SetupDAQ.C1AReader.ReadMultiSample(Count[3]);
V4Data = QST_SetupDAQ.C1AReader.ReadMultiSample(Count[4]);
}
I'm wondering if this is the best method, or is their a better way to setup the reading of 4 or more channels at the Same time
11-24-2009 06:36 PM
11-24-2009 06:49 PM - edited 11-24-2009 06:51 PM
Problem is each Channel need to be controled indivudally as they can be requesting diffrent voltages levels / scales
It's not a problem if I have to configure each channel indivudally, but I do need to know how to have them all start the test at the same time.
11-24-2009 09:57 PM
11-25-2009 09:50 AM
Hello RRobertH,
So there are some limitations with adding multiple channels to one task. One of these is that they must all operate with the same sample clock settings. Thus, you would only call "Timing.ConfigureSampleClock" once for the task. You can create seperate channels with seperate limits and scales, but they must all use the same timing and triggering. Additionally, you should use the AnalogMultiChannelReader to retrieve the information for all the channels, then you can parse out each channel.
Regards,
11-25-2009 01:44 PM
So just to verify the code would be along these lines then correct ?
try
{
Driver.AIChannels.CreateVoltageChannel("CARD_01/ai0", "", AITerminalConfiguration.Differential, -VScale[1], VScale[1], AIVoltageUnits.Volts);
Driver.AIChannels.CreateVoltageChannel("CARD_01/ai1", "", AITerminalConfiguration.Differential, -VScale[2], VScale[2], AIVoltageUnits.Volts);
Driver.AIChannels.CreateVoltageChannel("CARD_01/ai2", "", AITerminalConfiguration.Differential, -VScale[3], VScale[3], AIVoltageUnits.Volts);
Driver.AIChannels.CreateVoltageChannel("CARD_01/ai3", "", AITerminalConfiguration.Differential, -VScale[4], VScale[4], AIVoltageUnits.Volts);
Driver.Timing.ConfigureSampleClock("", Rate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, Count);
Driver.Control(TaskAction.Verify);
Reader = new AnalogMultiChannelReader(Driver.Stream);
VData = Reader.ReadMultiSample(Count);
}
11-25-2009 01:54 PM
I'm not exactly familiar with the C# code, but that looks like the proper format. As long as they are all in the same task, you are fine.
Regards,