12-10-2007 07:15 PM
12-12-2007 12:16 PM - edited 12-12-2007 12:18 PM
Hello ATMA,
I am a little confused about your post. I built an exemplary VI to show
the different behaviors, and I cannot figure out how you are creating the behavior
you are seeing. Below is how my program is set up, and the fast loop stops
immediately.
The only way I can replicate the behavior you are seeing is by using Functional
Global Variables. If this is the case, then I would recommend using a
local variable instead (like my example).
Your method of putting the two (with AI continuous) in the same loop should
work as well. The things to make sure you have include setting up the
task timing (to your 1kHz sampling rate), and have the samples to read on your
DAQmx read set to -1. This reads all the available values in the buffer,
and should not hang up the program at all when stopped.
In order to still control the rate of your counter (using software) you would
have to only sample once every X times your loop ran (so if your loop is set to
run once every 10ms, you want to read every 10th loop). The programming
would look something like this:
Depending on your DAQ device, you could also used a buffered counter.
This means that you provide a sample clock to read the value of the counter and
latch it into a buffer. Your sample clock would be running at 1Hz in your
example. The catch with this is that you need an external clock source
since the counters do not have one of their own. What we usually do is to
use another task (e.g. AO task) to generate the sample clock and then specify
that as the source for our counter. This way, you could read both tasks at the
same time and everything with the timing could be controlled in hardware.
I hope this helps you out, If I am misunderstanding the setup or if you
have any questions, please post back.