LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Analog Input Delay?

Hi Everyone,

 

I recently completed the Core 1 and Core 2 training courses and am developing my first program. Essentially, it is going to apply a fixed voltage over two heater strips that sink into an aluminum block and read back the temperture through 7 thermocouples. I want to monitor the current through each strip so I am using the NI 9227 module. The voltage module is the NI 9474 (digital).

 

In the "Initialize"state, I want to verify that the voltage (from an external supply) is set to 10V +- 0.5V. I trigger on the voltage channel and can see the current flowing (through an external meter and a 330 ohm resistor) but it takes about 3 seconds before the current module will read it. Initially I was trying to read in a single sample and it would take about 6 seconds to read the current. I tried playing with the sample rate, sample mode but haven't had any luck. I appreciate any input regarding a more efficient method for reading in the current.

 

Thank You,
Mike

Input Code.jpg

0 Kudos
Message 1 of 6
(4,040 Views)

Hi Mike,

 

Thanks for posting a screenshot!  I do have a few questions for you.  First, have you tried lowering the Wait until Next ms Multiple time?  It shows that you are waiting for 1 second before iterating the loop again.  Also, is there a specific reason for using a nested while loop?  Have you tried running highlight execution to see where your code might be hanging?  Thanks!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 6
(4,003 Views)

Hi Taylor,

 

Thank you for the input. My goal was to calculate the voltage from the current flowing through a resistor and prompt the user every 8 seconds if the voltage was out of range. Lowering the wait time to 10ms worked fine if the voltage is already set to 10V. It still had to run through the loop a couple of times before it would pull a good value though.

 

If the voltage is out of range, I have approximately a 7 second window after the prompt to set the voltage and press "OK". Over 7 seconds I will keep getting prompted to set the voltage even if it is within range. I tried setting the DAQmx read timeout to 100 seconds, but it didn't make a difference. Why don't I get good samples read the first time through the loop?

 

With highlight execution on, I am getting an ERR -200279 out of the DAQmx read and get stuck in the loop forever. Even though I am set to continuous sampling, it seems to only read in a finite amount of samples.

 

Error -200279 occurred at an unidentified location

Possible reason(s):

Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.

 

 

Thank You!
Mike

Message 3 of 6
(3,991 Views)

Mike,

 

Looks like you have a couple of things going on here.  The way you have your task configured it will start collecting data at 1000 points per second and put all that data in its buffer.  When your prompt interupts the loop the device is still collecting data (and eventually fills the buffer and overwrites old data that has not yet been read generating the error)

 

When you do read the data it reads out the FIRST[x] samples it took.  These might be older than you want and you don't know when they were taken!  It would be more common to set the task to take [x] samples on demand.  The Autostart property of the DAQmx makes the start task unnecessary in current versions of DAQmx (it was broken for the nCH nSample (DBL).vi for a while so make sure you have at least DAQmx 9.1.  More info on that can be found in this thread.

 

Then your vi looks more like this outline

 

DAQmx.png

You don't even need the Wait primitive since the DAQmx read will take 1 sec while collecting the 1000 points per ch and that will time your loop for you and you get FRESH data on every iteration.

 

 

 

 


"Should be" isn't "Is" -Jay
Message 4 of 6
(3,979 Views)

Hi Jeff,

 

I appreciate your feedback, this seemed to do the trick! Just so I understand this correctly, if you set 1000 Finite Samples in the sample clock, then every time the DAQmx read function is called, it will pull 1000 new samples. Will these samples overwrite the previous 1000 collected or will Labview point to the spot in memory where it started recording the new samples?

 

Thank You,

Mike

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

With Finite samples (1000) each time the task is started the device puts 1000 samples in the device memory.  Read removes the samples from the device memory (and hopefully you sent them down a wire for processing).   By using the read with Autostart the task starts when the read is called and (if the timeout is set correctly) removes the 1000 samples from the device moving them into your app so the device memory is clear at the end of the read and the task returns to a "Stopped" condition ready to start again.  This is where that darn BUG bit me since the task didn't stop correctly so I coudn't start again.  That Bug fix was nice to see!

 

Of course, if you set timeout for the read wrong you can get into trouble.  say 1000Samples at 1Khz and a TMO =100mS  The read will return only 100 samples and a timeout error.  900Msec later the device memory will have the remaining 900 samples in memory because no one read them and the task will stop

 

To be safe, when running this way you can calculate acquission time from Samples and Rate (and and some for overhead) to set the TMO for the read.

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(3,969 Views)