How to read 64 bit Data in DeltaV?

I have a requirement to read 64 bit Data (Double Precision) over OPC and convert into equivalent 32 bit data in DeltaV (Ver 11.3.1). Has anyone done this before?

5 Replies

  • Hi Mann,

    This could mean a number of things but I'll presume that you have your number as the raw 64 bits in IEEE754 format from another system and you simply want to see it in DeltaV as a floating point (real) number? If my presumption is wrong, sorry and please elaborate.

    If this is the case I've previously converted 32 IEEE754 bits to a float in DeltaV, but never the 64 bit double precision conversion, although I'd imaging it's a similar process. You'll see a linkedin thread on the 32 bit conversion.

    Check the many web resources for the 64 IEEE754 double precision bit format.

    Here is the DeltaV Calc Block code that converts the 32 bit word to a float. The version for 64 bit format would be similar with slightly more bit manipulation. I would suggest you thoroughly prove the conversion you produce and test around the special boundary numbers 0, -0, -infinity, +infinity, NAN (not a number)

    VAR EXPONENT END_VAR;

    VAR SGN END_VAR;

    VAR MANTISSA END_VAR;

    (* IEEE754_IN is a 32 Bit Unsigned Integer parameter *)

    (* FLOAT is a floating point parameter *)

    (* Extract the Exponent from the bits 24 to 31 of the 32 bit word *)

    (* AND Mask to extract bits 24 to 31 then shift 23 bits to the right *)

    EXPONENT := SHR(('^/IEEE754_IN.CV' & 2139095040),23);

    (* Extract the Sign from the bit 32 of the 32 bit word *)

    (* AND Mask to extract bit 32 then shift 31 bits to the right *)

    SGN := SHR(('^/IEEE754_IN.CV' & 2147483648),31);

    (* Extract the Mantissa from the bits 1 to 23 of the 32 bit word *)

    (* AND Mask to extract bits 1 to 23 *)

    MANTISSA := ('^/IEEE754_IN.CV' & 8388607);

    (* The maths used to create the FLOAT from SIGN, EXPONENT and MANTISSA *)

    OUT1 := EXPONENT - 127;

    OUT2 := SGN;

    OUT3 := MANTISSA;

    '^/FLOAT.CV' := (1+ (MANTISSA * (2 ** -23))) * (2 ** OUT1);

    IF SGN THEN '^/FLOAT.CV' := '^/FLOAT.CV' * -1; ENDIF;

  • In reply to IntuitiveNeil:

    IntuitiveNeil, you are right. I have a number as the raw 64 bits (in IEEE754 format - ? i don't know) from another system and need to see it in DeltaV as a floating point (real) number. A basic qt'n in my mind is : If DeltaV is a 32 bit system, a data of 64 bit scoming in will get truncated to 32 bit. Even if we write a piece of code to convert 64 to 32 bit, How we guarantee that the information is not lost at the edge? Any thoughts??

  • In reply to MPhatale:

    Hi Mann,

    Inevitably by placing the 64 bit number into a 32 bit (single precision) DeltaV controller format float you will lose precision. So if you had a number 123456789123456.7 in 64 bit double precision it'll probably end up something like 123456800000000.0 in the DeltaV 32 bit single precision representation.

    If you don't want to lose the precision I believe you'll need to retain the 64 raw bit representation within the controller as two 32 bit unsigned integers and if it's for representation on a DeltaV operate display perform some VB code that reads the raw bits and display a Double on the display, but if you wish to easily perform double precision mathematical calculations within the DeltaV controller. I think you may be out of luck.

  • In reply to IntuitiveNeil:

    A bit of an update.

    Might not be the answer to the problem posed but might provoke some thoughts for anyone struggling with DeltaV and 64 bit double precision floating point numbers in DeltaV.

    Seemed like an appropriate place to share these thoughts with the community.

    Download the guidance note pdf document from this location.

    www.intuitive.uk.com/deltav_double_float_guidance.php

  • In reply to IntuitiveNeil:

    Hello Neil,
    Could please recheck the code it's giving error at Mantissa SHR saying it requires 2 parameters.

    Secondly, any update on the code or built-in FB for converting 64 bit to Float in DeltaV Live 14.3?

    Let us build success,

    Zohaib Jahan