Discussion in "Project Help" started by    Pater    May 14, 2018.
Mon May 14 2018, 05:36 PM
#1
Basically my project is based on Data Acquisition system, so I want to acquire the data from various sensors in the PC.

For this i have used ADC0808 for converting Analog data to Digital data (8 bits), and these digital bits are given to any one port of micro-controller (89S52). The micro-controller then receives the bits and transmit it serially so that PC can receive the serial bits.

I have used "ADC0808 module with external clock" (By Silicon Technologies) :- attachment-1 &
"89S52 development board" (By Silicon Technologies) :- attachment-2

My code is as follows,
---------------------------------------------------------------------------------------------------------------------------
#include<reg51.h>

void delay_sec(unsigned int);
void delay_us(unsigned int);

void decimal();
void serial(char c);
unsigned char d1,d2,d3,d4;
void InitADC(void);
unsigned char ReadADC(unsigned char);

#define AN0 0
#define AN1 1
#define AN2 2
#define AN3 3

sbit Add_A = P2^0;
sbit Add_B = P2^1;
sbit Add_C = P2^2;
sbit ALE = P2^3;
sbit EOC = P2^4;
sbit OE = P2^5;
sbit START = P2^6;



#define Data_Bus P0
#define HalfCycleDelay 10 // usecs


void main()
{

unsigned char I;
InitADC();

while(1)
{
I= ReadADC(AN0);
}

}

void InitADC(void)
{
Add_A = 0;
Add_B = 0;
Add_C = 0;
ALE = 0;
EOC = 1;
OE = 0;
START = 0;

Data_Bus = 0xFF;
}

unsigned char ReadADC(unsigned char Channel)
{
unsigned int i = 0;
unsigned int ADC_value = 0;

/*Selecting analog Channel by providing respective
bits to A,B,C addresses*/
switch(Channel)
{
case AN0: Add_C = 0; Add_B = 0; Add_A = 0; break;

}

delay_us(HalfCycleDelay); // 250kHz Frequency
ALE = 1; // Enable Address Latch

delay_us(HalfCycleDelay); // 250kHz Frequency

START = 1; // Start ADC Conversion
delay_us(HalfCycleDelay); // 250kHz Frequency

ALE = 0; // Disable Address Latch
delay_us(HalfCycleDelay); // 250kHz Frequency

START = 0; // Complete the start pulse

for(i=0;i<2000;i++)
{

delay_us(HalfCycleDelay); // 250kHz Frequency
if(!EOC) // Wait for EOC to be low
break;
}

for(i=0;i<2000;i++)
{

delay_us(HalfCycleDelay); // 250kHz Frequency
if(EOC) // Wait for EOC to be High
break;
}


OE = 1; // Enable Output
delay_us(HalfCycleDelay); // 250kHz Frequency

delay_us(HalfCycleDelay); // 250kHz Frequency

delay_us(HalfCycleDelay); // 250kHz Frequency


ADC_value = Data_Bus; // Read value

decimal();
serial(d1+0x30);
serial(d4+0x30);
serial(d3+0x30);

delay_sec(1);

delay_us(HalfCycleDelay); // 250kHz Frequency
OE = 0; // Disable Output

delay_us(HalfCycleDelay); // 250kHz Frequency
return ADC_value; // Return ADC value
}


void decimal()
{

d1 = Data_Bus /100;
d2 = Data_Bus %100;
d3 = d2 %10;
d4 = d2/10;

}


void serial(char c)
{

TMOD = 0X20;
TH1 = 0XFD;
SCON = 0X50;
TR1 = 1;
SBUF = c;
while(TI==0);
TI = 0;

}

// Function for approximate delay in Secs.
void delay_sec(unsigned int d)
{
unsigned int i;
for(i=0;i<(d*20);i++)
delay_us(50000);
}

// Function for approximate delay in given uSecs.
void delay_us(unsigned int d)
{
unsigned int i, limit;
limit = d/15;
for(i=0;i<limit;i++);
}

----------------------------------------------------------------------------------------------------------------

So the main problem is that I am not getting Analog to Digital conversion on the port of micro-controller and also no data in the PC (Used hyper-terminal for getting serial data) & if getting, am getting any random data in the PC.

I have made all connections as per the code but it is not working.

So please help in this regard and give suitable solution regarding Hardware part or the Programming part.

Mon May 14 2018, 10:17 PM
#2


So the main problem is that I am not getting Analog to Digital conversion on the port of micro-controller and also no data in the PC (Used hyper-terminal for getting serial data) & if getting, am getting any random data in the PC.

Pater



You code works okay on Proteus.
Random values looks like wiring or power problems.

Where do you get your test input voltage ?

What happens if you connect ADC0809 IN0 directly to ground ?
What happens if you connect ADC0809 IN0 directly to +5volts ?


[ Edited Mon May 14 2018, 10:19 PM ]

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Jun 19 2019, 09:21 AM
latamdatetfv
swimming
Wed Jun 19 2019, 07:34 AM
RbaseoCamb
Rbaseo#gennick[OPPPORRORROR,3,4]ZJ
AdiGhazi
Tue Jun 18 2019, 11:21 AM
Hlo Dear , I've to program AT89C51AC3 RT-LUM using flip but I'm getting time out error for RS232. Will you please suggest me which programmer will be supportable to program this Chip.
Sun Jun 16 2019, 07:48 PM
hanoch Taub
i need to interface sim800 to 8051, the problem is that on the module sim800 there are 9 pins connector and I don't know how to connect him to 8051, which pins to tx and rx on 8051 module sim there is
Tue May 28 2019, 07:14 PM
Ron Otsig
KBI does not work on P89LPC920 but it works on P89LPC925
Mon May 27 2019, 09:03 AM
BIJI MATHEW
Hello friends....
DragonDad
Tue May 21 2019, 03:02 PM
Hi. Who is online?
Tue May 14 2019, 12:38 AM
Jayson Contreras
Hello
Xkalebar
Sun Apr 28 2019, 09:06 AM
Please provide me the code for gsm based sms controlled notice board
ExperimenterUK
Sun Apr 14 2019, 10:52 PM
@hassan malik post your problem in the "General help Guidance and Discussion" forum

Downloads

Comments

AdiGhazi
Tue Jun 18 2019, 11:15 AM
Easwaran22
Thu Jun 13 2019, 10:16 AM
JenniferJJ
Thu Jun 13 2019, 05:12 AM
seyoonnet
Tue Jun 04 2019, 12:37 PM
Charbel
Sun Jun 02 2019, 03:30 PM
ronotsig
Mon May 27 2019, 03:00 AM
WilsonNig
Sun May 26 2019, 03:11 AM
DragonDad
Tue May 21 2019, 02:50 PM

Online

Guests: 45, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38073
Newest member: AdiGhazi
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jun 18 2019, 10:19 PM
Okay.. I have never programmed the AT89C51AC3 or ...
AdiGhazi Avatar
Posted By AdiGhazi
Tue Jun 18 2019, 11:20 AM
Hlo Dear ,I've to program AT89C51AC3 RT-LUM using ...
JenniferJJ Avatar
Posted By JenniferJJ
Thu Jun 13 2019, 05:17 AM
Hi,Hello Members,I am the newbie member, I like ve...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 30 2019, 08:32 PM
It occurs to me that although the P89LPC921 and P8...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed May 29 2019, 09:05 PM
I would suggest a fresh approach.The Keil compile...
ronotsig Avatar
Posted By ronotsig
Wed May 29 2019, 03:13 PM
Since the code works for the P89LPC925, it is appa...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon May 27 2019, 06:23 PM
I can't see any reason that those registers would ...
ronotsig Avatar
Posted By ronotsig
Mon May 27 2019, 03:06 AM
I am trying to using P89LPC921 or P89LPC922 in a p...
Ansh12 Avatar
Posted By Ansh12
Sun Apr 28 2019, 02:15 PM
I made a minor change, it works in Proteus.Try the...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 25 2019, 08:20 PM
I made a minor change, it works in Proteus.Try the...