10 years, 5 months ago.

Execute three while loops simultaneously

Hello. I am implementing individual pitch control for a wind turbine model using three servo motors controlled by mbed controller. Each motor's response will depend on individual sensors placed on the blades. For this application i will have three while loops to control each motor. Can anyone please help me with sample codes of how to execute three while loops simultaneously?

1 Answer

10 years, 5 months ago.

The mbed-rtos library will make this very easy for you. It's a Real Time Operating System that allows you to create multiple threads (AKA multiple while loops) with different priorities that are run by a preemptive scheduler. They won't all run simultaneously, but the scheduler will switch between them so fast they'll look like they're running simultaneously. The handbook page should get you up and running quickly.

Thank you for the prompt reply. I have tried to understand the RTOS but since i am quite new to mbed i am getting confused. Any recommended sample program or flowchart which can help me?

posted by UniLeedsElec19 UniLeedsElec19 24 Jun 2014

The most basic led blinking program from the handbook page should pretty much work for your requirements. But tbh if each motor has equal requirements on speed of the loop, just put them all in a single while loop.

posted by Erik - 24 Jun 2014