LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fastest way to access 2d array

Hey Everybody!
 
So a quick background on my project.  I'm using position-velocity curves to control some motors using PWM.  I'm reading in position as well as generating the drive pulse output from a PCI-6602 counter timer card.  I got this project up and running initially by just defining 3 different regions for my position-velocity curve (accel, const vel, and deccel).  However, I am now wanting to have more data points to refine my PV curve.  I have written an outside program which allows the user to define a variety of velocity profiles and then exports them to a .csv file.
 
Herein lies my issue:  I'd like to import this data file into labview (which I found code for, posted below), and then take my current position, find the interpolated position on my 2D array that I've brought in, and then spit out the corresponding velocity.  Any thoughts on an ideal way to do this?
 
I've attached the file that I'm using to import the .csv to show you where I'm at at the moment.
 
(I have a control scheme worked out, I'm just having a hard time understanding how to do the lookup operations on my 2d array.
 
Thanks!
.jim
--
Jim S
GRA/Colorado School of Mines
Download All
0 Kudos
Message 1 of 5
(3,684 Views)

Jim,

Since you already have a delimited text file, why not try the Read from Spreadsheet File.vi.  Just remember to set the delimeter input to match the comma delimiter in your file.  You will also need to modify the default input on the format terminal to match the # of decimal places.  Should be a clean easy way to import data.  Of course you could always go all in and calculate the array values in LV as well.Smiley Very Happy

P.S.  Is Professor King still involved in the NI Training Center on campus?  Took a NI class in Golden a couple of years ago and had a great time on campus.



Message Edited by centerbolt on 01-17-2008 04:32 PM
0 Kudos
Message 2 of 5
(3,670 Views)
Thanks for the suggestion!  Read from spreadsheet file.vi is about 100 times simpler than what I had previous.  Smiley Happy
 
I'm still stumped on how best to determine the velocity that corresponds with the current position out of the 2d array. 
 
I see the search 1D array.vi (as well as threshold 1D array) in the array pallet, would it just be easy to just split the position and velocity 2d array into 2 1D arrays, use the threshold on the current position value to determine index value and then somehow use the interpolate.vi on the velocity 1d array to find the corresponding velocity?
 
Thoughts?
 
Thanks again!
.jim
--
Jim S
GRA/Colorado School of Mines
0 Kudos
Message 3 of 5
(3,640 Views)

Jim,

You should be able to use the Index Array on the 2D array to get the 1D array of position data.  Then use your current position and the Threshold 1D Array to get the index of the velocity that you want.  Since the threshold can put out a fractional index, you will need to round this up or down to an integer depending on how your table is set up/what direction you are moving.  You can now use this index and the Index Array to get the velocity info out of the 2D array.

0 Kudos
Message 4 of 5
(3,623 Views)
That's awesome!  Smiley Happy 
 
(oh and I forgot to mention:  yep, Dr. King is still around at mines, I was just talking to hime about this project).
 
Thanks again!
.jim
--
Jim S
GRA/Colorado School of Mines
0 Kudos
Message 5 of 5
(3,597 Views)