VAR
mycallOutput : INT;
onefunction: myFunction; //POU type of myFunction
END_VAR
in code body:
mycallOutput : = onefunction(x, y, z);
The way you are doing is using a POU type for processing, in fact no function instance is created, so there is output is default 0. Hope Codesys can explain the compiling process. I think the program should not pass compilation.
Yongzhi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I like to define a function named myFunction with input parameters a,b,and c
I wrote the function like this
FUNCTION myFunction : INT
VAR_INPUT
a:INT;
b:INT;
c:INT;
END_VAR
VAR
x:INT;
END_VAR
in the function body
I wrote
x:=a+b+c;
when i call the function, I got the output =0, can someone pls help me why I got the answer =0?
my prg is
PROGRAM PLC_PRG
VAR
mycallOutput:INT;
x:INT;
y:INT;
z:INT;
END_VAR
prog:
x:=4;
y:=5;
z:=6;
mycallOutput:=myFunction(x,y,z);
result is mycallOutput =0;
as the function has no idea what the output is you will have to define it.
so your x should be myfunction
I suggest in PRG:
VAR
mycallOutput : INT;
onefunction: myFunction; //POU type of myFunction
END_VAR
in code body:
mycallOutput : = onefunction(x, y, z);
The way you are doing is using a POU type for processing, in fact no function instance is created, so there is output is default 0. Hope Codesys can explain the compiling process. I think the program should not pass compilation.
Yongzhi
FUNCTION myFunction : INT
VAR_INPUT
a:INT;
b:INT;
c:INT;
END_VAR
VAR
END_VAR
in the function body
I wrote
myfunction :=a+b+c; <<<<<<<<<<