Perspective motor symbol animation

Hi All,

I am using motor symbol from components and would like to show the animation. I am changing the state of the motor with the help of text field in the value. Now I want to change the text field from my tags. I have 3 (BOOL) tags and want to configure them to write it to the text field. The 3 Bools are as follows

  1. Run/tag - should write running in the text field
  2. Fault tag - should write faulted in the text field
  3. Stopped - should write running in the text field

would request for any help!!!

Why have you got three tags instead of just one with, for example,

  • 1 = running
  • 0 = stopped
  • -1 = faulted

Then your binding becomes very simple.

I am working on a project and the program for PLC is already written and don’t have rights to change it.

It’s kind of messy, but try this in an expression binding:

if({[default]Tag1}, "Running",
	if({[default]Tag2}, "Faulted",
		if({[default]Tag3}, "Stopped", "")))

I’d create an expression tag in your UDT with (essentially @josborn 's expression, I like all ifs on the same vertical though) :

if({[.]Tag1}, "Running",
if({[.]Tag2}, "Faulted",
if({[.]Tag3}, "Stopped",
"")))

Then you can use this anywhere you need to show its status rather than having to write this 17 million times (probably an exaggeration). Expression tags only ever update when it’s conditions change

I like to indent for readability, though it doesn’t make much difference here.
I had to recreate some rather nonsensical color animations, and ended up with this nested if:

if({Cam_Angle1.Stat},
	if({Cam_Angle1.VCR_Stat},
		1, //flashing red
		if({Cam_Angle1.Alarm},
			2,  //Red
			if({Cam_Angle1.Manual_Stat},
				3, //Yellow
				4 //Tan
			)
		)
	),
	0  //No Color
)

if i were to remove the indentation it is not easy to tell what’s going on:

if({Cam_Angle1.Stat},
if({Cam_Angle1.VCR_Stat},1, //flashing red
if({Cam_Angle1.Alarm},2,  //Red
if({Cam_Angle1.Manual_Stat},3, 
4))),0)

On the contrary, I find it more readable if all conditions and results are aligned :person_shrugging:
However I would indent separate “case statement” if statements, e.g.

if({Cam_Angle1.Stat},
   if({Cam_Angle1.VCR_Stat},1, //flashing red
   if({Cam_Angle1.Alarm},2,  //Red
   if({Cam_Angle1.Manual_Stat},3,
   4))),

   0
)
1 Like

I’ll agree that’s not too bad actually. I’ll probably still do it my way though (;

I prefer the case statement to nested ifs, I don’t have to figure out how many close parenthesis are required and can add another case with copy/paste:

case(True,
    {[.]Tag1}, "Running",
    {[.]Tag2}, "Faulted",
    {[.]Tag3}, "Stopped",
"")
4 Likes

This case statement usage has always intrigued me, every time I have needed it though I haven’t remembered to use it :frowning: but it is much cleaner!

That's an awful lot clearer than the user manual example. Thanks!
https://docs.inductiveautomation.com/display/DOC81/case

I've suggested to docs@inductiveautomation.com an update to the manual.

Update: The docs have been updated.

1 Like

Yeah wow, they’re a bit hard to read, sorry @Paul.Scott :sweat_smile:

Perhaps a better example for the user manual:

case({[.]Tag1},
     1, "Running",
    -1, "Faulted",
     0, "Stopped",
"Unknown")

+1 for clean code
-But how will this be executed compared to having the actual condition tag as the first parameter?
-Will this be executed “constantly”, and put unnecessary load the client?

I would prefer a map transform over a case statement like this in Perspective:

Map Transform - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)

Recall the original question… 3 tags are used to define the 3 states. In a UDT or with expression binding on a window/view the case statement should execute exactly the same number of times as the nested if statement. In Perspective an expression structure with map transform would work as well and would only execute once per tag change per session with the view open.

  1. Expressions will be executed only when any of the inputs change.
  2. The expression is calculated on the gateway, not on the client. Obviously there will be some extra traffic to refresh the data binding on the client component but it shouldn't hurt.

Tip: for bulleted lists the markdown requires a space after the hyphen. - list item.