08-05-2011 10:54 AM
Hi there,
I have an VB2008 Application in which I measure some data from displacement sensors (analogue input). So far the system was running with NI PCI-9225 and it was running very well. I am collecting data from up to 24 sensors and I could measure up to 20 sets per second which was perfect for my application.
The code was like this:
'the initiation of the task myTaskAI = New Task() aiKanaele = "dev1" & "/ai0:79" myTaskAI.AIChannels.CreateVoltageChannel(aiKanaele, "", CType(NationalInstruments.DAQmx.AITerminalConfiguration.Rse, AITerminalConfiguration), _
0.0#, 10.0#, AIVoltageUnits.Volts) readerAI = New AnalogMultiChannelReader(myTaskAI.Stream) 'the measurement: Dim dataai2(,) As Double = Nothing dataai2 = readerAI.ReadMultiSample(20)
Now the system was redesigned and the hardware was changed to the NI CompactDAQ 4-Slot USB Chassis NI cDAQ-9174 and with an NI-9208 module. I had to change my software slightly because it is a current input instead of the voltage input. My problem is that in this sytsem I get data from my sensors only once every 2 seconds which is far to slow.
The new code is:
'the initiation of the task myTaskAI = New Task() aiKanaele = "cDAQ1Mod1" & "/ai0:15" myTaskAI.AIChannels.CreateCurrentChannel(aiKanaele, "", _
AITerminalConfiguration.Rse, 0.0#, 0.02#, AICurrentUnits.Amps) readerAI = New AnalogMultiChannelReader(myTaskAI.Stream) 'the measurement: Dim dataai2(,) As Double = Nothing dataai2 = readerAI.ReadMultiSample(20)
When I run the measurement from the Testpanel of the Measurement & Automation Explorer the speed is OK but it slows down when I run it form my VB-program.
What can I do? Do I need additional code to speed up the measurement from the VB code.
Any help is appreciated.
Axel
Solved! Go to Solution.
08-09-2011 06:31 AM
Hi Redrhino,
I'm not working with Measurementstudio VB, but I think in your sourcecode the daqmx timing is missing, isn't it?
It seems to me, that the Daq-Device takes a kind of default timing or samplerate.
Additional you former use a PCI Card. This is not comparable to the USB-Device you are using now with regard to the speed, but one sample per 2sec is very slow.
Hope I could help.
Tobias
08-11-2011 02:47 PM
Hi Tobias
Thank you for your suggestion. You are right, the a setting of the timing was requested.
I finally found out how to change the code:
'the initiation of the task myTaskAI = New Task() aiKanaele = "cDAQ1Mod1" & "/ai0:15" myTaskAI.AIChannels.CreateCurrentChannel(aiKanaele, "", _ AITerminalConfiguration.Rse, 0.0#, 0.02#, AICurrentUnits.Amps) myTaskAI.Timing.ConfigureSampleClock("", 1000.0#, _ SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 20) readerAI = New AnalogMultiChannelReader(myTaskAI.Stream) 'the measurement: Dim dataai2(,) As Double = Nothing myTaskAI.Stream.ReadRelativeTo = ReadRelativeTo.MostRecentSample dataai2 = readerAI.ReadMultiSample(20)
Thanks again
Axel