How to Make Mini Sumo Robot with EASYBOARD? Code Included!

How to Make Mini Sumo Robot with EASYBOARD? Code Included!

Hi friends,

In that article, I will introduce you our new controller, Easyboard. And we will write the program together.

What will we handle at that article?

  1. What is Mini sumo Robot?
  2. Easyboard Features
  3. Attaching sensors & Motors
  4. Programming the mini sumo robot code
  5. And further developments

First of all we need to explain.

1. What is Mini Sumo robot?

Minisumo robot is one of a branch of hobby robotics, Same as sumo matches or box matches main aim is beating an opponent by pushing out of the ring. You have one robot, an opponent has one robot and they work as autonomously. Each robot sense dohyo ring’s (you see, white bordered black circles) edges and detecting opponents position. And when the front sensor sees, or robot thinks as an opponent is at front and project trying to push another to out of the ring. Just that 🙂

rem-robot-6

It has a basic concept, pushing. And for that purpose we are using some components like dc motors (pushing power), opponent sensors (detection with reflected light beams), edge sensors (Detection of white, black line white reflects beam, black don’t). For controlling that components, you need to make electronics board. For this purpose, we created Easyboard.

Before connecting that things. I want to make list about what we want from robot:

  • Wait the start command (Before Pushing button)
  • When start button pushed wait 5 seconds (Which is general rule for lots of competitions)
  • Stay on the ring Prior aim (Sense the ring edges)
  • Find Opponent (Sense the opponent)
  • When you find opponent with sensors make maneuvering to opponent (forward, right turn, left turn)

2. Easyboard Features

Easyboard helps you to make your first projects (mini sumo robot, line follower robot etc..) Board includes common circuits for you to develop and make better projects without struggling circuit design etc.

For that purposes at Easyboard, we have terminals. With terminals, you can connect maximum 6 different sensors. We will use 3 Opponent sensors and 2 Edge Sensors (Total 5 Input). Board can work betwen 9-12V and it can give dual outputs maximum 600ma, peak 1 ampere. At below, you will find Easyboard‘s diagram.


3. Attaching Mini Sumo Robot’s Sensors & Motors

Opponent sensors should add to front, left and right (Left and right can be attached to diagonals also)

Edge sensors should face to dohyo surface from 2-3 millimeter. If they are far from the surface they can’t detect white, black. If they are too near they will see black as white. And it will try to make backward for escaping white edge.

Now assemble, for assembling you need to know the wire’s meaning.

For MZ80 Opponent sensor pins are below.

  • Red: 5V
  • Green:0V GND
  • Yellow: Signal
mr45-sensor-npn-output-mini-robot-sensor

And for MR45 Sensor which is another popular sensor for mini sumo robots.

  • Red: 5V
  • White: 0V GND
  • Yellow: Signal

And the edge sensors, for that sensors you need to solder wires or you can use female-male cables. Here are QTR1A pins.

  • Vin:5V
  • Gnd:0V
  • Out: Signal

Now we can connect wires to terminals. Also, you can connect your dc motors. Dc motors directly turn when the voltage applied. At Easyboard controller, we showed clearly motor terminals. (click for the bottom image of Easyboard) Just connect. When we start robot if the motor turns backward just we will swap motor wires. For connection diagram, you can click the bottom image.


4. Mini Sumo Robot Code

Before starting the code, I want to visualize what I done at programming side. Please click the flowchart below for bigger image.

Each program loop tooks microseconds to milliseconds and processed thousands of times at one match. Each execution time robot makes some behaviour and goes to main function. But if we push the button while it is in main execution code, robot will go to sensor diagnostics branch.

If we understand the program flow, we can continue.

Our readymade program is written at MikroC. It has a good community. I suggest you to use MikroC language at pic microcontrollers. For downloading mikroC software please look:

http://www.mikroe.com/mikroc/pic/

Demo version is enough for our system.

And if you don’t know the language, you can learn:) It is easy. Very similar to Arduino codes. At code, I made lots of comments for you to easy understanding.

/* Written in Licenced MikroC language for Minisumo Robot
Robot Controller: Easyboard Main Board V.4
Mini sumo Robot program for 3 Opponent Sensor, 2 Edge Sensor, 2 Motor
MCU: Pic16F628A
08/15 – JSumo.com – Firat Faris Dede */

#define FrontObject RA6_bit // Front Sensor Define – 0V when obstacle / opponent detected (For MZ80, MR45)
#define LeftObject RA4_bit // Left Sensor Define – 0V when obstacle / opponent detected (For MZ80, MR45)
#define RightObject RA7_bit // Right Sensor Define – 0V when obstacle / opponent detected (For MZ80, MR45)

#define LeftLine RA5_bit // Left Edge Sensor Define – 0V when white line sensed (For QTR1A)
#define MiddleLine RA0_bit // Middle Edge Sensor Define – 0V when white line sensed For QTR1A)
#define RightLine RA1_bit // Right Edge Sensor Define – 0V when white line sensed (For QTR1A)

#define BUTTON RA3_bit // Button Define – 5V goes When pushed

#define LED RB2_bit // Led lights when high given

#define MotorLeft RB1_bit // Left Motor Direction Pin – 5V Forward, 0V backward
#define MotorRight RB0_bit // Right Motor Direction Pin – 5V Forward, 0V backward
#define MotorPWM RB3_bit // Common Enable Pin For Motors, PWM speed channel

// Mode Dipswitch Pins
#define Dip1 RB7_bit // DipSwitch 1
#define Dip2 RB6_bit // DipSwitch 2
#define Dip3 RB5_bit // DipSwitch 3
#define Dip4 RB4_bit // DipSwitch 4
#define BUZZER RA2_bit // Buzzer beeps when 5V (high) given

void InOut_define()
{
// [ 0 -> Output | 1 Right Motor Output
B1 -> Left Motor Output
B2 -> Tied to Mode Led
B3 -> PWM Output _-_-_- Motor Speed Control

A0 A1 Buzzer
A3 A4 A5 A6 A7 */
TRISB=0xF0; // b7 b6 b5 b4 b3 b2 b1 b0
// 1 1 1 1 0 0 0 0
TRISA=0xFB; // A7 A6 A5 A4 A3 A2 A1 A0
// 1 1 1 1 1 0 1 1
PORTA=0; // A port Outputs at 0V
OPTION_REG.F7 = 0; // Enable individual pull-up
CMCON = 0x07 ; // Internal comparators closed
Sound_Init(&PORTA, 2); // Sound library Defined to Porta.2 (Buzzer Pin)
Pwm1_Init(5000); // PWM Frequency
Pwm1_Start(); // PWM function started
}

int i=0; // I defined and equals to 0.

void Beep5sec() // Buzzer Function
{
int LastValue=5; // This variable will be used for remembering what robot made last thing.

for(i=0;i<5;i++) // Buzzer Counter for 5 Sec Wait (Minisumo Start Routine)
{
BUZZER=1; // Buzzer, Porta.2 = 5V
LED=1; // Led, Portb.2 = 5V
delay_ms(500); // 500 ms Delay
BUZZER=0; // Buzzer, Porta.2 = 0V
LED=0; // Led, Portb.2 = 0V
delay_ms(500); // 500 ms Delay
}
}

void SensorTest()
{
while(1) {
if(LeftLine==0) { Sound_Play( 290, 100);} // If left Line Sensor gives signal, Give sound from buzzer at 290 hz for 100 ms.
if(RightLine==0) {Sound_Play( 500, 100);} // If Right Line Sensor gives signal, Give sound from buzzer at 500 hz for 100 ms.
if(FrontObject==0) { Sound_Play( 1500, 100); } // If Front Object Sensor gives signal, Give sound from buzzer at 1500 hz for 100 ms.

if(LeftObject==0 ) {Sound_Play( 4500, 100);} // If Left Object Sensor gives signal, Give sound from buzzer at 4500 hz for 100 ms.
if(RightObject==0) {Sound_Play( 12000, 100);} // If Right Object Sensor gives signal, Give sound from buzzer at 12000 hz for 100 ms.
BUZZER=0; // Buzzer Stopped
}
}

void Forward()
{
Pwm1_Set_Duty(255);
MotorLeft=1; // Left Motor Forward
MotorRight=1; // Right Motor Forward
}

void Forward2()
{
Pwm1_Set_Duty(195);
MotorLeft=1; // Left Motor Forward
MotorRight=1; // Right Motor Forward
}

void Backward()
{
Pwm1_Set_Duty(205);
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
}
void Stop()
{
MotorPWM=0; // Motors are passive
}

void RightTurn()
{
Pwm1_Set_Duty(220); // Motors are active speed is 220 / 255
MotorLeft=1; // Left Motor Forward
MotorRight=0; // Right Motor Backward
}
void LeftTurn()
{
Pwm1_Set_Duty(220); // Motors are active speed is 220 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=1; // Right Motor İleri
}

void RightEdge()
{
if (RightLine==0){
LED=1; // Led Lights
Pwm1_Set_Duty(250); // Motors are active speed is 250 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(50); // 50 milisecond delay // It will make Backward

MotorLeft=0; // Left Motor Backward
MotorRight=1; // Right Motor İleri
delay_ms(80); // 80 Ms delay, It will turn
LED=0; // Led don’t emits light anymore
}
}
void LeftEdge()
{
if (LeftLine==0){
LED=1; // Led Lights
Pwm1_Set_Duty(250); // Motors are active speed is 250 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(50); // 50 milisecond delay // It will make Backward

MotorLeft=1; // Sol Motor İleri
MotorRight=0; // Sağ Motor Backward
delay_ms(50); // 80 Ms delay, It will turn
LED=0; // Led don’t emits light anymore
}

}

void DoubleEdge()
{
Pwm1_Set_Duty(250); // Motors are active speed is 250 / 255
MotorLeft=0; // Left Motor Backward
MotorRight=0; // Right Motor Backward
delay_ms(200); // 200 milisecond delay // It will make Backward

MotorLeft=1; // Left Motor İleri
MotorRight=0; // Right Motor Backward
delay_ms(300); // 300 Ms delay, It will turn
}

int LastValue=5;

void main() {
InOut_define(); // Input Output Function Called
Stop(); // Motors are stopped
BUZZER=1; // Buzzer Beeps, 5V
LED=1; // Led Lights, 5V
delay_ms(200); // 200 ms delay , While Led and Buzzer Active
BUZZER=0; // Buzzer stopped, Led still lights.

while (BUTTON==0) { // While Button is not pressed (When it is pressed it gives 5V, logic 1)
Stop(); // Motors are stopped
}

Beep5sec(); // Buzzer beep function for 5 second. If your competition allows direct matches by remote start. Just add double slash (//) to that line.

//Main Code for sensor control
while(1) // Firmware stucks inside that while section.
{

if (Dip1==0){ // If dipswitch 1 Choosed // Turn to Left Till Sensors Detect Opponent
while (FrontObject==1 && LeftObject==1 && RightObject==1){ // While Object/Opponent Sensors Not Seeing Anything
Pwm1_Set_Duty(100);
LeftTurn();
} }
else if (Dip2==0){ // If dipswitch 2 Choosed // Left Turn 60 Ms And Forward
Pwm1_Set_Duty(100);
LeftTurn();
delay_ms(60);
Forward();
}
else if (Dip3==0){ // If dipswitch 3 Choosed // Right Turn 60 Ms And Forward
Pwm1_Set_Duty(100);
RightTurn();
delay_ms(60);
Forward();
}
else if (Dip4==0){ // If dipswitch 4 Choosed // Turn to Right Till Sensors Detect Opponent
while (FrontObject==1 && LeftObject==1 && RightObject==1){ // While Object/Opponent Sensors Not Seeing Anything
Pwm1_Set_Duty(100);
RightTurn();

} }

while (1){

LED=0;
// Line Sensor Control
if(LeftLine==0 && RightLine==1) { LeftEdge();} else // If Left Edge Sensor Detects White Line
if(LeftLine==1 && RightLine==0) { RightEdge();} else // If Right Edge Sensor Detects White Line
if(LeftLine==0 && RightLine==0) { DoubleEdge();} // If Both Edge Sensor Detect White Line
// Opponent Sensor Control
if(FrontObject==0) { Forward(); LastValue=5;} else // If Front Sensor Detects Opponent Go Forward, LastValue Variable is 5 (Dummy Value)
if(LeftObject==0 && RightObject==1) { LeftTurn(); LastValue=7; } else // If Left Sensor Detects Opponent Go Forward, LastValue Variable is 7
if(RightObject==0 && LeftObject==1) { RightTurn(); LastValue=3; } else // If Right Sensor Detects Opponent Go Forward, LastValue Variable is 3

// If that sensor values not detected, It will look to LastValue for remembering what robot made last thing.
{if (LastValue==5) {Forward2();} else // If last Value is 5, Call Forward function
if (LastValue==7) {LeftTurn();} else // If last Value is 7, Call Left function
if (LastValue==3) {RightTurn();} } // If last Value is 3, Call Right function
Pwm1_Set_Duty(120); // Speed is 120 / 255
if (BUTTON==1) {BUZZER=1; Stop(); SensorTest();} // If button pressed while robot is working it will call SensorTest block
//At Sensor Test Block, you can diagnose mini sumo robot’s sensors.
// That if button==1 statement must be commented if start module used.
}

}
}

That code is machine language of our flowchart. It is very basic but enough for lots of designs. I suggest you to, print the code and work on that 🙂 For assembling at mikroC you need to make a new project file, choose Pic16F628A and you need to choose that fuse configurations below. These are good settings for Easyboard.

Fuse Settings:

  • Clock Frequency: 4Mhz
  • Oscillator: Internal Oscillator (I/O Function – We are using that pins)
  • Watchdog Timer: Disabled
  • MCLR Feature: Disabled
  • Brown-out Detect: Disabled
  • Low Voltage Programming: Disabled

Nearly we disable all features which are not used at mini sumo robot programs. For compiling you need to click Build button or push the ctrl+F9.


Burning the Code to Mcu

Normally each Easyboard that we sent, is programmed before. But ig you want to program the microcontroller you need to use special hardware and software. For this purposes, we are using and selling Brenner type pic programmers.

It directly uploads the compiled C file (MikroC outputs hex file and that hex file is uploaded).  For programming we are using Usburn program. You can download program here:

http://www.sprut.de/electronic/soft/usburn/usburn.htm#download


5. Further Developments 

Tuning the Code

For instance, you made differently designed robot and used Easyboard. Each Easyboard comes with preprogrammed microcontroller (We are using Pic16F628A)  For more reliable control you should change delay times. That values inside delay_ms function determine how much robot will turn.

Setting the Speed

You can change robot’s speed by changing PWM values. Unfortunately at 16F628A Mcu we have one PWM channel (connected to portb.3), and we apply speed control to both left and right channels together. By changing that value, you can control motors speed same time.

Sensor Diagnostics Routine?

Maybe you see at flowchart, if we push the button while a robot is working (at main function) robot calls sensor test routine. Sometimes problems can occur. That function very helpful for controlling robot’s sensors about working or not. I added different frequency tone for each sensor with that different frequencies we can determine which sensor works which is not.

This routine is called when the button is pressed. And if you are using start module, robot will think as button is pressed always (Push button is giving non-permanent signal, but start module is giving Logic 1, 5V continuously) So, if you think about using start modules you need to add double slash // to beginning of if button==1 statement or delete that line.

Do you want to look to Easyboard Page?
Cheapest, most functional for mini sumo robots.
Visit now

Other Robot Parts For your MiniSumo Robot

We make robot business for all robotics enthusiasts in the world. And we have good priced parts for you! 🙂

[products columns=”4″ orderby=”title” order=”” ids=”3340, 1913, 1999, 2055″]

Users who found this page were searching for:

  • minisumo code
  • circuit robot sumo
  • mini millimeter comment code
  • robot mini sumo arduino code
  • mini sumo code
  • project to make robot to walk only on white line
  • Mini sumobot
  • how do you make a mini sumo robot
  • How to make mini robot that understand
  • arduino mini sumo code
  • sumo bot program code
  • arduino sumo robot code
  • how to make a my first mini robot
  • pic code not equal 5 second project mikroC
  • sumo robot using pic microcontroller
  • sumo robot code
  • how to program a sumo robot
  • Maker Projects/Mini Sumo Robot code
  • jsumo robots program
  • sumo arduino code

Share this post

Comments (8)

  • Eric Reply

    Lately I have been very tempted to get my first mini sumo robot or to get the pieces separately and assemble it myself (although this will be more difficult and I may leave this for later on when I know what I am doing).

    One of my friends already has 2 mini robots and he is thinking of getting a new one and I might join him. He goes to contests all the time and he seems to be loving this and his enthusiasm is rubbing off on me :). I will probably just show him this site and this page and ask for his help. Thanks!

    September 14, 2015 at 7:23 PM
  • Oscar Reply

    Thanks for this very detailed article on how to make a mini sumo robot with the Easyboard including the code! For someone like me who is a beginner at robotics, I am pleased with how easy to use this control board is.

    September 15, 2015 at 2:48 AM
    • Firat Dede Reply

      Thanks! We designed for everybody, not for only special technical people:)

      February 9, 2016 at 11:09 AM
  • Joseph Dunn Reply

    Great tutorial on creating a mini sumo robot using easyboard. I love the 4th point where you wrote all the necessary code for the sumo robot. It can be the base for our project and we can build a lot more things on it. Thanks 🙂

    September 15, 2015 at 3:16 PM
  • Gaye Morrison Reply

    Thanks for epic article, good information for mini sumo robots.

    September 16, 2015 at 7:10 PM
  • Gaye Morrison Reply

    Thanks for this very helpful article on creating a mini sumo robot using easyboard. wish I could do something so great like these!!!

    September 16, 2015 at 7:16 PM
  • How to Make a Sumo Robot Reply

    […] languages are very similar and easy to understand. In our mini sumo making page you can find lots of information about programming and MikroC (Also we are giving sample program […]

    February 22, 2016 at 2:47 PM
  • Hou Reply

    How i will get the program ito EasyBoard??

    May 17, 2016 at 7:16 PM

Leave a Reply

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