Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make "DAQmx AI read" stop when the maximum value set for the task is reached?

Hi,

I was modifying a program I have used without problems for a year now to support a new force sensor I added to the system. Since, contrary to the previous sensor I had, the new sensor has a very low maximum load capacity I created a custom scale using the "DAQmx create scale" function and added a maximum value to the "DAQmx create channel" function equal to the sensor limit. The "DAQmx timing" is set as "finite samples"

The problem is that when I acquire force data and plot it I see a plateau whenever force reaches or passes the maximum set. I checked the "AI max" and "AI min" using a task property node and it shows the right values (previously set in the DAQmx create channel). However, the DAQmx read keeps reading even though the maximum is reached. I put an "error out" indicator for the DAQmx read and shows no errors.

Is there any way to set the DAQmx to stop right away when the maximum limit is reached? (I'm using finite samples, so I can only see the data after all the samples have been acquired). I want the program to kill the linear motor that moves the sensor in case the maximum load allowed is reached.

Thanks a lot!,

                    Pedro.


0 Kudos
Message 1 of 8
(3,725 Views)
The max (or min) value is not intended to generate an error or to be used to stop acquisition. The min/max values are used by the driver to set the most appropriate range for the DAQ board. Say your board has ranges of +/- 100mv, +/- 1V, +/-5V, and +/- 10V. If you specify a min 0f -2 and a max of +3, the board will use the +/- 5V range. If you then apply a +6V signal, the A/D will report that as +5 as it is maxed out and really has no way to tell whether the input is actually +5V or anything greater. You need to monitor the return signal in your code. The time it takes to respond will depend on the ratio of sample rate to number of samples. If you have a sample rate of 1000 s/sec and are returning 100 samples, then you get data every 100 msec. If the sensor is in danger of being damaged by too high a load, then you should consider a sensor with a higher load capacity.
0 Kudos
Message 2 of 8
(3,711 Views)
Thanks for your reply Dennis.
 
I thought it was possible to use a property node to check when the limit was reached, but I guess as you explained the max and min only serve the purpose of setting the appropriate range of the DAQ.
 
Unfortunately precise timing during the reading is very important for my application (that's why I selected "finite samples" in the timing configuration so the DAQmx read function acquires all the data at once without having to go through a loop multiple times while getting the data), so I guess is not possible for me to check constantly if the maximum has been reached. I'll try to find a workaround that allows me to acquire data with precise timing and avoid damaging the sensor if the load goes above its limit.
 
Thanks again,
 
                       Pedro.
 
  
0 Kudos
Message 3 of 8
(3,678 Views)
Define 'constantly'. No matter what (finite samples or continuous), you have to have your DAQmx Read inside of a loop in order to get more than one read. You can't do it without a loop. You would do your comparison on the returned data - as soon as the DAQmx Read returns it.
0 Kudos
Message 4 of 8
(3,672 Views)
Dennis,
 
The "DAQmx read" doesn't have to be in a loop to get more than one read. If the task acquires a finite number of samples and you set the "number of samples per channel" input to -1 (or the exact number of finite samples you defined in the "DAQmx timing" VI), the VI waits for the task to acquire all requested samples, then reads those samples. So once the "DAQmx read" VI starts it doesn't stop nor output any data until all the samples have been read. The advantage of doing it this way is that timing is controlled by the hardware clock of the DAQ card (or PXI chassis, whichever you have set as your default clock) and samples are read are the exact time intervals I need. I tried using the "DAQmx read" VI in a timed loop but the timing is not perfect, specially when the sampling rate is high, and when more VIs or routines are run inside the loop (for example a routine to compare the returned data with the sensor limit).
 
Thanks,
 
                     Pedro.
 
 
0 Kudos
Message 5 of 8
(3,649 Views)
You are describing a basic read and I am more than familiar with requesting x number of samples. That is still a single read. Are you really saying that your program has a single DAQmx Read? That just does not make any sense. You get x number of samples and the program stops? You wouldn't be doing something like using the run continuous button on the toolbar, would you? That would be just plain wrong.
0 Kudos
Message 6 of 8
(3,642 Views)
Hi Dennis,
 
Of course I'm not using the run continuous button in the toolbar. I'm not new to labview, I've been using it for more tha 5 years. What I wanted to know was if I could use the maximum value set on the "DAQmx create channel" VI as a way to stop my program when the limit was reached.
 
I don't know what you mean with a "single read", but in case you mean the "DAQmx read" only reads 1 sample and then have to be in a loop to be able to read more samples; then the read process I described is NOT a single read. It is a "1 channel N samples" read. I'm attaching a very simple example of a code that has no loop and still reads multiple samples (for example, with the settings saved as default in the attached code: 1000S/s input rate and 10000 samples per channel, the "DAQmx read" will run during 10 seconds until the 10000 samples are acquired, no need for a loop. The output waveform will show up only after all the samples are acquired).
 
Thanks.    
0 Kudos
Message 7 of 8
(3,634 Views)

Listen - DAQmx basics - A single DAQmx Read can return either one or multiple samples. It really is that simple. If you only have a single DAQmx Read in your program (whether it returns 1 sample or a million), it's still a single read. If you only have one DAQmx in your program, you do one acquisition and no more. In your example, you get no data at all back from the single DAQmx Read until the entire 10 seconds have elapsed. That poses a problem for you. If you change the sampling to continuous, request 1000 samples at the 1000s/s rate, and put it in a while loop, you will get data every second, and after ten iterations of the loop, get exactly the same data you are getting now. It's your decision whether to wait for 10 seconds, 1 second, or a fraction of a second before getting any data back. I would think that you would want to get data back as soon as possible in order to avoid any damage.

Whether you have a single DAQmx Read or multiple, in order to protect your sensor, you can do a comparison in software or design some sort of hardware protection separate from DAQmx.

0 Kudos
Message 8 of 8
(3,632 Views)