jyothi1
Junior Member level 1
- Joined
- Sep 24, 2010
- Messages
- 19
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Anantpur, A.P
- Activity points
- 1,614
Hi 2 all,
Here I have written programming code but it is not working it is giving adc value as 128 only. and it is not varying as I change in input.. can any one please help me.The below is my code.
#include<reg51.h>
#define adc_data P2 //ADC data port
sbit ADDR_2=P0^0; // CHANNEL SELECTION PORT
sbit ADDR_1=P0^1;
sbit ADDR_0=P0^2;
sbit ALE=P0^4; //ADDRES LATCH ENABLE
//sbit CLOCK=P0^7; //CLOCK GENERATED FOT THE ADC0808 AT THIS
sbit SOC = P0^3; //START OF CONVERSION
sbit EOC = P0^5; //END OF CONVERSION
sbit OE = P0^6; //READ ENABLE
void convertion(unsigned char ans)
{
unsigned char i,x,k,l,j,a[3];
i=ans;
x=i/0X0A;
j=(i%0X0A);
k=(x%0X0A);
l=(x/0x0A);
a[0]=(l | 0x30);
LCD_DELAY(500);
a[1]=(k | 0x30);
LCD_DELAY(500);
a[2]=(j | 0x30);
send(a[0]);
send(a[1]);
send(a[2]);
void main()
{
unsigned char adc_val,i;
EOC=1; // MAKE EOC PIN INPUT PIN
ALE=0;
OE=0;
SOC=0;
init_serial(); // serial intialisation
ser_string("welcome");
while(1)
{
ADDR_2 =0;
ADDR_1 =0; // BY DEFAULT SELECT CHANNEL 1
ADDR_0 =0;
adc_val=adc_read();
convertion(adc_val);
}
unsigned char adc_read(void)
{
unsigned char value;
MSDELAY(1);
ALE=1; // sending high to low pulse
MSDELAY(1);
SOC=1; // SOC starts
MSDELAY(1);
ALE=0;
SOC=0;
//while(EOC==1); // wait until conversion ends
while(EOC==0);
OE=1;
LCD_DELAY(500);
value=adc_data;
OE=0;
return (value);
}
Here I have written programming code but it is not working it is giving adc value as 128 only. and it is not varying as I change in input.. can any one please help me.The below is my code.
#include<reg51.h>
#define adc_data P2 //ADC data port
sbit ADDR_2=P0^0; // CHANNEL SELECTION PORT
sbit ADDR_1=P0^1;
sbit ADDR_0=P0^2;
sbit ALE=P0^4; //ADDRES LATCH ENABLE
//sbit CLOCK=P0^7; //CLOCK GENERATED FOT THE ADC0808 AT THIS
sbit SOC = P0^3; //START OF CONVERSION
sbit EOC = P0^5; //END OF CONVERSION
sbit OE = P0^6; //READ ENABLE
void convertion(unsigned char ans)
{
unsigned char i,x,k,l,j,a[3];
i=ans;
x=i/0X0A;
j=(i%0X0A);
k=(x%0X0A);
l=(x/0x0A);
a[0]=(l | 0x30);
LCD_DELAY(500);
a[1]=(k | 0x30);
LCD_DELAY(500);
a[2]=(j | 0x30);
send(a[0]);
send(a[1]);
send(a[2]);
void main()
{
unsigned char adc_val,i;
EOC=1; // MAKE EOC PIN INPUT PIN
ALE=0;
OE=0;
SOC=0;
init_serial(); // serial intialisation
ser_string("welcome");
while(1)
{
ADDR_2 =0;
ADDR_1 =0; // BY DEFAULT SELECT CHANNEL 1
ADDR_0 =0;
adc_val=adc_read();
convertion(adc_val);
}
unsigned char adc_read(void)
{
unsigned char value;
MSDELAY(1);
ALE=1; // sending high to low pulse
MSDELAY(1);
SOC=1; // SOC starts
MSDELAY(1);
ALE=0;
SOC=0;
//while(EOC==1); // wait until conversion ends
while(EOC==0);
OE=1;
LCD_DELAY(500);
value=adc_data;
OE=0;
return (value);
}