0

I want to have a variable color for, in this case, a radio button in my Twincat Hmi project. I intended to do this by binding the hexadecimal color value to an integer variable in my PLC code.

When I tried to bind this Plc variable to the hexadecimal value of the color, the button would just adopt the standard blue color in the Twincat Hmi and the color would not change for a change in the variable. Since the data type for a SolidColor is string I tried to change the type of the Plc variable from int to string, however this resulted in the same error(see figure).

Screenshot of error

How can I control the state of a solid color via my plc code?

  • 2
    HI Niek, welcome to Stackoverflow. Can you add the whole error code in plain text? That way the error is easier to find for people in the future. Regarding your question: I'm not sure if this is possible. In general I would try to separate your HMI styling from the PLC logic. How I once implemented it something similar, is by defining colors in your HMI and then based on a switch case or if statement which is connected to a variable in your plc, apply a different color to your element. – Roald Apr 26 '23 at 16:16
  • See another example [here](https://github.com/benhar-dev/tchmi-color-from-value). – Roald Apr 26 '23 at 16:19
  • Thanks for the response Roald. I used your implementation and it works now. – Niek Morsinkhof May 04 '23 at 09:06

0 Answers0