# Using DI/DO asigned special functions in program

**URL:** <https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136>\
**Category:** General Application Help: How do I?\
**Created:** [August 27, 2021, 6:59am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136 "2021-08-27T06:59:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bandy](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bandy](https://forum.universal-robots.com/u/Bandy)\
**Post date:** [August 27, 2021, 6:59am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/1 "2021-08-27T06:59:28Z")

</div>

Hello,

I am very new to polyscope programming.

Is there a way to use the special functions inside a program?

I asigned the start, stop and pause function to digital inputs.  
Now I would like to let a variable inside the program pause the program.  
Of course variables can only set outputs, so this is not possible.

I could wire an output to the specific input to do this, but it must also be possible some other way?  
There already exists the “Halt” function, but it stops the program, I only need to pause it.

On a similar note I wanted to set an output when the program is running.  
There is a special function for this. But when I asign the “Prog\_Running” to a DO it is no longer usable inside the program.  
If I first use the DO in the program and then asign the special function it is possible, but I dont know if that is intended.

But the next problem is that I only want to set the output once (for like 200ms) when the program is running, but it gets constantly checked.  
Is there a way to use a rising trigger?  
(If prog\_running has a rising trigger, set output for 200ms)

---

<div class="post-metadata">

**Author:** ![anon3164729](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon3164729](https://forum.universal-robots.com/u/anon3164729)\
**Post date:** [August 27, 2021, 7:35am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/2 "2021-08-27T07:35:39Z")

</div>

> [@Bandy](#):
>
> Now I would like to let a variable inside the program pause the program.  
> Of course variables can only set outputs, so this is not possible.
> 
> I could wire an output to the specific input to do this, but it must also be possible some other way?  
> There already exists the “Halt” function, but it stops the program, I only need to pause it.

You can pause the program with the `pause` script command (which I think is not documented).

---

<div class="post-metadata">

**Author:** ![Bandy](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bandy](https://forum.universal-robots.com/u/Bandy)\
**Post date:** [August 27, 2021, 8:19am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/3 "2021-08-27T08:19:54Z")

</div>

> [@anon3164729](#):
>
> You can pause the program with the `pause` script command (which I think is not documented).

Thanks for this!  
Really easy and works.

Now I only need to fix my problem with the program running.  
I also noticed that Prog\_Running is TRUE if the program is paused, which is also problematic.

---

<div class="post-metadata">

**Author:** ![anon3164729](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@anon3164729](https://forum.universal-robots.com/u/anon3164729)\
**Post date:** [August 27, 2021, 9:53am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/4 "2021-08-27T09:53:09Z")

</div>

If you set the _Action in program_ for a digital output as _High when running-low when stopped_, then you see _Prog-running_ to the right of the output and the output goes false when you pause or stop. I don’t know why it is not working for you.  
One problem I had is that you cannot set an output to distinguish pause from stop, for that you have to use RTDE, primary/secondary interface or dashboard server.

---

<div class="post-metadata">

**Author:** ![Bandy](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@Bandy](https://forum.universal-robots.com/u/Bandy)\
**Post date:** [August 30, 2021, 5:07am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/5 "2021-08-30T05:07:30Z")

</div>

> [@anon3164729](#):
>
> If you set the _Action in program_ for a digital output as _High when running-low when stopped_ , then you see _Prog-running_ to the right of the output and the output goes false when you pause or stop. I don’t know why it is not working for you.

You are right, it is working. Thank you.

The problem I am facing right now is that I want to trigger an output signal every time the program starts (even after a pause).  
This signal has to be only short (like 500ms), I cant have it always HIGH.

As I can’t use a rising edge on Prog\_Running I am at a loss how to implement this.

---

<div class="post-metadata">

**Author:** ![anon63938643](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@anon63938643](https://forum.universal-robots.com/u/anon63938643)\
**Post date:** [September 3, 2021, 5:57am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/6 "2021-09-03T05:57:00Z")

</div>

If you are creating a local dashboard TCP server on your robot then you can use also variables to start, pause and stop the program using socket.

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/3/338d1a91b9a11e79c3ebcfc4e1c4bd8f2afd075a.png)

---

<div class="post-metadata">

**Author:** ![matteo.stagi](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@matteo.stagi](https://forum.universal-robots.com/u/matteo.stagi)\
**Post date:** [May 6, 2022, 10:08am UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/7 "2022-05-06T10:08:03Z")

</div>

How is the script command ‘pause’ exactly ?

---

<div class="post-metadata">

**Author:** ![MikeM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mikem/32/3114_2.png) [@MikeM](https://forum.universal-robots.com/u/MikeM)\
**Post date:** [May 6, 2022, 12:40pm UTC](https://forum.universal-robots.com/t/using-di-do-asigned-special-functions-in-program/16136/8 "2022-05-06T12:40:49Z")

</div>

Basically you are opening up the Dashboard Server within the robot program using the socket\_open() command and the IP 127.0.0.1 and port 29999. Some people use a true/false loop here to loop that command until the connection is made, however waiting 0.3secs is fine then they use socket\_send\_string() to send **pause** to the dashboard server which is basically like pressing the pause button on the teach pendant, this is followed by send byte “10” which is just the newline character “\n”. This command has been depreciated (depending on version of Polyscope you are running on robot) you can use _socket\_send\_line(“pause”)_ which will save you from writing an extra line of code.

Hope that helps or answered your question, and best of luck!
