Valve template with UDT - Animation

Hello all! Im getting started in Ignition and am trying to figure out the best way to accomplish valve animation for a template.

I am using the plantPAX objects (P_ValveSO) and want to animate a valve depending on the state.
So ideally the valve body turns grey when {Valvenumber}.Sts_Closed = 1 and the valve body turns white when open {Valvenumber}.Sts_Opened = 1.

Should I just make a new tag under the UDT called “Valve_Position_Feedback” and write an expression then animate the valve on the value of that tag? If so, is there documentation I can reference for building this - if not, any advice on best practice?

Regards,

Taylor Johnson

I create two expression tags for mode and status of devices which are string tags. Then I set these to their descriptive status.
Eg
Status:
-Opened
-Closed
-Faulted
-Opening
-Closing

Mode:
-Auto
-Manual
-Maintenance

I then use the descriptive tag everywhere for bindings etc so that the states are completely unambiguous and easy to know exactly what the expression is doing. It also means, if for some reason another device is created that doesn’t have the same logic and states (for example if the plc has an integer that represents the status as 0-closed,1-closing, etc) then it doesn’t matter, you can continue to use your templates regardless as their descriptive status remains unchanged. It’s a way of abstracting your plc logic from your gui objects.

I’m going to assume you’re using Vision. For the actual animation of colours, for Vision I define colours in Vision Client Tags which are essentially client-scoped internal memory tags. These should be set to strings and their values set either to an RGB e.g. ‘color(R, G, B)’ or to a hex e.g. ‘#F68C5A’ colour. Unfortunately the human interprettable colour model (HSL) isn’t supported :frowning:

I would define colours for device states: off, on, faulted, etc.
Then in your graphic, I use an expression binding for the colours that references those client tags:

Case({device/status desc} 
  ,'Closed', {[client]Styles/Devices/Closed} 
  ,'Closing',.... 
 ... 
  ,invalid colour... 
) 
1 Like

This is a really good and robust solution! Thank you for the write up - I’ll give this a crack.

Hey there! Quick question for you: I got the UDT state tag setup and working correctly. So now I am on the individual object and trying to bind its fill paint to the expression.

I used this syntax and a few others and Im not having much luck getting it to compile and not getting any errors.

case({[default]types/Solenoid_Valve/Valve_Status_FB}
“CLOSED”,
color(170,170,170,[255]),
“OPEN”,
color(255,255,255,[255]),
color(100,100,100,[255])

  • I tried to use #AAAAAA for the color and etc but think I am making syntax errors here. I also tried the expression with the “OPEN” to be ‘OPEN’ or OPEN with no luck! I dug through expression manual and such but am a bit stuck if you have any advice

You can’t use square brackets in the color function (square brackets in the function info mean the argument is optional) , and hex values need to be in strings.

E. G.

Color(255,255,255,255)
Or
"#ff00ff"

Figured out what I was doing wrong! I got the expression to accept but my valve kept showing the fallback color… Then realized that I mapped the status tag to the default instead of to the dynamic valve number parameter Im using in the template.

1 Like