Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Keil compiler and 8051 in c (at89c51)

Status
Not open for further replies.

pratti

Member level 3
Member level 3
Joined
Jun 15, 2013
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
471
I HAVE GOT MANY ERROR WHILE COMPILING MY CODE IN 8051 IN C.PLZ GUIDE ME
int count;
count=0x00;
error:multiple declaration why?
 

For you to get error while compiling it means that your code is wrong. Can you post the rest of your code so that we can see or you tell us what you want to do let us help you with a code.
 

here my code for solar tracker radiation.
i want to make the counter to count the step so that the position of stepper motor can be know.the vaious clock function to rotate in different spped.plz help me to debug my code plz its urgent for me
#include<reg51.h>
#include<stdio.h> //port2 for load(stepper motor)::port3 for ldrs(sensors)::port 1 for solarpanel
#define high 1;
#define low 0;
sbit ldr1=P3^2; //initializing the bit of port 3
sbit ldr2=P3^3;
sbit ldr3=P3^4; //signals from sensor
sbit reset=P1^0;//reset

void T0Delay();
void T0Delay();
void clock(); // for clockwise rotation
void clock1();
void clock2();
void clockfast();
void clockfast1();
void clockfast2();
void anticlock();//for anticlockwise
void rest(); //for rest at east position

void main(void) //LDR : WHEN LIGHT FALLS ON IT,IT GIVES THE SIGNAL TO THE MICROCONTROLLER

{
unsigned int i,count,count1,stepper_motor;
P3=0xFF; //initialize as input
count=0x00; //count =0 in first
count1=0x00;
P2=0x00; //count1=0 in first


if((0<=count&&count<=60 )| (0<=count1&&count1<=15)) //while tracking the sun to determine the position of stepper motor or moving fast to search the light
{
stepper_motor=1;
}
if((61<=count&&count<=120) | (16<=count1&&count1<=45))
{
stepper_motor=2;
}
if((121<=count&&count<=180) | (46<=count1&&count1<=60))
{
stepper_motor=3;
}

while(1) //when port 3 gets any signal ie when it get ldr get light
if(ldr1==1 & ldr2==0 & ldr3==0) //when signal came from 1st ldr
{
if (stepper_motor==1) //when motor is in the east postion
{

clock(); //rotate clockwise in a full 180
}

else if(stepper_motor==2) //when motor is in the middle position and ldr1 gets light
{
clock1(); //rotate clockwie from middle so only half rotation is required
}

else
{
clock2(); //rotate clockwise from west for little time only
T0delay(); //wait in west for sometime
anticlock();//move back to east fo the next day
T0delay(); //wait their for some time
rest(); //rest
}
}

if(ldr1==0&ldr2==1&ldr3==0) //when light falls on 2nd ldr
{

if(stepper_motor==1)
{
clock();
}

else if(stepper_motor==2)
{
clock1();
}
else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}
if(ldr1==0&ldr2==0&ldr3==1) //when light falls on 3rd ldr
{
if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}

else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}
while(ldr1==0&ldr2==0&ldr3==1)
{
if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}

else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}
if(ldr1==1&ldr2==1&ldr3==0)//both ldr receives light
{

if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}
else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}
if(ldr1==1&ldr2==0&ldr3==1)
{
if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}
else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}
if(ldr1==0&ldr2==1&ldr3==1)
{
if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}
else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}

if(ldr1==1&ldr2==1&ldr3==1)

{
if(stepper_motor==1)
{
clock();
}
else if(stepper_motor==2)
{
clock1();
}
else
{
clock2();
T0delay();
anticlock();
T0delay();
rest();
}
}

while(0)//for no light search for the light by rotating left and right
if(ldr1==0&ldr2==0&ldr3==0)
{
rest();
T0delay();
for(i=1;i<4;i++) //for four times rotation continues
{
if(stepper_motor==1) //when stepper motor is in east position and no light falls

{
clockfast(); //rotate clockwise
}
else if(stepper_motor==2)
{
clockfast1(); //rotate half clockwise
}
else
{
clockfast2(); //rotate little clockwise
T0delay1(); //wait for smtine in west position
anticlock(); //rotate anticlockwise
clockfast(); //rotate clockwise
T0delay1(); //wait fir smtime
rest();
reset=1; //rest position

}
}
}



void clock()
{
for(unsigned int count=0;count<=180;count++)
{ //function for clockwise rotation
P2=0x11;
T0delay();
P2=0x22;
T0delay();
P2=0x44;
T0delay();
P2=0x88;
T0delay();
}
}
void anticlock() //function for clockwise
{
for(unsigned int count=180;count=0;count--)

{
P2=0x88;
T0delay();
P2=0x44;
T0delay();
P2=0x22;
T0delay();
P2=0x11;
T0delay();
}
}
void clock1(); //function for halg clockwise
{
for(unsigned int count=61;count<=120;count++)
{
P2=0x11;
T0delay();
P2=0x22;
T0delay();
P2=0x44;
T0delay();
P2=0x88;
T0delay();
}
}
void clock2(); //function for little clockwise
{
for(unsigned int count=61;count<=120;count++)
{
P2=0x11;
T0delay();
P2=0x22;
T0delay();
P2=0x44;
T0delay();
P2=0x88;
T0delay();
}
}
void rest()
{ //at rest position
P2=0x00;
T0delay();
P2=0x00;
T0delay();
P2=0x00;
T0delay();
P2=0x00;
T0delay();
}
void clockfast() //function for clockwise rotation
{
{
for(unsigned int count=61;count<=120;count++)
P2=0x11;
T0delay1();
P2=0x22;
T0delay1();
P2=0x44;
T0delay1();
P2=0x88;
T0delay1();
}
}
void clockfast1() //function for halg clockwise
{
{
for(unsigned int count=61;count<=120;count++)
P2=0x11;
T0delay1();
P2=0x22;
T0delay1();
P2=0x44;
T0delay1();
P2=0x88;
T0delay1();
}
}
void clockfast2(); //function for little clockwise
{

for(unsigned int count=61;count<=120;count++)
{
P1=0x11;
T0delay1();
P2=0x22;
T0delay1();
P2=0x44;
T0delay1();
P2=0x88;
T0delay1();
}
}



//delay(unsigned int time) //delay function
//{
//unsigned int i,j;
//for(i=0;i<time;i++)
//for(j=0;j<1275;j++)
//}

// }
void T0Delay() //delay by using timer
{

TMOD=0x01; // timer 0, mode 1
TL0=0x00; // load TL0
TH0=0x35; // load TH0
TR0=1; // turn on Timer0
while (TF0==0); // wait for TF0 to roll over
TR0=0; // turn off timer
TF0=0; // clear TF0
}
void T0Delay1() //delay by using timer
{
TMOD=0x01; // timer 0, mode 1
TL0=0x00; // load TL0
TH0=0x35; // load TH0
TR0=1; // turn on Timer0
while (TF0==0); // wait for TF0 to roll over
TR0=0; // turn off timer
TF0=0; // clear TF0
}



}//main

- - - Updated - - -

the basic concept is:if the motor is in east then rotate full 180 degree,if the motor is in middle ie steppermotor=2,then rotate in half step and likewise.plz help me to debug the code plz.i hav keil uvision3
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top