DWORD to REAL conversion

Steven01

Member
Join Date
Oct 2015
Location
Prague
Posts
25
Hello,

I have been writing a program which reads values of reactive power from power analyser over Modbus RTU. 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. After reading 32 bits I need to convert the value into REAL data type. So I wrote following conversion code in Structured text:

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;
(structure stLovato_power contains in its items 16 bits words, which forms 32 bits representation of reactive power). 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 where I do a mistake? Thanks.
 
Thank you for your reaction kannanmkm. I am newbie in PLC programming and I have only some knowledge of structured text so
I would appreciate solution in ST.
 

Similar Topics

Hello, I am using Omron PLC: NX1P2 Software:-Sysmac Studio Plc in which I have to read data from an energy meter over Modbus RTU The data that I...
Replies
3
Views
882
I am needing to convert the low DWORD of a timestamp into a LREAL. The DWORD is a 32bit unsigned number. In TwinCat2, I keep getting a negative...
Replies
3
Views
1,683
Hey All, I'm looking for a simple way to take an incoming value in DWORD format and convert it to a real number. Does anyone know of a simple way...
Replies
4
Views
9,324
I'm trying to set alarm as DWord where each bit is individual alarm. So far I have tryed with DWord.0, DWord.1, DWord.2, etc. DWord.L0...
Replies
8
Views
822
Hello, I am provided with PLC tags with PLC_UDT datatype via symbolic connection. The structure of PLC_UDT (DI_hmi) is: DI_hmi.stat (UDINT)...
Replies
4
Views
1,438
Back
Top Bottom