Discussion in "8051 Discussion Forum" started by    qwertyboy    Apr 3, 2008.
Thu Apr 03 2008, 01:39 am
#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, 12:47 pm
#2
can u post data sheet??
Thu Apr 03 2008, 12:55 pm
#3
Hello! Yes, the ADC datasheet is:
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1037
Thu Apr 03 2008, 08:19 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, 09:14 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.
Fri Apr 04 2008, 01:02 am
#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, 10:05 pm
#7
mydata^0=P2.3;

What this does? the ^ after mydata?

tk´s;)
Wed Apr 09 2008, 10:18 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

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am