Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Analog input when VDD is below 5V ?!

Status
Not open for further replies.

brodin

New Member
I am building a handheld device with a PIC16F876A. I have got really far in this project, and i am almost finnished.

The circuit is using a 9V battery. I want to be able to check the battery voltage with my pic to warn for low batt. Is there possible to get an 0-9 volts on the A/D inputs? How do i solve this problem?


I have thougt about meassure the voltage after the 5V REG. But will the A/D work correctly when the VDD is below 5V?

I guess it compares the VDD and the A/D port, and if both VDD and the A/D input is the same voltage, that wouldn't work, right?


Measuring on the 5V side of the REG would not be really good anyway if it works, because the circuit stops working when the voltage is below 4V or something. So the resolution would be bad.
 
brodin said:
I am building a handheld device with a PIC16F876A. I have got really far in this project, and i am almost finnished.

The circuit is using a 9V battery. I want to be able to check the battery voltage with my pic to warn for low batt. Is there possible to get an 0-9 volts on the A/D inputs? How do i solve this problem?


I have thougt about meassure the voltage after the 5V REG. But will the A/D work correctly when the VDD is below 5V?

I guess it compares the VDD and the A/D port, and if both VDD and the A/D input is the same voltage, that wouldn't work, right?.

divide the voltage of your battery by 2 using resistors
connect 2 10K resistors in series between + and - of your battery
between the 2 resistors you'll now have Vbat / 2

so 4.5 V = battery full
4 V = battery 8 V
...
 
You can also avoid using an ADC altogether. Since you are measuring the battery voltage (which is as close to DC as possible), you can simply estimate its voltage with the internal comparator in some of the pics.

There are a couple of ways to do it:

(1) Attach an RC circuit (know the time constant) to an output pin, which is initially low and to one input of the comparator. Bring the pin high and measure the time until the comparator toggles. Known the time constant allows you to estimate the battery voltage.

(2) Use/Roll a PWM in conjunction with an RC lowpass filter. The DC voltage is proportional to the duty cycle of the pulse. Increase the duty cycle until the comparator bit toggles and you can estimate the voltage.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top