CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

a/d reading jumping all over the place

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
username
Guest







a/d reading jumping all over the place
PostPosted: Tue Mar 23, 2004 6:08 pm     Reply with quote

I have a 16f877A set up with all analog on port A, when I read a port i get values that are jumping all over the place.

main() {
setup_adc_ports(ALL_ANALOG); setup_adc(ADC_CLOCK_DIV_32); set_adc_channel(0); delay_us(10);
rms_grid = read_adc();
delay_us(10);
set_adc_channel(1);
delay_us(10);
rms_gen = read_adc();
delay_us(10);

.......

the values seem almost random eventhough they are tied to a constant voltage for testing. i put in a loop and printf statements to monitor the values and its just all over the place

thanks.

can someone give me some idea to settle the values i am reading
Guest








PostPosted: Tue Mar 23, 2004 6:17 pm     Reply with quote

what have you connected to the pin, is it just floating??
username
Guest







a/d
PostPosted: Tue Mar 23, 2004 6:33 pm     Reply with quote

actually what i have it connected to is a simple voltage divider. i am wanting to monitor the level of a 12v battery, and yes they have a common ground. So since the voltage is from a battery it is a static value but the a/d is giving random values.

I will try a new pic when i get one. I have used them before and got a fairly stable reading, since i am using 'all analog' the reference should be vcc so it should give me a stable reading.........
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 6:41 pm     Reply with quote

What resistor values are you using in your voltage divider ?
There could be a problem if they are too large.
username
Guest







a/d
PostPosted: Tue Mar 23, 2004 7:53 pm     Reply with quote

they are fairly high, i was trying to minimize the current in the divider, i dont have the cct here and cant remember the values used off hand.

i will reduce their value and give it a try.

thanks
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 9:07 pm     Reply with quote

According to the device datasheet, the maximum recommended impedance for analog sources is 10 kΩ.
kable
Guest







a/d
PostPosted: Tue Mar 23, 2004 11:09 pm     Reply with quote

hummmm I wonder if the problem is that the voltage is being sampled from a voltage divider and its loading it down. I wonder if I should throw in a buffer. Shouldnt the a/d have a high impedance and not load the input?

ohh well
tywais



Joined: 01 Apr 2004
Posts: 1
Location: Chiangmai Thailand

View user's profile Send private message Visit poster's website

PostPosted: Thu Apr 01, 2004 1:00 am     Reply with quote

I just finished designing a data acquisition system using a 16F877 and had the same problem before I realized I forgot to set the ADFN bit for right justified ADCON1 = %10000000 else your bottom 6 bits are all zero and you will be getting the 4 lsb's at the top of the resulting word.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group