Help Me! Real To Dint In Step7

nandao

Member
Join Date
Feb 2006
Location
Sao Paulo
Posts
7
Hi, can anyone show me how to convert from a Real to an DInt in Step7?
I have a md400 (real) with valor max. 150000.0 and i need convert to DINT to show in a HMI...
I am using LAD...

I have seen DI_R but, where is the oposite function R_DI?

Thanks!
 
Just an aside...
But I've always hated the fact that S5/S7 could cast to a more complex type in a single instruction, but can't cast down without a LOT of work.
 
rdrast said:
Just an aside...
But I've always hated the fact that S5/S7 could cast to a more complex type in a single instruction, but can't cast down without a LOT of work.

I don't quite get that. It takes the same number of instructions to convert numbers in both directions. Or maybe I don't quite understand what you mean by cast.
 
Nandao, in fact you have more possibilities, in LAD there're :

TRUNC - rounding towards zero
ROUND - rounding to the nearest dint
CEIL - rounding towards +infinity
FLOOR - rounding towards -infinity

Hopefully I made enough mess in your brain :ROFLMAO: .
 
jacekd said:
Nandao, in fact you have more possibilities, in LAD there're :

TRUNC - rounding towards zero
ROUND - rounding to the nearest dint
CEIL - rounding towards +infinity
FLOOR - rounding towards -infinity

Hopefully I made enough mess in your brain :ROFLMAO: .

but are round and trunc limit in 32768? I need to convert 150000.0 ...
 
S7Guy said:
I don't quite get that. It takes the same number of instructions to convert numbers in both directions. Or maybe I don't quite understand what you mean by cast.

but are round and trunc limit in 32768? I need to convert 150000.0 ...
 
From the ladder editor, click on Help>Help On STL and then type in the instruction. For example the help on RND is below:

RND (conversion of a 32-bit IEEE floating-point number to 32-bit integer) interprets the contents of ACCU 1 as a 32-bit IEEE floating-point number (32-bit, IEEE-FP). The instruction converts the 32-bit IEEE floating-point number to a 32-bit integer (double integer) and rounds the result to the nearest whole number. If the fractional part of the converted number is midway between an even and an odd result, the instruction chooses the even result. If the number is out of the permissible range, then the status bits OV and OS are set to 1. The result is stored in accumulator 1.
Conversion is not performed and an overflow indicated in the event of a fault (utilization of a NaN or a floating-point number that cannot be represented as a 32-bit integer number).
 
SimonGoldsworthy said:
From the ladder editor, click on Help>Help On STL and then type in the instruction. For example the help on RND is below:

RND (conversion of a 32-bit IEEE floating-point number to 32-bit integer) interprets the contents of ACCU 1 as a 32-bit IEEE floating-point number (32-bit, IEEE-FP). The instruction converts the 32-bit IEEE floating-point number to a 32-bit integer (double integer) and rounds the result to the nearest whole number. If the fractional part of the converted number is midway between an even and an odd result, the instruction chooses the even result. If the number is out of the permissible range, then the status bits OV and OS are set to 1. The result is stored in accumulator 1.
Conversion is not performed and an overflow indicated in the event of a fault (utilization of a NaN or a floating-point number that cannot be represented as a 32-bit integer number).

I have seen this on Help, but i have listened that there are problems with valors above 32768, and i don´t have a CPU here now fot test...
 
SimonGoldsworthy said:
Who reported these problems with values above 32768 ? What are the specifics ? First I've heard of it (I use 318/317 CPU's)

Help desk of Siemens in Brazil. I found very stranger this, exactly for having seen the help, and there it did not say nothing on this. It was then that I found the site and I decided to ask for helps vcs specialists.
 
What did Siemens Brazil tell you?
What are these 'problems'?
Are you sure they were answering the question you thought you were asking?

Ken
 

Similar Topics

I am needing to convert the low DWORD of a timestamp into a LREAL. The DWORD is a 32bit unsigned number. In TwinCat2, I keep getting a negative...
Replies
3
Views
1,683
Hi. I have been trying the Trafficsignal program, with sequence and wait and all. I kind of get that, but what I want to make is: A sensor for...
Replies
4
Views
1,996
Hello everyone. I have little to no experience working with PLC's. I have only done a little work on OLD A/B SLC 150's using PCIS. (yes, they...
Replies
30
Views
8,246
Hello to everyone!!! I have a problem in programming a plc. The plc i use is the siemens S7-200 CPU221. The problem is that i don't know how to...
Replies
4
Views
6,657
can anyone help me about how to use Real-Time Clock to run pump at certain time everyday
Replies
5
Views
4,201
Back
Top Bottom