From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

very slow single sample temperature measurement

I have a NI 9213 thermocouple module.  The specs give it a sample rate of 1200 samples per second.  Here's my C# code:

 

 

Task task = new Task();

 

task.AIChannels.CreateThermocoupleChannel("cDAQ1Mod1/ai1","",0,100,AIThermocoupleType.T,AITemperatureUnits.DegreesC);

 

AnalogSingleChannelReader reader = new AnalogSingleChannelReader(task.Stream);

 

double data = reader.ReadSingleSample();

 

The problem is that it's taking 700 ms to get each temp, which seems very slow.  When I use the NI Measurement and Automation Explorer Test Panel, it's getting measurements at the rate of about 6 per second (or ~160 ms), which I could live with.  I've tried lots of things.  I was on the phone with NI tech support for a few hours and made zero progress.  He kept trying to get me to set task.Timing.ConfigureSampleClock(), but no combination of parameters would even let it run without crashing.  In the NI Test Panel, I'm using the mode "On Demand" rather than "Finite" or "Continuous", and in the "On Demand" mode, both Rate and Sample# are grayed out, so I'm guessing the ConfigureSampleClock() doesn't even apply to me.  I've also tried only initializing on the first pass instead of new Task and reader each time.  Doesn't help.  I've been pounding on this problem for about a month now.  Any suggestions appreciated.

 

0 Kudos
Message 1 of 6
(5,149 Views)

@OregonCryo wrote:

I have a NI 9213 thermocouple module.  The specs give it a sample rate of 1200 samples per second.  


Where are you seeing that?

 

http://sine.ni.com/nips/cds/view/p/lang/en/nid/208788   says 75 S/s.

0 Kudos
Message 2 of 6
(5,135 Views)

http://sine.ni.com/ds/app/doc/p/id/ds-69/lang/en

says 1200 S/s aggregate.  Looking closer, 1200/16 is 75, so it probably is 75 per channel.  Still, I'm only getting 1 or 2 instead of anything close to 75.

0 Kudos
Message 3 of 6
(5,131 Views)

I'll mark this one done for now.  The 9213 seems to have a slow mode and a high speed mode.  So I now have some things I can try out.  Thanks.

0 Kudos
Message 4 of 6
(5,124 Views)
Why are you using ReadSingleSample and OnDemand? That is a software timed operation and of course you don't get anything like the max rate.
0 Kudos
Message 5 of 6
(5,102 Views)

Just in case anyone later reads this, my solution was:

channel.AdcTimingMode=AIAdcTimingMode.HighSpeed;

That reduced the time down to 140 ms, which is exactly where I wanted to be.  The plan is to now build it on a windows.forms timer making asynchronous calls so as to not lock up my UI.

 

Why don't I use hardware timing?  I don't need it to be blazing fast, I've not been able to get that working, and I'm pretty sure that there will still be a delay getting it to my software layer due to buffers, etc.  The obvious starting point is a series of synchronous calls to the hardware, and then to start working on fancier techniques from there. 

0 Kudos
Message 6 of 6
(5,068 Views)