10-28-2010 02:42 PM
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
10-29-2010 11:39 AM
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,
10-29-2010 11:58 AM
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
10-29-2010 12:32 PM
Are you trying to change the Sample Rate or the number of Samples to Read?
10-29-2010 12:37 PM
Actually both, but once I learn how to do one....
10-29-2010 12:42 PM
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.
10-29-2010 12:47 PM
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.