06-22-2010 03:11 PM
Hey everyone -
This is a follow-up to a previous thread that I had posted (
), but my next question has taken a bit of a different direction so I have made a new thread.
Following tbob's suggestion, I am trying to use a producer-consumer architecture to start and stop data acquisition from a simulated NI 9237 device. I have attached the current version of our code to this post (Producer_Consumer_architecture.vi). Our main problem is that there is a significant lag between when elements get added to the queue using the Enqueue function, and when they are removed from the queue using the Dequeue function. As a result, the signals from our simulated DAQ channels run for much longer than they are supposed to, and the start-and-stop of data acquisition is not keeping in time with the simulated square wave signal (we would like our NI 9237 device to acquire data when the square wave has an amplitude over 3, and stop acquiring when the amplitude is under 3). If you allow the program to run for about 30 seconds, you will see what I mean (press the stop button twice to quit the program).
If anybody has any suggestions as to how we can increase the speed of the program, they would be very much appreciated!
Thanks in advance!
06-22-2010 06:04 PM
hello,
i don't have tools needed but , i see one thing is that you enqueue
every time you are greater 3 that means about every 2-3 ms so consumer is really sought
is it really what you want ?
may be you want to start on a treshold so you can use a treshold fonction
if i don't make mistake your square is 10 hz and the daq is configured 25000 sample 25000 hz
so you aquire 1s of signal every 100ms , there is something to correct
make tests and tell us
Regards
Tinnitus
06-28-2010 04:19 PM
some improvement ?
06-28-2010 09:32 PM
Perhaps using a notifier would make more sense?
06-29-2010 07:18 AM
As others have said, you need to develop some understanding of what is going on and what you want to happen.
It appears that the enqueuing happens at about 100 Hz, whether the data has changed or not. The consumer loop takes at least 1 second for each iteration with the data acquisition parameters you have set. The queue will rapidly fill up because you are enqueuing much faster than your are dequeuing. If you want to start and stop your acquisition 100 times per second, then each acquisition must be less than 10 ms in duration. Simple math!
1. Set the producer loop to only enqueue an element when the data changes. Then your queue only gets 21 elements per second rather than 100.
2. Set the DAQ to acquire for about 2-5 ms so that the producer loop spins so that you can read the queue promptly.
3. Use a shift register in the consumer to keep track of the previous value of the start/stop signal, so that if the queue does not have new data, the program continues in the previous mode.
Lynn
06-29-2010 08:25 AM
Thank-you all for your suggestions! We are currently trying some new hardware and are in the process of trying to modify our code as a result. We may end up having to rely on our older hardware, in which case we'll try all of your suggestions.
Thanks again!
07-05-2010 12:06 PM
Hello everyone -
We have modified our program a little bit based off of an example we found in the NI Developer Zone (http://decibel.ni.com/content/docs/DOC-2431). We have run into some new problems with the buffer size in this program, and have posted a new thread that can be found at the following link that talks about this problem:
http://forums.ni.com/t5/LabVIEW/Error-200257-using-DAQmx/td-p/1170471
Thanks for all of your help!
Rachel