tag id

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.

Howdy, Stranger!

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

Categories