How to Make Mini Sumo Robot with XMotion?

How to Make Mini Sumo Robot with XMotion?

In that article we will look to this sections.

  1. What is Mini Sumo Robot?
  2. Mini Sumo Robot Parts List
  3. Opponent Sensors & Testing
  4. Line Sensors & Testing
  5. DC Motors, how to use?
  6. Soldering Part
  7. Mechanical Assembly
  8. Start to Coding
  9. How to Develop Mini Sumo Robot?
  10. Homeworks

What is Mini Sumo Robot?

Mini sumo robot is a special robot type that it beats the opponent mini sumo in special rules. Each robot is fully autonomous and tries to prudh other opponent robot. At mini sumo competition usually there is weight and dimension limit ( Max. 10 cm width, 10 cm length, no heigh limit, and max. 500 grams total weight)

Mini sumo robotics is very popular in lots of countries, Mexico, USA, Ecuador, Peru, Turkey, Romania, UK, Poland, Japan is some of them. Usually first timers try to make mini sumo robot due to easiness and fun.

In that article we will use XMotion at center of our mini sumo robot. Before starting I strongly suggest you to read our first XMotion Basics article. If you read that we can continue.

XMotion is best controller for mini sumo robots. We strongly emphasize this, but why? Just watch below video.

Yes, that was not mini sumo video. But I guess you understand the power controlling capability of XMotion. Now think as this 8 kg explorer robot shrinkified to 500 grams mini sumo robot. You have little monster in your hand. XMotion’s potential gives you to make best projects. It is Arduino based controller so nothing to new learn for code environment.

At this article we will use XMotion Mini Sumo Kit, but you don’t need to use. Just read and learn the concept. Any similar design can be made with xmotion.

At this article we will use XMotion Mini Sumo Kit, but you don’t need to use. Just read and learn the concept. Any similar design can be made with xmotion.

So for minisumo robot what should we have here the list:

  • 6V 300 Rpm Core Series Gear Motor x
  • Micro Line Sensor (ML1) x 2
  • JS1 Opponent Sensor x 5
  • Steel Mini Sumo Chassis x 1
  • JS2721 Silicone – Aluminum Wheel x 2
  • 3S 350 Mah LiPo Battery x 1
  • Mini Katana Blade
  • Screws
  • Cable 24 AWG (thin multi-stranded)
  • Double Sided Adhesive tape.

First we need to test every part before assembling. Our test procedure includes multimeter (voltage measurement mode) and power supply. Set power supply output to 5V and attach to JS40F sensors. JS40F cable definition.

  • Brown: 5V
  • Blue: Gnd (-)
  • Black: Signal

Just attach brown and blue. If it sees something red led at backside will light on. Test 5 of them.

Now test the ML1 sensors, before testing you need to solder wires. After soldering give 5V to ML1s. Attach multimeter’s Ground to sensor’s ground. and measurement prob (red one) to ML1’s signal output. At empty space or black it should give 5V and at white surface or at finger it should give 0V. If it gives 4V at black and 0.5V at white that’s ok too. it gives analog output but XMotion or any digital mcu reads Logic 1 as any signal input higher than 3V. So no problem.

Next, test the motors by applying voltage and look to power supply about how much current it draws. Both motors should be similar.At our tests motors were drawing 200 ma currents. If you don’t have laboratory power supply no problem, attach motors to lipo battery and listem the motor voice. They should be similar both.

Solder the opponent sensors. For opponent sensor soldering here the pins:

  • Left Sensor: D0
  • Left Diagonal: D1
  • Middle Sensor: D2
  • Right Diagonal Sensor: D4
  • Right Sensor: A5 (We will use it as digital input)

After soldering Oppoent sensors. We will solder ML1 sensors.

  • Left Line Sensor: A2
  • Right Line Sensor: A1

When soldering cables, length should be like 12-15cm. Little longer but it will help us to place the board or remove more easily.

After this stage, last things are battery and motors. Solder left and right motor cables to pins (due to programming we will look first motors should go forward and we will make trial. So you may need to resolder the cables with reversed. Another option is you can use green terminals.

If you solder the motors, next please solder the last component. Battery input pins. if you want you can solder green terminals. But I preferred male header pins. Xmotion has both different pitch (2.54mm and 5mm) input holes.

Now we will contiune to mechanical assembly. Place ML1 sensors to front spaces. This cables will help them to stay sturdy. And place opponent sensors to their places. They will tightly fit. Next place motors to backside with their mounts.

Until this stage everything was like a puzzle. Now we will attach the silicone mini sumo robot wheels. At wheels there is one allen key wrench. Remove the silicone side from rim and put the wheel to motor. Later use allen wrench with headless setscrew to link wheel rim and motor shaft securely.

Now we will add our battery to middle of chassis. No need to attach to anything. From upside XMotion board will hold it very well. After this screw xmotion board to cnc machined chassis. There is two threaded holes for xmotion.

At this stage, robot should be like that.

Now we can start to coding.

I am thinking that from previous article you downloaded the XMotion’s library. First we need to make sure both motors are going forward. So we will write this code and burn the Xmotion.

void setup() {

}

void loop() {

xmotion.Forward(30, 1000); // 1 Second (1000ms) Forward

xmotion.StopMotors(100); //Stop 100ms

xmotion.Right0(40, 100); //Right 0 turn 0.1 second

xmotion.StopMotors(100); //Stop 100ms

xmotion.Left0(40, 100); //Left 0 turn 0.1 second

xmotion.StopMotors(5000); //Stop 5000ms

}

With this code we will examine the motor connections. When first it must go forward, both motors. If they turn one motor is turning backward, please remove solder and reverse connections and resolder. If both is going backward make this process for both. After that look for they turning to right and left true. If motors are reversed they can go forward true but can turn at opposite sides.

Now let’s develop the code. We will start with definitions, what we have? Sensors… yes. At beginning of code we are writing these defs.

int RightSensor=A5;  //Right Opponent Sensor Pin
int RightDiagonalSensor=A4; //Right Diagonal Opppnent Sensor Pin
int MiddleSensor=2; //Middle Oppoent Sensor Pin
int LeftDiagonalSensor=D1; //Left Diagonal Opponent Sensor Pin
int LeftSensor=D0; //Left Opponent Sensor Pin
int LeftLine=A2; //Left Line Sensor Pin
int RightLine=A1; //Right Line Sensor Pin
int Start=10; //Start Button Pin

Now we can contiune to void Setup function.

void setup() {
xmotion.BlinkDelay(1000); // Blink Delay Function for blinking 2 User Leds
pinMode(RightSensor, INPUT); // We declare Digital Inputs and outputs.
pinMode(RightDiagonalSensor, INPUT);
pinMode(MiddleSensor, INPUT);
pinMode(LeftDiagonalSensor, INPUT);
pinMode(LeftSensor, INPUT);
pinMode(Start, INPUT);
}

At here important thing is we didn’t declared motor control and user led output pins. But they are declared at xmotion.h library. Also we don’t declare analog inputs with pinMode command. So these pins are enough.

At traditional competitions usually referee gives start and we push the signal and it waits 5 seconds. Nowadays usually start modules are used but first we will try with 5 second delay mode.

We will read the start button digitally. This button gives 0 when not pushed. So lets write while statement to main loop functions.

void loop() {
while (digitalRead(Start) == 0) // Button push is waited. When Button is pushed, it gives 1 value.
{
xmotion.ToggleLeds(20); //Toggle Both User Leds 20millisecond Intervals.
}

While is very useful statement. Xmotion’s Mcu reads the codes from up to down. So when it comes to this while, it locks to there because button output is 0 if not pushed to anything. If we push it will give logic 1 (It will be digital read as 5V= logic 1) And it will escape from this while routine. So when button is pushed it will wait 5 seconds. Lets write 5 seconds blinking code.

for (int i=0; i <= 4; i++){ // For loop counts from 0 to 4 total 5 times loop here.
xmotion.UserLed1(500); // 500 ms Light On, 500ms Light Off.
}

New thing! For statements, we use for statements for counting purposes usually. At here this led must blink 5 times, so we count from 0 to 4 with for loop and at inside paranthesis { } it makes 1 second each loop. 500+500 interval time.

Now we are contiuning to think as a robot, what will I do? Start? yes. But how?

You guessed true, we will use Forward statement. But let’s make some priority here.

1st rule is stay in dohyo. So robot will look to line sensors.

2nd rule is find the opponent so robot will look to opponent sensors.

3rd rule be smart 🙂

4rd rule did I say stay in dohyo?

Let’s try writing this to Arduino language. We will start with line sensors. How many combination can be happen with line sensors? Here:

  1. Left line sensor see the line, Right sensor Not.
  2. Right Line sensor see the line, left sensor not.
  3. Both sensor see the line.
  4. No sensor see the white line.

4 combinations (2^2) but for us first 3 is important. It will look to statements and later it will pass the opponent sensors

if (analogRead(LeftLine)<300 && analogRead(RightLine)> 300 ) //Left Line Sensor Saw the Line
{
xmotion.Backward(100,100); //Backward %100 speed, 100 ms retreat.
xmotion.Right0(100,200); //Right Turning %100 speed, 200ms duration.
} else if (analogRead(LeftLine)> 300 && analogRead(RightLine)< 300 ) //Right Line Sensor Saw the Line
{
xmotion.Backward(100,100); //Backward %100 speed, 100 ms retreat.
xmotion.Left0(100,200); //Left Turning %100 speed, 200ms duration.
} else if (analogRead(LeftLine)< 300 && analogRead(RightLine)< 300 ) //Both Sensor Saw the Line
{
xmotion.Backward(100,200); //Backward %100 speed, 200 ms retreat.
xmotion.Left0(100,300); //Left Turning %100 speed, 200ms duration.

Now look to if statements. It will make backward movement at first and later turning. Turning to other sides. Let’s make visual.

It is clear I hope. If you are good at programming sure you can develop the code but now we are starting from basics. Soo, what’s next? Opponent sensors.

We are continuing with else if. Because at every scan we want only one aim until if statement happens. We start with if statements Now we have 5 opponent sensor, so at least we need to write 5 if statements.

else if (digitalRead(MiddleSensor) == 1 ) //Middle Sensor see the opponent (0 Not Seen, 1 Seen)
{
xmotion.Forward(100, 1); // Both Motors Forward %100 Speed, 1 Milliseconds
}
else if (digitalRead(RightSensor) == 1) //Right Sensor see the opponent
{
xmotion.Right0(70, 1); // Right Turn %70 Power 1 Milliseconds
}
else if (digitalRead(LeftSensor) == 1) //Left Sensor see the opponent
{
xmotion.Left0(70, 1); //LeftTurn %70 Power 1 Milliseconds
}
else if (digitalRead(LeftDiagonalSensor) == 1) //Left Sensor see the opponent
{
xmotion.ArcTurn(20,70, 1); // Left Motor %20 Speed, Right %70 Speed 1 ms.
}
else if (digitalRead(RightDiagonalSensor) == 1) //Left Sensor see the opponent
{
xmotion.ArcTurn(70,20, 1); // Left Motor %70 Speed, Right %20 Speed 1 ms.
}

Here we finished the opponent sensor queries.

So we are continuing to thinking. First it looks to line sensors, second looks to opponent sensors and now? If robot don’t takes any signal from these sensors what should it do? Forward? Turning or what?

First idea it should go little more slowly to forward so just add this line.

else {
xmotion.Forward(20,1);
}

So if robot doesn’t see opponent or doesn’t see white line it will go forward. But is it enough? No!

We need to lock the opponent if opponent is not seen, we need to remember about which sensor saw the opponent lastly. So let’s add one integer variable as an LastValue and add to beginning section.

int LastValue=0;

So this LastValue is a variable that it will hold the which sensor last see the opponent. Now we will add some numbers to each sensor query. Here I am updating the opponent sensor queries. and later adding more if statements for checking LastValue.

else if (digitalRead(MiddleSensor) == 1 ) //Middle Sensor see the opponent (0 Not Seen, 1 Seen)
{
xmotion.Forward(100, 1); // Both Motors Forward %100 Speed, 1 Milliseconds
LastValue=0;
}
else if (digitalRead(RightSensor) == 1) //Right Sensor see the opponent
{
xmotion.Right0(70, 1); // Right Turn %70 Power 1 Milliseconds
LastValue=1;
}
else if (digitalRead(LeftSensor) == 1) //Left Sensor see the opponent
{
xmotion.Left0(70, 1); // Left Turn %70 Power 1 Milliseconds
LastValue=2;
}
else if (digitalRead(LeftDiagonalSensor) == 1) //Left Diagonal Sensor see the opponent
{
xmotion.ArcTurn(20,70, 1); // Left Motor %20 Speed, Right %70 Speed 1 ms.
LastValue=2;
}
else if (digitalRead(RightDiagonalSensor) == 1) //Left Sensor see the opponent
{
xmotion.ArcTurn(70,20, 1); // Left Motor %70 Speed, Right %20 Speed 1 ms.
LastValue=1;
} else if LastValue==0 { //Middle Sensor Saw the opponent
xmotion.Forward(20,1);
} else if LastValue==1 { //Right or Right Diagonal Sensor saw the opponent
xmotion.Right0(30, 1);
} else if LastValue==2 { //Left or Left Diagonal Sensor saw the opponent.
xmotion.Left0(30,1);
}
}

And closing the loop with } Finished 🙂

Now our code is more logical. Think like that if opponent is fast and suddenly passed from side sensors, it will remember last sensor value and will contiune to turn or go forward according to this value. But speeds are lower due to more balanced, not agressive finding.

How to Develop Mini Sumo Robot?

Here I will explain mechanical and electronics developments. For software side, it will be new article.

  • Paint your robot to black
  • Use best wheels, best wedge
  • Don’t make empty attacks.
  • Try new things.
  • Make it exactly 500 grams. Add more weight.
  • Add some starting tactics (we will handle this at next lecture)

Homeworks

At software we used Forward, Backward, Right0, Left0, ArcTurn Functions. Except Arcturn all other functions uses 1ms delay. Can we use MotorControl(); function to make better timeless turn? 

  • How we can use trimpot?
  • How we can implement Start Module?

Users who found this page were searching for:

  • mini sumo robot
  • minisumo 3d

Leave a Reply

Your email address will not be published. Required fields are marked *