Stepper Posted November 1, 2010 Report Share Posted November 1, 2010 Hello, I am using LV 8.0 and trying to read a simple .lvm file that has 2 integer columns. The first column represents motor position (in revs), the second column represents an associated parameter (frequency). What I am trying to do is to manually enter a "target" value for the frequency, and have the vi return the associated interpolated motor position. With my obviously limited experience, I have tried all the possible designs/options that I could find - but just can't get the darn thing to work... The .vi and .lvm files are attached. Would greatly appreciate any and all help! Quote Link to comment
ShaunR Posted November 1, 2010 Report Share Posted November 1, 2010 The .vi and .lvm files are attached. Post them and we'll take a look Quote Link to comment
Stepper Posted November 2, 2010 Author Report Share Posted November 2, 2010 My booboo... I should have checked the correctness & completeness of my posting. Here they are. The uploader didn't accept the .lvm file extention, so I renamed the file to .txt file-reading-and-interpolate.vi Cal-data.txt Quote Link to comment
crossrulz Posted November 2, 2010 Report Share Posted November 2, 2010 If you put in an indicator to see the array before your interpolating, you will see that it has two elements (36, 15370). What you need to do is split the signals and take the second signal (frequency) and then interpolate. Quote Link to comment
ShaunR Posted November 2, 2010 Report Share Posted November 2, 2010 Interpolation (As the name suggests) is for creating intermediate values where none exist. I don't think this is what you are trying to do (maybe wrong ). From the VI implementation and description it looks like you are trying to find a motor position that is a close match to the desired frequency since the motor position cannot be fractions (discrete steps). I.e you have a look-up table. So based on that I have modified your VI to do this. Quote Link to comment
Stepper Posted November 2, 2010 Author Report Share Posted November 2, 2010 Actually, I am trying to interpolate. My intent is to use the target frequency value to get an interpolated number of required motor revolutions (that will in turn be converted in number of steps for a stepper-motor, by multiplying by 400. I could also multiply all values in the first column of the .lvm file by 400). So, if I enter "7300" (between 7200 and 7824 in the second column of the data file), I expect to get something like 28.086 as a final answer. From its description, it looks like one needs to input an index value to the "Interpolate 1D Array" function. My original hope was that I could use the target frequency value for this, as is. But it looks like the index value needs to be between 0 and the number of elements in the array columns (36 in my case). To make that work, I would have to 1) iterate through the frequency data column to identify between which two entries the target frequency lies (similar to Shaun's vi), then 2) look up what the associated two frequencies are, then 3) create a fractional index by dividing the difference between these frequencies by the target frequency, then 4) add the resulting fractional index to the lower index of those two looked-up frequencies, and finally 5) use the total index to interpolate the motor position in the position column of the array. Wow! And this approach might not even work for the case where the target frequency is identical to a value in the data file... Quote Link to comment
crossrulz Posted November 2, 2010 Report Share Posted November 2, 2010 (edited) To make that work, I would have to 1) iterate through the frequency data column to identify between which two entries the target frequency lies (similar to Shaun's vi), then 2) look up what the associated two frequencies are, then 3) create a fractional index by dividing the difference between these frequencies by the target frequency, then 4) add the resulting fractional index to the lower index of those two looked-up frequencies, and finally ... Or just use the Threshold 1D Array primitive (should be right next to the Interpolate 1D Array) on your array of frequencies. Edit: I might have the signals backwards, but the concept is still the same. Edited November 2, 2010 by crossrulz 1 Quote Link to comment
Stepper Posted November 2, 2010 Author Report Share Posted November 2, 2010 file-reading-and-interpolate-final.vi Or just use the Threshold 1D Array primitive (should be right next to the Interpolate 1D Array) on your array of frequencies. Edit: I might have the signals backwards, but the concept is still the same. How sweet it is! Thank you so much! Quote Link to comment
ShaunR Posted November 2, 2010 Report Share Posted November 2, 2010 Or just use the Threshold 1D Array primitive (should be right next to the Interpolate 1D Array) on your array of frequencies. Edit: I might have the signals backwards, but the concept is still the same. Very elegant Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.