Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 20th January 2008, 06:18 PM   (permalink)
Default Line Follower PIC16F877A

Hey everyone just wanna seek some help, im building a line follower robot using a pic16f877a but my problem is that my hardware doesn't go with the program i make in PIC-LITE using C. I already simulated the program thou Proteus everything works fine but when im load it my PIC then put it to my system my servo motors does not act the way the simulation do. But when im using a PIC16F84 everything works the same as the simulated version.
Klitzie is offline  
Old 20th January 2008, 08:01 PM   (permalink)
Default

I would suggest you aren't configuring the code correctly for the 877?, are you disabling the analogue inputs?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 20th January 2008, 08:24 PM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
I would suggest you aren't configuring the code correctly for the 877?, are you disabling the analogue inputs?.
That's exactly what I thought.
Klitzie, your program might run on the simulator even if you did not care of configuring the analog modules of the PIC, but when you test it with real hardware, you might get unexpected results.
Give some details about your circuit and your program. Are you experiencing problems with PORTA or PORTE? You said that the same program runs ok with a PIC16F84, that doesn't have analog features. This again suggests a possible problem with the configuration of the 16F877A.
eng1 is offline  
Old 21st January 2008, 05:06 PM   (permalink)
Default

I just initialized ADCON1=7 set all inputs to digital. I will post here our program just try to scan if for probable errors in initializing our port's. This is our config PORTA=Ra0,Ra1,Ra2 are for sensors, PORTB=Rb0,Rb1,Rb2,Rb2 are for Left and Right Servo Motor we are using L2983D for the motor driver by the way:
/*Here is the source code*/
#include<pic.h>

/* BLACK LINE = 1 */
/* WHITE SURFACE = 0*/

#define FORWARD 0x09
#define RIGHT 0x08
#define LEFT 0x01
#define L_SENSOR 0x01
#define C_SENSOR 0x02
#define R_SENSOR 0x04
#define Off 0x00

void mydelay(int x);
void turnLEFT();
void turnRIGHT();
void forward();
void stop();
void main()
{

__CONFIG(0x3D39);
ADCON1= 7;
TRISA = 0x1F;
TRISB = 0x00;
PORTB = Off;

while(1)
{
if((PORTA&L_SENSOR)==L_SENSOR)
{
turnLEFT();
}
else if((PORTA&R_SENSOR)==R_SENSOR)
{
turnRIGHT();
}
else if((PORTA&C_SENSOR)==C_SENSOR)
{
forward();
}
else
{
stop();
}
}

}

void stop()
{
PORTB = Off;
}
void turnLEFT()
{
PORTB = LEFT;
}

void forward()
{
PORTB = FORWARD;
}

void turnRIGHT()
{
PORTB = RIGHT;
}
void mydelay(int x)
{
int y,z;
y=5000;
z=5000;

while(x)
{
while(y)
{
while(z)
{
z--;
}
y--;
}
x--;
}

}
/************************************************** */
Klitzie is offline  
Old 21st January 2008, 06:08 PM   (permalink)
Default

Hi,
What are the configuration bits?
__________________
Superman returns..
bananasiong is online now  
Old 21st January 2008, 06:12 PM   (permalink)
Default

Quote:
Originally Posted by bananasiong
Hi,
What are the configuration bits?
They're set with the __CONFIG() function, they're OK.
And the problem is not with the ADCON1 register like I had supposed.

Last edited by eng1; 21st January 2008 at 06:17 PM.
eng1 is offline  
Old 21st January 2008, 06:17 PM   (permalink)
Default

Oops I didn't notice
__________________
Superman returns..
bananasiong is online now  
Old 22nd January 2008, 10:02 PM   (permalink)
Default

you might also be able to read the configuration bits if you load the hex to MPLAB.
__________________
F.N.
Funny NYPD is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Line Follower Design Challenging Problems Michael Chua Robotics Chat 1 2nd March 2007 07:41 AM
line follower whit atmega8 Igor Moreira Robotics Chat 23 1st November 2006 01:34 PM
line follower help owika Micro Controllers 18 14th April 2005 04:48 PM
Help with a line follower! nestor Robotics Chat 2 5th October 2004 06:06 PM



All times are GMT. The time now is 01:59 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker