Jump to content

Arka Dipta Das

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Arka Dipta Das

  1. 27 minutes ago, hooovahh said:

    Your Fig 1 still has a couple issues.  First the memory issue.  You build the array, then put it into a shift register that continues to build.  You need to perform the array subset, and then put that into the shift register.  Because adding elements at the start of an array were less efficient than at the end (not sure if LabVIEW improved) I often put elements at the end, then perform an Array Size, and if it is greater than some value, I use the Delete From Array, providing the index to delete as 0.  Just a pointer that probably doesn't matter.  The other issue with Figure 1 is you start with 1000 elements, then add elements one at a time.  I suspect you either want to start with an empty array, or use the replace array subset but then things like pointers and shifting might be an issue.  If you are just trying to keep it simple, I'd suggest this.  Also if you are preallocating the array with a bunch of data, doing an Array Min/Max is going to use that preallocated data too which probably isn't what you want.  If you go with a preallocated method you can still use array min max, but you will have to keep track of how full it is with real data, and then do array subset before Min/Max.  This seems easier and honestly isn't that bad.

    Example_VI_BD.png.f27674906d42c8fb48cf08b6e1e371ff.png

    Also you should be posting VI Snippets, these allow for posting pictures of your code as PNGs, that can then be dragged into the block diagram.  Then others can get your code more easily.

    this implementation seems interesting. Thank you for the suggestion.

    I realize now the mistake of initializing with a 1000 element array. 

    I am not sure if you mean "initializing the array" when you say "preallocating the array". I was talking about memory allocation for the array rather then the initial values of the array.

    VI Snippets is something I did not know about. Thank you for bringing it to my notice.

  2. I use this method to do a couple of things:-

    1. to create a stream of historical data points (say values generated in the last 1000 iterations of the loop) and then find the highest value in that array. Data points older than 1000 iterations are not required and I would want them to get overwritten. Does this code (Fig.1) work as an alternative of what you mentioned

    Quote

    Another method that might be suggested is to preallocate the array with the initialize array function, then perform replace array element inside the loop.

    about pre-allocation of the size of the memory that the Build Array block will use?

    Since I am using a while loop here, i can not achieve this with a indexing tunnel. If (Fig.1) does not achieve this, will (Fig.2) be a good substitute?

    (Fig.1):-   image.png.e9522c7154a5a31f9deeb6cb941f287a.png               (Fig.2):- image.png.58dd1a5c1f152c9c5564450f66110508.png 

    2. to monitor the loop execution times in real-time rather than use the Profile>Performance and Memory tool and getting only snapshots. (Fig.3)

    (Fig.3):- image.png.5c00799946c3bca143d405f3ed4b43a5.png

     

    3. to check the response of hardware vs. each value generated by the For loops. This I do by having a XY-plot within the loop. (Fig.4). This is used in a For-Loop.

     

    (FIg.4):- image.png.c2ecfa126aeaf20650be1dcd52ca19cd.png

  3. Building an array with a while loop is never a good idea but I somehow am guilty of that practice and now it has come back to bite me.

    I started using such a method after I read in a forum discussion that is a simple way to track changes due to a looped structure and that the "build array" block itself optimizes the memory so that the Vi does not get bogged down when run for long periods.

    My state of my code says otherwise and therefore I want to know for certain how building such an array is handled in LV.

    I have attached a sample VI to demonstrate what I mean. 

     

    image.png.ba4086737856cc77dc241d99504b57e9.png

    Growing build Array.vi

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.