Shop OBEX P1 Docs P2 Docs Learn Events
ActivityBot Detecting Battery Level — Parallax Forums

ActivityBot Detecting Battery Level

djgsi974djgsi974 Posts: 16
edited 2014-08-21 11:40 in Robotics
Hi everybody.

In the tutorial for the activity board (http://learn.parallax.com/propeller-c-simple-circuits/measure-volts) it says :
Voltage is like a measure of electrical pressure, and measuring voltage answers questions like: “How much life is left in this battery ?”
I'd like to add a battery level indicator to my robot (activityBot), but there is no details on this tutorial for that.
I can measure voltage from the 3.3v or 5v, but it seems that it just answers the question : "is there sufficient voltage or not ?".
At what voltage must i consider that the battery level is low ?
The integrated components transform the 5x1.5v (7.5v) in 5v or 3.3v, so it's difficult for me to understand.
So, does anybody know if it's possible to have a battery level indicator : in percentage for example, and how to do this in this case.

Thanks in advance.

Comments

  • bomberbomber Posts: 297
    edited 2014-04-29 08:10
    The Activitybot''s board has a built in ADC, which measures something like 0-3.3 or 5V. Since the battery voltage is higher than that, you will need to put it through a resistor divider (1 resistor at ground, 1 resistor at +v source, and tie the two resistor's together, and that point will have a lower voltage proportional to the input voltage. How that voltage translates to a percentage varies wildly from battery type to battery type; if you are using rechargeable batteries google may have the answer, but if not you can simply observe how long it takes between battery cycles. A similar thing can be done with non-rechargeable batteries.
  • djgsi974djgsi974 Posts: 16
    edited 2014-05-05 10:13
    Hi Bomber, and thank you for your answer.
    If i understand : my rechargeable battery is a 7.4v 4000 mA/h : so i don't matter about the 4000 mA/h but just the voltage.
    the schemas should be that :

    schemas.jpg


    I must start to test my battery (with a volt-meter) when it's completely charged (to know the exactly max voltage because i know that some battery give more that is indicated when it is charged).
    i make the hypothese that the max voltage is 8v
    If i use R1=470ohms and R2=470ohms -> the max voltage i read is 470/(470+470) x 8 = 4v. (or 3.7v if the max is 7.4v instead of 8v)
    I know that the minimum voltage for the motors for the activityboy is 6v (we have problems when we drop below 6 V) -> so i can consider minimum read voltage = 3v (low battery).
    And i can have a percentage : (read voltage - 3) / (max read voltage - 3) * 100.
    Exemple : 3.8v -> 80 % (if the battery max is 8v)
    Exemple : 3.9v -> 90 % (if the batttery max is 8v)
    Exemple : 3.5v -> 72.42 % (if the battery max is 7.4v)

    Do you think i'm right ? Sorry to ask you to confirm, but i'm a beginner in electronic and robotic, and i don't want to crash my robot.
    And sorry for my approximate english.

    See you soon.
    1024 x 286 - 31K
  • djgsi974djgsi974 Posts: 16
    edited 2014-08-18 10:53
    djgsi974 wrote: »
    Hi Bomber, and thank you for your answer.
    If i understand : my rechargeable battery is a 7.4v 4000 mA/h : so i don't matter about the 4000 mA/h but just the voltage.
    the schemas should be that :

    schemas.jpg


    I must start to test my battery (with a volt-meter) when it's completely charged (to know the exactly max voltage because i know that some battery give more that is indicated when it is charged).
    i make the hypothese that the max voltage is 8v
    If i use R1=470ohms and R2=470ohms -> the max voltage i read is 470/(470+470) x 8 = 4v. (or 3.7v if the max is 7.4v instead of 8v)
    I know that the minimum voltage for the motors for the activityboy is 6v (we have problems when we drop below 6 V) -> so i can consider minimum read voltage = 3v (low battery).
    And i can have a percentage : (read voltage - 3) / (max read voltage - 3) * 100.
    Exemple : 3.8v -> 80 % (if the battery max is 8v)
    Exemple : 3.9v -> 90 % (if the batttery max is 8v)
    Exemple : 3.5v -> 72.42 % (if the battery max is 7.4v)

    Do you think i'm right ? Sorry to ask you to confirm, but i'm a beginner in electronic and robotic, and i don't want to crash my robot.
    And sorry for my approximate english.

    See you soon.

    Hi everybody no response. For everybody that is interresting about that, the solution is working fine.
    I used 2 x 20 KOhm resistors.
    See you soon.

    PS : if you want to see my bot (in construction), you must go there :https://djgsi974.wordpress.com/
  • photomankcphotomankc Posts: 943
    edited 2014-08-20 14:58
    Couple of things to consider:

    At 40K Ohms Total for your divider you're voltage at the ADC is generated by about 200 microamps of current. That's likely to mean that even small amounts of local noise can swamp out the signal. I would prefer about a 10X stronger source. Even small changes in voltage there can make it appear that battery is several percent more or less charged. I'd prefer 2K resistors in that case. It's a mostly static signal so averaging can clean up the numbers a lot if you only are reading voltage every few seconds or minutes.

    I'm assuming that you are using a LiPO/LiON battery based on the 7.4v @ 4000 mAH. So don't base 100% on the max a battery might show right off the charger. That will skew your percentages badly because that voltage only lasts a very short time. Base it on the conservative 7.4 to 7.6V instead. The discharge graph between 7.4 and 6.3 will be fairly flat and predictable. Outside that it gets very steep and difficult to accurately show percentage. Don't play around too close to the 6.0V level. The additional runtime gained is short and not worth the hazard of over-discharging the cells.

    If you are using NiMH batteries the discharge graph is even worse. It's very difficult to present a percentage for those batteries based on voltage. Instead it's easier to just have Full / Partial / Low set points and react accordingly. They are a serious pain though. The voltage is 'springy', in that it bounces up.... by a lot when the load is removed and even really dead cells will build back up enough to seem useable when they sit for a while so make your set points one way traps. Once the "low" point is reached don't reset to "partial". Instead It has to reach "full" again to reset.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-08-20 15:06
    Instead of lowering the resistance, I would simply add a cap across the lower resistor of the divider. This will effectively lower the impedance to AC noise. In any event, you don't want the battery level detector to drain the battery! :)

    -Phil
  • photomankcphotomankc Posts: 943
    edited 2014-08-20 19:42
    True, I've just had better luck in practice with a stronger source to sample than I have with caps. At 1.85mA I think his run time would be reasonably safe at 90days. Maybe 8K total (4K / 4K) instead for about 1ma and get out to 180 days!

    ;)
  • djgsi974djgsi974 Posts: 16
    edited 2014-08-20 21:06
    Hello photomankc and Phil.

    Thank you for you responses.
    For information photomankc, the battery is a Li-ion one, and thank you for you explanation for the usage of it (min, max etc...).

    So, what is the better solution for you : i prefer to have a low level consumption for the current.
    I can change the resistors, and add a capacitor if it is necessary : but what should be the model, and what should be the value of it, or how to calculate it ? I suppose that i must connect the first pin to the output of the divider, but the second pin : must i connect it to Ground of the battery (-) ?

    Sorry, my question certainly seems stupid, but i'm a beginner (and sorry too for my poor english, i'm french).

    See you soon.
  • photomankcphotomankc Posts: 943
    edited 2014-08-21 09:47
    If you prefer lower current consumption then you may prefer Phil's solution. The selection of the capacitor will depend on the frequency of the noise you are trying to suppress. As this is a static signal you can use a larger capacitor which has the effect similar to putting a rock on the end of a slinky. The heavier the rock the less the end is going to move even if you wiggle the slinky around violently. If you stay with high resistance then that could help. The other idea is to sample say every 1/2 second and average over 5 seconds. Even a fairly noisy signal should even out. Or do both. The capacitor also helps feed the ADC input a nice, low resistance source for it's sampling circuit. Capacitor value of maybe 1 - 10uf given the 20K resistance? If my calculation is right 5uf should nearly block out any frequency above 7Hz by 80%.

    You are correct on the placement. One lead (+) goes to the divider output and the other (-) to ground. Electrolytic capacitors, as I understand it, are not good for this application.
  • djgsi974djgsi974 Posts: 16
    edited 2014-08-21 11:40
    Hi !
    Thanks a lot, it's perfect. I finaly use a 10uf capacitor (have nothing else in stock).
    bye.
Sign In or Register to comment.