Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

adding tag

dear viewers,
this will be a program for data acquisition using 8051
here i want to add sensor identification to program
example
if temperature sensor 1.......it shows as t1 then value
and this will display in vba
please help me to change program .

#include
sbit start=P3^3;
sbit end=P3^4;
sbit oe=P3^5;
sbit ale=P3^6;
sbit clock=P3^2;

unsigned char sensor=0;

void delay()
{
int k,l;
for(k=0;k<30;k++)
for(l=0;l<80;l++);
}
void initSerial()
{
TMOD=0x22;
TH1=0xFD;
SCON=0x50;
TR1=1;
EA=1;
ES=1;
}
void usDelay(int a)
{
TH0=256-(a/1.085);
TR0=1;
ET0=1;
}
void timerRoutine() interrupt 1
{
clock=~clock;
}
void sendChar(unsigned char ch)
{
SBUF=ch;
while(!TI);
TI=0;
}

void sendReading(unsigned char val)
sendChar(val);
sendChar(',');
}
void latch()
{
ale=0;
delay();
ale=1;

}
void startConv()
{
delay();
start=0;
delay();
start=1;
}
void wait()
{
while(end==1);
}
void get()
delay();
oe=0;
delay();
oe=1;
}
void main()
{

unsigned char reading;
P1=0;
initSerial();
usDelay(50);
while(1)
{
if(sensor==8)
sensor=0;
if(sensor==0)
sendChar('N');
P1=(P1&0xf8)+sensor;
latch();
startConv();
wait();
get();
reading=P2;
sendReading(reading);
sensor++;

}
}





Sign In or Register to comment.