Get a site

Archive for category Tips

How to choose the motors for the robot


One of the problem building a robot is the choice of motors. I’m speaking about a mobile robot with wheel. So, I’m not speaking about legs or others geometries.
A simple robot with 2 wheel that goes around in the house. So a robot moving on a flat surface, no hills. Without tracks, without rough terrain. No SUV!
In this situation the calculations are complex and out of the aim of this little tutorial for beginners.
First we can start from the value usually reported in any motor datasheet: the torque. The torque is, in the rotation, the equivalent of force in the linear motion. To push a box, bigger it is the force, bigger it is the acceleration. For a wheel, bigger it is the torque, bigger it is the wheel acceleration (rotational).

In the datasheets often it speaks about stall torque (start-up torque, stall torque) and, somethimes, about nominal torque (rated torque).

The start-up torque is the maximum torque that the motor can provide. But when the motor is in stall, the motor is stopped. So it isn’t very useful. It would be useful to have the rated torque, that is, (approximately) the maximum torque that ensures continous operation of the engine, without problems.

If the rated torque is not present in the datasheet, we can consider the first formula (approximated):

Rated torque=star-up torque / 2

Now, we can consider the robot motion formulas. There is a formula that links the motor torque with the robot weight and acceleration. So this formula provides us a very important information. That is, knowing the robot weight (in kg), knowing the acceleration desired, this formulas says wich is the torque that we have to consider in the motor choice.

Some information are required:
– robot mass (you can put the robot in a balance and read the weight in kg).
– the wheels radius (in cm.). Please note that the radius is half the diameter
– the robot acceleration desired. For example, 0.5 m/s^2. This means that we start the robot motion, after 2 seconds it will have a speed of v=a*t=0.5*2=1 m/s, i.e. a meter for each second. Not so bad for a home robot.

The motion formula is:

C/r=m*a + Fattr

where: C is the rated torque of the motor, r is the wheel radius, m is the mass, a is the acceleration and Fattr is the attrition force (here mostly rolling) between the wheel and the floor.
The Fattr is complicated. We can do a semplification:


Basically, when we have to calculate the torque, we can double the torque deriving from the m*a calcolation. Maybe, this could be a conservative calculation, but we can be serene in the motor choice.

So let’s recap:


We must consider that the robot is pushed by two engines, the right one and the left one, so we just need half torque. The formula becames:

C/r=m*a –> C=m*a*r

Let’s take an example. Suppose you have a little robot that weights 2 kg, with two wheels with 8 cm diameter (4 cm radius) and we want an acceleration of 0.5 m/s^2. You get:

C=2*0,5*4=4 N*cm.

So the engine should have a 4 N*m torque. The motors often have a torque indicated in kg*cm. So we have to divide by 9.81 (approximately 10).

So you get a motor with a rated torque of 0.4 kg*cm, and 0.8 kg*cm of start-up torque. Easy or not?

Now consider the speed. Suppose we want a robot whit 1 m/s of speed, that means 3.6 km/h.
If the wheel has a 4 cm radius, the distance traveled at each revolution is:
d=2*pi*r = 6.28 * 4 = 25.12 cm
So, to make 1 meter per second:
100/25.12 revolution per second = 3.98 revolution per second.
knowing that in a minute there are 60 seconds, you get the revolutions per minute (rpm), another data often written in a motor datasheet.

rpm = revolutions per second * 60 = 3.98 * 60 = 239 rpm

With the data of torque and the rpm we are able to choose the right motor.
All the formulas are simplified, however, it is enough for beginners and for DIY robot builders!

Tags: ,

Charting data sent via serial port in real time

Often it is needed to chart in real time the values coming from the serial port (RS-232). In Arduino environment it is a common need. If you have some values, only one possibility is offered by the Arduino IDE: to use the serial monitor. But on the serial monitor, the values are textual and also they are difficult to read during the elaborations. You can use Processing, but Processing is complicated when you like to show many graphics or when you like to see graphic and text values, when you like to customize the graphic. You must program in Java.
I discovered a simple tool made with QT graphic libraries, that needs only a light parametrization for plotting in an easy way the serial values. The sw is SERIALCHART.
Easily it is possible to customize the graphic and modify the colors without become crazy. The sw is explained here. You have to use also an easy configuration file explained here.
I made a test to see in a graphic the values read by a 3-axis accelerometer wired to an Arduino.

The code to read 3 axis from Arduino is very easy:

// read x,y,z accelerometer values

// set input variables
int analogInput0 = 0;
int analogInput1 = 1;
int analogInput2 = 2;

// store input variables
int value0 = 0;
int value1 = 0;
int value2 = 0;

void setup(){

// set input pins
pinMode(analogInput0, INPUT);
pinMode(analogInput1, INPUT);
pinMode(analogInput2, INPUT);

// begin serial port communication

void loop(){
// read accelerometer values
value0 = analogRead(analogInput0);
value1 = analogRead(analogInput1);
value2 = analogRead(analogInput2);

// print values in the serial port, separated by comma

// wait and loop again
delay(100);   }

The output produced by SerialChart is shown in the picture below, where I inserted also the parametrization made.

Tags: , ,