marke Posted December 14, 2014 Report Share Posted December 14, 2014 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 thenEReal := 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); Mark Empson | administratorSkype Contact = markempson | phone +64 274 363 067LMPForum | Power Factor | L M Photonics Ltd | Empson family | Advanced Motor Control Ltd | Pressure Transducers | Smart Relay | GSM Control | Mark Empson Website | AuCom | Soft Starters Link to comment Share on other sites More sharing options...
marke Posted February 27, 2022 Author Report Share Posted February 27, 2022 Here is the Structured Text Subroutine code that can be imported to CScape Version 9.6 or later. Right Click on Logic Modules and select Import Modules and chose eint2floadtST.XK5 eint2floatST.XK5 Mark Empson | administratorSkype Contact = markempson | phone +64 274 363 067LMPForum | Power Factor | L M Photonics Ltd | Empson family | Advanced Motor Control Ltd | Pressure Transducers | Smart Relay | GSM Control | Mark Empson Website | AuCom | Soft Starters Link to comment Share on other sites More sharing options...
marke Posted February 27, 2022 Author Report Share Posted February 27, 2022 If you really want to do it the hardway, you can use ladder code (ugly!!) Right Click on Logic Modules and select Import Modules and chose eint2floadtLD.XK5 eint2floatLD.XK5 Mark Empson | administratorSkype Contact = markempson | phone +64 274 363 067LMPForum | Power Factor | L M Photonics Ltd | Empson family | Advanced Motor Control Ltd | Pressure Transducers | Smart Relay | GSM Control | Mark Empson Website | AuCom | Soft Starters Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now