# How to set up Multitasking correctly

**URL:** <https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444>\
**Category:** RobotStudio\
**Created:** [April 18, 2020, 9:42am UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444 "2020-04-18T09:42:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AuxiliumD](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@AuxiliumD](https://tech-community.robotics.abb.com/u/AuxiliumD)\
**Post date:** [April 18, 2020, 9:42am UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444/1 "2020-04-18T09:42:28Z")

</div>

I have searched for hours, here, in ABB litterature and on google. Everyone is talking about multitasking but nowhere to be found is a proper instruction of how to acutally set up multitasking. I have seen things like “semi-static”, “parallell” and “multitasking”. I want to have my robot doing it’s things, but I also want a sensor to measure different distances and making calclulations with these measurements. The sensor is not corralated with the robot hence I want another program for it. I want a program that runs in the background at all times, as fast as an object moves in the way it is going to measure the max and min distances from the sensor as in the attached image. How do I set-up a task to run parallell and making calculations simultaneously?

 ![sensor.png](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/2X/e/e560baf120a30454d79b991cfb5a60f41b0a1a0b.png)

---

<div class="post-metadata">

**Author:** ![AuxiliumD](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@AuxiliumD](https://tech-community.robotics.abb.com/u/AuxiliumD)\
**Post date:** [April 18, 2020, 9:49am UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444/2 "2020-04-18T09:49:15Z")

</div>

I might have found where I set up a new task now, but where do I put my code and make it run? I would have a pseudocode looking like this

var mindist := 10000  
var maxdist := -10000  
WHILE sensed\_object DO  
IF dist\_to\_object \> maxdist THEN  
maxdist := dist\_to\_object;  
ELSE IF dist\_to\_object \< mindist THEN  
mindist := dist\_to\_object;  
ENDIF  
ENDWHILE

Just put it in the task and it will run in parallell?

How do I send values or share values between tasks?

---

<div class="post-metadata">

**Author:** ![Maxim](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/maxim/32/4429_2.png) [@Maxim](https://tech-community.robotics.abb.com/u/Maxim)\
**Post date:** [April 18, 2020, 10:13pm UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444/3 "2020-04-18T22:13:42Z")

</div>

Hello,

I’ll try to put together a guide for setting up multitasking next week. But here’s a hint for now (it’s 00:13 in the morning/evening):

 ![](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/2X/9/9bdb6b52c36c25e16486c63f08e452459782a861.png)  
See this post about sharing variables: [ABB Robotics Community - Maintenance](https://forums.robotstudio.com/discussion/3815/multi-tasking/)

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [April 18, 2020, 11:53pm UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444/4 "2020-04-18T23:53:41Z")

</div>

Have you seen the attached extract from IRC5 controller software application manual?  
[Multitasking.pdf](https://tech-community.robotics.abb.com/uploads/short-url/jQIVaQmQQDrEdamSb3lXTV7elec.pdf) (548 KB)

---

<div class="post-metadata">

**Author:** ![AuxiliumD](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@AuxiliumD](https://tech-community.robotics.abb.com/u/AuxiliumD)\
**Post date:** [April 26, 2020, 2:28pm UTC](https://tech-community.robotics.abb.com/t/how-to-set-up-multitasking-correctly/9444/5 "2020-04-26T14:28:23Z")

</div>

Thanks, they really have to make these PDFs more readely avaliable…
