How Long Does A GoPiGo3 Go When It Doesn't Go Go?

gopigo3
noteworthy-answer

#1

How Long Does A GoPiGo Go When It Doesn’t Go Go?

I was wondering “How long will my GoPiGo3 run if it only contemplates its navel?

The following is the report of my experiment.

Required elements:

  • GoPiGo3 with updated firmware
  • Fully charged 8x AA NiMH cell batteries in standard GoPiGo3 battery holder.
  • Configured Raspian For Robots with updated Dexter Industries software
  • Optional: Voltmeter, DC-Clamp-On Ammeter, (or special cable and in-line ammeter)

Steps:

  • Make sure batteries/battery pack is fully charged
    – Each battery measures about 1.5v individually at no load
    – Battery Pack measures about 12v at no load
  • Connect battery cable
  • Press GoPiGo3 Power Button
  • About a minute after power light turns solid green,
    login to GoPiGo3 via ssh or browser terminal session
  • mkdir batterytest
  • cd batterytest
  • nano measureLife.py
  • copy/paste the program below into the terminal window
  • cntl-X, y to exit and save file
  • chmod 777 measureLife.py
  • type: ./measureLife.py (doesn’t shutdown properly with “python measureLife.py”)
  • record first battery voltage reading
  • record battery voltage reading every 60 minutes until GoPiGo shuts down
  • Wait for blinking green light, then press power button to turn GoPiGo3 off
  • Disconnect battery cable and connect to charger
  • Compute average voltage (V1+V2+Vn)/n

Questions To Answer:

  • How long will a GoPiGo3 go when it doesn’t go go?
  • What can we calculate from this knowledge?
    – Average Battery Pack Voltage (V0+V1+V2+Vn)/n
    – Estimated Available Power (Watt-Hours) in Battery Pack
    (Time * Vaverage * Iestimate=0.275A for Idle Battery Draw with Pi3B)
    – Estimated System Load at idle in watts (Vaverage * Iestimate=0.275A)
    – Given a 9.6v 2000mAh battery pack, how long might a GoPiGo3 contemplate his navel?
    (Use measured Vaverage, and Estimated system Load: Iestimate of 0.275A)

Definitions:

milliampere-hour (mAh): measure of battery capacity to store energy
equivalent to average milliAmperes times time
Watt (W): unit of instantaneous power, equivalent to volts times amperes
Watt-hour: unit of energy/power used over time
milliWatt-hour mWh: W-hr times 1000
Volt: unit of electrical force or charge
Ampere: unit of current or flow of electrons

Program to run to find out just how long a fully charged GoPiGo will “run” while meditating on the power of silence.

#!/usr/bin/python
#
# measureLife.py     Controlled Battery Life Measurement
#      Run Battery down while printing status every 10 seconds
#
#      This test will loop reading the battery voltage
#        UNTIL voltage stays below 7.4v 4 times,
#        then will force a shutdown.
#
#
import sys
import time
import signal
import os
from datetime import datetime

import gopigo3

LOW_BATTERY_V = 7.4   # 8cells x 0.925v  # safe value, could go to 0.9

# Return CPU temperature as a character string
def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    return(res.replace("temp=","").replace("\n",""))

# Return Clock Freq as a character string
def getClockFreq():
    res = os.popen('vcgencmd measure_clock arm').readline()
    res = int(res.split("=")[1])
    if (res < 1000000000):
        res = str(res/1000000)+" MHz"
    else: res = '{:.2f}'.format(res/1000000000.0)+" GHz"
    return res

# Return throttled flags as a character string
def getThrottled():
    res = os.popen('vcgencmd get_throttled').readline()
    return res.replace("\n","")

def getUptime():
    res = os.popen('uptime').readline()
    return res.replace("\n","")


def printStatus():
  global gpg

  print "\n********* CARL Basic STATUS *****"
  print datetime.now().date(), getUptime()
  vBatt = gpg.get_voltage_battery()  #battery.volts()
  print "Battery Voltage: %0.2f" % vBatt
  v5V = gpg.get_voltage_5v()
  print "5v Supply: %0.2f" % v5V
  print "Processor Temp: %s" % getCPUtemperature()
  print "Clock Frequency: %s" % getClockFreq()
  print "%s" % getThrottled()

# ######### CNTL-C #####
# Callback and setup to catch control-C and quit program

_funcToRun=None

def signal_handler(signal, frame):
  print '\n** Control-C Detected'
  if (_funcToRun != None):
     _funcToRun()
  sys.exit(0)     # raise SystemExit exception

# Setup the callback to catch control-C
def set_cntl_c_handler(toRun=None):
  global _funcToRun
  _funcToRun = toRun
  signal.signal(signal.SIGINT, signal_handler)




# ##### MAIN ######

def handle_ctlc():
  global gpg
  gpg.reset_all()
  print "status.py: handle_ctlc() executed"

def main():
  global gpg

  # #### SET CNTL-C HANDLER 
  set_cntl_c_handler(handle_ctlc)

  # #### Create instance of GoPiGo3 base class 
  gpg = gopigo3.GoPiGo3()
  batteryLowCount = 0
  #print ("Starting status loop at %.2f volts" % battery.volts())  
  try:
    while True:
        printStatus()
        vBatt = gpg.get_voltage_battery()
        if (vBatt < LOW_BATTERY_V): 
            batteryLowCount += 1
        else: batteryLowCount = 0
        if (batteryLowCount > 3):
          print ("WARNING, WARNING, SHUTTING DOWN NOW")
          print ("BATTERY %.2f volts BATTERY LOW - SHUTTING DOWN NOW" % vBatt)
          gpg.reset_all()
          time.sleep(1)
          os.system("sudo shutdown -h now")
          sys.exit(0)
        time.sleep(10)    # check battery status every 10 seconds      
                          # important to check often to catch rapid drop at the end
    #end while
  except SystemExit:
    print "status.py: exiting"

if __name__ == "__main__":
    main()


Results from my run

  • GoPiGo3, Raspberry Pi 3B,
  • 8x NiMH AA cells with 2200 mAH rating
pi@Carl:~/Carl $ ./measureLife.py

********* CARL Basic STATUS *****
2018-08-28  11:43:51 up 0 min,  2 users,  load average: 1.67, 0.50, 0.17
Battery Voltage: 10.56
5v Supply: 5.05
Processor Temp: 37.0'C
Clock Frequency: 1.20 GHz
throttled=0x0


... (Intermediate output removed for brevity) ...


********* CARL Basic STATUS *****
2018-08-28  18:43:13 up  7:00,  2 users,  load average: 0.12, 0.03, 0.01
Battery Voltage: 8.22
5v Supply: 5.05
Processor Temp: 50.5'C
Clock Frequency: 600 MHz
throttled=0x0



********* CARL Basic STATUS *****
2018-08-28  19:02:52 up  7:19,  2 users,  load average: 0.08, 0.03, 0.00
Battery Voltage: 7.32
5v Supply: 5.03
Processor Temp: 50.5'C
Clock Frequency: 600 MHz
throttled=0x0
BATTERY 7.28 volts BATTERY LOW - SHUTTING DOWN NOW
Connection to X.0.0.X closed by remote host.

My Results:

  • My original guess of 4 hours (2200mAh/500mAh) was based on very wrong understanding
  • When Carl did not shutdown per first guess, I had to shut him down “early”
  • On two subsequent tests, “Carl” sat quietly meditating in his corner for 7.3 hours
  • Actual “Idle Battery Life” of 7.3hrs is within 8% of revised estimate of 7.9hrs
  • Actual life is within 5% of post experiment estimate 7.6 hrs
  • Max startup battery current seen on meter: 430ma at 10.7v
  • Beginning idle battery current: 225ma at 10.7v or 2.4wt
  • Estimated Power Used: 7.3 hrs at 9.1v ave. 260mA ave.: 17.2 Watt-Hours or 1898mAh
  • Estimate Portion of Rated Battery Capacity Used 81-85%
  • Distance Sensor draws 30mA at 10.1v battery
  • Pan Servo draws 70-100mA at 10.1v battery
  • forward() “no-load” draws ~200mA extra (~430mA total) at 9.8v
  • forward() “loaded” draws ~330mA extra (~580mA total) at 9.5v
  • Connecting with remote desktop adds 10mA
  • Each “Eye” draws about 15mA at 9.5v
  • Speaking with espeak TTS draws about 15mA at 9.1v
  • Running glances draws ~40ma ave., 80ma peak, temp +3deg to 53C, (CPU at 5%)
  • Wired speaker draws 20-50mA when charging in “on” state
  • GoPiGo PowerLED went “yellow”, then quickly red at 7:21 around 7.4v?
  • GoPiGo3 power circuit contains Schottky diode for reverse polarity protection
    (perhaps 0.3v voltage drop?) and DMP3017SFG NMOS FET power switch (0.6v drop?)
    between battery pack and the Voltage Regulator
  • GoPiGo3.get_battery_voltage() is reading 0.6v less than battery voltage measured
    at the battery pack terminals

Experiment Notes


#2

This is fascinating! Thanks for the tests and reports. Seven hours is approximately what I get in a work day, although the robot is doing a bit more than navel gazing :slight_smile:
Now I need to find batteries that will last a full work day .

Cleo


#3

After advice from some folks over at raspberrypi.org robotics forum, and thinking about the 168 NiMH cells in my 10 year old Prius, I have selected a shutdown limit of 1.1375v per cell, 9.1v at the battery, which is 8.5v indicated by gopigo3.volt(). This will yield a little more than 6.5 hours of mindless contemplation by my bot in its corner. (Sacrificing 45 minutes of immediate gratification for longevity.)


#4

What I’m really happy about is that you made an actual graph of the battery voltage vs time. That really shows everyone the expected run-time of the robot in very specific conditions, like those mentioned by you. I also added the noteworthy-answer to bring awareness to this post when referred in others.

This is really great and thank you!