[HELP] PR23 Multifunction Mobile Robot

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

[HELP] PR23 Multifunction Mobile Robot

Postby NSH » Sun Oct 14, 2012 1:38 pm

Hi everyone,
I need some help regarding the changes of codes.

What am I going to change is the Ultrasonic part. The web given codes as follow:

Code: Select all
   while(1)                                                   
   {
      lcd_goto(20);                                             
      distance = us_value(n);                                       
      dis_num(distance);                                          


       if (distance> 40)                                          
      {
         forward();                                             
         SPEEDL = 255;
         SPEEDR = 255;
         buzzer = 0;
      }
      else if (distance> 30)                                       
      {
         forward();                                             
         SPEEDL = 230;
         SPEEDR = 230;
         buzzer = 0;
      }
      else if( distance >20)                                       
      {
         stop();                                                
         buzzer = 0;
      }


Now my problem is, I would like to change the range of the distance. When I change either one of it, there will show this to me:

********** Build failed! **********


So, what should I do nw?
Is it affected by the "us_value(n)"?
Sadly, I don't understand the formula given by "us_value(n)" as below :

Code: Select all
//====================================================================================================
unsigned int us_value (unsigned char mode)                                 
{
   unsigned int value;
   switch (mode)                                                   
   {
      case 1:   read_adc(CHANNEL0);
            value = result;   // max vslue 2.55v = 2.55/5 *1024 - 1 =  522, resolution = 10mV/ inch, 10m/5*1024 =~ 2
            break;
      case 2:   value = TH;   // each value = 256*4/20mhz = 51.2us, i inch = 147us 
            break;      // can change using smaller timer prescale, but resulation fixed 147us / inch
      case 3:   if ( data [0]=='R')   value = (data[1] - 0x30)*100+ (data[2] - 0x30)*10+ (data[3] - 0x30); // 1 = 1 inch
            else
            {   
               lcd_goto(20);               // if stater byte is not 'R', Display 'not connected'
               send_string("not connected");
               while(1);                  // loop forever
            }   
      default: ;
   }
   return value;
//====================================================================================================
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby NSH » Sun Oct 14, 2012 5:10 pm

Can anyone help me?
Thanks a lot :?
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby robosang » Sun Oct 14, 2012 9:04 pm

so sad that you don understand :o

What is the error message when you get build failed? Before you din change anything it build failed or after you modify?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby NSH » Sun Oct 14, 2012 11:36 pm

Hi robosang, thanks for your reply.

Everything is fine before I modify the codes.
But when I change the range of the Ultrasonic part, in the end it shows me"********** Build failed! **********"
I didn't change anything but just for the range of the Ultrasonic part.

So, what should I consider in order to modify the value of the range?
Thank you so much! :)
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby yonghui » Mon Oct 15, 2012 12:12 am

pls do find what is the error reported at the output.

the compiler will mention what is the error.
most probably will be syntax error.

post the error shown by the report and the portion code after u modified.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby robosang » Mon Oct 15, 2012 8:05 am

Printscreen the output window of MPLAB IDE, you keep saying build failed does not help. We need to know what is the error before can point it to you.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby NSH » Tue Oct 16, 2012 10:27 pm

coding error(Original).jpg
This is the Original Codes download from the page. There is nothing wrong (Successful) to compile.
The ranges of "40" ,"30" and "20" are given in the original codes.
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby NSH » Tue Oct 16, 2012 10:30 pm

coding error(Modified).jpg
And this is the modified code.
I just changed the range from 40,30,20 to 30,20,10.
And it gives me the output "********** Build failed! **********"
I am wondering why and what is the problem.
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby NSH » Tue Oct 16, 2012 10:31 pm

Thanks Robosang and Yonghui.
Hope that you could find out my problem.
Thank you :)
NSH
Newbie
 
Posts: 13
Joined: Fri Oct 12, 2012 9:15 pm

Re: [HELP] PR23 Multifunction Mobile Robot

Postby gadgetng » Wed Oct 17, 2012 10:15 am

NSH wrote:
coding error(Original).jpg


what did the error msg showing? The msg is block by the red circle.
You can double click on the error msg. Sometimes it will takes you to the line of the error source code.
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Next

Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 6 guests

cron