Go to Post See, another reason for going--you can find out your chances of being thrown off the field for a safety violation! - EricH [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 Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 12-10-2008, 14:03
tivomatic's Avatar
tivomatic tivomatic is offline
Registered User
FRC #2262
Team Role: Mentor
 
Join Date: Sep 2008
Rookie Year: 2007
Location: Massachusetts
Posts: 2
tivomatic is an unknown quantity at this point
Re: Basic Labview Programming Questions

I am trying to write a Labview vi that takes a one dimensional numerical array, for example A= 5,4,3,2,1, and sorts the values in ascending order. We do not want to use the sort array operator since the whole purpose is to practice using labview. Although I can write this no problem using Basic, I am having trouble in Labview. . I have attached the vi.

Thanks.
Attached Files
File Type: vi Sorting arrays.vi (10.4 KB, 82 views)
Reply With Quote
  #17   Spotlight this post!  
Unread 12-10-2008, 15:21
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Basic Labview Programming Questions

Quote:
Originally Posted by tivomatic View Post
I am trying to write a Labview vi that takes a one dimensional numerical array, for example A= 5,4,3,2,1, and sorts the values in ascending order. We do not want to use the sort array operator since the whole purpose is to practice using labview. Although I can write this no problem using Basic, I am having trouble in Labview. . I have attached the vi.

Thanks.
I've attached a version that does what I think you want. The main thing you needed was a shift register (or feedback node) to take your changed array and feed it back so it could be operated on. The way you had it, each loop it was always operating on the original array. I must admit that this has been the thing I've messed up the most in LabVIEW.

You'll need another loop of some type to finish sorting. You can also use the array size VI for the input to the count terminal input of the for loop.
Attached Files
File Type: vi Sorting arrays.vi (11.2 KB, 109 views)

Last edited by Joe Ross : 12-10-2008 at 15:24.
Reply With Quote
  #18   Spotlight this post!  
Unread 13-10-2008, 13:25
BitTwiddler's Avatar
BitTwiddler BitTwiddler is offline
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 251
BitTwiddler is on a distinguished road
Re: Basic Labview Programming Questions

Quote:
Originally Posted by Joe Ross View Post
I've attached a version that does what I think you want. The main thing you needed was a shift register (or feedback node) to take your changed array and feed it back so it could be operated on. The way you had it, each loop it was always operating on the original array. I must admit that this has been the thing I've messed up the most in LabVIEW.

You'll need another loop of some type to finish sorting. You can also use the array size VI for the input to the count terminal input of the for loop.
Taking Mr. Ross' vi a bit further, I've modified it to swap array elements without overwriting the ith array element. Still needs another loop to control the number of passes through the array in order to propagate all of the changes each pass makes.
Attached Files
File Type: vi Sorting arrays.vi (13.2 KB, 95 views)
Reply With Quote
  #19   Spotlight this post!  
Unread 13-10-2008, 14:24
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,709
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Basic Labview Programming Questions

Well that last VI is mostly correct, aside from either a second FOR loop to run it n-1 times, or a while loop that will stop if it didn't make any swaps in the last run of that inner FOR loop... But seeing Bubble Sort implemented in Labview seems very very wrong to me. There's a reason NI has VIs like this already made, after all.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #20   Spotlight this post!  
Unread 13-10-2008, 14:47
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Basic Labview Programming Questions

Quote:
Originally Posted by Kevin Sevcik View Post
But seeing Bubble Sort implemented in Labview seems very very wrong to me.
I enthusiastically agree. Bubble Sort is a highly procedural algorithm, something which LabVIEW does only grudgingly. I wonder if a Partition Sort would more closely align with LabVIEW's data-flow nature.

But I think sorting is the kind of operation that should be implemented by people having deep knowledge of the runtime environment, and not used as an exercise in learning how to use a data-driven programming language.
Reply With Quote
  #21   Spotlight this post!  
Unread 13-10-2008, 18:29
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: Basic Labview Programming Questions

If this is for learning purposes, then I see nothing wrong with it. In fact I've attached a few other implementations of sort, which will hopefully show some of the tricks and syntax with arrays as well as the relative performance.

[ATTACH]More sorting[/ATTACH]

If you decide to use a Bubble Sort on your robot, well then perhaps you'd like to build your own chain too.

Greg McKaskle
Attached Files
File Type: vi Sorting arrays Expanded.vi (29.1 KB, 96 views)
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
A few Labview questions Japper NI LabVIEW 14 09-09-2008 20:41
A few basic EasyC Pro questions Joe G. Programming 5 11-03-2008 21:18
Some Basic Questions... bglass Motors 5 02-07-2007 21:53
BASIC programming John Gutmann Programming 3 17-05-2005 12:15
Very Basic Programming Question kewlkid382 Chit-Chat 5 18-01-2003 11:11


All times are GMT -5. The time now is 22:19.

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