Hi Graham, Thanks for your reply. Please see my comments below: At 08:35 PM 5/30/99 +1200, you wrote: >Sean, >1) if another interupt (WDT, external pin change, eeprom write) >completes then the PIC will wake again. (this would include pending >interupts caused during an A2D service interupt) If you RTFM then you >wil find more relevent answers. Yes, I suppose I wasn't being clear. I'm NOT surprised that the PIC is coming out of sleep. It is supposed to do so,when it completes the ADC conversion. What I AM surprised at (or at least was surprised) is that the oscillator SEEMS to continue to run (although with a different DC bias level) during sleep (which only lasts 50uS,which seems about right for the conversion length). > >2) you must provide adequate sample time for the internal A2D >capacitance to aquire the input voltge, this is lengthened for high >resistance path between A2D & sense voltage. Rapid sequential scaning >of multiple chanels will provide some charge sharing between the sampled >chanels. Yes, I am aware of this,and my code already waits 800 uS between enabling the ADC channel (begin of S&H) and the start of the conversion. This is about 20 times longer than the minimum wait time stated in the datasheet. > >3) you must enable the on chip A2D oscilator. Once again,I am already doing that. > >4) the voltage reference for the A2D is often the PIC's VCC, is this >stable to within significantly less than your error value ? Good question. As far as DC goes, it is staying exactly at 4.98 volts. As for AC,it turns out that there is some power supply line noise, BUT it goes down to a very low level (< 10mV) when in sleep. > >5) for long term stability it is worth noting that a 7805 regulator can >significantly alter it's "regulated" output voltage as it's temperature >changes, good heatsinking will minimise this. Thanks for the tip. I am using a 7805 but as I said above, my meter always says 4.98 when connected to Vdd. Perhaps I should restate my problem a bit. I really have TWO questions: #1) I am seeing an ADC behavior as follows: if I apply a voltage of,say,2.00 volts to the ADC, I might get a code of 102, as expected. HOWEVER, if I apply 4.00 volts, I might get 206 instead of 204. I guess that this might simply be my meter not being exact and in fact the voltage I applied originally was on the verge of giving a 103 count, BUT I see the behavior even at low voltages (1.5V or so) where my meter has much greater resolution (1.500 V). Question #2) When the PIC is placed in sleep, the ADC conversion begins and this only lasts 50uS. During this 50uS,the xtal apparently doesn't have a chance to stop oscillating. Is this a normal behavior? My guess was yes, given that the xtal could easily have a Q of several hundred,AND 50uS is only about 200 cycles at 4MHz. If it IS normal, does sleep still decrease switching noise during this 50uS? I guess the PIC internally prevents the ringing xtal from clocking it,but I am just wondering. Thanks, Sean > >Sean Breheny wrote: >> >> Hi All, >> >> Thanks in advance for any help you can give me with a problem I am having: >> >> I am trying to use the ADC on a 16C71 and I am getting an error of as much >> as 2 LSB (when the datasheet says +/- 1 LSB max). I am measuring the >> voltage directly between the ADC pin and the PIC's Vss pin and the output >> code seems to be off. I am waiting about 800 uS from the time I enable the >> ADC until I begin the conversion, and the output impedance of my source is >> 2.2K >> >> Now as to the reason why this is entitled "SLEEP": AS recommended in the >> datasheet, I am placing the pic in sleep mode during the ADC,using the >> internal RC oscillator for the ADC. My normal oscillator element is a 4MHz >> xtal with 20 pF load caps. When I observe the pic's oscillator pins with my >> scope (about 20pF loading with my x10 probe),instead of seeing the >> oscillator exponentially decay to zero during sleep (as I would expect), I >> see the DC level increase slightly and the the amplitude remain constant. >> This region of the waveform is about 50 uS long after which there is a >> small glitch and then the DC level returns back to the same as before >> sleep. Is this normal for sleep mode? I thought the whole idea was to >> disable the oscillator (and other internal PIC circuits) to prevent digital >> switching noise! Perhaps the xtal's Q is so high that it won't even begin >> to decay in only 50uS? (This is my guess, since 50uS is only a few 100 >> cycles at 4MHz,BUT if this is the case,are we loosing some of the benefit >> of sleep mode?) >> >> I know that 2 LSB error isn't that bad,but in my case,it is really annoying >> because the actual ADC count gets multiplied by 7 before being displayed on >> an LCD display. SO, if I calibrate it to be correct in one portion of the >> scale, I get as much as 14 or sometimes even 21 counts (after being >> multiplied by 7). Yeah, I know,an 8 bit ADC on a ucontroller is not a >> really precision device and multiplying by 7 is making things worse,but I >> think I could live with 1 LSB of error more easily. MORE IMPORTANTLY, I >> want to make sure I am not doing something dumb with the sleep mode. >> >> Thanks, >> >> Sean >> >> | >> | Sean Breheny >> | Amateur Radio Callsign: KA3YXM >> | Electrical Engineering Student >> \--------------=---------------- >> Save lives, please look at http://www.all.org >> Personal page: http://www.people.cornell.edu/pages/shb7 >> mailto:shb7@cornell.edu ICQ #: 3329174 >> ________________________________________________________ >> NetZero - We believe in a FREE Internet. Shouldn't you? >> Get your FREE Internet Access and Email at >> http://www.netzero.net/download/index.html > >-- >Steam engines may be out of fashion, but when you consider that an >internal combustion engine would require recovery of waste heat by >transfer just before top dead centre then fashion becomes rather >redundant, USE STRATIFIED HEAT EXCHANGERS ! and external combustion. > >You heard it first from: Graham Daniel, managing director of Electronic >Product Enhancements. >Phone NZ 04 387 4347, Fax NZ 04 3874348, Cellular NZ 021 954 196. > | | Sean Breheny | Amateur Radio Callsign: KA3YXM | Electrical Engineering Student \--------------=---------------- Save lives, please look at http://www.all.org Personal page: http://www.people.cornell.edu/pages/shb7 mailto:shb7@cornell.edu ICQ #: 3329174 ________________________________________________________ NetZero - We believe in a FREE Internet. Shouldn't you? Get your FREE Internet Access and Email at http://www.netzero.net/download/index.html