data-bindingtwincattwincat-hmi

How to set a string variable via the Twincat Hmi interface


My goal is to set a string variable in my PLC code via my Twincat Hmi project. Setting a Textbox in the Twincat Hmi is no problem, however setting the string variable in my Plc code via the textbox in the Hmi does not seem to work.

  • First I created a textbox in my Hmi project
  • Then I created a string variable in my Plc project
  • I used binding to couple the Textbox and the string variable

When I tested this, the string variable in my Plc code would not change when I changed the value in the textbox of the Hmi. However, the other way around, when I changed the value in the Plc the value of the textbox would change. But I also hoped that I could change the Plc variable via the Hmi.

Does anyone know what I should be doing differently, in order to realize this goal?


Solution

  • You need to change the binding mode to two-way as explained on InfoSyS:

    1 Binding mode: Binding mode determines whether the binding acts in one direction or in both directions.

    • One-way binding (read-only): The value of the symbol is read.

    • Two-way binding (read and write access): The value of the symbol is read and the symbol is written when a specific event is triggered.