Today is...
Thursday, November 27, 2014
Welcome to Control.com, the global online
community of automation professionals.
Advertisement
Featured Video...
Featured Video
Wiring and programming your servos and I/O just got a lot easier...
Advertisement
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
S7 300 integer to real conversion
How do you convert an integer format to real format in the S7 300 CPU's?
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.

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

By Schneider Electric Italy on 4 September, 2009 - 12:50 pm

L xx
ITD
DTR
T yy

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

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

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