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 CCS Technical Support

Help reading in analog signal
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
weg22



Joined: 08 Jul 2005
Posts: 91

View user's profile Send private message

PostPosted: Thu Nov 16, 2006 9:07 am     Reply with quote

Mark:
Thanks for the suggestion, but that didn't work either :-(

Ttelmah:
I checked all Vss and Vdd pins and they're all connected. I am powering my circuit with 12V and feeding through a 5V regulator to power my PIC. I doubt this could be the source of the problem?

Also, I change my TX and RX pins for serial output to PIN_G1 and PIN_G2 (used to be A4 and A5). This should also eliminate the other problem you were referring to...and still I'm getting the same result.
weg22



Joined: 08 Jul 2005
Posts: 91

View user's profile Send private message

PostPosted: Thu Nov 16, 2006 9:46 am     Reply with quote

Perhaps this is a clue? All of my analog pins (at least the ones I can safely check) are HIGH including the one that I'm feeding the voltage from my sensor into. I'm not sure this is normal especialy since I'm only specifying AN0 as analog?
Ttelmah
Guest







PostPosted: Thu Nov 16, 2006 10:44 am     Reply with quote

weg22 wrote:
Mark:
Thanks for the suggestion, but that didn't work either :-(

Ttelmah:
I checked all Vss and Vdd pins and they're all connected. I am powering my circuit with 12V and feeding through a 5V regulator to power my PIC. I doubt this could be the source of the problem?

Also, I change my TX and RX pins for serial output to PIN_G1 and PIN_G2 (used to be A4 and A5). This should also eliminate the other problem you were referring to...and still I'm getting the same result.

What decoupling is round the chip, and the regulator?. If this is something like a 7805, it needs something like a 10uF electrolytic, in parallel with a 0.1uF ceramic capacitor _close_ to the regulator on it's output pin to prevent oscillation. The PIC also really needs a couple of small ceramic capacitors close to the chip.

Best Wishes
weg22



Joined: 08 Jul 2005
Posts: 91

View user's profile Send private message

PostPosted: Thu Nov 16, 2006 12:54 pm     Reply with quote

Umm...I know this is bad practice, but I have no capacitors on my board. Do you really think this could be the problem?

Has anyone looked at the errata sheet (page 2) where it talks about A/D conversion for the 18F8722. It states 3 things:
1. Configure the A/D to use the VREF+ and VREF pins for the voltage references. This is done by setting the VCFG<1> bits (ADCON1<5>).
2. Perform a conversion on a known voltage reference voltage and adjust the A/D result in software.
3. Increase system clock speed and adjust A/D settings accordingly. Higher system clock frequencies decrease offset error.

I'm not sure how to do #1? I tried #3 by using the ADC_CLOCK_2. I was able to get values that fluctuated with distance with the setup_adc functions outside the while loop...but the values only fluctuated slightly => 890-920.
newguy



Joined: 24 Jun 2004
Posts: 1946

View user's profile Send private message

PostPosted: Thu Nov 16, 2006 1:54 pm     Reply with quote

[Grip desk firmly, tense arm muscles, whack head into desk. Repeat.]

Sorry. Now I feel better.

Add the caps, then come back if problems persist.
weg22



Joined: 08 Jul 2005
Posts: 91

View user's profile Send private message

PostPosted: Fri Nov 17, 2006 7:09 am     Reply with quote

Haven't added the caps to my PCB board b/c that's a little time consuming. However, I did breadboard an identical circuit with a 16F877 (and 7805 regulator) with *no* caps and the ADC was working perfectly. Do you still think the caps are the problem?? If so, I will add them.

Thanks!
Ttelmah
Guest







PostPosted: Fri Nov 17, 2006 8:11 am     Reply with quote

Capacitors are needed to help ensure stability on the regulators. Read the data sheet on this. Individual units will differ as to how bad the effects are, and different layouts will change the behaviour. They are also needed by the PIC itself, again how many, and where, will change with board layout.
If you have ever played with audio circuitry, you will now how easy it is to make something oscillate when a high gain stage is involved. A voltage regulator, is a high gain amplifier, and unless properly laid out, will not work as expected. Tiny changes in the layout, can determine whether oscillation actually occurs.

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 17, 2006 5:37 pm     Reply with quote

weg22 wrote:
Haven't added the caps to my PCB board b/c that's a little time consuming. However, I did breadboard an identical circuit with a 16F877 (and 7805 regulator) with *no* caps and the ADC was working perfectly. Do you still think the caps are the problem?? If so, I will add them.

Thanks!


If the code worked in the other circuit then obviously it is a hardware problem which is most likely caused by the layout.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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