| ??? 09/27/09 22:46 Read: times |
#169205 - ADuC848: Trouble of reading all 10 ADC channels, pleas help! |
Hi guys, I am using ADuC848 that has 10 ADC channels. I am having a trouble that if I only read 5 or 6 channels of 10 then I can see this message on the PC's terminal:
e.g. Time start now Head #1&2: 1000, 1000 But if I read all 10 channel then I only can see message: e.g. Time start now Is that because the effect of delay in reading all of 10 ADC channels? And what is a better method to overcome that? I do appreciate any advice.. Thanks guys! if(!CONDVOL_Time_Flag)
void Test (void)
{
//...some codes here
{
CONDVOL=1; //start 10s timing + turn on 10VDC
CONDVOL_Time_Flag=1; //start 10s timer
printf("Time start nown");
}
if(CONDVOL_Time>=400 && CONDVOL_Time_Flag)//10s due since voltage is on, read ADC now
{
Head1_ADC=ADC_read(1);
Head2_ADC=ADC_read(2);
Head3_ADC=ADC_read(3);
Head4_ADC=ADC_read(4);
Head5_ADC=ADC_read(5);
Head6_ADC=ADC_read(6);
Head7_ADC=ADC_read(7);
Head8_ADC=ADC_read(8);
Head9_ADC=ADC_read(9);
Head10_ADC=ADC_read(10);
printf("Head #1&2: %u, %u n", Head1_ADC,Head2_ADC) ;
CONDVOL=0; //10s timing expired, turn OFF 10VDC
CycOut=1; //turn off cylinder
CONDVOL_Time_Flag=0; //reset timer flag
CONDVOL_Time=0; //reset timer
Start_Flag=0; //READY for the next cycle
}
}
int ADC_read(unsigned char ch)
{
int ADC_result;
if(ch==1)
ADC0CON2 = 0x40; //Refin+/-, Ain1->AINCOM 1000000
else if(ch==2)
ADC0CON2 = 0x41; //Refin+/-, Ain2->AINCOM 1000001
else if(ch==3)
ADC0CON2 = 0x42; //Refin+/-, Ain3->AINCOM 1000010
else if(ch==4)
ADC0CON2 = 0x43; //Refin+/-, Ain4->AINCOM 1000011
else if(ch==5)
ADC0CON2 = 0x44; //Refin+/-, Ain5->AINCOM 1000100
else if(ch==6)
ADC0CON2 = 0x45; //Refin+/-, Ain6->AINCOM 1000101
else if(ch==7)
ADC0CON2 = 0x46; //Refin+/-, Ain7->AINCOM 1000110
else if(ch==8)
ADC0CON2 = 0x47; //Refin+/-, Ain8->AINCOM 1000111
else if(ch==9)
ADC0CON2 = 0x48; //Refin+/-, Ain9->AINCOM 1001000
else if(ch==10)
ADC0CON2 = 0x49; //Refin+/-, Ain10->AINCOM 1001001
ADCMODE = 0x23; // continuous conversion on Main channel on main channel
while (! RDY0) {}
ADCIN = ADC0H*0x100 + ADC0M; //Combine ADC data registers into one.
ADC_result= ADCIN;
RDY0 =0; //Clear the ADC interrupt
return ADC_result;
}
|
| Topic | Author | Date |
| ADuC848: Trouble of reading all 10 ADC channels, pleas help! | 01/01/70 00:00 | |
| Watchdog? | 01/01/70 00:00 | |
| Yes, it's watchdog reset problem! | 01/01/70 00:00 | |
| Style | 01/01/70 00:00 | |
| IF-ELSE problem | 01/01/70 00:00 | |
| Re: IF-ELSE problem | 01/01/70 00:00 | |
| still rather clunky! | 01/01/70 00:00 | |
| Re: still rather clunky! | 01/01/70 00:00 | |
| read all 10 ADC channels at once | 01/01/70 00:00 | |
| Re: read all 10 ADC channels at once | 01/01/70 00:00 | |
| Refresh | 01/01/70 00:00 | |
| Re: Refresh | 01/01/70 00:00 | |
| That slow? | 01/01/70 00:00 | |
Re: That slow? | 01/01/70 00:00 |



