Discussion in "Project Doubts" started by    liverpool_fan    Dec 29, 2010.
Thu Jan 06 2011, 04:41 pm
#21
Hey guys...the code below is for a line following robot...but there are 8051 resgiter and 8051io included in the code..does anyone have these register codes
that i could use plz?

#include d:\mc51\8051io.h
#include d:\mc51\8051reg.h
extern register unsigned char speedleft,speedright;
register unsigned char high,low,flag,time;

main()
{
P1=0x40;
P3=0xff;
high = 80;
low = 30;
flag = 0;
time = 50;
Start();
while(1) {
P3|= 0x0f;
Run();
}
}

Start()
{
char exit,key;
exit =1;
while(exit)
{
key = P1;
if((key & 0x40)==0) exit=0;
}
}

Run()
{
char sensors;
sensors = (P3 &=0x0f);

if((sensors & 0x01)==0) {
TurnRight();
flag = 1; }

else if((sensors & 0x08)==0) {
TurnLeft();
flag = 2; }
else if(sensors == 0x09) {
Forward(high);
flag = 0; }

else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0))
Forward(low);

}

Forward(char speed)
{
P1=0x64;
speedright = speed+10;
speedleft = speed;
delay(time);
}

TurnRight()
{
P1=0x68;
speedright = low+5;
speedleft = low;
delay(time);
}

TurnLeft()
{
P1=0x54;
speedright = low+5;
speedleft = low;
delay(time);
}

Reverse(char speed)
{
P1=0x58;
speedright = speed;
speedleft = speed+5;
delay(time);
}
Thu Jan 06 2011, 07:45 pm
#22
which compiler are you using?

if its keil simply remove those include files and add

#include <reg51.h>
 liverpool_fan like this.
Thu Jan 06 2011, 08:33 pm
#23
im using keil,ajay...so it is not necesary to include those header files izit?will the code work without the header files?
Thu Jan 06 2011, 11:25 pm
#24
hi liverpool_fan
that code is not written in keil i think that is written in SDCC
so dfor using keil u has to edit the code as it is for line following robot
code should work
just edit these lines


#include d:\mc51\8051io.h
#include d:\mc51\8051reg.h
extern register unsigned char speedleft,speedright;
register unsigned char high,low,flag,time;


write it as
#include <reg51.h>
unsigned char speedleft,speedright;
unsigned char high,low,flag,time;


[ Edited Thu Jan 06 2011, 11:27 pm ]
 liverpool_fan like this.
Fri Jan 07 2011, 12:54 am
#25
hey majoka..so i still need to include a file named reg51.h rite?i mean to define the ports and interupt of the 8051?
Fri Jan 07 2011, 10:51 am
#26
it is the heart of 8051
without
#include compiler not know what is P0,1,2 and 3 and do not know about sfr's
Fri Jan 07 2011, 10:57 am
#27
alrite thankz majoka...neway..i contructed the sensor circuit using the Ir led and receiver but when i put an obstacle near it....the normal led is still not off..izit supposed to off?
Fri Jan 07 2011, 11:16 am
#28
hi liverpool_fan
ru use photo transistor
i use photo transistor with white color led
with photo transistor i use 1MOhm resistor for significant change in voltage
as in original circuit 10kohm is use it depend on which sensor ur using
but this resistance has significance importance
i connect collector to 5 volt and emitter to ground through h1Mohm resistance
try this configuration and update about ur results
connect the multimeter to emitter and other end to ground and check voltage across 1 Mohm resistance
check voltage to place photo transistor in light and without light and check its behaviour
Fri Jan 07 2011, 11:45 am
#29
hie majoka...cn i noe what type of photo transistor u used?if im nt mistaken it has 2 legs only rite?i used the npn photo transistor..its white in color..izit the same as urs?
Fri Jan 07 2011, 12:27 pm
#30
hi liverpool_fan
i use three pin photo transistor
two r used third r for base that is not used in circuit can u upload a pic of photo transistor that ur using
i use like this

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

DJGlido
Wed May 08 2024, 09:28 pm
migCar
Wed May 08 2024, 04:48 pm
TimmyJup
Wed May 08 2024, 12:22 am
Shawnarows
Tue May 07 2024, 10:16 pm
GlennVet
Tue May 07 2024, 04:46 pm
RonaldJoump
Tue May 07 2024, 10:15 am
Jasonkam
Mon May 06 2024, 10:00 pm
JamesroW
Mon May 06 2024, 09:37 am