Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help setting samplerate in DAQMX, vb.net

In MS VS-2005, I createted via the new project option a DAQMX windows form, used the wizard to configure the analog inputs (USB-6212) and I can read the data just fine.

What I can't figure out is how to change the sample rate (or any other property) after the fact.

 

My project has a daqmx task class named DaqTask1 in the DaqTask1.mxb file.

So I tried to set the number of samples to 20000 with this code (it was set at 10000 with the wizard):

 

Dim analogInTask As New DaqTask1

 

analogInTask.Timing.ConfigureSampleClock("", 100000, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, 20000)

 

It doesn't blow up, but does not change the number of samples.

thanks

Bob

 

0 Kudos
Message 1 of 7
(4,344 Views)

Hi p15218,

 

A good place to start would be to look at the code used with the shipping examples for the DAQmx driver.  If you browse to Start»Programs»National Insturments»NI-DAQ»Text-based Code Support».NET Examples   you will be able to find exapmles for VB.NET for Data Acquisition.  In these examples, you will find that there is a from created to input these values in a combo box or a text box, but the code will have hte call to setup the sample rate.  Let me know if this helps.

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 2 of 7
(4,328 Views)

Adam,

Thanks but the examples I found show how to programmably create a task and set it's properties. I understand how to do that, my issue is with using the wizard to create a task (so the project has an .MXB file) and then trying to change properties of the wizard created task.

I didn't find any examples that helped me.

Bob

 

 

0 Kudos
Message 3 of 7
(4,323 Views)

Are you trying to change the Sample Rate or the number of Samples to Read?

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

Actually both, but once I learn how to do one....

0 Kudos
Message 5 of 7
(4,319 Views)

So, to change the rates, you set the following items in the function call:

analogInTask.Timing.ConfigureSampleClock("", 100000, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, 20000)

Sample Rate (100000 kHz in this case)

Samples to Read (20000 samples in this case)

 

Sample rate will change how fast the samples are taken.

Samples to Read doesn't change much besides the buffer size on continuous tasks.  If you want to change the number of samples returned by the analog Reader, you'll need to set the Number of Samples To Read in the Reader function, not in the timing function.

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

If you are editing the values in the .MXB file, that is not what I want to do. I want to be able to change them in my main form and effect the Wizard created DAQ object.

0 Kudos
Message 7 of 7
(4,314 Views)