Race To The Wall

On the 22nd of October every team that was a part  of the RoboSumo design project had to participate or attempt to participate in race to the wall. This required the robot to drive forward hit a wall reverse and then stop on a white line, breaking a beam of light that determined the time for the run.

The Code

During the preparation my team and I ran into a few problems. Coding which was up to myself  seemed to be going OK with a few snag here and there. I was at first using the set motors function that was supplied to us at the start of the RoboSlam project, but after a few bugs and myself and Gareth getting horribly confused we eventually reverted to doing everything out in there respective pins and in stages. This made things a little clearer at the time for Emma to help us and get everything working. In the end the issue we had was that our pull down resistor was after which means that the output was not how we had previously thought.

// Race to the wall //Writen by Ciaran O'Connor //Last modified:22/10/2014 #include //void GoForwards(void); // main function int main( void ) { // stop watchdog timer to prevent timeout reset WDTCTL = WDTPW + WDTHOLD; // configure digital inputs and outputs P1DIR = 0b00000001; P2DIR = 0b00011011; // set P2.0 P2.1 P2.3 P2.4 as outputs // P1IN & 0b00000110; // set P1.1-2 into a variable __delay_cycles(2000000); // starting delay of 2 seconds while(1) { if ((P1IN & 0b00100000)>0) // if detection wall by touching { do { P2OUT = 0b00010010; // go backward P1OUT &= 0b11111110; // LED OFF } while((P1IN & 0b01000000) >0); // while black line NOT detected } else if (((P1IN & 0b01000000)==0 )&& ((P2OUT & 0b00000010) >0)) // if Black line detected and robot going backward { P2OUT = 0; // stop motor on the line __delay_cycles(8000000); // for 8 seconds P2OUT = 0b00010010; // go backward __delay_cycles(1000000); // for 1 second } else if(( (P1IN & 0b00100000)==0 )&& ((P1IN & 0b01000000)>0)) { P2OUT = 0b00001001; // go forwards( until wall detection ) P1OUT |= 0b00000001; // LED ON } } return 0; }  

The Build

The main structure for our robot was everybody’s collaboration but Gareth was in charge of design. He had the main base for the robot built out of a piece of plastic and some wood on which the motors where attached, the rest of the robot was then crudely taped on in no particular fashion as we were  bit stuck for time after hours of dissembling and reassembling. We have some really good ideas for our main design but I fear to put them up too soon, as I have heard rumours of infidéls  searching through opponents Blogs to source intel.

The Circuit

The circuit was kept very basics as not to cause confusion. It consists of a basic switch and IR sensor that are across around 3.3 volts. Then the regular motor setup.

Featured image

Leave a comment