----- Original Message ----- From: "Dwayne Reid" To: Sent: Tuesday, June 11, 2002 12:54 PM Subject: Re: [PIC]:strange analog in problem > At 10:14 AM 6/11/02 -0600, Micro Eng wrote: > >Using the F877, I have PortA configured for analog inputs, and had 10K pots. > >Seemed to work ok, I had a watch window set up, and a breakpoint right after > >the read sequences (for 4 pots). > > > >I've changed the pots to 50K now, and upped the aquisition time, but the > >values seem to be way off now, and are affected by each other. > > > >ie... > > > >if I read just one, it is close...but not exact. If I put the second pot in > >the loop to read, the first one goes way off scale. I've read the actual > >voltages on the pins, and they are not changing. > >Anyone ever seen where just reading a second port affects the value of the > >first one? > > You have 2 potential problems: input impedance and acquisition > time. Microchip specifies that your source impedance should be no higher > than 10K - you have a worst case source impedance of 25K (when the pot is > in the exact middle). The cure is simple - add a 0.1 - 1 uF cap from the > analog input to gnd. The cap supplies the charge required when the input > is sampled and restores full accuracy to the a/d input. This is _not_ a complete cure because, in addition to the CHOLD charge time, there is leakage on the input pin that can pull the voltage away from where the pot sets it. Bob Ammerman RAm Systems > The 2nd problem is acquisition time. You have to allow a minimum setup > time between when you select the desired analog input pin and when you > start the a/d conversion. This time is specified fully in the data sheet > but is typically 30 us or so. In other words, do this: select a/d pin, do > something useful or waste time for at least 30 us, start a/d conversion. > > Note that when you are processing the result of a conversion that has > already completed, you can select the next desired a/d channel BEFORE you > actually start processing the data. Changing the a/d input does not > corrupt the a/d result register (ADRES). > > Deal with both of those issues and see if the problems go away. > > dwayne > > -- > Dwayne Reid > Trinity Electronics Systems Ltd Edmonton, AB, CANADA > (780) 489-3199 voice (780) 487-6397 fax > > Celebrating 18 years of Engineering Innovation (1984 - 2002) > .-. .-. .-. .-. .-. .-. .-. .-. .-. .- > `-' `-' `-' `-' `-' `-' `-' `-' `-' > Do NOT send unsolicited commercial email to this email address. > This message neither grants consent to receive unsolicited > commercial email nor is intended to solicit commercial email. > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads