Is it possible to add an timer on the scripting menu on a tag?
I have an numeric label for the process value "PV", and an numering label for an setpoint "SP".
When the PV goes over the setpoint SP i have it automaticly pressing a One Shot Button trough scripting.
But I dont want it to be pressed right away, I want it to wait a few seconds before pressing the One Shot Button.
Is there possible to add a timer in the scripting menu of the PV?
You will not find a robust solution that runs in the user interface. You need repeating gateway logic that examines your conditions, sets timestamps, and acts upon past timestamps.
Is it possible to script the value of the button to 1 after the alarmEvent.state.isActive goes true? then I can use the alarm active delay to push the button iguess?
Like, what do you want to happen when no client is open? Or not open to the window with that button? Or with a modal notification up that stops your scripts?
Or when you have more than one client open?
Really, this is not a task for your user interface.
This is absoluetly something that should be done in the PLC.
Here's my 2¢:
You'll want a UDT to organize everything.
OPC tag for the SP Process_SP
OPC tag for the PV Process_PV
Memory tag for the button-press delay Auto_Adj_PRE
Expression tag to detect when the PV exceeds the SP Auto_Adj_Req [{Process_PV} > {Process_SP}]
Memory tag used as intermediary before actually executing the update button Auto_Adj_INT
OPC tag for the button Update_SP_PB
2 different valueChange scripts should get the job done here.
Auto_Adj_INT.valueChaged()
def valueChanged():
if currentValue != previousValue and not initialChange:
if currentValue.value == 2:
system.tag.writeBlocking(['Update_SP_PB'], ['1']) #psuedo-path
Auto_Adj_Req.valueChanged()
def valueChanged():
if currentValue != previousValue and not initialChange:
#PV > SP
if currentValue.value:
#get the delay
delay = system.tag.readBlocking(['Auto_Adj_INT'])[0].value #psuedo-path
system.util.invokeLater(maybeUpdate, delay)
#PV < SP
else:
#reset INT to 0 - cancels the PB
system.tag.writeBlocking(['Auto_Adj_INT'], [0]) #psuedo-path
def maybeUpdate():
#read current INT
autoAdjINT = system.tag.readBlocking(['Auto_Adj_INT'])[0].value #psuedo-path
#INT is still 1, update to 2 - triggering the INT's valueChanged script
if autoAdjINT == 1:
system.tag.writeBlocking(['Auto_Adj_INT'], [2]) #psuedo-path
Again, way easier in the PLC. Also, I am unsure if your oneshot button exists in the GUI or in the PLC, or how it gets reset
What exactly are you trying to accomplish? I think if you described what the end goal was, it would help everyone understand what you're doing. What is the function of the one-shot button? Is it tied to a PLC tag? Are you running a script to do something else?
While ideally this is something done in the PLC, if it's doing something in Ignition or a DB, or something else, sharing that information would help everyone else out.
Thanks everyone by your input. And sorry if what I tried to explain/ask for was very unclear.
I ended up setting up an alarm for the process value PV rising over the setpoint SP, this with the . And with this i added the Active delay property on the alarm.
I then went on the scripting on the same tag, with the Alarm Events > Alarm Active. Wrote what thag to be changed to 1/TRUE when the alarm is active:
system.tag.writeBlocking(TagPath, 1)
This ended up working and did what I tried to accomplish without changing the PLC code (due to old PLC and dont want to edit code thats havent been touched in years).