We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
How to resolve the contention between 2 ADC0801!!!???
I would like using two ADC0801 in order to read 2 Vol electric signal ., 2 ADC interfaces with AT89c51 by using common input..If I use an ADC, no problem, but with 2 ADC ,ADC will not working!!!! Please help me!!!
My programmer and file Proteus is below
www.MegaShare.com/512261
There is no reason why it shouldn't be simple!
It only gets complicated because you make it so:
"i want to use RTOS for this application"
Why do you want to do that?
Usually, the reason to ues an RTOS is because you need one - so, if you don't actually need one, don't use one!
If you simply want an exercise in using an RTOS, then start with stuff that you already understand - don't confuse the issue by trying to learn both ADC interfacing and RTOS at the same time!
Master one first, then move on to the other...
"For example:,read ADC1,read ADC2,comunicate with keyboard,and show with led 7segs..."
Absolutely no need whatsoever for an RTOS to do all that - and more!
"i only want know the reason, in single task system: why can't i use 2 ADC in turn in order to read"
If you don't know how to do it in a single task system, then you are certainly not ready to start doing it in a multi-task system!
Learn to walk before you try to run.
Lay the foundations before you try to put the roof on.
etc, etc,...
For a start, how do you know that you have "contention" between the two ADCs in the first place?
Does each one work independently if you remove the other from the circuit?
If this doesn't work, then you have a far more fundamental problem...
Andy Neil.. i understand what you mean,i am doing that work right now, i don't want to dispute,please focus my subject which i mention
i have alredy run 1 ADC...and you can see my file here... www.mediafire.com/
if you alredy see my project,you will see clear,when i press button, chip can't read ADC cause there is not any "interrupt signal" which is sended by ADC after convert...
"Does each one work independently if you remove the other from the circuit?" i can drive ADC1 when i remove ADC2...see my first file above
To my knowledge, the /INTR signal is not tristate, so you can not directly connect two /INTR outputs to a single interrupt pin on your processor.
You either have to connect them using a AND gate (any /INTR going low will drive the output of the AND low) or connect them to two separate inputs of the processor.
The problem with letting them feed the same interrupt is that you will not know which ADC that is ready to be serviced (unless you only started one conversion).
This is a big reason for using an external analog multiplexer, or an ADC with multiple inputs. Then you have _one_ ADC that will issue an interrupt, and you will always know which signal that is currently multiplexed into the ADC or which channel of the ADC that you requested to perform a conversion.
thank for caring my problem..... my english is not good,download my project,and all of you can undenstand clearly...
In my progam: i use 2 button to control 2 ADC.each ADC have each pin INTR to connect 2 separate input pin of the processor..so why d'ont INTR pin of ADC work,after converted...this thing cause ADC can't be read by processor
Problem with an interrupt signal only affects how you will know that a conversion is done - it does not affect your ability to talk with the ADC.
when I remove ADC2 in my circuit(proteus),ADC1,processor run as normal When i remove ADC1,then ADC2 also does not work...Why??There is only ADC1 work actually if all 2 ADC connect in circuit,When I press any buttons,,chip does not work...see here.www.mediafire.com/
"Problem with an interrupt signal only affects how you will know that a conversion is done - it does not affect your ability to talk with the ADC"
i understand this thing.My mean:i use button to allow operate ADC,star convert,,then wait signal INTR from ADC send to CHIp to alert "finish start convert",after chip will read ADC then show in leg7seg...is this right??
my code use for operating ADC
if(button1==1){ CS_1=0; WR_1=0; WR_1=1; while (INTR_1==1);//wait for signal INRT_1...cho den khi co tin hieu ngat tu ADC CS_1=0; RD_1=0; //CS_1=1 not write here khong the dat o day...dan toi ko doc duoc }
... you need to post them in a format people can read.
Unfortunately, as far as I know, there is no universal schematic format - so you will have to export it to something like GIF or PDF.
Note that JPEG is not (generally) a good choice for schematics...
"When i remove ADC1,then ADC2 also does not work...Why??"
That's for you to find out!
You have the hardware there - what investigations have you done?
Do you have an oscilloscope?
"You have the hardware there - what investigations have you done?" i d'ont have hardware, i have just only stimulate my circuit with Software proteus 7.2,and program with keil c,
"Unfortunately, as far as I know, there is no universal schematic format - so you will have to export it to something like GIF or PDF."
i imported my circuit to file format bitmap..,first ,start testing my circuit here....www.mediafire.com/
alert me when link die!!!!
In that case, use whatever facilities your simulator provides as it's simulated equivalent of probing with an Oscilloscope.
For help in how to use your simulator, you're going to have to go to their site - it's not a Keil product. Do they have a forum?
i have already debuged my code C with Keil,run as normal,but it can't stimulate with PROTEUS, ,so i will write my code here,,help me to test my code please!!
this program use each button to read each ADC //button1=P2_6 //button2=P2_7
#include <REGX51.H> sbit ledD0=P0^0; sbit ledD1=P0^1; sbit ledD2=P0^2; sbit ledD3=P0^3; sbit ledD4=P0^4; sbit ledD5=P0^5; sbit ledD6=P0^6; sbit LED_0=P2^0; //hang don vi sbit LED_1=P2^1; //hang chuc sbit LED_2=P2^2; //hang tram sbit INTR_1=P3^2;//INTR0 of CHIP sbit INTR_2=P3^3;//INTR1 of CHIP sbit CS_1=P3^4; sbit CS_2=P3^5; long n; int a,b,c; void delay(long time) { for(n=0; n<time; n++) { ; } } void bit_dec() { c=P1%10;//hang don vi b=((P1-c)/10)%10;//hang chuc a=((((P1-c)/10)-b)/10)%10; //hang tram } unsigned char x; void Hienthiled(x) // Co 1 bien dau vao de xac dinh xem la hien thi so nao { int arr[]={64,121,36,48,25,18,2,120,0,16} ; P0 = arr[x]; } void inhangtram() { LED_2=0; LED_1=LED_0=1; Hienthiled(a); } void inhangchuc() { LED_1=0; LED_0=LED_2=1; Hienthiled(b); } void inhangdonvi() { LED_0=0; LED_1=LED_2=1; Hienthiled(c); } void laymauADC1() { //convert voi ADC1 CS_1=0; //Make CS low RD=1; WR=0; WR=1; CS_1=1; while(INTR_1==1); //Read ADC CS_1=0; //Make CS low RD = 0; //Make RD low RD = 1; //Make RD high CS_1=1; //Make CS high } void laymauADC2() { //convert voi ADC2 CS_2=0; //Make CS low RD=1; WR=0; WR=1; CS_2=1; while(INTR_2==1); //Read ADC CS_2=0; //Make CS low RD = 0; //Make RD low RD = 1; //Make RD high CS_2=1; //Make CS high } void phimbam() { if(P2_6==0){laymauADC1();} else if(P2_7==0){laymauADC2();} } void main(void) { while(1) { WR=1;// chuyen doi lai RD=1;// xoa gia tri da doc truoc do phimbam(); bit_dec(); inhangtram(); delay(3000); inhangchuc(); delay(3000); inhangdonvi(); delay(3000); } }
if you want to see schema you can see here www.mediafire.com/