S7NetPlus / s7netplus

S7.NET+ -- A .NET library to connect to Siemens Step7 devices
MIT License
1.35k stars 596 forks source link

how to read S1500 LReal Type value #438

Closed easyboot closed 2 years ago

easyboot commented 2 years ago

plc = new Plc(CpuType.S71500, PLCIP, 0, 1); object Ob = new object(); Ob = plc.Read(“DB53.DBW16.0”);

I get Ob value is 16639. I Use PLC Tools get value is 1.6

how can i get correct value is 1.6

mycroes commented 2 years ago

You should read a DWORD instead: DB53.DBD16 (WORD has only 2 bytes of data, LREAL is 4 bytes) and then you can use S7.Net.Types.Single.FromDWord((uint) value).