Go to Post Sorry [the easy button] does not exist in robotics :D - Arkorobotics [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 16-05-2009, 21:03
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: LabVIEW - Need help with Arrays

If you want a quick and dirty diagram, then I'd build it as...

ForEach element in B,
Search for and optionally delete the element in A.

See the image below.

The ForEach in LV is simply a For loop with the array wired as an input and with auto-indexing left on for the tunnel. The default is to have [] on the tunnel, and that indicates that the array will be auto-indexed.

The Search can be done with the Search 1D Array, the icon with the looking glass, probably third row, second column. Delete uses Delete from Array.

A key element you'll need is that A needs to be wired to and through a shift register on the For loop. The shift register is the best way for one iteration of a loop to feed data to the next. If you use a regular tunnel, the original array on the wire will enter the loop each iteration. NOTE: You may be tempted to make a control and read/modify/write to it each time through the loop instead of using the shift register. While this will work in simple programs, it opens you up to race conditions as the diagram grows, and it is slower because the UI is updated for each write, and each access now needs to be protected -- again due to potential parallelism. Since shift registers have a limited scope, they avoid race conditions and performance implications. It is an important element of the LV language, so don't fall to the temptation.

The contents of the loop will be a search for the element of B, with the output index wired to the index on the array delete. Then wire the output array to the right shift register. If the search fails, it will return -1 for the index, and a delete of -1 is a no op on the array.

This diagram may need to be modified if you want to search and delete every instance of the B element. And of course if this needs to be optimized for big arrays, you can improve it with some sorts and by using the search from input and by avoiding the numerous resizes by using replace with a nonsense value instead of deleting and resizing the array each time.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Picture 12.png
Views:	584
Size:	8.1 KB
ID:	7951  
Reply With Quote
  #2   Spotlight this post!  
Unread 16-05-2009, 21:16
sanddrag sanddrag is offline
On to my 16th year in FRC
FRC #0696 (Circuit Breakers)
Team Role: Teacher
 
Join Date: Jul 2002
Rookie Year: 2002
Location: Glendale, CA
Posts: 8,516
sanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond reputesanddrag has a reputation beyond repute
Re: LabVIEW - Need help with Arrays

This looks really great. Thanks for the help. Just before you posted, I was able to come up with something that works. I did it a very similar way, but I used an Index Array function to send each value of B, into the "element" part of the Array Search. And I did the way you said not too, and I didn't use shift registers. I'll definitely have to read up on shift registers, and try your way. Thanks!
__________________
Teacher/Engineer/Machinist - Team 696 Circuit Breakers, 2011 - Present
Mentor/Engineer/Machinist, Team 968 RAWC, 2007-2010
Technical Mentor, Team 696 Circuit Breakers, 2005-2007
Student Mechanical Leader and Driver, Team 696 Circuit Breakers, 2002-2004
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Festo Solenoid and Labview Team2883 General Forum 3 17-02-2010 12:56
timer help with labview T3H_K3YM45T3R Programming 6 16-02-2009 18:34
Help with LabView daviamp NI LabVIEW 2 03-02-2009 19:55
Sorting 2-D Arrays [Labview] Kahn! NI LabVIEW 4 12-01-2009 21:58
help: cannot get the picture in the labVIEW program .. (was: need help!! quickly!) liad LabView and Data Acquisition 8 18-01-2006 12:20


All times are GMT -5. The time now is 21:37.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi