Multiple trigger

I am attempting to set up an expression that will look at the time and set the trigger value when the time is 7:28 AM or PM. At the same time, I need to set the trigger flag on the haschanged for another PLC value. From what I gathered, this was suggested in another post, but i could be confused on the basics of it. I am also confused with the Python syntax and the whole process in general. I have tried a number of variations to the syntax.

I keep getting an evaluation error on both expressions. Here is the time check expression:

if {[.]Hour}= 7 || {[.]Hour} = 19:
	if ({[.]PLCMinute}= 28):
 		{[.]Trigger)}= 1
 	if (hasChanged {[.]MainMotorRunning_4}):
 		{[.]Trigger)}= 1
 		{[.]Trigger)} = 0)

Can you help?

Indeed, that’s your first problem- there should be no python involved :smiley:

Ok, so you have a trigger in a group- it’s an Expression Item named “Trigger”, which uses expression sytanx. The difference between the two systems commonly trips up new users, and I wish we had a video outlining the two, but for now there’s this section in the user manual.

So then, in expression syntax:

if( ({[.]Hour}= 7 || {[.]Hour} = 19) && {[.]PLCMinute}=28, 1, if( hasChanged({[.]MainMotorRunning_4}), 1, 0) )

You were trying to assign a value to “Trigger”. This is not how it works- instead, your tag “Trigger” is set to run as an Expression, with the code above. All expressions always boil down to a value, so what we have above is an “if” expression with a nested expression in the “else” case. Here’s the user manual entry for the if function, if it’s not clear what’s going on in that block.

Hope this helps,

That was it! && I tried the book method If( condition, trueReturn, falseReturn) and I couldn’t seem to incorporate the minute value into the condition so strayed off into python land to try to fix it.

Thank you Colby!