# Obtener en un PLC la posición home por comunicaciones

**URL:** <https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565>\
**Category:** Technical Questions\
**Created:** [April 13, 2022, 7:49am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565 "2022-04-13T07:49:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon24758380](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon24758380](https://forum.universal-robots.com/u/anon24758380)\
**Post date:** [April 13, 2022, 7:49am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/1 "2022-04-13T07:49:36Z")

</div>

Creando un punto en el menú - Instalación - Funciones - Punto. Lo llamamos “Home”

Porque no funciona el siguiente código

If get\_actual\_tcp\_pose() = Home  
var\_1 = True  
write\_output\_Boolean\_register(0,var\_1)  
Else  
var\_1 = False  
write\_output\_Boolean\_register(0,var\_1)

La línea 1 del programa no funciona, he probado varias cosas, conociendo el punto exacto home he probado lo siguiente

If get\_actual\_tcp\_pose() = p[0.23,0.45,-1.14,0,0,0]  
var\_1 = True  
write\_output\_Boolean\_register(0,var\_1)  
Else  
var\_1 = False  
write\_output\_Boolean\_register(0,var\_1)

La línea 1 tampoco la entiende el programa

Gracias de antemano

---

<div class="post-metadata">

**Author:** ![m.hammerton](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@m.hammerton](https://forum.universal-robots.com/u/m.hammerton)\
**Post date:** [April 14, 2022, 9:17am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/2 "2022-04-14T09:17:42Z")

</div>

When comparing the get\_actual\_tcp\_pose() to your Home position, your looking for an exact match of co-ordinates.

due to the robot being under servo control the robot is continually adjusting to keep the position.

So when the get\_actual\_tcp\_pose() is taken there are some small discrepancies.

You will never get var\_1 = True.

You can use the built in Home position and assign Safe Home to a Configurable Output

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

---

<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:** [April 15, 2022, 2:31am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/3 "2022-04-15T02:31:55Z")

</div>

Could you perform a check at Start of Program? I’m thinking something like below:

```auto
Current_Pose:=get_actual_tcp_pose()
Positional_Tolerance:=0.001
Is_Home:=True
i:=0
While(i<6) {
   if(norm(Current_Pose[i]-const_Home[i])>Positional_Tolerance)
      Is_Home:=False
   i:=i+1
}
if(Is_Home=False)
   write_output_boolean_register(0,False)
   // move Home code here
   write_output_boolean_register(0, True)
else()
   // Robot is home
   write_output_boolean_register(0,True)

```

I’m not a great coder but I think this might be a decent duct tape and bandaid solution you can try. **Note: this is off the top of my head so I’m not 100% sure it will work. You may have to play around with the tolerance variable**

There may also already be a URscript function already developed for checking this _as in manual mode the program wants to jog you to the start position if you are not already there_. The UR dev team might have a better answer or they might be using the distance URscript function between two points to check if the robot is out of start position for the beginning of the program (I guess I could have also used that above as well or compared the joint angles with get\_actual\_joint\_pose() as well, but oh well I’m sure there are several ways to skin this cat).

Anyways sorry for the long post, hope this helps and best of luck!

---

<div class="post-metadata">

**Author:** ![anon24758380](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon24758380](https://forum.universal-robots.com/u/anon24758380)\
**Post date:** [April 18, 2022, 11:00am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/4 "2022-04-18T11:00:51Z")

</div>

Thank for the answer.

First for Hammerton.  
Is curious but in my system the E-Series that opcion does not appear. What do you version use?

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

For Michael

I have checked his code in a script, for the moment there is much fault, I have found some.  
I am tryed correct it.

Thank you so much

---

<div class="post-metadata">

**Author:** ![kadams](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/kadams/32/4024_2.png) [@kadams](https://forum.universal-robots.com/u/kadams)\
**Post date:** [April 20, 2022, 7:03am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/5 "2022-04-20T07:03:36Z")

</div>

Good morning @anon24758380

Did u configure a “Safe Home” position?

To do this you have to go to “Installation”-\> “Safety” → “Safe Home”:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/7/72ed23bd18de7315319606089fbdb22cf824ec82.png)

After that you can select at “Safety” → “I/O” , “Safe Home”:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/f/fe49050ec12a755fe44e6614ff255de98416966e.jpeg)

Greetings from Luxembourg!

---

<div class="post-metadata">

**Author:** ![anon24758380](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@anon24758380](https://forum.universal-robots.com/u/anon24758380)\
**Post date:** [April 20, 2022, 10:24am UTC](https://forum.universal-robots.com/t/obtener-en-un-plc-la-posicion-home-por-comunicaciones/20565/6 "2022-04-20T10:24:04Z")

</div>

Muchas Gracias  
Así funciona correctamente.
