%d representation with decimal part

fleaplc
2019-01-23
2019-01-24
  • fleaplc

    fleaplc - 2019-01-23

    I need to visualize into Codesys 2.3 HMI an INT value like this:
    myVAR:INT;
    100 = 10.0 sec

    is there some way to get 10.0 visualization using INT? I found this

    ,

    but if it's ok on reading, when I write it miss 0.1 : ex I write 10 , then I should expect 100 into INT var but I get 99!

    Any help is appreciated

    IMG: Codesys_2019

     
  • JAPIB

    JAPIB - 2019-01-24

    Hello,

    If I understand you idea, you want to :
    dispay 10.0 if MyVar=100
    display 10.2 if Myvar=102
    and so on ...

    To do that you can, in the settings of a rectangle (by example) write :
    Category Text -> Content: %2.1f //display format for a REAL, with 2 digits before point and 1 digit after
    Category variable -> Textdisplay : INT_TO_REAL(MyVar)/10 //conversion of the INT into REAL, then division by 10

    Another solution could be :
    Category Text -> Contente: %2.1f //display format for a REAL, with 2 digits before point and 1 digit after
    Category variable -> Textdisplay : INT_TO_REAL(MyVar) //conversion of the INT into REAL
    Conversion factor : 0.1 //Division by 10

    It works ... but you can't change the value of MyVar directly by this rectangle. You can't have a text imput with a such equation.
    If you want to change the value of MyVar, you have to add another rectangle close the display (I put it in the background under the first, letting it go a little beyond, so I can click on it).
    In this second rectangle you can display MyVar with %d and configure a text input.

    It's just an idea. Maybe there is a smarter solution ?

    BR

     
  • fleaplc

    fleaplc - 2019-01-24

    JAPIB hat geschrieben:
    To do that you can, in the settings of a rectangle (by example) write :
    Category Text -> Content: %2.1f //display format for a REAL, with 2 digits before point and 1 digit after
    Category variable -> Textdisplay : INT_TO_REAL(MyVar)/10 //conversion of the INT into REAL, then division by 10

    great it works! I 100% miss I can use conversion function into HMI, good to know.
    Thanks

     

Log in to post a comment.