Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

my small linear interpolator

For general discussion related FlowStone

my small linear interpolator

Postby tester » Tue May 21, 2013 8:22 pm

I made a small linear interpolator (or at least something, that allows smooth float calculations?), that uses custom made tables of (x,y) ranges, which means distances between x values don't need to be equal. But my question is - in this case - can this be made simpler?

p.s.: added 2 limiters by purpose (one serves to reject lower values, the other can be ised as indicator for getting out of range).
Attachments
linear-interpolator.fsm
(2.49 KiB) Downloaded 996 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: my small linear interpolator

Postby trogluddite » Tue May 21, 2013 9:35 pm

tester wrote:can this be made simpler?

I don't think simpler - the auto-generated index lookup and if-then logic is rather good!

Hpwever, I did notice a couple of little problems that could be solved by adding a primitive or two...

1 - connect a trigger counter to the output. You will see that each input change is creating five output triggers (possibly with incorrect intermediate values; I didn't look that far). I think that is each of the four array lookups producing a trigger each time. Easy to fix with a sample and hold at the output triggered from the input value.

2 - it didn't work at load. Seems that the if-then input array is not remembered between save/load. Another sample and hold to store the array should fix that.

3?? - depends how "sequential" your input values are - but possibly an 'integer changed?' at the if-then output so that the array 'Gets' don't get to be triggered when the index hasn't changed.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: my small linear interpolator

Postby tester » Tue May 21, 2013 9:49 pm

Well. well. well, look who is back! :-)

Thanks for notes. I just made it from scratch, haven't checked yet for issues. I had some thoughts in regards to "get" prim (whether to change it into "section"), but I guess it's the weakness in my thinking/understanding. Generally it will serve for following (general, green recalc between two values) custom "curves" in multiple units. Frequency to frequency type and frequency to gain I guess.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: my small linear interpolator

Postby tester » Tue May 21, 2013 10:10 pm

Something like this?
Attachments
linear-interpolator-02.fsm
(2.73 KiB) Downloaded 975 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: my small linear interpolator

Postby MyCo » Tue May 21, 2013 11:22 pm

Here is my Ruby version for this task. It uses binary search, to find the right index. So this can be quite fast even for huge arrays. In my version, when you hit the upper limit it doesn't output 0, instead it outputs the highest destination value... I think that makes actually more sense.
Attachments
Linear Interpolator (MyCo).fsm
(2.96 KiB) Downloaded 1004 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: my small linear interpolator

Postby tester » Tue May 21, 2013 11:51 pm

Thanks for variation. "Large arrays" start at/around...?

I'm outputing "n.a." for zeroes and overs only in cases where no data is present )it's a conceptual thing, for display). In other cases - I just make the border values = minmax thresholds.

Have question however, to my green version, with non-scaled input. Are there some formulas, to make that linear approximation more "generally" accurate (less flat), via some non-sophisticated "curves" or equations between points? (I guess it would include at least 3 points).
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: my small linear interpolator

Postby stw » Wed May 22, 2013 1:09 am

Here's a slightly different approach in green. Maybe a bit lighter in performance (not sure about that). I left MyCos ruby based version in for result comparison.
Attachments
Linear Interpolator (stw).fsm
(3 KiB) Downloaded 965 times
stw
 
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am

Re: my small linear interpolator

Postby tester » Wed May 22, 2013 1:26 am

Thanks, good to know how to approach it in various ways.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: my small linear interpolator

Postby Drnkhobo » Wed May 22, 2013 10:37 pm

Hey guys, i dont want to sound stupid, but what is this used for? :oops:

im curious what it does. . .
Drnkhobo
 
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: my small linear interpolator

Postby tester » Wed May 22, 2013 10:55 pm

Good question.

Let say, that you have two sliders. Frequency and Gain.
Let say, that you would like to have 6dB gain at 200Hz, and 12dB at 400Hz.
Okay, pick 200Hz and you have 6dB. Pick 400Hz and you will have 12dB.

But what about 300Hz, in the middle of them? How many dB?
This module calculates values for all frequency points between A and B.
But that's not all.

Let say, that you would like to have different change of gain between 200 and 400Hz and different between 400 and 1000Hz. If so, then you create two tables. In one you pick the points of your interests, and in the second - results you get.

Like this.

200 --> 6
400 --> 12
1000 --> 2
...
which means: progresively moving from 200 to 400 - output value will be progresively changing from 6 to 12, but moving then from 400 to 1000 - the output will change from 12 to 2.

The module will calculate all corresponding output values between reference points.
If you have more points, then you get an X,Y plot. Give X and receive Y.

Here - you also don't need to have equal distances between X values. Just pick any points of your interest, and module will do the rest.

Where it can be used? Everything non-linear.
For example - automatic gain change according to fundamental frequency change of a signal.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Next

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests