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 support@ccsinfo.com

PIC measuring voltage level from its own supply

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



Joined: 28 Aug 2014
Posts: 29
Location: Colombia

View user's profile Send private message AIM Address

PIC measuring voltage level from its own supply
PostPosted: Mon Jan 12, 2015 2:27 pm     Reply with quote

Hi to everybody,
I have a project, and one of its projected features is the ability to measure its power supply level and send it by a email message. I never have used A/D converter with PICs, so, I am not sure if this can be possible. I have read a lot of posts, but all are focused in to read a external source. The problem that I see is that the Vref will change every time I try to measure the battery level. Is there some way to program a PIC with this feature or do you have a idea? Thanks.
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 2:50 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=24560&highlight=reference+supply

Measure a known voltage reference with your A/D. As battery (supply) level drops, A/D reading will rise.
samus111



Joined: 28 Aug 2014
Posts: 29
Location: Colombia

View user's profile Send private message AIM Address

PostPosted: Mon Jan 12, 2015 3:32 pm     Reply with quote

newguy wrote:
http://www.ccsinfo.com/forum/viewtopic.php?t=24560&highlight=reference+supply

Measure a known voltage reference with your A/D. As battery (supply) level drops, A/D reading will rise.


Thanks for your collaboration, basically the post you quote is for indicate a low battery alarm, well I will explain my project better:
The uC will control a transmitter, both components will be fed by 4,2V ( a single cell LiPo battery), The transmitter will work until the battery gets around 3,7V, and I need to measure constantly the power level. So, I want take the voltage value (not the low battery indicator). The Vref always will vary if I set it with the Vcc from the PIC, I wonder if maybe there is a internal zener diode that I could configure from the PIC or something alike, thanks.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 3:49 pm     Reply with quote

Hi,

You haven't told us which PIC you are using, so all we can offer are general comments/guidelines. Most PICs will allow you to specify the A/D reference source. By specifying an external source, such as a precision voltage reference, your A/D readings will be independent of the Vcc supply voltage. The external source is then applied to the appropriate PIC pin.

Search around the forum a bit, as this topic has been well covered in the past!!

John
samus111



Joined: 28 Aug 2014
Posts: 29
Location: Colombia

View user's profile Send private message AIM Address

PostPosted: Mon Jan 12, 2015 3:56 pm     Reply with quote

ezflyr wrote:
Hi,

You haven't told us which PIC you are using, so all we can offer are general comments/guidelines. Most PICs will allow you to specify the A/D reference source. By specifying an external source, such as a precision voltage reference, your A/D readings will be independent of the Vcc supply voltage. The external source is then applied to the appropriate PIC pin.

Search around the forum a bit, as this topic has been well covered in the past!!

John

sorry, I forgot, I am using the 12f1840, I have read the datasheet of it, but I don't find if a ability just like you have commented can be possible with this PIC's family.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 4:34 pm     Reply with quote

If you are still in the design phase you might want to go back and look through the various PICs on Microchip - some of them have a built in precision reference that you can enable. A quick snoop turns up the 12(L)F1822 and 16(L)F1823 that appear to have internal references. I have not used those 2, but there are a possible solution. I know there are others as well (I have used the 18F14K22 and it has an internal vref as well you can enable although older version 4 of the compiler did not correctly handle it (I had to set the bits myself to enable it).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 5:22 pm     Reply with quote

Quote:
The problem that I see is that the Vref will change every time I try to
measure the battery level.

12F1840 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/40001441E.pdf
Quote:

14.0 FIXED VOLTAGE REFERENCE
(FVR)
The Fixed Voltage Reference, or FVR, is a stable
voltage reference, independent of VDD, with 1.024V,
2.048V or 4.096V selectable output levels. The output
of the FVR can be configured to supply a reference
voltage to the following:
• ADC input channel
• ADC positive reference
• Comparator positive input
• Digital-to-Analog Converter (DAC)
• Capacitive Sensing (CPS) module
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Mon Jan 12, 2015 6:14 pm     Reply with quote

samus111 wrote:
newguy wrote:
http://www.ccsinfo.com/forum/viewtopic.php?t=24560&highlight=reference+supply

Measure a known voltage reference with your A/D. As battery (supply) level drops, A/D reading will rise.


Thanks for your collaboration, basically the post you quote is for indicate a low battery alarm, well I will explain my project better:
The uC will control a transmitter, both components will be fed by 4,2V ( a single cell LiPo battery), The transmitter will work until the battery gets around 3,7V, and I need to measure constantly the power level. So, I want take the voltage value (not the low battery indicator). The Vref always will vary if I set it with the Vcc from the PIC, I wonder if maybe there is a internal zener diode that I could configure from the PIC or something alike, thanks.


Think about it - this approach will enable you to measure the supply voltage accurately. See what you can come up with and if you have trouble post what you have and we'll help.
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