4bytes to real

aracioppi

Member
Join Date
Mar 2004
Posts
35
Using S7400 and SCL
I have 4 bytes in a DB. How can I do to assign those bytes to a real variable??
Thanks in advance
Ariel
 
Thanks for your answer

I can´t see inwich window are you doing that change.
I´m programming in SCL.
Let´s say that I´m using BRCV with serial port.
BRCV puts four bytes in DB1.DBB0 to DB1.DBB3
Now, those four bytes are one single precision float number
The question is how to assign those bytes to one real variable
 
Hello, aracioppi;
Why not read DB1.DBD0? If you are correct and the four bytes are set-up as one IEEE floating-point value. just access them as a 32 bit (DBDx) value, and treat them as a REAL value.



For example:



FUNCTION FC10
VAR
Result : REAL
...
End_VAR



...
Result = SQRT(DB1.DBD0); // SQRT needs a REAL variable argument
...
End_Function

Hope this helps,
Daniel Chartier
 
Daniel:
I understand what you say, but in that way, I depend on a boundary of a double (4 bytes)
Maybe I´m not asking in the right way.
Lets say that a serial communication brings me 15 bytes. Those bytes are in DB1 from DB1.DBB0 to DB1.DBB14.
now, let´s assume that the first 3 bytes (0,1 and 2) are header bytes (I don´t need them), Now, bytes 3,4,5 and 6 are a float to me
but byte 3 isn´t a boundary of dword
Do you understand??
Thanks in advance
Ariel
 
hello Aracioppi;
No importance; read DB1.DBD3, and you will read DBB3, DBB4, DBB5 aand DDB6. You must make sure that the data in those bytes is correct for a REAL value. And make sure you do not read over those bytes.
Or MOVE the 4 bytes to another address with correct boudaries, if you want.
For the processor, it is not important. There are no strict word boundaries in S7, as every address is manipulated at byte level.
Hope this helps,
Daniel Chartier
 
Daniel:
Thanks a lot, it worked in that way (DB1.DBDx, with x being the position in the DB where the float starts, and no mattering if that number is a boundary of Dword)

Ariel
 

Similar Topics

I am working on a project using a NB screen and NX1P2 PLC. I am having a really hard time getting a real number to properly translate through to...
Replies
3
Views
116
I am trying to copy an array of real numbers into a UDT with a real data type element. I have attached a snip below showing my COP instruction...
Replies
4
Views
197
Hi Iam using monitouch hmi(V9 soft) with omron plc cj2m (CX programmer). In this I want to read a data from hmi to plc. The data was like...
Replies
0
Views
91
Hi all. Me again still learning Rockwell. So I'll be polling an INT data array from a Modbus SE power meter with a L82 (with a Modbus ProSoft in...
Replies
56
Views
1,351
Hi all, I'm having an issue with connecting View Studio emulation to a real PLC. I am running View Studio 8.01 on a Hyper-V virtual machine...
Replies
0
Views
255
Back
Top Bottom