Mimic a Momentary Button via Scripting

Hopefully this isn’t too easy of a question. Alot of times in SCADA applications you need to send a “pulsed” command down to a device, hence the Momentary Button. Is there an easy way to do this via scripting? In other words, use either a transaction group or other event to send a pulsed command (say for 3 to 5 seconds) and then set the value back to zero.

Any help is appreciated.

You could use the GetVariable()/StorVariable functions in SQLBridge to count out a timer for you. ie make a group that runs every second with the following Expression item steps:

get: GetVariable()
write: If(var > 5, 0, 1) (writes back to the trigger opcitem)
increment: If(var > 5, 0, var+1)
store: StoreVariable(increment)

Did you really want to do this in a transaction group or in scripting? In scripting it could be as simple as:

import time system.tag.writeToTag("MyTags/TagX", 1) time.sleep(5) system.tag.writeToTag("MyTags/TagX", 0)

OK, slightly off topic question. If you have a script like this on a screen, does this block other scripts until that one is complete? Is the scripting engine threaded?

Sorry for the question if this is covered in the manual, but it just popped into my head while reading the thread.


Unless you tell it otherwise, all client scripts use the GUI thread. That means they will block everything until it is complete (including interaction with the screens). Check out system.util.invokeAsynchronous() in the help manual for more information.

Right, to be clear, scripting is not single-threaded, but the Ignition UI, based on Java Swing, is. So code on a button press will by default run on whats known as the EDT, or Event Dispatch Thread. But you can easily make your script run in a background thread so the UI keeps on chugging.