multiply gives negatives

domoticom
2024-01-04
2024-01-04
  • domoticom - 2024-01-04

    Hi,

    Attached net gives sometimes negatives, what am I doing wrong ?
    PS: detectie_nalooptijd_s = INT

     

    Last edit: domoticom 2024-01-04
  • tvm - 2024-01-04

    It's probably because you have an INT in the input to the MUL function, which will then try to output an INT as well. INT variables can only handle values of -32768 to 32767. Your value of 523000 won't fit in an INT, so it turns into an invalid number.

    Use a DINT. This is usually better for working with time values anyway, because time values are all 32 bit. Or if you can't, use INT_TO_DINT(gvlp.detectie_nalooptijd_s) in the input to the MUL function.

     
    πŸ‘
    1
  • domoticom - 2024-01-04

    thnx, meanwhile I added a INT_TO_REAL, now it works.
    Can I leave it like this or better DINT ?

     

Log in to post a comment.