First step: CREATING THE SUMOBOT BUMPER
(Front View)
3D View |
Bottom View
Side View
Pictures which are shown above are my dimensions for the bumper design for pushing other sumobot out from the battle arena.
Second Step: CIRCUIT DESIGN
SUMOBOT CIRCUIT DESIGN
The image shown above is my personal circuit design. I utilized a PIC16F877A microcontroller. There were 4 CNY70 sensors that were implemented. 3 sensors for sensing the opponent and the other sensor for sensing the arena track in order for my sumobot to avoid in getting out of the arena.
Program code:
#include <pic.h>
#include "delay.h"
__CONFIG(HS & WDTDIS & PWRTDIS & UNPROTECT & LVPDIS);
#define LeftCol RB0
#define BackCol RB1
#define RightCol RB2
#define FrontLine RB3
#define Forward 0x05
#define Left 0x06
#define Right 0x09
#define Backward 0x0A
#define Stop 0x00
#define Full 0b11111001
#define Reduce 0b11000111
void PWMInit(void);
void main()
{
TRISB=0xFF;
TRISA=0x00;
PORTB=0x00;
ADCON1=0x06;
PWMInit();
capture_init();
TRISC=0x00;
RC1=1;
while(1)
{
if(FrontLine==1)
{
if(LeftCol==1)
{
PORTA=Left;CCPR2L=Full;
}
else if(RightCol==1)
{
PORTA=Right;CCPR2L=Full;
}
else if(BackCol==1)
{
PORTA=Backward;CCPR2L=Full;
}
else if(LeftCol==0 && RightCol==0 && BackCol==0)
{
PORTA=Forward;CCPR2L=Full;
}
}
else if(FrontLine==0)
{
PORTA=Backward;
DelayMs(250);
DelayMs(250);
PORTA=Stop;
DelayMs(250);
PORTA=Right;
DelayMs(250);
DelayMs(250);
DelayMs(250);
PORTA=Stop;
DelayMs(250);
PORTA=Forward;
DelayMs(250);
DelayMs(250);
}
}
}
//Initialize CCP1 & CCP2 for PWM Operation
void PWMInit(void)
{
TMR2 = 0x00; //Clear TMR2 & CPP related registers
T2CON = 0x00;
CCP2CON = 0x00;
PR2 = 249; //Set PWM freq = 5Khz
CCPR2L = Full; //Set PWM2 Duty Cycle
TRISC2 =0; //Enable PWM1 output pin
TRISC1 = 0; //Enable PWM2 output pin
T2CKPS1 = 0; //Prescaler = 4
T2CKPS0 = 1;
CCP1CON-0x0C; //CCP1 in PWM mode
CCP2CON = 0x0C; //CCP2 in PWM mode
TMR2ON = 1; //Enable TMR2. PWM signal is generated.
return;
}
Third Step: TESTING & TROUBLESHOOTING
Well, as an electronics engineering student, one of the most challenging and fun thing to do is testing the unit and troubleshooting if there may seem to be no full functionality of the unit. Troubleshooting enhances one's skill in order to accomplish the desired goal. It may seem tiring but the accomplishment is worth striving for. So never give up if you may have messed up in creating you sumobot or if the result may not be fully functional, because as an ECE, we should be patient and persistent in troubleshooting things. =)
HERE ARE SOME IMAGES OF MY SUMOBOT:
Here is the sample vid
THE RESULT?
I won with my SUMOBOT for the Championship!.. =)
¿que compilador para lenguaje c usaste?
ReplyDelete