01-07-2010 09:53 AM
Hi
I have a data acquisition and Rs-232 control all in a while loop.
The biggest problem is it takes a certain amount of time when
I press abort or stop button to actually stop. How can I set this
stop button to the highest priority or as an interrupt so that
whenever I use stop, application stops instantly. Right now it doesnt
respond to stop when its acquiring.
Solved! Go to Solution.
01-07-2010 10:37 AM
Rule #1 : Never stop a VI with the abort button. It is like using a tree to stop a car !
Obviously, the stop button will be read only once in every iteration of the loop. So the first thing is to ensure (dataflow) that the button is read after the acquisition. Doing so, a change of its value during the acquisition will be detected in the current iteration and the loop will stop without an additional iteration.
What is the duration of the acquisition ? If it is too long to get an acceptable response time of the loop, you must redesign it to acquire a smaller number of samples at once.
01-07-2010 11:17 AM
Thanks for your quick response. The usual acquisition time
is around 3-4 seconds. The data flow is simple but its required
to be continous. It acquires data and then based on a condition
automatically increases or decreases using Visa write and read
commands to the control device, and this process continues until
a refernce value of acquisition is reached.
Sometimes when you want to stop the code in the middle of the process
it takes couple of seconds respond if its in the midle of acquisition. I only
want that to go away andit respond instantly. Shouls I create an event
structure for that.
01-07-2010 12:10 PM
Let me try and rephrase what JB suggested because his reply is what you need to do.
Instead of doing the acquisition in a single 3-4 second chunk, grab a smaller amount of data (100ms worth?) then check the Stop button. If no stop, grab another 100ms of data, add it to the end of the previous data and check Stop button again. Doing this, the stop button will be acted on in no more than 100ms.
Once the data acquisition process starts, there is no way to interrupt it except to use the Abort button (which is bad) and that may not work depending on the hardware being used.
An Event Structure won't really help as it is designed to react to front panel actions, but still cannot stop an acquisition in process.
01-08-2010 02:30 AM
01-08-2010 03:22 AM
01-08-2010 09:03 AM
Here's the basic DAQ setup.
The important thing here is what values you set the "Sample Rate" and "Samples to Read" controls to. I usually try to keep a 10:1 ratio between these. So if you set a sample rate of 1000Hz, set Sample to Read to 100. This will grab 100 samples from each channel each iteration of the loop and will let the loop iterate at a 100ms rate. With a 100ms loop rate, the loop will stop when you click the stop button.
01-08-2010 10:06 AM
Your example is really good. I was acquiring data from a color meter using DLL files.
The only question is if I donot get any samples within 100 ms, then it could be an issue.
The amouint of data I am geting is not very high, but the speed is slow. Anyway I really liiked
your idea. Is there anyway else I could implement sample rate and sample to read controls.
I think I should have explained about my code. Since I am using .dll file I dont think I could use
the DAQ functions. I will see if it works.
Yesh
01-08-2010 11:07 AM
You're correct in that you will not be able to use the NI DAQ functions for acquiring data from another manufacturers hardware, but the over concept would be the same. Acquire a smaller amount of data so the the application is not stuck in a 3-4 second acquisition process. If 100ms isn't long enough to get any data, you can lengthen that time as needed. It will end up being a balancing act between amount of data to grab and how "responsive" you want the Stop button to be.
Without knowing how the configuration for your hardware works, I can't really give any advice on how to set the sample rate and samples to read. Sometimes you just need to do a little trial and error until you find a good balance.