04-15-2014 09:35 AM
Hi!
I need to set the AI convert rate property of the DAQmx Timing class in my .NET application.
C API style works:
DAQmxSetAIConvRate(TaskHandle taskHandle, float64 data);
Labview works if I specify the active device:
.NET API has a property -> "analogInputTask.Timing.AIConvertRate"
But if I set this property and run my application (cDaq-9188 Ethernet, NI9205 device), I get following exception:
"An exception of type 'NationalInstruments.DAQmx.DaqException' occurred:
DAQmx Timing property specified requires per device configuration.
Explicitly specify the device(s) to which this property should apply.
Property: NationalInstruments.DAQmx.Timing.AIConvertRate"
Cannot find an ActiveDevs property in the Timing class to use it like in Labview.
Any suggestions how to do this?
Best regards
Holger
Solved! Go to Solution.
04-16-2014 04:33 AM
Hi Holger,
could you post the manipulation of the convert clock property in the context where you create the task and set the timin settings in .NET? I would like to take a look at this, if there is something missing. The exception sounds like that.
Regards,
Melanie
04-16-2014 05:55 AM
Hi Melanie,
thanks for your help!
My code is splitted in too many small pieces, but essentially I do the same like the "AcqVoltageSamples_IntClk" from the examples:
// Create a new task myTask = new Task(); // Initialize local variables double sampleRate = Convert.ToDouble(rateNumeric.Value); double rangeMinimum = Convert.ToDouble(minimumValueNumeric.Value); double rangeMaximum = Convert.ToDouble(maximumValueNumeric.Value); int samplesPerChannel = Convert.ToInt32(samplesPerChannelNumeric.Value); // Create a channel myTask.AIChannels.CreateVoltageChannel(physicalChannelComboBox.Text, "", (AITerminalConfiguration)(-1), rangeMinimum, rangeMaximum, AIVoltageUnits.Volts); // Configure timing specs myTask.Timing.ConfigureSampleClock("", sampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, samplesPerChannel); // Verify the task myTask.Control(TaskAction.Verify); double convertRate = myTask.Timing.AIConvertRate
I`ve tested this example and the exception occurs in the last line.
Regards
Holger
04-16-2014 09:30 AM
Hi Holger,
thank you for testing the example.
Could you try it with
myTask.Timing["cDAQ1Mod1"].AIConvertRate
instead of
myTask.Timing.AIConvertRate
? Replace the cDAQ description with the name of yours. You can look it up in MAX, if you are not sure what it is called.
Please let me know if this works for you.
Regards,
Melanie
04-17-2014 02:25 AM
Thanks Melanie! This works!
I`ve never seen an example for using Timing like an array...
Best regards
Holger