Battery checker


Closed Thread
Results 1 to 19 of 19

Thread: Battery checker

  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.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I got it going somehow. I dont even know what I was doing wrong...
    maybe I am still sleeping
    k
    Last edited by lerameur; - 29th January 2007 at 17:18.

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Ok I think I know where lies the confusion.
    Ihave two batteries I want to check.I can check the battery that powers the microcontroller with voltage reference. I am trying to check the second battery . There is no common ground and I dont want one because of the isolation I want to have. Therefore I think when I do an A/D, is reads as a floating value.
    How do I go around this ?

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    lerameur, Why not just read the total voltage of the series connection and then the lower cell voltage. Then subtract the lower voltage from the total voltage to get the upper cell voltage? That way you only have 1 ground connection.

    Dave Purola,
    N8NTA

  10. #10
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    the batteries are not in series. One 12v battery for the controller, and a 24v (well 2 12v battery in series) for the motors. That is if I understood you correctly
    k

  11. #11
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    lerameur, After my reply I re-read the post and understood the grounds are not common. Is this true? Why can't you common the grounds?

    Dave Purola,
    N8NTA

  12. #12
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I want to isolate the circuit . There was too much harmonics on the ground, it was killing the microcontroller.
    what about an opto coupler ?
    I am also looking some amplifier , any thoughts on this one: ISO124
    Last edited by lerameur; - 30th January 2007 at 22:42.

  13. #13
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Ground Loops

    Quote Originally Posted by lerameur View Post
    I want to isolate the circuit . There was too much harmonics on the ground, it was killing the microcontroller.
    what about an opto coupler ?
    I am also looking some amplifier , any thoughts on this one: ISO124
    Hi leramuer,
    about 35 years ago I worked for a company that made audio gear for radio stations and such. I remember, talking to the engineers about ground loops and they advised using 1 common tie point for all grounds, period. You might try that for the problem you mentioned.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  14. #14
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    lerameur, Joe S. is right.... I have been designing test systems for about 30 years and have repaired problems with systems that stemed from having multiple grounds. If I was to design the type of system you are talking about I would have 1 single ground point. The noise you are talking about (upsetting the processor) is more than likley caused by the current being drawn from the 24 volt return from the motor drive system and where you are sensing or referencing the ground. I can't beleive that the processor 12 volt supply is that noisy or is drawing that much current. If both battery system returns were tied together at the batterys this should eliminate most of your problems. How much current is the 24 volt motor supply battery required to deliver?

    Dave Purola,
    N8NTA

  15. #15
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    so basically tieing the two grounds together? then why not use a single battery for everything, wouldn't that be the same?
    I am using about 2.5A for the motor battery.
    you are saying that the harmonic going back to the battery will not affect the microcontroller ?
    I suppose the harmonics is g0ing back on the ground, therefore affecting all the grounds in the system ?
    I dont have 35 years experience like you guys, just trying trying to learn.
    Last edited by lerameur; - 31st January 2007 at 13:39.

  16. #16
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    lerameur, If your current is not exceeding more than 2.5 amps I have to ask, What gage wire are you using to supply the motor drive electronics from the battery? You could see spikes in the current if your drive electronics have crossover problems with the H switch or if you are driving a low resistance load. This is why you should have the drive electronics wired as a separate set of feeds to the battery. What type of battery and size are you using for the drive electronics and what kind and size are you using for the microprocessor electronics? I have in the past build robotic drive systems that run off of a single 12 volt battery driving the controller electronics and dual H bridge drive electronics that can supply upto 100 amps. The only thing I had to do is to place a LC network in series with the microprocessor supply to kill some of the noise as I was using the A/D convertor on board the processor with a gyro rate sensor. The battery I used was an 18 amphour 12 volt used for UPS supply's.

    Dave Purola,
    N8NTA

  17. #17
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    hi
    When i was blowing up my microcontrollers, I was using a single 12v battery at 7AH. 20Gauge wire between the battery and motor (via the h-bridge) I was actually running at 1.95Amp.
    Now I added opto couplers between the microcontroller and the h-bridge. I am still working on the circuit, should be powering it up today.
    k

  18. #18
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    lerameur, Where are the opto isolators used in the circuit?

    Dave Purola,
    N8NTA

  19. #19
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    opto isolators (mct6) between the microcontroller and h_bridge

    ken

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