Battery checker


Results 1 to 19 of 19

Thread: Battery checker

Threaded 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.

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