Jump to content
LMPForum

Converting Eint Values To Reals Using Scripted Text In A Plc


marke
 Share

Recommended Posts

EInt2Float Subroutine in Scripted Text on a Horner Series PLC.

 

 

(******************************************************************)
(* EInt2Float *)
(* Convert Emotron EInt values to standard floating point. *)
(******************************************************************)

If And_Mask(EIntIn,16#8000) = 0 then
EReal := ANY_TO_REAL(And_Mask(EIntIn,16#7FFF));
Return;
End_If;

(* Get Mantissa and convert to real *)
TempWord := And_Mask(EIntIn,16#3FF);
TempInt := ANY_TO_INT(TempWord);
If And_Mask(EintIn,16#0400) = 16#0400 then TempInt := TempInt-16#0400; End_If;
EReal1 := ANY_TO_REAL(TempInt);

(* Get Exponent and convert to real *)
TempWord := And_Mask(EIntIn,16#3800);
TempInt := (ANY_TO_INT(TempWord))/2048;
If And_Mask(EIntIn,16#4000)=16#4000 then TempInt := TempInt - 8;
End_If;
TempReal := ANY_TO_REAL(TempInt);

(* Combine Mantisa and Exponent and output. *)
EReal := EReal1 * EXPT(10, TempReal );

 

 

Typical Subroutine Call.
DispCurrent := eint2floatST(FDU2Curr);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...