Struggling to build an expression

Last time, I learned about BinEnc. I'd like to take it a bit further and need help with the syntax.

I have 2 DINTS...
If DINT 1 > 0... 1
if DINT 2 > 0... 1
Then, BinEnc(DINT 1 Result, DINT 2 Result)

How do I write that? I'm using it to change the color and text of a multi-state indicator.

binEnc(
	DINT_1 > 0,
	DINT_2 > 0
)

However, you might want to use this state elsewhere. If these 2 DINTs are part of a UDT (which they probably should be, since it seems like they are related), you can make an expression tag and bind to that to control your style customizer.

1 Like

To expand further,

case(
  binEnc(
    DINT_1 > 0,
    DINT_2 > 0
  ),              // value to inspect
  0, "Off",       // case 0, return 0
  1, "Running",   // case 1, return 1
  2, "Fault",     // case 2, return 2
  "BAD STATE!"    // default return
)

This would work, if you wanted to do a binding for each property, but I think @brians.laptop just wants the resulting INT so he can use it in a style customizer (or at least that's what he should do).

1 Like

Brians should probably add the vision or perspective tag to his original question!

2 Likes

Thanks to both of you. Its pretty simple stuff... but I'm trying to copy the functions on an existing Red Lion HMI, on a similar plastic sheet extruder. One DINT has 32 warnings, and the other DINT has 32 alarms. Green: No Alarms, Yellow: Active Warnings, Red: Active Alarms. If there are both, warnings and alarms, then the flasher flashes Yellow and Red for 1000 ms each. Thanks again for the info.