LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Online estimation with recent collected samples

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!

0 Kudos
Message 1 of 7
(3,298 Views)

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,  

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 2 of 7
(3,288 Views)

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 

0 Kudos
Message 3 of 7
(3,281 Views)

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,  

Message Edited by Hillman on 11-05-2008 09:08 PM
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 4 of 7
(3,277 Views)
I'm using Labview 8.5
0 Kudos
Message 5 of 7
(3,272 Views)

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 

0 Kudos
Message 6 of 7
(3,266 Views)

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

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 7 of 7
(3,244 Views)