i need help to program the pic16f877a....

Thread Starter

hosalya

Joined Oct 26, 2010
8
im doing my project using pic16f877a mobile library robot which need to scan and take the book from the book shelf...Im already programmed the line track...but nw the problem is i need to program the arm for the robot....
plz any one who can help me to do this program...bcz im tried my level best to do the program for arm bt its nt working....

the things tat need to be consider is the pic should on the web cam to start the book rack after scanning the book rack then the robot will process the image whther the book code insert by the user was been place in that particular book shelf or not.If yes the webcam send a signal to pic to turn the side of the book rack and the pic will send a signal to webcam to start its scanning process from the beginning of the rack till the end of the rack(in each level of the book shelf).If the book is detected the webcam will send a signal to the pic to start its work to give instruction to the arm of the robot the take out the particular book from the book shelf.After that the robot will back to the starting place.



im using line track for the navigation of the robot using 4- infrared sensor (left move, right move,forward and backward).

for the arm part im using power window motor to lift the arm of the robot up and down (according to the book shelf level =5) .for this up and down mechanism im required to use proximate sensor to detect whether the arm is in which level.the proximate sensor is placed in body of the robot and the level of the book shelf.If the proximate sensor placed in body of the robot equal to the level of the book shelf the arm will stopped from moved . if the book nt placed in that level the arm will move up/down.


after detecting the book where its placed in the book shelf the hook type arm which attached with the switch type sensor will move towards the book to pick up the book from the book shelf. After that the robot return to the starting place.



this is the program that need to create....bt im facing alot of problem to do it...plz help me .....i need it very urgent...because need to submit the coding report by this 3 nov 2010....plz help me i dnt have any other choice except asking for help....
 

retched

Joined Dec 5, 2009
5,207
You will need reference points for the arm-cam to recognize when the bottom and top and leftmost rightmost ends of the shelf.

If you have a row of same colored encyclopedias, hoy is the bot to distinguish each book from the next?

A hook to grab the top of the book to tilt it out would help give the "pinchers" something to grab. You WILL also need a place holder to keep other books from falling into the space that the picked book was taking up. Else you will have a problem "returning" the book.


I understand your urge to use a PIC, but a $47(at quantity) credit-card-sized computer would make this a ell-of-a lot easier if space is an issue. Wi-fi ready to talk to the wireless network installed at the library. Great for realtime locating and other on-the-fly updates.

You can use linux or windows and harddrives to store the voluminous amount of info like images of the book spines for recognition and other complexities

http://gizmodo.com/184234/credit-card+sized-pc
 

Thread Starter

hosalya

Joined Oct 26, 2010
8
the pic function when the webcam send signal to him....


this the coding for line track tat i ve created
but i dnt know how to do programming for the arm part
somemore i dnt f any circuit diagram for this project bcz i dnt know the arm part
if line track i gt using 4 IR sensor n encoder...n using dc motor...
somemore i dnt know whether tis coding can work or nt..try in proteus can bt in reality i dnt know
plz help me the coding part for line track combine the arm part for the robot..
plz im really need it..thanks anyway for the guide...

Rich (BB code):
#include <pic.h>
__CONFIG ( 0x3F32 );
#define MHZ *1000L 
#define KHZ *1 
#define DelayUs(x) 
 
//int x; 
//unsigned char _dcnt; 
//__dcnt = (((x)*(20MHZ))/ (24MHZ)) |1; 
//while(--__dcnt != 0) 
//continue
//__dcnt = (((x)* (20MHZ))
//while(--__dcnt != 0) 
//continue
 
#define arm RC3
#define IR_1 RD0 
#define IR_2 RD2 
#define IR_3 RD3 
#define IR_4 RD1 
#define DC_nleft RB0
#define DC_pleft RB1
#define Speed_l CCPR1L
#define DC_nright RB5
#define DC_pright RB4
#define Speed_r CCPR2L
int b=0;
unsigned int cnt=0;
void initialize(void);
void forward(void); 
void stop(void);
void left(void);
void right(void);
void reverse(void);
void line_follow(void); 
void DelayMs(unsigned char y);
void delay(unsigned long data);
void loading(void);
void unloading(void);
void turun (void);
void interrupt isr(void)
{
if(TMR0IF==1)
{
TMR0IE=0;
TMR0=61;
int j;
for(j=1; j<=5 ;j++);
cnt=j;
if(cnt==1)
{
arm=1;
DelayUs(250);
DelayUs(250);
DelayUs(250);
DelayUs(250);
DelayUs(250);
DelayUs(250);
arm=0;
DelayMs(18);
DelayUs(250);
DelayUs(250);
}
if(cnt==2)
{
arm=1;
DelayMs(250);
DelayMs(250);
DelayMs(250);
arm=0;
DelayMs(19);
DelayUs(250);
}
if(cnt==3)
{
arm=1;
DelayMs(250);
DelayMs(250);
DelayMs(250);
arm=0;
DelayMs(20);
DelayUs(250);
}
if(cnt==4)
{
arm=1;
DelayMs(250);
DelayMs(250);
DelayMs(250);
arm=0;
DelayMs(21);
DelayUs(250);
}
if(cnt==5)
{
arm=1;
DelayMs(250);
DelayMs(250);
DelayMs(250);
arm=0;
DelayMs(22);
DelayUs(250);
}
TMR0IE=1;
TMR0IF=0;
}
}
void main(void)
{
initialize();
line_follow();
}
void initialize()
{
TRISB=0b00000000;
TRISC=0b11000000;
TRISD=0b00001111;
TRISE=0b00000111;
PORTA=0; PORTB=0; PORTC=0; PORTD=0; PORTE=0;
PR2=255;
T2CON=0b00000100;
CCP1CON=0b00001100;
CCP2CON=0b00001100;
TMR0 = 61;
OPTION = 0b10000111;
INTCON = 0b11000000;
}
void line_follow()
{
int b=0;
while(1)
{
if((IR_1==0)&&(IR_2==0)&&(IR_3==0)&&(IR_4==0))
{
if(b==1)
{
turun();
}
else
{
forward();
}
}
if((IR_1==0)&&(IR_2==0)&&(IR_3==0)&&(IR_4==1))
{
reverse();
}
if((IR_1==0)&&(IR_2==1)&&(IR_3==0)&&(IR_4==0))
{
forward();
}
if((IR_1==0)&&(IR_2==1)&&(IR_3==0)&&(IR_4==1))
{
forward();
}
if((IR_1==1)&&(IR_2==0)&&(IR_3==0)&&(IR_4==0))
{
left();
}
if((IR_1==0)&&(IR_2==0)&&(IR_3==1)&&(IR_4==0))
{
right();
}
if((IR_1==0)&&(IR_2==1)&&(IR_3==1)&&(IR_4==0))
{
stop();
}
if((IR_1==0)&&(IR_2==1)&&(IR_3==1)&&(IR_4==1))
{
stop();
}
if((IR_1==1)&&(IR_2==1)&&(IR_3==0)&&(IR_4==0))
{
forward();
while(IR_3!=1)
{
left();
}
forward();
}
if((IR_1==0)&&(IR_2==1)&&(IR_3==1)&&(IR_4==0))
{
forward();
while(IR_1!=1)
{
right();
}
forward();
}
if((IR_1==1)&&(IR_2==1)&&(IR_3==1)&&(IR_4==1))
//object detection
{
if(b==0)
{
forward();
delay(100000);
stop();
loading();
forward();
b++;
}
else
{
stop();
}
}
}
}
void forward()
{
DC_pright=1;
DC_nright=0;
DC_pleft=0;
DC_nleft=1;
Speed_l=255;
Speed_r=255;
}
void right()
{
DC_pright=1;
DC_nright=0;
DC_pleft=0;
DC_nleft=1;
Speed_l=255;
Speed_r=200;
}
void left()
{
DC_pright=1;
DC_nright=0;
DC_pleft=0;
DC_nleft=1;
Speed_l=200;
Speed_r=255;
}
void stop()
{
DC_pright=1;
DC_nright=0;
DC_pleft=0;
DC_nleft=1;
Speed_l=0;
Speed_r=0;
}
void reverse()
{
DC_pright=0;
DC_nright=1;
DC_pleft=1;
DC_nleft=0;
Speed_l=255;
Speed_r=255;
}
void DelayMs(unsigned char y)
{
unsigned char i;
do {
i = 4;
do {
DelayUs(250);
} while(--i);
} while(--y);
}
void delay(unsigned long data)
{
for( ;data>0;data-=1); 
}
void loading()
{
cnt=1;
TMR0IE=1;
}
void unloading()
{
cnt=2;
TMR0IE=1;
}
void turun()
{
{
stop();
unloading();
reverse();
delay(300000);
right();
delay(300000);
stop();
}
}
 
Last edited by a moderator:

Thread Starter

hosalya

Joined Oct 26, 2010
8
Post your schematics and code you already have. A photo of the robot might be helpful.

PIC and webcam. How did you connect them?
hi can help me to program pic16f877a for movements of motor power window up and down from level 1 until level 4 using proximity sensor as input to make sure the motor stop at each level like elavator function
 
Top