LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make use of adjacent data elements within the same buffer

Hi,
         Does anyone know how to make use of adjacent data elements within the same buffer? To make my question clearly, I would like to give you an example. In my application, I set "sample to read" as 10 which means at each loop 10 data samples will be taken into a buffer. Now, what I would like to do is to do some calculations on adjacent data samples in same buffer. I tried to use "shift register" for this, but it seemed to me that it only can deal with the calculation between data from adjacent loops. In other words, it skips 9 data elements and take the 10th one for the calculation.
         Here I also attach my VI showing what I did.
 
 
    Thank you very much in advance,
                        Suksun
   
0 Kudos
Message 1 of 7
(2,564 Views)
Hello,
what you get from the DAQmx read is an array of ten values.
If I understood well, you need to do some calculations (a mean for instance) on these 10 value, right ?

so just use an "index array" function

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 7
(2,545 Views)
Have you tried using the rotate 1D array function ?
If you know size of your array then just rotate as desired and thus manipulate  salient data !!

It may be necessary to resize  array .

Function is found under the array palette.

Xseadog
0 Kudos
Message 3 of 7
(2,543 Views)
Hello suksunh,

I simplified your example and it calculates on all 10 elements.
So you only want to calc with 1 of 10 elements?
Or calc with all elements and pick only one?

Where's the problem?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(2,534 Views)

Hi all,

          Thanks for giving me some ideas. I've brainstormed all your ideas and come up with this modified VI which I'm going to test tomorrow with my encoder. I think it should work. I have also attached the VI with this reply.

          I have also rated your answers, so GerdW I hope my rating satisfies you.

 

    Thanks a lot,

        Suksun

0 Kudos
Message 5 of 7
(2,519 Views)

Hi Suksun,

      I hope you'll forgive me for distilling your code - mainly to understand it better.  I tried to duplicate your logic exactly - which required reversing the "derivatives"-array before concatination with the current samples array.  As in your code, the last velocity is being paired with the first position.  If first velocity is really supposed to be paired with first position, just remove the "Reverse 1D Array" node. Smiley Wink

cheers

Message Edited by Dynamik on 01-07-2006 03:17 AM

Message Edited by Dynamik on 01-07-2006 03:19 AM

When they give imbeciles handicap-parking, I won't have so far to walk!
Download All
Message 6 of 7
(2,506 Views)

Hi Dynamik,

           Thanks for improving my VI. It looks much more professional with your clever rearrangement and experience.

 

     Cheers,

      Suksun

0 Kudos
Message 7 of 7
(2,491 Views)