11-05-2008 12:21 PM
Hi there, I'm trying to implement an online estimation task. I collect the most recent samples (say within 500ms) w.r.t. current time and use these samples for an estimation. And then correspondingly apply control signals based on the estimation result. After another 500ms, I want to get another estimation result and update my control law. I don't know if there's any tutorials for this type of application. I don't know how I can make sure that the data I use for parameter estimation is recent, not the overall collection of data from the very beginning.
The device I am using is USB-6211 DAQ. Thank you very much for your help!
11-05-2008 02:27 PM
Hi LucyXF,
Thanks for the post!
When doing a continuous DAQ you could collect all the samples and display them on a chart - this is fairly standard.
Now, as I understand it you'd only want to keep the last X samples which were collected in a period of time. Well lets say in this period of time you had 200 samples.
I would then initialize an array of 200 elements outside the loop, then shift this array around the loop. On every iteration you could then add the new sample to the array (and replace the oldest). This can be done with using the replace array subset vi - which will allow you to replace an element at a given point. I would then use the loop iteration count to alter the index of this vi to replace the oldest element. This is effectively producing a circular buffer of the last 200 samples.
I have example code of this back in the office - which I can post up tomorrow morning if your interest.
Kind Regards,
11-05-2008 03:01 PM
Hi Hillman,
Thank you very much for your fast reply. I think I know what you mean and I'll try to work this out. Meanwhile, I also would like to refer to your example. Could you please post it tomorrow? Thank you!
-Lucy
11-05-2008 03:08 PM - edited 11-05-2008 03:08 PM
Hi Lucy,
Thanks for the reply.
I will certainly post it tomorrow.
Let me know how you get on with your attempt,
* just one note, what version of LabVIEW are you using?
Kind Regards,
11-05-2008 03:15 PM
11-05-2008 03:44 PM
Hi Hillman,
I have another related question. If I want to access the data in the array (of 200 elements as you discribed) from another task, is "creating a local variable" the only way of implementing this?
Thank you,
Lucy
11-06-2008 03:16 AM
Hi Lucy,
Thanks for the update and I hope your well today.
Here is my example. LabVIEW 8.5.
So get share data out of a loop (or between loop in most cases) local variables is one method. These generally arn't the greatest / most reliable method because they could cause race conditions - unexpected behaviour.
I would suggest using queues or any other form of synchronisation.
Some good examples are in the example finder ( Help>>Find Example>Search - queue Basics). This vi shows you one of the better methods for data transfer between loops.
Please let me know how you get on,
Kind Regards