Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when I use 1MHz sample rate ...

Hi .. I am trying ot write a porgram in VB .NET 2008. I am using Visual Studio 2005, Measurement Studio nad DAQmx. I have a 6120 card. I started by extracting from  the example code C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Analog In\Measure Voltage\ContAcqVoltageSamples_IntClk\vb  adn then ading graphs etc to my code. Now the problem is that my code works fine when I use rates of 100 KHz for the sample clock. But if try to use 1MHz, the data is collected only once and then the following error message appears:
Measurements: Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: NationalInstruments.DAQmx.DaqStream.ReadRelativeTo
Corresponding Value: NationalInstruments.DAQmx.ReadRelativeTo.FirstSample
Property: NationalInstruments.DAQmx.DaqStream.ReadOffset
Corresponding Value:

Task Name: _unnamedTask<0>
Status Code: -200279
 
Please help me out. And I do need sampling rates of 1MHz.
 
Thank you in anticipation.
 
Vijay
0 Kudos
Message 1 of 14
(5,695 Views)
Hi Vijay,

Check one of my earlier posts here that addresses this issue.

Hope this helps!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 14
(5,692 Views)
Hello Jonathan,
Thank you for your reply. My problem is solved. I have one another question. Let me try to exaplin it. Suppose that I call for the analogInreader.BeginReadMultiSample(10000, analogCallBack, myTask) and the it acquires 10000 samples and reports to me. Now I want to pause the daq for sometime until I need that. For that I apply an if condition
if dummy is true then
analogInreader.BeginReadMultiSample(10000, analogCallBack, myTask)
end if

That means Daq keeps acquiring data only if dummy is true. Now my question is that if i get some data(10000 samples) and pause for some time and then again call analogInreader.BeginReadMultiSample(10000, analogCallBack, myTask) at some later time, Then will the new 10000 points that are reported now correspond to what was acquired during the second run or the previous run or some data(in case my card did that) in between the two runs. Ofcourse I want the data that is collected only after I called for BeginReadMultiSample.

I also placed
myTask.Stream.ReadOverwriteMode = ReadOverwriteMode.OverwriteUnreadSamples
myTask.Stream.ReadRelativeTo = ReadRelativeTo.MostRecentSample
just before I called BeginMultiSample for the first time.

Thank you once again Jonathan.

Vijay
0 Kudos
Message 3 of 14
(5,668 Views)
Hi Vijay,

I am a little unclear of your actually setup. Are you putting some "delay" in between your EndReadMultiSample and BeginReadMultiSample lines in the callback?  Even during this time, the underlying DAQ buffer is still being filled up.  As stated in the Controlling Where in the Buffer to Read Samples NI-DAQmx help topic,

"The place where a read begins is called the Current Read Position. Each time data is read, the Current Read Position is computed based on the settings of the Relative To and Offset attributes/properties. When there is no Reference Trigger, the default for Relative To is Current Read Position. When there is a Reference Trigger, the default for Relative ToOffset is 0. Changing the settings of these two attributes/properties controls where in the buffer data is read. is First Pretrigger Sample. In either case, the default for

During a continuous acquisition, for example, you can always read the most recent 1000 points by setting Relative To to Most Recent Sample and Offset to -1000. Even when a Reference Trigger is configured, you can begin reading samples immediately by setting Relative To to First Sample."

Hope this clears it up

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 4 of 14
(5,663 Views)
I can understand yu a little, but I m still stuck with my problem. Let me put it this way.
When I call BeginMultiSample for the first time, 1000 points are put into the buffer. Now I Do my calculations,while card gathers another 500(lets say) samples. After I am done with calculations, I call for BeginMultiSample again and this will put another 1000 sample into the buffer. Now how do I read just the last 1000 samples and ignore 500 samples in between?
I hope that clears my problem to you.

Thank you.

Vijay
0 Kudos
Message 5 of 14
(5,662 Views)

Hi Vijay,

When doing a continuous acquisition the DAQ card begins sampling and buffering samples as soon as the task starts. The first 1000 samples you read will the samples 0-999. Then if you delay and read 1000 samples you will still receive samples 1000-1999. This is because the DAQ driver buffers the acquired samples. There are two ways around this. The first is to change your task from continuous acquisition to finite acquisition. Then once the task starts it will only acquire as many samples as you specify. You can then read and process those samples. When you need more samples you can stop and start the task to acquire more right then.  The other option is to do what Jonathan mentioned above and control where you are reading sample from in the buffer. You can setup the task to always read the newest 1000 samples by setting the “Relative To” property to Most Recent Sample and the “Offset” property to -1000. In your case these properties are part of the DAQStream class and are the ReadRelativeTo and ReadOffset properties.

Please let me know if you have any questions and take care.

Thanks,

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 6 of 14
(5,632 Views)
Nathan,
Hi, Thank you for your reply. I get your point. I have come across another problem. Yesterday I did not have any problem reading the samples at the rate of 1MHz (ofcourse after I did what Jonathan had told me too). BUt all of a sudden, I don't know why, I started to see this error now:
Measurements: ADC conversion attempted before the prior conversion was complete.
Increase the period between ADC conversions. If you are using an external clock, check your signal for the presence of noise or glitches.
Task Name: _unnamedTask<0>
Status Code: -200019
 
I did not make any changes in my programme. Is it due to some error in my hardware (I am using PCI 6120)? I can't figure out that why this error has shown up, all of a sudden.
0 Kudos
Message 7 of 14
(5,615 Views)

Hi Vijay,

This error may be caused by the sampling rate you are using. The 6120 supports up to 800kS/S using the onboard sample clock. You can go up to 1 MHz by using an external clock or generating a clock using an onboard counter and enabling Warp Mode on the card. Currently the only way I know how to enable Warp Mode is using a LabVIEW Vi available in the Developer Zone, Implementing Warp Mode on NI-6120 an NI-613x Devices. I will try to find a way to enable Warp Mode in .net for you.

In the meantime can you try lowering the sampling rate to 800kHz and see if the error goes away?

Please let me know if you have any questions.

Thanks,

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 8 of 14
(5,589 Views)
Nathan,
Hello. Now I know why my device sometimes works and sometimes does not. Actually My colleague used warp mode with his Lab View program on the same machine. And that is why it was working day before yesterday. And ofcourse, device does not produce any error with 800 KHz. Thank you very much for your help.

Regards
Vijay Rana

P.S. Please let me know if you come up with warp mode for the .NET version. Thank you once again.
0 Kudos
Message 9 of 14
(5,587 Views)
Hey Vijay,

I think I have come up with a way to enable and disable warp mode in the .net environment but I still need to test it more to make sure. I will post how as soon as I'm sure it is working.

Thanks,
Nathan
NI Chief Hardware Engineer
0 Kudos
Message 10 of 14
(5,571 Views)