Jump to content


Photo

Converting Eint Values To Reals Using Scripted Text In A Plc

PLC FDU VFX eint ST

  • Please log in to reply
No replies to this topic

#1 marke

marke

    Posting Freak

  • Moderator
  • PipPipPipPipPipPip
  • 2,617 posts
  • Gender:Male
  • Location:Christchurch, New Zealand

Posted 14 December 2014 - 06:01 PM

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);







Also tagged with one or more of these keywords: PLC, FDU, VFX, eint, ST

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users