# Passing a mecunit as a parameter to a PROC

**URL:** <https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188>\
**Category:** RAPID Programming\
**Created:** [November 5, 2019, 7:02pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188 "2019-11-05T19:02:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shawndietrich](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shawndietrich](https://tech-community.robotics.abb.com/u/Shawndietrich)\
**Post date:** [November 5, 2019, 7:02pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/1 "2019-11-05T19:02:18Z")

</div>

I have a few robots with external servos on the gripper and I want to write a PROC that all the robots can use, so I’m trying to pass a Mecunit as a parameter into a routine. I’m presented with a fault saying that a mecunit is not a value. Is there a clean way of passing a mecunit?

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [November 5, 2019, 7:03pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/2 "2019-11-05T19:03:34Z")

</div>

How about using a switch, then use function Present?

---

<div class="post-metadata">

**Author:** ![Shawndietrich](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shawndietrich](https://tech-community.robotics.abb.com/u/Shawndietrich)\
**Post date:** [November 5, 2019, 7:11pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/3 "2019-11-05T19:11:36Z")

</div>

I thought about that but I some robots have one external axis and some have 4 so I want to write a routine that I just feed the parameters and no matter how many axis it will be the same code.

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [November 5, 2019, 7:13pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/4 "2019-11-05T19:13:22Z")

</div>

The switch is optional, you a.) don’t pass any at all, b.) pass one or more or, c.) use them all if appropriate.

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [November 5, 2019, 7:15pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/5 "2019-11-05T19:15:36Z")

</div>

IF Present(swMecUnit1) THEN  
ActUnit MecUnit1;  
Do whatever;  
either another IF or ELSEIF  
blah blah  
ENDIF

---

<div class="post-metadata">

**Author:** ![Shawndietrich](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shawndietrich](https://tech-community.robotics.abb.com/u/Shawndietrich)\
**Post date:** [November 5, 2019, 7:16pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/6 "2019-11-05T19:16:22Z")

</div>

Is there a way to read which mechanical unit is configured on the robot?

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [November 5, 2019, 7:17pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/7 "2019-11-05T19:17:59Z")

</div>

Maybe, but I am almost done here for today. I can look tomorrow if you have not found out.

---

<div class="post-metadata">

**Author:** ![Shawndietrich](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shawndietrich](https://tech-community.robotics.abb.com/u/Shawndietrich)\
**Post date:** [November 5, 2019, 7:26pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/8 "2019-11-05T19:26:05Z")

</div>

I think I got it. I had to put a VAR in front of the data type

PROC EOATServo(var mecunit Servo,robtarget pTarget,num Speed)

---

<div class="post-metadata">

**Author:** ![Shawndietrich](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Shawndietrich](https://tech-community.robotics.abb.com/u/Shawndietrich)\
**Post date:** [November 5, 2019, 7:44pm UTC](https://tech-community.robotics.abb.com/t/passing-a-mecunit-as-a-parameter-to-a-proc/9188/9 "2019-11-05T19:44:20Z")

</div>

Yup that’s what it was
