from the Prime Controls department...
S7 300 integer to real conversion
PLCs and related questions. topic
Posted by Luiz Rodriguez on 4 September, 2009 - 12:26 am
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.

Posted by kevin grey on 4 September, 2009 - 12:32 pm
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


Posted by Schneider Electric Italy on 4 September, 2009 - 12:50 pm
L xx
T yy

Posted by Jan Steen Nielsen, Denmark on 11 September, 2009 - 2:05 pm
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>
T <A+B>

Good luck
Jan Steen Nielsen
L-N [at]

Posted by david mertens on 14 September, 2009 - 3:14 am
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).

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

I could dance till the cows come home. On second thought, I'd rather
dance with the cows till you come home.
-- Groucho Marx
Advertise here
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive