From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CompactDaq AI with Visual Basic .NET

Here is the project without Excel, but now I have an error whose message I have attached as an image.  It happens with I try to execute Reader(0).ReadMultiSample

Thanks
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
Download All
0 Kudos
Message 31 of 115
(2,019 Views)
Hi Michael,

Hopefully, I have found the problem!  You are receiving the -200278 error because your timing mode is set to Finite, even though you are doing a Continuous acquisition.  This may be causing the slow acquisition rate as well.

Try this change, replace Finite with Continuous.

                Tasks(TaskCount).Timing.ConfigureSampleClock("", frm.numSampleRate.Value, SampleClockActiveEdge.Rising, _
                                                             SampleQuantityMode.FiniteSamples, frm.numSamples.Value)

Replace with

                Tasks(TaskCount).Timing.ConfigureSampleClock("", frm.numSampleRate.Value, SampleClockActiveEdge.Rising, _
                                                             SampleQuantityMode.ContinuousSamples, frm.numSamples.Value)

Please let me know if this solves the problem!
Thanks,
Erik
0 Kudos
Message 32 of 115
(2,008 Views)
Now I am getting "Attempting to read a sample that is no longer available."
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 33 of 115
(2,004 Views)
Hey Michael,

I think you are getting error -200279, Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

This error indicates that the DAQ card acquired samples, placed them on the buffer, and that the samples were overwritten before your .NET code could read from the buffer.  The buffer size is determined by the number of samples input, we may want to increase that number.

What numbers are you using for your rate and number of samples?

Thanks,
Erik
0 Kudos
Message 34 of 115
(2,003 Views)
200 S/s and 1 or 2 samples per channel.  I'd like to keep my loop time under 500 ms if possible.  I am happy with one reading as long is it isn't subject to noise.  It seems to run very close to our SCXI system which is taking 100 samples and averaging them.  If I increase the number of samples I want, won't it take longer to respond?  Should I just decrease my rate?
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 35 of 115
(1,997 Views)
Hey Michael,

If your goal is 1 or 2 samples per second, why is your rate set to 200 S/s?  I think that you are correct in that the rate needs to be decreased to 1 or 2 S/s.  I would suggest trying 1 sample per channel and acquire at 2 S/s (2 Hz).  This way, your loop will take 500 ms and you shouldn't get any buffer problems.

Regards,
Erik
0 Kudos
Message 36 of 115
(1,982 Views)
Have you been able to get my software working on your computer?  The latest one with no excel reference.
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 37 of 115
(1,979 Views)
Hi Michael,

I was able to get your code to run without error if I use 2 samples per channel and a rate of 2 S/s.  I am unsure where it writes to file though.

Erik
0 Kudos
Message 38 of 115
(1,976 Views)
It's in bin\data where the application startup path is
Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 39 of 115
(1,973 Views)
Hi Michael,

I found the data file, it is attached.  I am still having trouble understanding your code.  It seems that no matter what I put in for the rate, it still samples at 1 S/s for me.

Erik
0 Kudos
Message 40 of 115
(1,969 Views)