0

I'm using S7.net to communicate with S7-1500 PLC. One of the value set in the plc is -90, when I read this value using code below, it show 65570 in winforms instead of -90.

var data = (ushort)plc.Read("DB10.DBW100");

The type set in plc program is "ShortToSignedWord".

How I can get the -90 and show in winforms?

Bubble Bub
  • 651
  • 4
  • 12
  • 32
  • 1
    `ShortToSignedWord` has a range of `-32768...+3276` whereas `ushort` goes from 0...65535. Are you sure you're using the right conversion? – Alex Oct 02 '19 at 09:52
  • 1
    Thanks for the guide, finally found need convertoShort after cast using "ushort" var data = ((ushort)plc.Read("DB10.DBW100")).ConvertToShort(); – Bubble Bub Oct 03 '19 at 07:09

0 Answers0