S7 300 integer to real conversion

L

Thread Starter

Luiz Rodriguez

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.
 
K
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

Kevin
 
J

Jan Steen Nielsen, Denmark

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:
L <A>
L <B>
+R
T <A+B>

Good luck
Jan Steen Nielsen
Denmark
L-N [at] mbox301.get2net.dk
 
D

david mertens

I think you are looking for the SCALE function. This function converts the input of an analog input card to the engineering units you specify. This is a standard library block available in step 7. There is also an UNSCALE function for driving analog outputs (Real to PQW).
 
Top