Discussion in "8051 Discussion Forum" started by    qwertyboy    Apr 2, 2008.
Wed Apr 02 2008, 08:09 PM
#1
Hello! i´m new here,in this forum, and i have a question;)
Does anyone have work with max192 and de 89S51? I need to take mesures of 8 analog channels and i´ve buyed the maxim adc, MAX192, but i ´m having trouble putting the micro and the adc working. Does anyone have a tutorial in C language or some "lights" to help me (a beginer) to make an serial adc conversion with 89S51? Tk´s;)
Thu Apr 03 2008, 07:17 AM
#2
can u post data sheet??
Thu Apr 03 2008, 07:25 AM
#3
Hello! Yes, the ADC datasheet is:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1037
Thu Apr 03 2008, 02:49 PM
#4
Hi...
You need to look at pg13,fig.9 to get an idea of what steps your microcontroller has to perform to select an analog channel,configure the ADC and read in the digital data.
Connect CS pin of the ADC to,say,P2.0 of 89S51.
SCLK to say P2.1
DIN to P2.2
DOUT to P2.3

Now according to the fig. 1st thing you have to do is make CS low.
Thus P2.1=0;

Next you have to clock in a control byte to the DIN pin.Read about the control byte in pg9.
So suppose you have to select channel 0 for adc in unipolar,single-ended mode you must send in the fol. control byte.
10001110
For this you make SCLK(P2.1) low and then set P2.2(DIN) to the MSB of the control byte followed by a small delay,then a high pulse on SCLK.
Thus P2.1=0; //SCLK low
P2.2=1; //the MSB of the ctrl byte
delay();
P2.1=1;
delay();
This comprises clocking in one bit of the ctrl byte.Clock in the other 7 bits in a similar manner.
After all 8 bits have been clocked out you need to make SCLK low and CS high according to the fig.
Thus
P2.1=0;
P2.0=1;
Now wait for atleast 10us for the conversion to take place.
Thus
delay(); //wait 20us

After the delay you make CS low and start clocking in the 10 bits representing the converted data.
P2.0=0; //make CS low
P2.1=1; //make SCLk high
delay();
P2.1=0; //make SCLK low
delay();
mydata^0=P2.3; //read in msb of data into variable 'mydata'
mydata=mydata<<1; //shift in the bit by one place.

In tis way you can read in 8bits into 'mydata' and the remaining 2 bits into another variable.

Hope this is enough to get you started.
 qwertyboypdi33 like this.
Thu Apr 03 2008, 03:44 PM
#5
89S51 doesn't have SPI interface.. so either you have to implement SPI on 89S51 or you can use a controller with onchip SPI.

For more information on programming see page 12 of datasheet.. well that not all.. read the datasheet completely. start with something.. will help you as you move on
 qwertyboy like this.
Thu Apr 03 2008, 07:32 PM
#6
wow shashi , u surely have given the whole code itself just disguised in simple english language for interfacing. . It would save a lot of time if such explaination were given in the datasheet application notes.
Wed Apr 09 2008, 04:35 PM
#7
mydata^0=P2.3;

What this does? the ^ after mydata?

tk´s;)
Wed Apr 09 2008, 04:48 PM
#8
mydata^0 means 0th bit of 8-bit data variable. Please make sure you define the variable in bit addressable area, using bdata directive.
 qwertyboy like this.

Get Social

Information

Powered by e107 Forum System

Conversation

Thu Jun 11 2020, 06:27 AM
anudee
sir could please send the code for I2C and wifi interfacing with 8051
scena
Tue May 19 2020, 10:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 07:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 01:39 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 10:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 12:55 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 05:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 04:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 10:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 06:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 79, Members: 0 ...

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

Members: 38215
Newest member: Mirza123