thunderrobot

 #MAKE 

 01/14/14 

An omnidirectional robot derived from the ones that we used for RoboCup

This robot derives from the robots that we made to participate at the RoboCup, with whom we won the Italian championship and we qualified for the World Championship of Mexico 2012.
This robot has many of the features of our robots that palyed soccer, like: the cylindrical shape not to get stuck in the corners of the playing field, omnidirectional wheels to move in any direction, 24 infrared receivers to track the ball, the Bluetooth module to communicate with team-mate, the ultrasonic sensors and the compass for orientation in the field.
In addition to that, in this robot we mounted a graphic LCD with a resolution of 128x64 and a keyboard to choose from the various functions that the robot can do, to calibrate the sensors and read values from them.
All this system is controlled by an Arduino Mega2560 and three ATMEGA328 (The microcontrollers that are used on the Arduino UNO, so, practically, there are four Arduino). The Arduino Mega2560 has the task of managing the whole system in general, like the engines, the display, the keyboard, the bluetooth connection with the other robot and the communication with other microcontrollers. Simultaneously two of the three ATmega328 mounted on the robot are used to read the data of the infrared receivers; while the other ATmega has the function of calculating the position of the robot in the space through the reading of the four distance sensors and the compass sensor. The motivation for the selection of a multiple microcontroller system is straightforward: the sensors that are managed by the ATmega328 need to be continuously read to minimize errors and, also, this allows to have a multitasking system that speeds up all operations.
Talling about the movements, the robot exploits four DC motors totally independent from each other and placed on two perpendicular axes. The motors are pretty powerful and fast, they can rotate up to 500 RPM and they have a torque of 5 kg-cm. Therefore they require a lot of energy and, in fact, to control them we mounted four powerful integrated H-bridges which allow to control the speed and direction of rotation of the motors by PWM signals generated by the microcontroller.
For the power supply of the robot we used a three-cell LiPo battery with 2000mAh because it is a good compromise between weight, size and power supplied.

How does it work?

In this description, we will restrict ourselves to the explanation of how to handle the motors and the combinations of the relative speed to move the robot in any direction, because if we had to speak about the whole system it would be an infinite description, where most of the text would be code that would be nteresting only for a few people.
Therefore, referring to our tutorial about how to manage our models of omnidirectional wheels, we try to imagine the combinations that we need to make the basic movements. Considering that motors are all connected with the same polarity, for convenience we number the motors starting with the one at the top right and going clockwise. We see that if we want to move the robot forward we need to make the right motors turn forward and the left motors turn backward, while if we want to move it 45° right we need that the motors 1 and 3 stay still, with the motor 2 that rotates forward and the 3rd rotating backward. If we want to make it move 90° right we have to rotate the front motors backward and back ones forward. To get the robot to move 135° right we need that the motors 2 and 4 stay still, with the motor 3 that rotates forward and the number 1 that rotates in the opposite direction.
The other rectilinear movements are very similar to those described above and we will not procede with their explanation, while we go ahead to see the rotational movements that are very simple: if you want the robot to rotate clockwise all motors must rotate backward; on the contrary, to rotate counterclockwise all motors must rotate forward.
So we have seen how simple it is to manage a robot that mounts our omnidirectional wheels and that a bit of reasoning is enough to be able to move it in any directions.
One last thing to note is that the maximum speed of the robot moving in a straight line depends on how many motors are used for the movement, clearly when it goes diagonally using only two motors its maximum speed is less than the one that is obtained when it moves using 4 motors.
With this reasoning it is clear that each motor must be handled individually, then the next question to be answered is: how to handle these four motors?

Hardware

To drive each motor individually everyone must have its control circuit, that's why in our robot there are four VNH2SP30, which are integrated H-bridges produced by STMicroelectronics. They are very good because they are SMD and they can supply up to 30A to the load without overheating, thanks to the appropriate areas of heat dissipation that we designed in the boards.
In the schematic below you can see the dedicated circuit to each of these chips, for convenience we consider only a VNH2SP30 because the circuite for the other drivers is the same, they just change a controll pin of the Arduino. You can notice that only two controll lines arrive from the microcontroller, one goes to the pin called PWM and that is used to manage the speed of rotation of the motor and which is in common for all motors. While the other pin of the Arduino is used to control the direction of rotation of the motor: this line must be connected to the input A of the IC, while it arrives at input B through a NOT port, so the two inputs of the H-bridge always have opposite logic levels. This is very useful because it saves an output of the microcontroller.



Moving on to specific circuit of the IC you can notice the power supply pins GND and VCC, which in this IC can be up to 41V; then there's the Current Sensing pin (CS), which provides an analog output proportional to the current that is absorbing the load, in our case it isn't connected because there wasn't particular interest about this data. There are also two particular pins which are called "enable/diagnostic" and which have two functions: they are normally inputs that are used to enable the relative half H-bridge to work (enable function); while, if there is a problem on the IC they acts as an output reporting the fault (diagnostic function). In this circuit they were only used as enable connecting them to a pull-up resistor, since the application is quite simple and if there were problems, however, they would be easily found. Let's see the final part of this explanation about how to use VNH2SP30: the connection of the outputs with the engines. In fact, there is to pay close attention to those diodes which go to VCC and GND, they could seem unnecessary, but they are actually essential to avoid big problems. As you may know, motors have an inductive component and, then, at every variation of current which they are subjected, they produce reverse voltages that can damage the rest of the electronic components in the circuit. These diodes are used, therefore, to "cut" these spikes to avoid problems on the driver and on other ICs. Typically to perform this function schottky diodes are used because they can be polarized with a lower voltage and therefore they are faster than the others. Now we just have to understand which signals we have to send to our powerful H-bridges and how to produce them by our program.

Software

Below we will describe the part of the code used to manage the 10 basic movements, more precisely the function that is used to manage these movements.
The values of m1, m2, m3 and m4 means the percentage of the duty cycle of the PWM signal.

/*
 La variabile speed può assumere valori da 0 a 255 e va a regolare
 la velocità di rotazione di tutti i motori. 

 La variabile direction può assumere i seguenti valori:
 - 0 per far star fermo il robot;
 - 1 per far muovere il robot in avanti rispetto all'asse 0;
 - 2 per far muovere il robot in avanti rispetto all'asse a 45°;
 - 3 per far muovere il robot in avanti rispetto all'asse a 90°;
 - 4 per far muovere il robot in avanti rispetto all'asse a 135°;
 - 5 per far muovere il robot indietro rispetto all'asse 0;
 - 6 per far muovere il robot indietro rispetto all'asse a 45°;
 - 7 per far muovere il robot indietro rispetto all'asse a 90°;
 - 8 per far muovere il robot indietro rispetto all'asse a 135°;
 - 9 per fare ruotare il robot su se stesso in senso orario;
 - 10 per fare ruotare il robot su se stesso in senso antiorario.
*/

void Move(byte direction, byte speed)
{ 
  // Controlla che il valore di speed richiesto non sia sopra il limite
  speed=speed>100?100:speed;
  
  // Il pin 39 è un ingresso usato per abilitare o disabilitare il limitatore di velocità
  // se è a livello basso dimezza la velocità
  speed=digitalRead(39)==0?speed/2:speed; 
  
  // Aggiorna il valore della velocità
  motor.setPWM(2,speed);
  
  byte m1,m2,m3,m4;

  // Sceglie quale movimento fare in base al valore di direction inserito
  switch(direction){
  
  // Direzione 1 -> i motori 1 e 2 girano in avanti e i motori 3 e 4 all'indietro  
  case 1:{  
      m1=100; 
      m2=100; 
      m3=0; 
      m4=0; 
    }
    break;

  // Direzione 2 -> i motori 1 e 3 stanno fermi, il motore 2 gira in avanti e il 4 all'indietro
  case 2:{  
      m1=50; 
      m2=100; 
      m3=50; 
      m4=0; 
    }
    break;

  // Direzione 3 -> i motori 2 e 3 girano in avanti e i motori 1 e 4 all'indietro
  case 3:{  
      m1=0; 
      m2=100; 
      m3=100; 
      m4=0; 
    }
    break;
  
  // Direzione 4 -> i motori 2 e 4 stanno fermi, il motore 3 gira in avanti e l'1 all'indietro
  case 4:{  
      m1=0; 
      m2=50; 
      m3=100; 
      m4=50; 
    }
    break;

  // Direzione 5 -> i motori 3 e 4 girano in avanti e i motori 1 e 2 all'indietro
  case 5:{  
      m1=0; 
      m2=0; 
      m3=100; 
      m4=100; 
    }
    break;
    
  // Direzione 6 -> i motori 1 e 3 stanno fermi, il motore 4 gira in avanti e il 2 all'indietro
  case 6:{  
      m1=50; 
      m2=0; 
      m3=50; 
      m4=100; 
    }
    break;

  // Direzione 7 -> i motori 1 e 4 girano in avanti e i motori 2 e 3 all'indietro
  case 7:{  
      m1=100; 
      m2=0; 
      m3=0; 
      m4=100; 
    }
    break;

  // Direzione 8 -> i motori 2 e 4 stanno fermi, il motore 1 gira in avanti e il 3 all'indietro
  case 8:{  
      m1=100; 
      m2=50; 
      m3=0; 
      m4=50; 
    }
    break;
  
  // Direzione 9 -> tutti i motori girano all'indietro
  case 9:{  
      m1=0; 
      m2=0; 
      m3=0; 
      m4=0; 
    }
    break;

  // Direzione 10 -> tutti i motori girano in avanti
  case 10:{ 
      m1=100; 
      m2=100; 
      m3=100; 
      m4=100; 
    }
    break;

  // Tutti i motori fermi
  case 0:
  default:{  
      m1=50; 
      m2=50; 
      m3=50; 
      m4=50; 
    }
    break;
  }

  // Aggiorno i segnali PWM
  motor.setPWM(3,m1);
  motor.setPWM(4,m2);
  motor.setPWM(5,m3);
  motor.setPWM(6,m4); 
}

Result

So, what do we get by doing all we described so far? The answer is easy and we just need to watch a random video of the many about ThunderRobot that there are on YouTube or the pictures on our facebook page on the albums "Working on ThunderRobot" and "ThunderRobot".


CONTACTS

At the moment we don't have an office,
we are often between Padua and Vicenza.
If you need to meet us, contact us
and we will organize it.

We usually reply quickly, if you don't
get any answer just resend the email
or try another method.
Info@VicenzaThunders.com

Attention: if you need to call us,
we suggest you to send us an email or an
SMS first because we aren't always available.
You can also use Whatsapp if you want.
+393484808073
+393494548359

You can find us on many social networks,
when we have free time we like to share
our works and experiences!