# Two-wheeled self-balancing robot - Choosing the control system

Would an Arduino Uno have the precision-timing required (using only firmware) to control a two-wheeled inverted pendulum robot, or would it need a RTOS?

Note: Thanks for both answers, they both helped a lot. I just chose the last answer as the accepted answer.

• One key factor is traversal distance. That is, how much space do you have available for the robot to try to balance itself? This constraint will determine how much acceleration you will need to be able to achieve.
– Paul
May 26, 2017 at 5:06

You only have to do simple calculations.

We have done it with different hardware: first with a Lego mindstorm to prototype and then with a powerfull myRIO.

The hardware used:

• So, i should add to your question: we did not use a real time component to control it. The myRIO has a FPGA for fast calculations but we did not need it as 400Hz was enough for us with the normal CPU. Jun 10, 2017 at 22:03

There are several aspects that you have to consider. If the size of the balancing robot is small, you can easily control two 5V small dc motors directly with arduino/RPi-3. But, if the motors are big, then you would need 2 big motors (12V) and you would need a Raspberry Pi 3 + motor controllers or Arduino + motor controllers.

Your choice of control algorithm (LQR, PID, etc) will affect the type of microcontroller board that you shuold use. But, Raspberry Pi-3 should be able to do the job as Arduino is lacking in the computational power when running complex algorithm.

• Thanks goddar. The motors are 12V and the control algorithm is PID, so should I use the RPi with an Arduino + motor driver? Jun 9, 2017 at 13:57
• You either need one of these combinations: i) RPi + motor driver or ii) Arduino + motor driver. I dont see why you would need to use all RPi + Arduino + motor driver in one setup. Jun 9, 2017 at 14:22