Asynchronous method?

Im working on an application where I need to energize some electro magnets individually. They will be energized over time using PWM but I need some way of change their energy level simultaneously. So for example I would have one magnet going for 100% down to 50% over a period of 500ms, but at the same time have two other magnets energize from 0% to 100% over a period of 700ms.
What is the best way to do this? Separate threads or is there some other way?

How accurate do you have to be? If 50ms delay is okay then threads are fine but if you need microseconds accuracy then you can use “tasking” services available in RLP.

It isnt time critical at all so you feel that threads are my best (only?) option?

There were days where threads didn’t exist :slight_smile: You can always do things without threads. It is really up to you on how you do it and also depends on the rest of your application. You still need a way to control your loops and the rest of your application.

Since your loop is 500ms long but the other one is 700ms long then threads (or timers) would be the better option.

Then threading it is. Thank you for your time Gus.