DWORD to REAL conversion
<p>I have been writing a program which reads values of reactive power from power analysed over Modbus RTU. </p>

<p>Reactive power is represented by 32 bits while the MSb determine the sign. Program doesn't read the whole 32 bits instead of it reads two 16 bits words. </p>

<p>After reading 32 bits I need to convert the value into REAL 
data type. So I wrote following conversion code in Structured text:</p>

<pre><code>rQs: REAL := 0.0;
rQs := DINT_TO_REAL(DWORD_TO_DINT((SHL(WORD_TO_DWORD(stLovato_power.iQ_HW),16) + WORD_TO_DWORD(stLovato_power.iQ_LW))))/100.0;
</code></pre>

<p>(structure stLovato_power contains in its items 16 bits words, which forms 32 bits representation of reactive power). </p>

<p>It seems that reading is OK but something in the conversion is wrong. I still get 0 despite the values in iQ_HW and iQ_LW are nonzero. Can somebody tell me </p>

<p>Where I have done a mistake? </p>

<p>Thanks. </p>