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

ADC

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



Joined: 05 Jun 2020
Posts: 27

View user's profile Send private message

ADC
PostPosted: Fri Jun 05, 2020 8:30 am     Reply with quote

I'm using an 16F1847 with a supply voltage of 3.3V supplied by a buck-boost regulator.
I would like to measure the incoming voltage of the regulator which is in a range of 3.0V ... 4.1V using AN11 (RB1).

How can I do?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 05, 2020 9:54 am     Reply with quote

See this topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=56711
Spaeth



Joined: 05 Jun 2020
Posts: 27

View user's profile Send private message

PostPosted: Fri Jun 05, 2020 10:42 am     Reply with quote

Thank you very much.
But there must be another way. In a further project I'm measuring the VDD voltage in an 16F1847 using the following way:

setup_vref (VREF_ON | VREF_ADC_2v048);
setup_adc (ADC_CLOCK_DIV_16);
setup_adc_ports (VSS_VDD);
set_adc_channel (FVR_CHANNEL);

Ok, it is not the VDD voltage directly what I'm measuring, but I can calculate the VDD voltage.
The question is now whether I can use sAN11 as input to the ADC instead of VDD in the same way? What do I have to change?
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Jun 05, 2020 11:55 am     Reply with quote

The point is ypu need a divider on the voltage.
The incoming voltage to an ADC channel cannot be above the Vref
or the PIC supply (whichever is lower). Since your voltage can be
above the PIC supply, you must use a resistive divider.

Now the problem of this is that it will draw power off the incoming
battery.
If this is not to be a problem, you need to turn the divider off
when it is not being used. Look at:
<https://electronics.stackexchange.com/questions/404230/do-voltage-dividers-waste-battery>

To feed the PIC ADC, you will need to use much lower resistors than this
shows. But otherwise the circuit is fine.

Now if you are using the internal Vref for the ADC reference, a division
of perhaps 0.4* will be ideal. You then switch the ADC to use the internal
Vref as it's reference, and can read the voltage.
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Fri Jun 05, 2020 11:57 am     Reply with quote

sAN11 is going to have to have a physical connection to the input voltage you want to monitor. Most likely a resistive divider like was described in the post previously provided by PCM programmer.

It cannot monitor an external voltage without some physical connection that which has to be made by you.
Spaeth



Joined: 05 Jun 2020
Posts: 27

View user's profile Send private message

PostPosted: Fri Jun 05, 2020 2:06 pm     Reply with quote

Thank for the replies!

I wanted to avoid a divider but no chance!
Now it's running using VREF and a divider.
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