I've created a function for linear interpolation and depending on how I call it either works or doesn't. Using the shorter method of function call doesn't work. I'm using Codesys 3.5 SP8 Patch 4.
interp_in := 7;
// function call - linear interpolation
lin_interp( x0:= 0, x1:= 100, y0:= 0, y1:= 50, in:= interp_in, out=> interp_out0 );
// function call - linear interpolation (same as above, different format)
interp_out1 := lin_interp( 0, 100, 0, 100, interp_in ); //this format is not working correctly, I don't know why
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've created a function for linear interpolation and depending on how I call it either works or doesn't. Using the shorter method of function call doesn't work. I'm using Codesys 3.5 SP8 Patch 4.
interp_in := 7;
// function call - linear interpolation
lin_interp( x0:= 0, x1:= 100, y0:= 0, y1:= 50, in:= interp_in, out=> interp_out0 );
// function call - linear interpolation (same as above, different format)
interp_out1 := lin_interp( 0, 100, 0, 100, interp_in ); //this format is not working correctly, I don't know why
Are you sure it is a function?
It seems to be a function block, which is different.
Try this:
lin_interp( 0, 100, 0, 100, interp_in );
interp_out1 := lin_interp.out;
This should work if it is a function block.
This doesn't work: interp_out1 := lin_interp.out;
It doesn't like the .out
It says 'out' is no input of 'lin_interp'
The function in the tree menu shows, lin_interp (FUN). This would be a function or not necessarily?
Originally created by: scott_cunningham
If you only have one output for the function, don't define it as a var out.
Don't:
Do:
Now you can call it in the way you want:
If you define one or more VAR_OUTPUTs, then you have to use the full notation so the compiler knows which output you want.
This worked thanks!
I changed the function by removing the out var, and setting the function name := (equation).
And then updated the code to:
// function call - linear interpolation
interp_out0 := lin_interp( x0:= 0, x1:= 100, y0:= 0, y1:= 50, in:= interp_in);
// function call - linear interpolation (same as above, different format)
interp_out1 := lin_interp( 0, 100, 0, 100, interp_in );
I believe I found the old method in the help file too, not so helpful!