Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Low battery detection with digital input

Status
Not open for further replies.

DrBudz

Junior Member level 3
Joined
Dec 5, 2011
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,500
Hello people,

Is there any way to detect low battery with digital input?

I made a mistake while designing PCB, I routed the signal from voltage divider to digital input of PIC mcu instead to analog input.

I have a li-ion battery and linear voltage regulator that drops the voltage from 4V to 3V to supply the mcu.
The voltage divider is conected to the battery, and the signal from voltage divider is routed to PORTA 4 pin on PIC 16F886.
I need to detect when the battery voltage drops to 3.3V, without modifying the pcb or circuit.

Is there any software technique to detect voltage drop on battery?

Thanks
 

You will have to make some sort of hardware modification. What unused PIC pins do you have?

Keith
 

Maybe this can help you just like an example :

http://www.mikroe.com/forum/viewtopic.php?f=10&t=16759

1493fd9d69.jpg


Code:
program BatteryMonitor
    symbol BAT_HI  = PORTA.1
    symbol BAT_MID = PORTB.5
    symbol BAT_LOW = PORTA.3
   
    dim x as word
'===============================================================================
    sub procedure MainInit
        'P16F628A
        VRCON = 0
        CMCON = 7
        OPTION_REG = 0
        INTCON = 0

        TRISA = %00010000
        PORTA = 0
        TRISB = %00000000
        PORTB = 0
       
        x = 0
    end sub
'===============================================================================
main:
    MainInit
   
    while true
        TRISA.4 = 0
        PORTA.4 = 0
        Delay_ms(10)
        TRISA.4 = 1

        x = 0
        while PORTA.4 = 0
            inc(x)
            if x >= 65000 then
                break
            end if
        wend
       
        if (x >= 125) and (x <= 145) then    ' voltage = 13V
            BAT_HI = 1
            BAT_MID = 1
            BAT_LOW = 1
        end if

        if (x >= 146) and (x <= 170) then    ' voltage = 12V
            BAT_HI = 0
            BAT_MID = 1
            BAT_LOW = 1
        end if

        if (x >= 171) and (x <= 220) then    ' voltage = 11V
            BAT_HI = 0
            BAT_MID = 0
            BAT_LOW = 1
        end if

        if (x > 220) then                    ' voltage < 11V
            BAT_HI = 0
            BAT_MID = 0
            BAT_LOW = 0
        end if
       
        Delay_ms(500)
    wend
end.


Also this can be useful :

Measuring resistance or voltage with 1 digital I/O
http://reibot.org/2011/05/23/measuring-resistance-or-voltage-with-1-digital-io/

Low-cost ADC using only Digital I/O
http://letsmakerobots.com/node/13843
 
Last edited:

I have PORTB1 and B0. I can't change the pcb design, pcb is already made.

Can I use that voltage divider and set it somehow to make logic 0 on pin input when battery voltage drops bellow 3.3V?
I'm sure it can be done, but the problem is that before it drops to logic 0, it will be somewhere between 0 and 1 (when VBAT>3.3V)...

- - - Updated - - -

Thanks Tpetar,

It's almost the same situation I have. Hope it will help.
 

The problem with using digital I/O, including various 'tricks' for trying to make an ADC out of a digital pin is that the accuracy will be very poor. You could probably make a prototype work fairly well until you change the temperature or use a different batch of PICs.

Adding a link to the PCB manually (until you get to a new batch of PCBs which are modified when you have used up the first batch) would be the logical solution.

What is your battery voltage (3.7V I assume) and regulator dropout voltage? What will stop working when the supply voltage drops (the PIC will work below 3.3V)?

It may be possible to find an alternative PIC which has more flexible I/O options but I guess that is not an option.

Keith
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top