![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| I would suggest you aren't configuring the code correctly for the 877?, are you disabling the analogue inputs?. | |
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) |
| 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--; } } /************************************************** */ | |
| |
| | (permalink) |
| Hi, What are the configuration bits?
__________________ Superman returns.. | |
| |
| | (permalink) | |
| Quote:
And the problem is not with the ADCON1 register like I had supposed. Last edited by eng1; 21st January 2008 at 06:17 PM. | ||
| |
| | (permalink) |
| Oops I didn't notice
__________________ Superman returns.. | |
| |
| | (permalink) |
| you might also be able to read the configuration bits if you load the hex to MPLAB.
__________________ F.N. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| 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 |