Previous in Forum: High Fidelity Sound   Next in Forum: The Removal of Sylgard 184 Silicone Elastomer Potting From Electronic Assemblies
Close
Close
Close
Rate Comments: Nested
Participant

Join Date: Sep 2011
Posts: 4

Pic16f676a ADC Problem

06/12/2012 12:02 PM

Dear friends,
I am using Pic16f876a in my project,I wanted to read 2.5v through ADC,my result will be 10 bit ..I am using pickit 3 for debugging. I have made a function called "adc_read()",which will read the analog voltage and returns the result.in the "adc_read()" function i have used an int variable called "result",which will store the converted 10 bit result.My problem is the value i see in the "adc_read()" is different from what it return. example:
int a=0;int adc_read(char channel);

void main(){a=adc_read(4);...............................}........
in the adc_read() function variable "result" will be showing 455 ,but after the return operation variable 'a' will be showing 349. please help... i am using high tech c as compiler

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Popular Science - Evolution - New Member Popular Science - Weaponology - New Member

Join Date: May 2006
Location: The 'Space Coast', USA
Posts: 11119
Good Answers: 918
#1

Re: pic16f676a adc problem

06/12/2012 12:12 PM

First, change int to unsigned int.

Second, what are you doing for averaging the signal? I would recommend a sliding window average by summing a number of consecutive samples and dividing the resulting sum by the number of samples.

Four samples would be fine as you can do a left-shift the result by 2 (Avg = Avg >> 2;)

Third, join the Microchip Forum as you will get more help and people that are actually using that chip with experience.

The 16F has some complicated hoops you need to jump through and the documentation is not easy to find and digest (been there, done that). The Microchip forums are a huge help.

Register to Reply
Register to Reply

Previous in Forum: High Fidelity Sound   Next in Forum: The Removal of Sylgard 184 Silicone Elastomer Potting From Electronic Assemblies

Advertisement