Hello everyone,
I have a problem. I want to divide one number(Real data type, i need it as real, because numbers behind comma have importance too) with number 3600. How can i do that? When I try to use DIV, I get some kind of number(*e-003), even when i try to divide 10.0/3600.0 i get 2,77e-003, although i should get 0.002777**, is there any possible solution how to scale the output or round it? Thanks for every reply
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
VAR
inputtime:TIME; ( here you start making the difference)
inputdivider:real:=3600; ( make sure this is a real variable when you type in th eprogram 3600 it is treated as an INT)
workingtime:real; ( for holding the converted time just to let you see if it works)
outputhours:real;
END_VAR
RETURN
This can best be done in a function block in FBD for example.
make the inputdivider GLOBAL (put all constants and upthere i use even zero and 1 as reals in GLOBAL
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
abyss616 hat geschrieben:
Hello everyone,
I have a problem. I want to divide one number(Real data type, i need it as real, because numbers behind comma have importance too) with number 3600. How can i do that? When I try to use DIV, I get some kind of number(*e-003), even when i try to divide 10.0/3600.0 i get 2,77e-003, although i should get 0.002777**, is there any possible solution how to scale the output or round it? Thanks for every reply
Hello everyone,
I have a problem. I want to divide one number(Real data type, i need it as real, because numbers behind comma have importance too) with number 3600. How can i do that? When I try to use DIV, I get some kind of number(*e-003), even when i try to divide 10.0/3600.0 i get 2,77e-003, although i should get 0.002777**, is there any possible solution how to scale the output or round it? Thanks for every reply
VAR
inputtime:TIME; ( here you start making the difference)
inputdivider:real:=3600; ( make sure this is a real variable when you type in th eprogram 3600 it is treated as an INT)
workingtime:real; ( for holding the converted time just to let you see if it works)
outputhours:real;
END_VAR
program:
workingtime:=TIME_TO_REAL(inputtime);
outputhours:=DIV(workingtime,inputdivider);
RETURN
This can best be done in a function block in FBD for example.
make the inputdivider GLOBAL (put all constants and upthere i use even zero and 1 as reals in GLOBAL
Correct result actually:
2,77777e-003 = 2,77777 *10^-3= 2,77777 * (1/1000) = 0.002777
So it's only a display thing in the CodeSys debugger.
http://en.wikipedia.org/wiki/Scientific_notation m
old problem , but display with %1.6f or anything you like.
yes rounding is also possible, but not accurate.