PDA

View Full Version : 18F2520 ADC issue



Acetronics2
- 23rd May 2008, 09:32
Hi,

A little thing I do not understand :

I have a 4.096 voltage ref for ADC
Input sees a LM335 , through a 10k/.22µ L.P.F., powered from 5 v with a 2.2k series resistor.
Wiring to lm335 is ground shielded.

Everything has worked fine for 25+ hours ... ( reading Ok ... etc,etc ...)


Now,

An ADC input overflow has occured ( logged by the system ) that should NEVER had happend ... and the ADC result now is DIVIDED by 2 !!!

a ( say many ! ) system reset did not change anything ...


I took the chip off to read its logging values and just rewrote the "wrong logged" data. ( NO change to the program ).


Pic placed Back to its place ...

ISSUE has disappeared... everything fine again.



Soooo ...

Is there some limitation on ADC input voltage relative to the ADC Vref ??? ...

Yess ... Parameter A25 ( Midrange data ) says ... Vref + 0.3v !!! , that seems logical not to input more than what can be read, ... but no such issue specified ...

Alain

skimask
- 23rd May 2008, 15:19
I am just wondering if there are some one know how to change c code to picbasic.
Or if some one can help me to write PICBASIC code for LCD03
I also use BASIC.

How did this go from Ace's ADC issue to converting code from C to PicBasic?
If you know C (cut and paste from some website somewhere?), then reading your code in Post#3 and converting that to a similar PicBasicPro program should be easy enough. Looks easy enough to me...but that's just me...


ADC issue - maybe a spike on the A/D input, CMOS latchup or something similar?

mister_e
- 24th May 2008, 01:38
What about if you add some clamping diode, but instead of sending them to Vdd, send them to Vref... well a buffered Vref.

Acetronics2
- 24th May 2008, 18:20
Hi, Steve

Good idea ... I've placed a low-leakage BAW62 ... hope my TL431 ref. will agree !!!

Alain

Acetronics2
- 22nd May 2009, 20:30
Hi, pros

One more 18F2520 Out of use after 30 Hours of good work, like the others, and still the same AN2 ADC input leakage current tremendously increasing. ( I repeat here AN1 has EXACTLY the same input circuit : a LM335 fully filtered and clamped : a 10k resistor in series ...).

EVERYTHING has been carefully verified ... Even Microchip gurus didn't have anything to reply ...

another " damaged " circuit has been continuously running for more than a year ... all other analog inputs are still Ok !!!

Has anyone a little idea ???

Date Markings are 07204AY ...

Alain

Jerson
- 23rd May 2009, 02:24
Alain

I'm not sure if just powering off and on the PIC would solve your problem. Most likely it would if the input protection got clamped on a spike and stayed stuck(latched). I've seen similar behaviour in other hardware with input protections and the usual way to recover was a power cycle. Is it possible for you to rule that out?

Jerson

Darrel Taylor
- 23rd May 2009, 03:23
... and still the same AN2 ADC input leakage current tremendously increasing.
Is there any possibility that the CVRCON register is getting modified somewhere along the way?

Either intentionally ... CVRCON = %11000000

or Unintentionally ... if you have ASM in your program and are in the wrong bank when writing to address B5.

If the CVref is turned on, and the CVROE bit is set, the CVref will output on RA2/AN2/VREF-/CVREF.
<br>

Acetronics2
- 23rd May 2009, 09:36
Hi, Darrel and Jerson

CVRCON would be a good Idea ... but it is cleared at each power-up, and there's no asm ... other than DT Instant interrupts !

but the ADC still works ( it follows input, but as if a ghost divider was placed : for 3.4 v @ sensor input it "sees " 2.28v - confirmed by the voltmeter placed on the input pin )

Now, after a power down, the problem comes back , first times after ~ half an hour, then quicker and quicker ... and finally at power up and continuously.

if re-programming the device ... the problem still is here.

Note the problem only occurs after ~ 30 Hours of work ... whether the chip stays in sleep mode ( 400 Hours ) or powered down.

May be I should try another chip ... a 2580 i.e. ...

Alain

Jerson
- 23rd May 2009, 12:28
Repeated failure after a fixed duration suggests stack problem to me. I can suggest you check the nesting levels in your code and if you have sufficient stack left over for interrupts use. Due to stack failure, the program could be returning to a wrong location and somehow modifying the CVRCON register and turning the AN2 port to output VREF. There may be other symptoms that accompany this.

Acetronics2
- 23rd May 2009, 12:52
Hi, Jerson

as the AN2 input permanently stays "damaged" after some times ... I do not think it could be a stack or soft problem ...
as I wrote : re-programming the chip do not solve the issue ...

let's say the program continue to run pretty fine, of course excepting what relies to AN2 input ...

I must make some tests with RA2 as digital input/output ... just to try to see if something abnormal and verify if it is in the ADC input multiplexer or in the clamping diodes that the problem is ...

Alain

Acetronics2
- 24th August 2009, 16:11
Hi,

I finally found something ...

I used AN0 to AN2 ... and AN3 for external reference.

Innocently ... I had declared AN3 as analog in the ADCON1 register.

Looking closer to the Datasheet ... The reference DO NOT use the ADC multiplexer path.

So, I declared AN3 as digital ...

AND The right AN2 value re-appeared !!!



BUT that is because I do not use AN's inputs greater than 2 ... I would have to valid AN3 as Analog if using AN4 ...

So problem is still here.

I Just found a Turnaround ...

Alain