Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.

## Linear interpolation document.SUBSCRIPTION_OPTIONS = { "thing": "topic", "subscribed": false, "url": "subscribe", "icon": { "css": "fa fa-envelope-o" } };

Anonymous
2013-03-16
2021-03-04
• Anonymous - 2013-03-16

Originally created by: H87

Hi
Annyone here know a good algorithm for linear interpolation. I know that oscat lib can provide a block that can do that. But i need the algorithm, so i can make a block my self. I need that bacause i'm making a PID regulator with a gain-scheduling option.

I'm programming the PID in Codesys structured text.

Best Regards
Henrik

• shooter - 2013-03-19

if you open the oscat.lib in your codesys as a library, you can see the source code complete it is open source.

If you tell us what you want, we will look into your problem.

btw if it is complicated you can always use fuzzy.

• shooter - 2013-04-03

ymax/ymin*((value-xmin)/xmax-xmin)+ymin

• laruso - 2021-03-04

I'm pretty sure that the formula should be:
(ymax-ymin)/(xmax-xmin)*(value-xmin)+ymin

For me the formula worked perfectly and is used to interpolate values for special needs, w/o using the function from the OSCAT library called LINEAR_INT.

• laruso - 2021-03-04

I'm pretty sure that the formula should be:
(ymax-ymin)/(xmax-xmin)*(value-xmin)+ymin

For me the formula worked perfectly and is used to interpolate values for special needs, w/o using the function from the OSCAT library called LINEAR_INT.