Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic18f458 adc channel problem

Status
Not open for further replies.

Faisal Nouman

Junior Member level 1
Joined
Sep 22, 2011
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Pakistan
Activity points
1,399
hello
i am using pic18f458 controller
the input to the controller is from accelerometer and output is being displayed on lcd
i had a same problem twice now
the first channel of adc does not work (it was working quiet well before but suddenly it stops working)
when the same input was fed to other channel, results were good but first channel is damaged
it happens to me 2nd time and i am worried now
circuit diagram is attached please help me out to troubleshoot the problem

 

Did you disable the analogue comparator?

As you can see, RA0 is connected to AN0 but is also connected to CVREF.

So, if you haven't done so already, disable the comparator:
Code:
CMCON=7;

Hope this helps.
Tahmid.
 

It is good practice to have a filter on the input to the A/D input pin.
A 1K series resistor to the pin and a 100nF ceramic cap connected between the pin and ground.
This reduces any high voltage spikes that might be damaging your inputs.

It is also good practice to have some decoupling caps on the power supply close to the IC's.
 
no i did not disable the comparator
i am using mikroC as a compiler
this is my code

unsigned long adc_valuey;
unsigned long adc_valuez;

void Display_Valuex() {

if (valueinx/10000)

xx[0] = valueinx/10000 + 48;
else xx[0] = ' ';
xx[1] = (valueinx/1000)%10 + 48;
xx[2] = (valueinx/100)%10 + 48;
xx[3] = (valueinx/10)%10 + 48;

Lcd_Out(1, 3, xx);}

void Display_Valuey() {
if (valueiny/10000)
yy[0] = valueiny/10000 + 48;
else yy[0] = ' ';
yy[1] = (valueiny/1000)%10 + 48;
yy[2] = (valueiny/100)%10 + 48;
yy[3] = (valueiny/10)%10 + 48;

Lcd_Out(1, 12, yy);}

void Display_Valuez() {
if (valueinz/10000)
zz[0] = valueinz/10000 + 48;
else zz[0] = ' ';
zz[1] = (valueinz/1000)%10 + 48;
zz[2] = (valueinz/100)%10 + 48;
zz[3] = (valueinz/10)%10 + 48;

Lcd_Out(2, 6, zz);
}

void main() {

TRISC = 0x00;
TRISA = 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,message0);
Lcd_Out(1,10,message1);
Lcd_Out(2,4,message2);

do {
adc_valuex = ADC_Read(0);
adc_valuey = ADC_Read(1);
adc_valuez = ADC_Read(2);

valueinx = adc_valuex*10;
valueiny = adc_valuey*10;
valueinz = adc_valuez*10;

Display_Valuex();
Display_Valuey();
Display_Valuez();
delay_ms(500);
}
while(1);
}
 

no i did not disable the comparator
i am using mikroC as a compiler
this is my code

So, disable the comparator in the main code by writing
Code:
CMCON=7;

Hope this helps.
Tahmid.
 
can you tell me why only the first channel is damaged twice ( RA0 pin)
why other channels are not destroyed ?
 

It's not really "damaged". It's multiplexed to the analogue comparator as the reference voltage. So, to use it as an ADC channel, you have to disable the comparator. The other channels aren't multiplexed to comparator, so you don't notice it.

Hope this helps.
Tahmid.
 
yeah now i understand it
that is why it was giving continuously 4v which were constant
thanks a lot brother :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top