electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

problem interfacing 89c2051


Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing -> problem interfacing 89c2051
Author Message
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post22 Apr 2008 4:18   

micro 8051 + 89 c2051 + datasheet


Hi friends,
I am doing project named Auto Measurement of Current from power supply for one of my application.
I am amplifying the analog output using an OP-Amp OP07,the amplified output is given to ADC,there i am converting to digital,this digital value i am taking at one of the Port of microcontroller(89c2051).I want to get this value using serial communication.for that i have connected the microcontroller to max233.

my problem is no value is displayed in the hyperterminal.
can any body tell me what problem do i have?
The code i have used is

#include<reg52.h>
#include<stdio.h>


sbit adc_port=P1;
sbit rd = P3^0;
sbit wr = P3^1;
sbit CS=P1^2;
sbit intr=P1^3;

void conv();
void read();
void transmit(unsigned char);


unsigned char adc_val;

void main()
{
TMOD=0x20;
TH1=-3;
SCON=0x50;
TR1=1;
TI=1;
while(1)
{
conv();
read();
P3=adc_val;
}
}
void conv()
{
CS=0;
wr=0;
wr=1;
CS=1;
while(intr);
}

void read()
{
CS=0;
rd=0;
adc_val=adc_port;
rd=1;
CS=1;
}

void transmit(unsigned char data1)
{
SBUF=data1;
while(!TI);
TI=0;
}


thanks in advance.



Sorry, but you need login in to view this attachment

Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post22 Apr 2008 5:43   

header file at89c2051 download


Hi viswanath;

I dont see the transmit function being called anywhere in your program. Dont make TI=1 at the start. make EA =1. First display in the LCD and check if u r getting the outout.

HOW to appraoch?
First convert the ADC value. store in a variable. move the variabe data to SBUF and transmit as u r doing. Also keep this transmit routine in the while(1) infinite loop.

Are u using any interrupt in while(intr);

there are more possiblilties like matching the baudrate of the hyperterminal and cross checking hte serial cable that u r using. I will talk of this issues for u once u confirm that do u get output in LCD.
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post22 Apr 2008 6:36   

89c2051 india


hi shiv,
thanx 4 replying.

di i need to write the interrupt function for this....
and what abt PCON and TCON registers,do i need to use these registers.
Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post22 Apr 2008 8:08   

at89c2051 hyperterminal problem


there is no need for any knid of interrupt. after conversion just call the transmit function. see if the hyperterminal is also set for the 9600 baud rate and 8 data bits and 1 stop bit and flow control none.

Added after 33 seconds:

there is no need for any knid of interrupt. after conversion just call the transmit function. see if the hyperterminal is also set for the 9600 baud rate and 8 data bits and 1 stop bit and flow control none.
if u r using KEIL IDE then u can check in the simulator itself.
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post22 Apr 2008 9:34   

Re: problem interfacing 89c2051


ok sir,

Why do serial communication doesn't need interrupt and in what type applications we will use interrupt concept for serial communication.

Could you please clarify me the above two queries.

thanks.
Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post22 Apr 2008 9:48   

problem interfacing 89c2051


The basic general purpose controller which have UART have internal pins RI and TI that takes cares of the interrupt. Other interrupts will be handled by the controller by the priority assigned.
Even though UART in 8051 in full duplex we use them as half duplex by monitoring TI and RI pins.
Without these interrupt serial comm, does not work.

please send me your mob. number if teh doubt is not clarified. I will call u if u r within karnataka
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post24 Apr 2008 13:26   

Re: problem interfacing 89c2051


hi shiv,

i got success in serial communication.
The problem which i am facing nw is with ADC.
according to the datasheet for 5V with 2.5 as Vref/2 the output binary should be FF(11111111),but i am getting reverse for 0V input i am getting FF as output and for 5V input i am getting 00000000 as output.

could you have any idea where the problem mighht be?

actuallly the input to the ADC is in the range 0-4.3V.
Vref/2 which i have used in the circuit is 2.5volts,is it correct r hw do we calculate the vref voltage..

my mob is 09963517504.
send me ur's.

thanks,
viswanath.
Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post25 Apr 2008 5:42   

Re: problem interfacing 89c2051


Check the Vref documentation of the manual.

Some times register to which we need to move the Vref value may be configured negatively.

If Vref selection is through hardware we need to refer the document.

If possible send the data sheet of the ADC u r using. Is It ADC0808 or any other company. I will download the data sheet and see myself.
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post25 Apr 2008 8:03   

Re: problem interfacing 89c2051


Hi,
I am using ADC0804 n i have attached the datasheet.

Added after 2 minutes:

sory,
some problem is coming when attaching,
plz download it from the website,i am using ADC 0804 from national semiconductors
Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post25 Apr 2008 8:11   

problem interfacing 89c2051


Regarding ADC I think You need to check the reference voltage point ..because there will also be Negative reference..
Why Vref /2? Are you using any potential divider o f/2 at reference point?
I hope the Analog input you are giving is also Positive...
Is there any conversion Logic selection which can be control through software?
What is the ADC logic?
Successive approximation? R2R ladder logic?
I think I am asking question to you but that would infact may help you.
Please cofirm the voltage exactly at pins of controller..
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post26 Apr 2008 4:42   

Re: problem interfacing 89c2051


Hi shiv,
ADC is 8 bit parllel Successive Approximation type.
Back to top
yviswanathbe



Joined: 14 Jun 2007
Posts: 116
Helped: 3


Post29 Apr 2008 4:29   

Re: problem interfacing 89c2051


hi shiv,
now my circuit is ok with ADC.
I am not able to read converted data from the microcontroller in the PC.

i am sending my code,plz tell me where i am doing mistake,


#include<stdio.h>
#include<reg51.h>

sbit MYDATA=P1;
sbit rd=P3^0;
sbit wr=P3^1;
sbit cs=P1^2;
sbit intr=P1^3;

unsigned char receive();
void transmit(unsigned char);
unsigned char chr;
unsigned char result;

void main()
{
unsigned char value;
SCON=0X50;
TMOD=0X20;
TH1=-3;
TR1=1;
TI=1;
MYDATA=0XFF;
intr=1;
rd=1;
wr=1;
while(1)
{
wr=0;
wr=1;
while(intr==1)
rd=0;
value=MYDATA;
rd=1;
transmit(value);
}
}

void transmit(unsigned char data1)
{
SBUF=data1;
while(!TI);
TI=0;
}






thanks,
visu
Back to top
ypnayak



Joined: 20 Apr 2006
Posts: 90
Location: india


Post29 Apr 2008 5:04   

Re: problem interfacing 89c2051


write the interrupt routine and then execute
Back to top
Google
AdSense
Google Adsense




Post29 Apr 2008 5:04   

Ads




Back to top
ckshivaram



Joined: 21 Apr 2008
Posts: 331
Helped: 23
Location: india


Post18 May 2008 6:55   

Re: problem interfacing 89c2051


send me your code for reference

Added after 10 minutes:

adc prog



Sorry, but you need login in to view this attachment

Back to top
DrBob13



Joined: 26 Mar 2008
Posts: 140
Helped: 36
Location: UK


Post03 Jun 2008 0:07   

Re: problem interfacing 89c2051


Hi,
You are not converting the data sent in 'data1' to the transmit routine, which is a 'binary' hex number into an 'ASCII' Hex number to print it out on hyperterminal in a readable form, hyperterminal will try to print whatever character is the ASCII code in 'data1' (if it is printable) for the code sent to it.

Try something like :-


void transmit(unsigned char data1)
{
unsigned char cChar[6]; //Make the string limits longer than 6 if required.
int i;

sprintf(cChar, "%02x\n\r\0", (unsigned int)data1);
//May not need the (unsigned char) cast, some compilers don't.

//Use "%02i\n\r\0" if you want it in decimal this will print each new value on a
//new line. Should then print something like 7f for a value of #7f. If you use the
//"%#05x\n\r\0" you should get 0x07f printed out.
//include more math routines if you want to convert value to a voltage directly.
//you could then make the format string more fancy including adding "Volts" etc.
//before the line feed & carriage return character.

for(i = 0; i < 5; i++) //Make the character count longer if required.
{
SBUF=cChar[i];
while(!TI);
TI=0;
}
}

You will also need to include the header file <stdio.h> for this to work.

I hope this helps.

Best regards
Bob.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing -> problem interfacing 89c2051
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
problem in interfacing cc2500 to at 89c2051 (2)
Interfacing 89c2051 (7)
89c2051 interfacing (3)
89c2051 programmer - problem! (4)
fpga PROBLEM...RAM interfacing... (4)
8051 interfacing to LCD problem???? (6)
sensor interfacing circuit problem (9)
problem with Interfacing IR receiver (1)
Problem with ADC interfacing!! (4)
interfacing MCP3002 TO 8051 problem (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS