I need to convert and integer number from a PIW to a real number. What is the easiest way to do this. I don't see any standard function that is capable of converting this.
Hi, You need to convert int to double then double to real i.e.
l piw 123 //int
itd //int to dint
dtr //dint to real
t md 0 // store result in double word
you can do this in ladder using d_int and di_r
You may also use S7 standard function-blocks:
"I_DI" followed by "DI_R"
To convert back from REAL to INT you use
the command "RND":
Load <REAL> become: L <REAL>
Round become: RND
Transfer <INT> become: T <INT>
These 3 commands goes fine, if you first ensure
that <REAL> is within the limits
from -32768.0 to +32767.0
Please note that Siemens use reverse polish
calculation. Example, if <A> and <B> are REAL:
Jan Steen Nielsen
L-N [at] mbox301.get2net.dk