COnverting S5 Real (KG) to S7 Real

smersh

Member
Join Date
Aug 2003
Posts
21
I have an S7 program which is receiving data from an S5. Does anyone know the best way to convert the S5 real numbers (KG format) to S7 real number format.
Multiplying the raw number in the S5 to an integer and then transferring to S7 is one way, but I would prefer to do the work in the S7. Has anyone written any STL in S7 to convert an S5 real number
to an S7 Real?
 
Hi Smersh..

Only you can get Real in S5-135U, the last vertion (100 to 115U) you can´t get REAL, only INT one word (KF format)...

Ok, about your problem, you can make something like this in S7:

L "S5_INT" // load the data from S5 in one word (KF) for example!
ITD
DTR
T "S7_REAL" // transfer data to S7 in REAL

I hope this help! :D
 
Hi LaRocca,
Im using an S5-155U. You can get REAL numbers - format KG.
I have written code in S7 that works for a range of positive numbers
but not for negative numbers!
There are some FC's you can download from Siemens website but you have to pay for them!
Mick
 
Hi Smersh..

Look the floating-point notation in S5:

the bit 0 to bit 22 are the Mantissa
bit 23 --> 0 is positive / 1 is negative
bit 24 to bit 30 exponent
bit 31 => 0 is positive exponent / 1 is negative exponent

This constrution is diferent in S7 (IEEE notation), it meant that you need to create a conversor.. in the S7 library have some examples than it help. Look at Standart Library-->S5-S7 converting block..
 
Hello again,

The standard lib. does not contain a function to do this.

I have managed to write the code myself!

If you ever need it let me know and i will post it for you.

Smersh
 
KG Format decoding ...

Thanks to Larocca for giving the structure of KG floats.

The following table may help you decoding S5 KG format by yourself:

^ Step5 value ^ Hexadecimal value ^
| Value in float| Exp Mantisse |
| +2500000+00 | 01 100000 |
| +5000000+00 | 01 200000 |
| +1000000+01 | 01 400000 |
| +1250000+00 | 01 080000
|
...

There is a ratio between the hexadecimal value formatted in decimal (0x100000 = 1048576 /= 2500000) But this ratio is the same for all the lines.

Hope this help,

Deverne
 
Last edited:

Similar Topics

Hi all, I've got a bit of a need to convert an integer (and a real in another situation) to a string with a particular format. This seems possible...
Replies
11
Views
2,415
Hello all, We need to convert ASCII data into Real Raw data, here we use Trimble GPS and need to get the position data. We use SCADAPack 357...
Replies
4
Views
2,763
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,648
I am having problems expressing an ANALOG OUTPUT 16bit INT word (0-10V Proportional Valve Voltage) as a REAL decimal number. From my...
Replies
6
Views
9,048
Hi, I'm faced with a rather annoying issue. I'm using CoDeSys 2.3 on an IFM CR0401 PLC which is talking to a CR0451 HMI via a CANfox network. The...
Replies
10
Views
5,342
Back
Top Bottom