IEEE754 block not working properly
I am using IEEE754 block to merge higher order & lower order "dint" values coming from MFM (elite 440-446) to get the value of Power Factor.
Issue is when the power factor is positive value (eg. 0.98) it shows exactly same value. however when the power factor is negative value (eg. -0.98), it shows some eratic value like 4.32, 4.87 like this.
I have no clue what the issue is. Can someone help.
I don't know from where you got that logic. Just use the code below, where IN is dint and out is real.
IN should be Upper Word X 65536 + Lower Word
IN1 :=dint_To_DWORD( IN);
Fraction := dint_to_real( dword_to_dint( IN1 AND 16#7FFFFF)) / expt( 2,23 );
Exponent := dword_to_int( shr( in := IN1,n := 23 ) AND 16#FF);
out1 := (1.0 + Fraction) * expt( 2,(Exponent-127) );
signbit := dword_to_bool( shr( in := IN1,n := 31 ));
if signbit then
out := 0.0 - out1;
out := out1;