How Do I Read a REAL as a SINT

Green Man

Member
Join Date
Dec 2011
Location
Near Manchester
Posts
17
Folks

I have a bit of a dilema here. On a profibus network, Prosoft on ControlLogix Platform, I have an instrument that is giving me two values as REAL, however the Prosoft Card reads these as SINT!!!

Just not sure how to handle this data and retrieve it from the instrument, transmitted as REAL, and read it as a SINT.

Any pointers would be greatly appreciated.

Green Man
 
Does the Prosoft card read each Real (32 bit float) as two 16 bit integers? If so, you may be able to perserve this bit pattern by copying those INTs into a Real using the COP instruction.

When using the COP instruction, the destination data type determines the bit-length of the data which gets copied, so if the destination is a Real (or DINT), a Length of 1 in the instruction will result in 32 consecutive bits being copied. If the source is a single integer, the bits will be copied from two consecutive integers.
 
Last edited:
Hi,

I recently came across the same situation. Apart from the data part you need to know how is the byte order your device giving out the data [low and high].

As the Profibus addressing is SINT, I had to use 4 separate Bit Field Distribute to combine the read data from 4 SINT tags to a DINT. Then convert them to real. In my case, I was able to scale the value at the device, then after combining the value to a DINT tag, divide it to convert back to real.

For eg, the device giving out 1.23456, I convert it to 123456 at device and in PLC, after reading it to a DINT, divide the DINT by 100000 to get back 1.23456.

Note: Study the byte order of the read data.

Regards
_______
 
Last edited:

Similar Topics

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
103
Hi all, I have an issue with read time of Q-PLC. In case of FX is possible to read time, day, year... via D registers (D8013-D8019). In case of...
Replies
2
Views
2,877
Hello. I've been learning about PLC's in a few months now, mainly PLC programming, and yesterday I got an assignment to read an analog laser...
Replies
3
Views
4,610
Hey all, We're trying to read values from a Beckhoff PLC that is programmed by a third party. We see in the PLC the value...
Replies
1
Views
3,385
Hi all on s7 318 I havn to read a pulse from a laser senser which gives 0 output. when on. I have used a optocoupler relay to chang it to 24 v dc...
Replies
4
Views
2,929
Back
Top Bottom