Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Read and Write variables through Visualization

rhoward
2017-05-17
2017-05-18
  • rhoward

    rhoward - 2017-05-17

    I am thoroughly befuddled on how to properly read variables out of my Codesys script (located in active application Freewheeling POU) and then write into the software (preferable as a global). It stands to note that the variables are all LREAL. For learning sake (3 wks green), I'd like to know if any solution is dependant on data type.

    Current approach is derived from older (2011) posts. {} brackets for emphasis.

    Text Field
    State Variables -> Texts -> {%2.5f}

    At this point I'm getting confused as 'Inputconfiguration' houses options and 'Tap' and 'Toggle' are boolean flags. This leaves OnMouseUp/Down. I get into that editor and loose myself when I try to write or read my globals. Any thoughts or suggestions? This isn't hard, I just don't know where to look.

     
  • Comingback4u

    Comingback4u - 2017-05-18

    I'll attempt to help you out but can't say I fully understand all the questions:

    To display your variable on the screen you need to format your element to know what data type it is going to be displaying. If I was to setup a rectangle to display a variable I would first define the formatting sequence in the properties > Texts > Text. The %2.5f would work for the LREAL data type. The different formatting sequences can be found in the help under, CODESYS Visualization > Elements > Generally Configuring Elements > Use Text and Language, in the formatting text section. Now that you have defined what type of variable will be displayed there you will need to define the variable. This can be done in the rectangle properties > Text variables > Text variable.

    OnMouseUp/Down can be used to change the value when the object is clicked. For example if I want to increase a global variable by a POU variable when I click the mouse button I would do something like this under Execute ST Code of either the OnMouseUp or OnMouseDown event: GVL.GlobalVarName := GVL.GlobalVarName + POU.LocalVarName;

    Hopefully this helps in someway.

     

Log in to post a comment.