‎06-26-2011 10:49 PM - edited ‎06-26-2011 10:50 PM
I have a laser system with a frequency of 1kHz, I am using this 1kHz signal to trigger the DAQmx and get the data from a photodetector, e.g. I will get 1000 data points during 1 second from DAQmx, but I need to separate this 1000 data points into the even and odd list, which is two list of 500 data points, e.g.. The 1st, 3rd, ... 99th data is one array, the 2nd, 4th,... 10th data is another array, then I will do further calculations based on these two arrays.
To seperate the even and odd data, the only way I can find is put these 1000 points into an array and then seperate them afterwards.
Can I do things like this pic?
I don't know the speed of the for loop, because the 1kHz trigger is always there, once it is triggered, the DAQmx read will give a data point, if the speed of the for-loop( the time from the end of a loop to the beginning of the next loop) is slower than the 1kHz trigger, then the for-loop will miss data point, then the ordering of the 1000 points in 1 second will be changed.
Or I need to put everything, e.g. AI Voltage, Trigger, sample clock, into the for-loop and then return a Y? Thanks!
‎06-27-2011 01:31 AM
Hi Fredltq,
you can you simple function called Decimate 1D Array which splits input array into more output arrays. If you are splitting into 2 arrays, the elements are like follow:
1st array: 0, n, 2n, 3n ....
2nd array: 1, n+1, 2n+1, 3n+1, ...
I guess it is exactly what you need to get odd and event elements from array.
regards,
stefo
‎06-27-2011 10:43 AM
Thanks a lot for your help. But I need to generate an array first, then I can use the Decimate 1D Array. The DAQmx read output data as waveform, I can get the Y value of the waveform as an elements and use a for-loop to generate an array, e.g. an array of 1000 points each second, then I can use Decimate 1D Array to separate 2n and 2n+1.
But now, the thing that I am not sure is that can I use a for-loop to generate an 1000 points array using the labview as illustrated in the picture? Will I miss any point if the for-loop is not as fast as the 1kHz trigger? Thanks!
‎06-28-2011 11:10 AM
Hi,
I think I'm lost in our discussion. Could you please be more specific where is your concen now, or, could you please be more specific with your question?
If you are asking about whether you will read all data from buffer from DAQ card with the code you posted, then answer is that you will read properly 1000 x number of samples per channer, unless you get buffer overflow/overwritten (this you would notice 🙂 ).
You could also use shift register to keep your part arrays, or you can generate 2D array on the output of the for loop, and at the end you can reshape it to 1D and then decimate it.
unfortunately i'm not convinced that i'm answering your question, therefore please explain more precisely what you need.
regards,
stefo
‎06-28-2011 01:21 PM
Thanks for your reply. I think you answered my question.
In my understanding, the DAQmx read subVI will read one value when the trigger is on, and then output one data point, then the for-loop will ask the DAQmx read to wait for the trigger and when it reeives the next trigger, it will read and output another data point. Ideally, in one second, there are 1000 triggers, the DAQmx read will read and output 1000 points conrespondingly.
The thing that I am conerning is that if the for-loop is not fast enough, e.g. after the 1st trigger, the first data point is output by DAQmx read, then for-loop takes a time which is longer than 1ms (e.g. 1.5ms) to ask the DAQmx to wait the trigger, then the 2nd trigger signal is not received by the DAQmx read, if that's the case the DAQmx will miss the data for the 2nd trigger, and it will receive the 3rd data triggered by the 3rd trigger signal, which means for one second, it will ge less than 1000 data points.
But as you said, it will get exactly 1000 points during 1 second, which means the time for the for-loop to iterate is much lees than 1ms. Is that correct?
Thanks!
‎06-29-2011 12:42 PM
Clarification:
The VI you have posted will work as following:
1) The task will read 2 analog inputs (ai0, ai3).
2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel" number of samples.
You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
I hope it is clear now.
regards,
stefo
‎06-29-2011 09:59 PM
Thank you. It works now.
‎06-30-2011 01:38 AM
Feel free to mark a solution or use kudos if it helped you to resolve your question - it will help searching for answer for people who will have similar question.
regards,
stefo