Battery checker


Closed Thread
Results 1 to 19 of 19

Thread: Battery checker

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Battery checker

    hello

    i wrote this program below. I am putting the Vref- on the lead of a fourth diode in series . There are 4 diode connected in series so that there is always 1.6v . I assume the Vref+ and Vref- is always 2.6 differnce. It is doingan A/D convertion on a voltage divider with a max voltage of 2.5.
    The problem is that My lcd always shows me 373 (10 bit a/d) no matter what the voltage input is. Any idea what is wrong.
    SO , I have a voltage divider on the battery to bring the voltage down. Right now I am reading 1.03v with a supply at 4.57 and on the 4th diode I am reading 2.98v.
    My voltage divider I have Vdd -51Kohm -15Kohm- Vss

    'Battery test for transmit pic

    INCLUDE "modedefs.bas"
    @ DEVICE PIC16F88 , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
    DEFINE OSC 20 'use external 20mhz crystal

    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 0 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000

    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ADCON1 = %10100010
    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00000000

    input1 var word

    loop:
    ADCIN 0, input1
    'pause 30

    Lcdout $fe, 1 'Clear screen
    Lcdout "Left: ", Dec input1
    Pause 100
    Goto loop ' Go back to loop and blink LED forever

    End
    Last edited by lerameur; - 29th January 2007 at 01:09.

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I got it working but have no clue why .
    If i do what is on the pic :
    http://www3.sympatico.ca/lerameur/
    then it works.
    In this manner the output voltage also moved at the same time as the reference voltage no ?

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Talking

    Anybody ??

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Wink Rtfds !!!

    Hi,

    I think ( ! ) a look to the '88 Datasheet ( ADC config ) could help you a bit ...

    Alain

    PS: common diodes as voltage refs ... that's a bit rock and roll ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I just changes the circuit a bit. I have new ideas this morning. night was good.
    I am getting 1.06v steady on the diode as reference. My voltage divider shows me 0.7, but I am getting zero as output now.
    Is it the hardware or the programming ?
    I posted a new pic.
    http://www3.sympatico.ca/lerameur/
    also changed this line:
    ADCON1 = %10010010


    ken
    Last edited by lerameur; - 29th January 2007 at 14:36.

  6. #6
    brianwu's Avatar
    brianwu Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    but I am getting zero as output now.
    Is it the hardware or the programming ?
    I posted a new pic.
    http://www3.sympatico.ca/lerameur/

    ken
    Picture show you have both input connected to same place (ref. diode), resistor divider left unconnected.

Similar Threads

  1. Of battery discharge curves
    By ardhuru in forum General
    Replies: 0
    Last Post: - 21st January 2009, 16:24
  2. Low battery signal from an RTC
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th March 2008, 17:13
  3. Replies: 1
    Last Post: - 20th December 2005, 03:56
  4. Help with setting adcon1 for 16f877
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th August 2005, 11:13
  5. Battery backup with long delay
    By Dwayne in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th January 2004, 20:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts