[Videograime] Estimating Run Time

Portuguese Version
Since we are powering the Raspberry with batteries, how can we estimate the run time?

When looking for batteries you may spot two very important information. One of them is the voltage of the battery, the other one is the capacity, which is represented by mAh (miliamp-hour). When we say a battery is rated 2000mAh, it means that if we draw 2000 miliamps (2 amps) from it, it will last exactly 1 hour. And if we draw just 1000 miliamps? It will last 2 hours!

So it’s easy to know how long the battery will last, if we know its capacity rating and how much the Raspi will draw, right?

More or less. Remember, we are using two 18650 batteries in series, that sum 7.4v. The Raspi runs at 5v, not 7.4v. So our UBEC will draw X miliamps from the batteries, and deliver Y miliamps to the Raspi. That’s why we can’t do a simple calculation only knowing the Raspi current draw.

So, to make things simpler, we break this problem in three steps:

1) How much energy our battery can store?
2) What is the power draw of our setup?
3) Which are our main losses?


1) How much energy our battery can store?

We can use the following equation to find out how much energy (joules) given battery can store:
Energy (joules) = Voltage * Current (amps) * 3600 (1h, in seconds)

We are using two 18650 batteries (3.7v) rated 2500 mAh. In series we sum the voltage and keep the current, so we have 7.4v and the same 2500mAh. The equation can be expressed like this:

Energy = 7.4v * 2500mAh
Energy = 7.4v * 2.5Ah // Converting mAh em Ah
Energy = 7.4v * 2.5A * 1h // Taking aside the “h” of mAh
Energy = 7.4v * 2.5A * 3600s // Converting the “h” em seconds
Energy = 18.5 Watts * 3600s // Voltage multiplied by Current gives us the Power value
Energy = 66600 joules // We multiply the Power for how long the battery will last if we draw that much (3600s)

Now we now how much energy can our battery stores: 66600 joules!


2) What is the power draw of our setup?

Our setup is composed of a Raspberry Pi Model A and a LCD display.
I searched about the display that I bought (still in transit) and found that it will probably draw 350 miliamps at 5v.
As you can see in the photo, the Raspi is drawing 220 miliamps while running Super Mario.

Raspi model A drawing 220 miliamps.

Raspi model A drawing 220 miliamps.

Summing both and we found that the total current draw at 5v is 570 miliamps. This way we know that the power draw of our setup is 2.85 Watts (5v * 0.570A).


3) Which are our main losses?
When we convert (through the UBEC) the 7.4v of the batteries to 5v we have some energy loss. Normally this is a thermal loss, that is dissipated and not used. Our UBEC have 90% efficiency, which means that we lose 10% of the energy to the environment in form of heat.

If our UBEC has 90% of efficiency, then we don’t have 66600 joules to use as we intend anymore, we have just 90% of that. So let’s adjust our “Energy” variable in order to reflect this thermal loss during voltage conversion:

Energy = Energy * UBEC Efficiency
Energy = 66600 joules * 90%
Energy = 66600 * 0.9
Energy = 59940 joules


Ok, now we have the two variables that we need in order to calculate how long our battery will last:
Energy = 59940 joules
Setup Power Draw = 2.85 Watts

We can use a variation of the Energy equation to find out the “Time” variable:
Time (seconds) = Energy (joules) / Setup Power Draw (Watts)
Time = 59940 joules / 2.85 Watts
Time = 21031.57 seconds

Finally we convert these seconds in hours and we have the estimated run time of our setup: 5:50.

Advertisements

[Videograime] Running Pi Over Batteries

Portuguese Version
According to the FAQ, the Raspberry Pi was not created to run on batteries. It needs to be supplied with a 5v stabilized power supply. Anything below 4,8v will make it reboot or behave strangely. Much more than 5v and you will damage it or destroy it.

This is particularly complicated with batteries, because when they are fully charged their voltage is greater then their nominal voltage, and while they get discharged their voltage drop to lower levels than the nominal. So a battery of 3,7v when fully charged gets to 4,2v, and when fully discharged drops to 2,7v. So how we regulate this madness to stable 5v?

One way is to use an UBEC (Universal Battery Eliminator Circuit). This component is responsible to stabilize varying input voltages to a single output voltage.

The UBEC I’m using is this one, easily found on Ebay or anywhere. He can be supplied with voltages between 5,5v and 26v, regulating the output to 5v or 6v, changing between then with a jumper. I’m using two batteries 18650, with nominal voltage of 3,7v, like these ones.

Both in series sum 7,4v, but look when they get fully charged they get more than 8,2v!

Without UBEC 8,2v!

Without UBEC 8,2v!

But that’s OK, our UBEC will regulate it to stable 5v. When we wire the batteries to the UBEC we get a regulated 5,2v power supply

With UBEC 5,2v

With UBEC 5,2v

Ok, now you are thinking: “Shouldn’t it be 5v?”

The answer is “yes”! But is kind of normal this deviation, and 5,2v has not fried my Raspberry YET, and I don’t think it will do (but I cannot guarantee what will happen to yours…). With the output power supply regulated to 5v, we just need to wire it to the corresponding pins on the Raspi (VCC and GND)…

Wired to VCC and GND GPIO pins. CAREFUL!

Wired to VCC and GND GPIO pins. CAREFUL!

and voilá:

Beautiful!

Beautiful!

Yes, we are already running Pokemon Yellow and we hacked a Playstation controller for testing purposes. But these are topics for another posts =).

I’ve learned it from here and here.

[Videograime] Project

Portuguese Version
One of the the projects I’m working on is to create a portable device to play games, so I can kill time while I’m on a time-blocking situation, like waiting on the airport, bank line or when my girlfriend takes a little longer to get ready.

Of course I could use my tablet (actually, I do), but is not the same experience as playing a portable videogame like PSP or GameBoy. So I raised the requirements and created a project that I call Videograime.

I know I’ll learn a lot with each challenge I face, and I intend to write here everything useful during this quest.


The Requirements:

  • Portable
    • Run on batteries
    • Small, like a PSP
  • Run retro plataforms. At least:
    • SNes (Super Nintendo)
    • Game Boy
    • PSX (Playstation 1)
  • Use SNes or PSX buttons. No noisy-push-buttons.
  • External speakers and headphones out.
    • Speakers should mute when headphones get plugged in.
    • Volume control.

Requirements out of first version:

  • Analog stick.
  • Screen brightness control.

No different from the references, the choice was to use a Raspberry Pi as platform to run the emulators. After a quick search I realized that the software part will have a great head start, since there is a project called RetroPie, that is a Raspberry Pi image with all the emulators already installed, among other cool things like a interface to config and start all the emulators.

References:


Ben Heck
Kaushlesh Chandel
Mr Walkway