# Can't get tool\_digital\_out signal to show up on my simulation I/O

**URL:** <https://forum.universal-robots.com/t/cant-get-tool-digital-out-signal-to-show-up-on-my-simulation-i-o/1225>\
**Category:** URScript\
**Created:** [October 2, 2017, 4:03pm UTC](https://forum.universal-robots.com/t/cant-get-tool-digital-out-signal-to-show-up-on-my-simulation-i-o/1225 "2017-10-02T16:03:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon44882538](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon44882538](https://forum.universal-robots.com/u/anon44882538)\
**Post date:** [October 2, 2017, 4:03pm UTC](https://forum.universal-robots.com/t/cant-get-tool-digital-out-signal-to-show-up-on-my-simulation-i-o/1225/1 "2017-10-02T16:03:35Z")

</div>

Here is the code I used for the TCP/IP communication and the method for sending ur script. Is it because I am sending the script as a string? Please let me know if any of you have some insight. thanks!

// localhost IP  
private String TCP\_IP = “127.0.0.1”;  
// Port for secondary client  
private int TCP\_port = 30002;

```
	public void sendClose(String whichOut, String signal1){
		sendToSecondary("set_tool_digital_out("+whichOut+", "+signal1+")");
	}
	public void sendOpen(String whichOut2, String signal2){
		sendToSecondary("set_tool_digital_out("+whichOut2+", "+signal2+")");
	}
	
	private void sendToSecondary(String command){
		try{
			Socket sc = new Socket(TCP_IP, TCP_port);
			if (sc.isConnected()){
				System.out.println("Connected to UR Secondary Client");
			}
			
			DataOutputStream out;
			out = new DataOutputStream(sc.getOutputStream());
			
			String thisCommand = "def myCustomCode():\n "+command+"\n end\n";
			
			out.writeUTF(thisCommand);
			System.out.println("Send this: "+thisCommand);
			out.flush();

			out.close();
			sc.close();
			System.out.println("Disconnected from UR Secondary Client");
		} 
		catch (IOException e){
			System.out.println(e);
		}
	}

```

}

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [October 3, 2017, 12:11pm UTC](https://forum.universal-robots.com/t/cant-get-tool-digital-out-signal-to-show-up-on-my-simulation-i-o/1225/2 "2017-10-03T12:11:37Z")

</div>

You have to send it as [secondary program](https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/secondary-program-17257/), but this is very inefficient way of setting output value.  
It would be much more robust to use [RTDE interface](https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/real-time-data-exchange-rtde-guide-22229/) to control IO state.

Create a background thread that subscribes to tool\_digital\_output, and tool\_digital\_output\_mask and set values there. You should also subscribe to receive actual\_digital\_output\_bits to confirm actual value set.

---

<div class="post-metadata">

**Author:** ![anon44882538](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@anon44882538](https://forum.universal-robots.com/u/anon44882538)\
**Post date:** [October 3, 2017, 2:18pm UTC](https://forum.universal-robots.com/t/cant-get-tool-digital-out-signal-to-show-up-on-my-simulation-i-o/1225/3 "2017-10-03T14:18:57Z")

</div>

Thanks for the input! I will try switching over to the RTDE. I am new to URCaps so its a learning process at the moment. I tried using very similar code in the sample for Sending URScript with Buttons and it worked for me there to use a button to move the robot to a pose so I am confused about why it would work for that, and then not work for setting the tool output? In the meantime I will start working on implementing the RTDE.
