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.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the AIConvertClock rate in DAQmx .NET API

Solved!
Go to solution

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:

LV-DaqmxTiming.jpg

 

 .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

 

 

0 Kudos
Message 1 of 5
(4,013 Views)

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

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 2 of 5
(3,996 Views)

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

 

 

 

0 Kudos
Message 3 of 5
(3,991 Views)
Solution
Accepted by topic author HoNeu

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

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
Message 4 of 5
(3,973 Views)

Thanks Melanie! This works!

 

I`ve never seen an example for using Timing like an array...

 

Best regards

Holger

 

0 Kudos
Message 5 of 5
(3,961 Views)