View previous topic :: View next topic |
Author |
Message |
Spaeth
Joined: 05 Jun 2020 Posts: 27
|
ADC |
Posted: Fri Jun 05, 2020 8:30 am |
|
|
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
|
|
|
Spaeth
Joined: 05 Jun 2020 Posts: 27
|
|
Posted: Fri Jun 05, 2020 10:42 am |
|
|
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: 19515
|
|
Posted: Fri Jun 05, 2020 11:55 am |
|
|
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
|
|
Posted: Fri Jun 05, 2020 11:57 am |
|
|
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
|
|
Posted: Fri Jun 05, 2020 2:06 pm |
|
|
Thank for the replies!
I wanted to avoid a divider but no chance!
Now it's running using VREF and a divider. |
|
|
|