Jump to content

Reading 2-column data file and interpolate


Recommended Posts

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!

Link to comment

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 rolleyes.gif ).

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.

Link to comment

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...

:frusty:

Link to comment

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.

post-11268-099178200 1288715197_thumb.pn

Edit: I might have the signals backwards, but the concept is still the same.

Edited by crossrulz
  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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