帖子被jwdz在05-30-2007 09:31 AM时编辑过了
您的意思是我一个通道采样一点,一次循环吧?这样会不会浪费时间?下面是我的一段代码,采样九个通道,每个通道4000点,采样频率4000,这样消耗的时间是1秒多钟。如果单点采集的话应该远远超过这个时间吧,不能满足需要阿!
各位能不能给一段简单的、能节省时间的代码,不胜感激!
For i = 0 To 9
daqchannel = " Dev1/" + "ai" + CStr(i)
myTask.AIChannels.CreateVoltageChannel(daqchannel, "", AITerminalConfiguration.Rse, -5, 5, AIVoltageUnits.Volts)
Next
myTask.Timing.ConfigureSampleClock("", 4000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, 4000)
myTask.Control(TaskAction.Verify)
reader = New AnalogMultiChannelReader(myTask.Stream)
reader.SynchronizeCallbacks = True
ar = reader.BeginReadMultiSample(Convert.ToInt32(daqsample), Nothing, Nothing)
data = reader.EndReadMultiSample(ar)
帖子被ian fung在05-30-2007 12:10 PM时编辑过了
呵呵!是的,每个通道总共采样4000点。但在实际应用中我们需要同时采集两个通道的数据(即每个通道采一个,并根据这两个数据X和Y来得到位移Z)。如果一个通道采完4000点后再采第二个通道的4000,然后根据每个通道的头两个点再来求位移就没有多大意义了,时间差相对来说大了很多。
不知道有没有别的方法,而且我刚也试过了,一个点的采集任务是会出错的,最少要两个点。
谢谢!
Confused!
Anyway...
You may choose to perform DAQmx Read either
By configuring Dev1/ai0:9, you should be able to acquire all channels at the same time with the above alternatives.
Use index array to extract sample(s) from each channel for post processing.