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

Sun May 20 2018, 01:16 PM
justinb
how to write and execute a program that read the keypad button and display the number on 7 segment on intel8051 at89s52 in assembly language?
Thu May 17 2018, 09:51 AM
HAMZA TAJ
sir iwant to ask about controller of three phase supply by using back to back thyristor instead of triac....will u give me some guideline?
Sat Apr 28 2018, 04:09 PM
ashutosh jain
IR Remote Switch using TV remote (RC5 Protocol) is not working properly. opp1 & opp2 is in problem.plz help
ExperimenterUK
Fri Apr 27 2018, 11:24 PM
@kaiserslautern Post in forum
Wed Apr 25 2018, 10:24 AM
kaiserslautern
Hello everyone, using software uart is a very good idea for a second serial port. Thank you so much. I would kindly like to know how to connect this port to the PC?
ExperimenterUK
Sat Apr 21 2018, 11:05 PM
This is a community site. Feel free to help anyone needing advice
hareeshchamiyar
Thu Mar 29 2018, 02:02 PM
please help me for the configuration bits for dspic30f2010
hareeshchamiyar
Thu Mar 29 2018, 02:00 PM
can any one using dspic30f2010.
Thu Mar 29 2018, 09:18 AM
Neena
can anybody give solar tracking in 8051 using proteus and keil to mail [email protected]
ExperimenterUK
Mon Mar 19 2018, 10:48 PM
sorry bedo.. maybe next time

Downloads

Comments

bdmehta
Tue May 22 2018, 02:30 AM
kmag1953
Sun Apr 29 2018, 07:09 PM
udiwonder
Sat Apr 28 2018, 12:41 PM
pirpiri
Sat Apr 21 2018, 03:35 PM
Pater
Fri Apr 20 2018, 02:38 PM
jamiel
Sat Apr 14 2018, 12:47 AM
akrepkral76
Wed Apr 04 2018, 07:51 PM
samanthaeaves
Mon Apr 02 2018, 06:27 AM

Online

Guests: 56, Members: 0 ...

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

Members: 37998
Newest member: bdmehta
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Jul 12 2018, 08:27 PM
I'm glad we got there in the end :)>whats differen...
LAMBO Avatar
Posted By LAMBO
Thu Jul 12 2018, 06:51 AM
hi sir as u mentioned above to change crystal and ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jul 10 2018, 07:20 PM
I assume you meant a AT89S52.It seems to me that...
LAMBO Avatar
Posted By LAMBO
Tue Jul 10 2018, 06:06 AM
hi sir i have checked now much of the distortion ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 09 2018, 06:55 PM
Okay that is very interesting.I have attached two ...
LAMBO Avatar
Posted By LAMBO
Mon Jul 09 2018, 08:14 AM
hi sir as u mentioned above program i have tried ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jul 06 2018, 11:58 PM
Okay..That motor creates a lot of sparks which mig...
LAMBO Avatar
Posted By LAMBO
Fri Jul 06 2018, 01:33 PM
hi sir as u told >Try the original code againi hav...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jul 02 2018, 06:20 PM
>is it ok to work on 12.10 v Yes, that is ok.>now...
LAMBO Avatar
Posted By LAMBO
Mon Jul 02 2018, 08:22 AM
hi sir as u mentioned in the program i have checke...