Author Topic: somebody help me!!!!!!!!!!!  (Read 1678 times)

0 Members and 1 Guest are viewing this topic.

Offline kim3sarmyTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
somebody help me!!!!!!!!!!!
« on: April 11, 2010, 06:07:07 PM »
someone plez help me to solve my coding..
i'm working on line follower robot using pic 16f877a,relay mtr driver,12V DC motor...
i use port b = RB1 to RB3 for 3 set of IR sensor
       port c = RC1 & RC2 for PWM
       port a = RA to RA4

somebody plez check my coding

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: somebody help me!!!!!!!!!!!
« Reply #1 on: April 11, 2010, 08:40:49 PM »
What kind of errors are you getting?  What exactly isn't working?

Having a full program and having nothing to look for really makes people NOT want to look through the program.  However, if we know what's wrong, then we can specifically look for things that could be wrong.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: somebody help me!!!!!!!!!!!
« Reply #2 on: April 11, 2010, 09:12:08 PM »
What is your code doing wrong or not doing?

Please add comments to every line so we know what you think the line of code should do.

Quote
i use port b = RB1 to RB3 for 3 set of IR sensor
       port c = RC1 & RC2 for PWM
       port a = RA to RA4
Put this info in the code as comments with info on what each port is used for.

I assume that RB1-3 are inputs so why are you testing all those ports?
Code: [Select]
if (RB2==0)if(RB3==1)if(RB4==1)if(RB5==1)if (RC3==1)if(RC4==1)
What are the other ports for? State what these inputs are and what combination is required for the action.

What are the config bits set for? See the HiTech manual (look at the file pic1687x.h in the HiTech install directory)  and the Special Features section of the PIC data sheet.
You can also set these in the code or from MPLAB menu Configure\Configuration Bits.

Does the code compile?????
It did not for me as there is an extra '}' and code line.

Did you run this code in the MPLAB simulator????
I do 98% of debugging in the simulator.

Offline kim3sarmyTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: somebody help me!!!!!!!!!!!
« Reply #3 on: April 12, 2010, 01:19:42 AM »
port b are used for input from sensor array...the problem is i can't compile this code using mplab

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: somebody help me!!!!!!!!!!!
« Reply #4 on: April 12, 2010, 08:38:39 AM »
Quote
the problem is i can't compile this code using mplab
Yes I stated that and gave told you why.
You have mismatched curly braces, a } without a { and a return 0; that should not be there.

Fix those and the code will build.

Hint: In the MPLAB editor, if you place the cursor in front of a } the matching { will be also  highlighted. If a { or } does not highlight than there isn't a matching { or }.

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: somebody help me!!!!!!!!!!!
« Reply #5 on: April 12, 2010, 08:43:42 AM »
I hate when I get my curly brackets get messed up.  You always get a TON of errors because you forgot one simple character.   :P

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: somebody help me!!!!!!!!!!!
« Reply #6 on: April 13, 2010, 05:25:08 PM »
Hi,

A simple way of keeping your brackets sorted is to simply allways place them in pairs
Eg.
SomeFunction(void)
{}

Then you separate the curls (and if like me, indent them).
SomeFunction(void)
   {
   }

Then you're ready to write the contents
SomeFunction(void)
   {
      // Programming in C is allways ugly...
      // But there's no reason to trip ones own feet
      C + Programming != Beauty
   }

Now you'll never have missing or leftover brackets (unless you cut and paste too rigorously).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives