Grouping of different routines

Dear Community

Do you know if it is possible to group 3 different routines so that the program runs them alternately?

I have a flow created with certain movements for servos (2) with N repetitions.
In turn I have another flow with another routine for these servos and a third different from the other two routines.

Is it possible to leave each flow in each workspace and have a master program control the different flows in view of time?

I would appreciate any suggestions,

regards :wink:

You will want to use pulses to control program flow, as described here:

You can also do a deeper dive by taking a look at

Basically, your main patch will send a pulse to each of three different patches that will execute your three different routines. You just need to make sure your main patch waits for the previous patch to finish before sending pulse to another patch, and each patch needs to finish all its actions before sending a done pulse.

Since the 3 patches are controlling the same 2 servos, you will want to create a servo object for each & pass them to each patch, so you will need to use rotate-slow instead of just rotate so you can pass the servo device to it. Each servo will also need a MUX; it would be best to create both MUXs in your main patch & pass them to each of your routines to make sure 2 different routines are not trying to control a servo at the same time.

Hi @gweimer !!

Thank you very much for your great guidance.

Would it be possible to explain a little more in detail how to apply the MUX nodes you mention to me?

Thank you again :slight_smile:

I think the traffic-light-advanced is the only example that demonstrates Mutex. Basically, the “mutex” node creates a single MUX (flag/lock/semaphore). Each MUX can only have one lock on it at a time, so any nodes/actions sharing the same MUX can only be done one at a time.

The rotate-slow node uses a MUX because it is continuously making adjustments over time and your program is likely to be trying to do other things at the same time. By using a MUX, the rotate-slow is able to create a lock that doesn’t get released until the servo has reached its end destination after multiple updates. For the MUX to actually work as designed, any actions made against that servo must share the same MUX. You could share the same MUX between multiple servos also, but that would prevent you from updating more than one servo at a time, so the most “logical” method would be to use one MUX for each servo. This prevents two different parts of the code from updating the same servo, but still allows multiple servos to be updated at the same time.

Thank you very much for your help @gweimer

I will try to get what you suggest and I will tell you later how I find it :wink: