control robot using other program

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

Re: control robot using other program

Postby zamlak » Fri Mar 05, 2010 11:01 am

The new code

CODE: SELECT_ALL_CODE
void wireless_xbee (void)      
{   lcd_clr();                                                // clear the lcd
   while(1)                                                // looping forever
   {
      lcd_goto (0);
      
                                 
      if (data[0] == 100)                                       // check if UART start byte is met
      {
         send_string("  XBEE CONTROL  ");                        // display string
         SPEEDL = 200;                                       // set the motor speed
         SPEEDR = 200;
         while(1)
         {
            lcd_goto(20);
            
            if (RCREG == '8')                                    // if character '8' is detected, the robot move forward
            {
               forward();
               send_string("FORWARD        ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='F';
               while(TXIF==0);
               TXREG='O';   
               while(TXIF==0);
               TXREG='R';
               while(TXIF==0);
               TXREG='W';
               while(TXIF==0);
               TXREG='A';
               while(TXIF==0);
               TXREG='R';   
               while(TXIF==0);
               TXREG='D';     
            
            }

            else if (RCREG == '2')                                 // if character '2' is detected, the robot move backward
            {
               backward();
               send_string("BACKWARD        ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='B';
               while(TXIF==0);
               TXREG='A';   
               while(TXIF==0);
               TXREG='C';
               while(TXIF==0);
               TXREG='K';
               while(TXIF==0);
               TXREG='W';
               while(TXIF==0);
               TXREG='A';   
               while(TXIF==0);
               TXREG='R';   
               while(TXIF==0);
               TXREG='D';   
            }
            else if (RCREG == '6')                                 // if character '6' is detected, the robot turn right
            {
               right();
               send_string("TURN RIGHT      ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='R';
               while(TXIF==0);
               TXREG='I';   
               while(TXIF==0);
               TXREG='G';
               while(TXIF==0);
               TXREG='H';
               while(TXIF==0);
               TXREG='T';
            }

            else if (RCREG == '4')                                 // if character '4' is detected, the robot turn left
            {
               left();
               send_string("TURN LEFT       ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='L';
               while(TXIF==0);
               TXREG='E';   
               while(TXIF==0);
               TXREG='F';
               while(TXIF==0);
               TXREG='T';
            }

            else if (RCREG == '5')                                  // if character '5' is detected, then stop the robot
            {
               stop();
               send_string("INVALID COMMAND  ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='S';
               while(TXIF==0);
               TXREG='T';   
               while(TXIF==0);
               TXREG='O';
               while(TXIF==0);
               TXREG='P';
            
            }

            else                                              // else then stop the robot
            {
               stop();
               send_string("INVALID COMMAND  ");
               while(TXIF==0);   //only send the new data after the previous data finish sent
               TXREG='I';
               while(TXIF==0);
               TXREG='N';   
               while(TXIF==0);
               TXREG='V';
               while(TXIF==0);
               TXREG='A';
               while(TXIF==0);
               TXREG='L';
               while(TXIF==0);
               TXREG='I';   
               while(TXIF==0);
               TXREG='D';   
            }
         }
      }
      else    send_string("COMMAND");
   }
}
}


The previous code for textReceived==RCREG does not gives any effect.May i know how to view (coding in pic) what the character that have been send to the robot.For example when we enter '8' at vb what form that the data been sent.data[0]=100 is detecting 'd' from vb to start controlling the robot using keyboard.Please help me.Thank you.
zamlak
Newbie
 
Posts: 9
Joined: Mon Feb 22, 2010 11:11 pm

Re: control robot using other program

Postby tkleong1437 » Thu Jun 17, 2010 1:33 am

Try check does ur robot section receive extra character such as vbCr or vbCRLF from PC.
tkleong1437
Freshie
 
Posts: 7
Joined: Fri May 28, 2010 10:49 pm

Previous

Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 13 guests

cron