Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure multiple read channels for reading at the same time

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

0 Kudos
Message 1 of 7
(4,705 Views)
I don't use c# but I can tell you that you are using too much code and code that will generate an error. You need to create a single task and that means a single CreateVoltageChannel, ConfigureSampleClock, etc. Define multiple channels at once using syntax such as Dev1/ai0:4.
0 Kudos
Message 2 of 7
(4,699 Views)

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.

 

Message Edited by RRobertH on 11-24-2009 06:51 PM
0 Kudos
Message 3 of 7
(4,694 Views)
As long as you add the channels to a single task you can do it. You cannot configure separate clock rates. If you have a single task and start that, then you do a single read with multiple channels. Sorry, I'm not familiar enough with the c# syntax to tell you what the command for that is. I'm more familiar with LabVIEW and C.
0 Kudos
Message 4 of 7
(4,682 Views)

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,

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 7
(4,672 Views)

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);
}

0 Kudos
Message 6 of 7
(4,660 Views)

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,

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 7 of 7
(4,657 Views)