docbender / openHAB-Simatic

openHAB binding for Siemens Simatic S7 PLC
Eclipse Public License 2.0
20 stars 4 forks source link

I can´t read the Data Type Time from PLC #36

Closed Maddin2020 closed 2 years ago

Maddin2020 commented 2 years ago

Hello Docbender,

i want read a value with the Datatype "Time" from the PLC (32 bit). Example i want read the actual Time Value from a IEC Timer. Then i have connect the Data Point DB2001.DBD3028 in the Things Data Table. I only received 0 in the value Dammerung_Restzeitms.

All other data Points working correctly.

 Thing generic_device gobal {
        Channels:                          
            Type chNumber: Dammerung_Restzeitms         "Dämmerung Restzeit"            [ stateAddress="DB2001.DBD3028"]
    }

Thanks a lot for your support and thank for the great binding.

Martin

docbender commented 2 years ago

Hi, isn't problem in address "DB2001.DBW3028"? It should be DBDxx instead DBWxx. Right?

    1. 2021 17:21, 17:21, Maddin2020 @.***> napsal/a:

      Hello Docbender,

      i want read a value with the Datatype "Time" from the PLC (32 bit). Example i want read the actual Time Value from a IEC Timer. Then i have connect the Data Point DB2001.DBD3028 in the Things Data Table. I only received 0 in the value Dammerung_Restzeitms.

      All other data Points working correctly.

      Thing generic_device gobal {
             Channels:                          
      Type chNumber: Dammerung_Restzeitms         "Dämmerung Restzeit"       
         [ stateAddress="DB2001.DBW3028"]
         }

      Thanks a lot for your support and thank for the great binding.

      Martin

      -- Reply to this email directly or view it on GitHub: https://github.com/docbender/openHAB-Simatic/issues/36 You are receiving this because you are subscribed to this thread.

      Message ID: @.***>

Maddin2020 commented 2 years ago

Hey docbender yes DBxxx.DBD is right because the data Type "Time" have 32 Bit. If i change the data Type in "DInt" then it work but i don't understand the reason because the length is the same. I think you know that the data type Time is only the value in Milli seconds. If i select Time data Type in the Tia Portal i can read it easilier.

docbender commented 2 years ago

Data are read as byte array. I have no idea why it is read as zero. If you read DBD address with whatever type on Simatic side, on binding side have to be data stored in that 4 bytes (number of millisecond in this case). As a workaround I would use a transfer in code:

 L    TIME_VARIABLE
 T    DINT_VARIABLE
Maddin2020 commented 2 years ago

Thanks again for answer. Ok i will use this workaround. Do you have the same Issue if you Test it on your plc ?

docbender commented 2 years ago

With S7-400 no problem image