Jump to content

Recommended Posts

This is perhaps not directly related to a programming issue, so I have not posted any code.

I am using a 16F877A ADC channels; I'm fairly sure I've got all the configuration register set up OK, as much of the code has been 'upgraded' from my previous version run on an '876.

My problem seems to be more hardware related; I am using all 5 ADC channels on Port A, leaving the 3 on Port E as digital. As the project progresses, I have only 3 of the channels connected to an analogue source - two are LM335 temp. sensors with calibration pots and the third is a potential divider to a backup battery. The 2 remaining channels presently only have the pots. connected, no temperature sensors, giving about 4.0V at the PIC input.

The problem is that each channel returns the same value, more or less, i.e. about 20 deg C as room temperature. I can vary the input voltage to the channel connected to the potential divider over the range 0 - 5V, but the ADC value remains unchanged.

I had noticed this effect when I previously had only one channel connected to an analogue source and the rest 'floating' when the unconnected channels gave the same value as the one with a true source. But I did not expect this behaviour when all channels connected to some source.

Is my PIC pickled??!! ( I hope not, its a TQFP on an expensive module!)

 

Any suggestions welcome.

 

:(

Share this post


Link to post
Share on other sites
This is perhaps not directly related to a programming issue, so I have not posted any code.

I am using a 16F877A ADC channels; I'm fairly sure I've got all the configuration register set up OK, as much of the code has been 'upgraded' from my previous version run on an '876.

My problem seems to be more hardware related; I am using all 5 ADC channels on Port A, leaving the 3 on Port E as digital. As the project progresses, I have only 3 of the channels connected to an analogue source - two are LM335 temp. sensors with calibration pots and the third is a potential divider to a backup battery. The 2 remaining channels presently only have the pots. connected, no temperature sensors, giving about 4.0V at the PIC input.

The problem is that each channel returns the same value, more or less, i.e. about 20 deg C as room temperature. I can vary the input voltage to the channel connected to the potential divider over the range 0 - 5V, but the ADC value remains unchanged.

I had noticed this effect when I previously had only one channel connected to an analogue source and the rest 'floating' when the unconnected channels gave the same value as the one with a true source. But I did not expect this behaviour when all channels connected to some source.

Is my PIC pickled??!! ( I hope not, its a TQFP on an expensive module!)

 

Any suggestions welcome.

 

:(

 

When you "upgraded" from the 16F876 to the 16F877A did you change the setup of the peripherals on PORTA to accomodate the differences between these parts? Theses two platforms are similar but there are many differences, most of which pertain to PORTA. For example, the 877A has a divisor bit for the ADC clock. The 877A also has a comparator module which defaults to enabled which overrides the ADC converter. There are other differences. Try setting up a watch window for the all of the peripheral control SFRs on PortA and post them. It's probably something simple like that. If the ADC input is fried it's far more likely to read 0x3FF or 0x000.

Share this post


Link to post
Share on other sites

Many thanks for your response. I hadn't realised there could be any conflict with other functions; I'll need to take a closer look at the data sheet.

Are you referring to the Compare/Capture function?

 

Regards,

Mike W

Share this post


Link to post
Share on other sites
Many thanks for your response. I hadn't realised there could be any conflict with other functions; I'll need to take a closer look at the data sheet.

Are you referring to the Compare/Capture function?

 

Regards,

Mike W

 

The "A" version of the part has new feature which adds a hardware comparator (like an op-amp). The comparators default to enabled which overrides the ADC converter. The capture/compare you're referring to is part of the PWM peripheral on PORTC. Don't forget the differences in the ADCONx bits also.

Share this post


Link to post
Share on other sites

Thanks for all your help, but I'm still a little confused. I have scoured my Microchip data sheet for the 16F87XA PICs but cannot find any reference to the features you mention over-riding the ADC; can you be a bit more specific? I have ADCON0 and ADCON1 set up correctly; having tried a few variations on the code to read the ADC the only firm conclusion is that only channel 0 is read, that is, reads of channel 1 - 4 all return the same value as channel 0. I'm really beginning to suspect that my PIC is fried!

 

Regards,

Mike W

Share this post


Link to post
Share on other sites

For the sake of anyone considering this post, an update.

I have a test program designed for use with the module I'm using. It's really designed to verify the USB connection but also allows access to some limited features of the '877A, including ADC channels. Using this test program I have determined that the ADC channels work as expected, so the PIC is not pickled!! About the only difference I can find between this tester and my code is that it uses the internal clock for ADC operation. The PIC has a 20MHz clock, which I have used with the 64 divisor. According to the data sheet this should be OK at 20MHz - so what am I doing wrong??

Next step will be to modify my code to use the internal clock and see what happens.

 

Any comments from PIC experts welcome.

 

Regards,

Mike W

Share this post


Link to post
Share on other sites

From section 12.0 of the datasheet:

 

"The inputs to the comparators are multiplexed

with I/O port pins RA0 through RA3, while the outputs

are multiplexed to pins RA4 and RA5."

 

Did you turn off the comparators?

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...