Time is an illusion. Compile time - doubly so.

Posts from: April '12

Battery Level Meter

One of the things I finished recently. 6+ months.
This time it's a small and compact measurement instrument. Not the "most useful thing on earth" though (but I guess that hardly surprises anyone).
I took a lot of photos during the development, so that I can represent an entertaining worklog of its development, from The Scratch to The Finished Product™.

The motivation

It's all because of a stupid point-and-shoot camera and its stupid firmware. The battery indicator has four ticks, whose meaning is really something like:

4 ticks: you're all set, go and shoot as much as you wish!
2 ticks: I'm about to die in a minute or so!
1 tick: GOOD B—....*turns off*

I imagined it would be convenient to have a small "battery level meter", with two wires sticking out of it. Connect them to a battery, and it displays voltage and capacity remaining, in percent. Piece of cake!

The whiteboard phase

It should be a small circuit board with a PIC, a 7-segment LED display, a voltage regulator converting any voltage->3.3V, and a resistor divider, so that the input voltage could be read. So, it's a battery meter which feeds on the battery under test. The readout would be then looked up in some table and the remaining capacity would be displayed. The plan was to support anything above 3.3V, which I eventually revised to 1.8V-9.3V (2÷7 cell AA/AAA NiMH, Li-Ion (1- or 2-cell); others can be added as well).

The prototype

What followed was an implementation of that basic idea on a breadboard. The 3.3V voltage regulator was unavailable in a non-SMD form, so I had to solder appendages to it (as I've written earlier):


Initially, I envisioned it with a 2-digit display:


However, that part actually didn't even have a decimal point. Fractional numbers need to be printed as "3_6" instead of "3.6", and this is cumbersome (requires scrolling). So I replaced it with a 4-digit one, which I quickly transferred to a breakout board:


Isn't it an evil-looking monster? Like the tripods from "War of the Worlds", but having a lot more legs, and thus far more blood-thirsty, hehe (ò_ó)

In the soldering chaos that ensued, I grew quite dissatisfied with the way I was storing and organizing my electronic components. It was a box-filled-with-dozens-of-plastic-bags setup, and I moved to something a bit more civilized:


Anyway, here's that centipede beast mounted on the breadboard:


At this point I decided to implement an important additional feature of the tool: a discharge function (initially, just for memory effect treatment, but later it got extended quite a bit):


Right to left, we have a big resistor that handles the discharge, along with the switching transistor (it could've been a smaller part; I just have a thing for TO-220s), and finally, a pot for user input (the user selects the desired ending voltage, and the discharge current. So the discharger is not just a stupid resistor, connected across the battery).

Shortly after I (overoptimistically) "froze" the design and moved it out of the breadboard. These are the two parts of the sandwich, ready to be assembled:


The sandwich itself:


This would be the last thing I do on a perfboard, I swear:

The enclosure

With the hardware almost ready, I looked for a similarly-sized plastic box in the shop.


The one I settled on could've won any design competition. Bottom-up. It's basically a severely uninspired, dull and apathetic box: sporting an ugly color, ugly texture, sharp and ugly edges, and it gives off an awfull smell when melted (I'm still using the cutting metod from the previous post).

I couldn't leave it like this, so a rasp joined in:

... then some sandpaper, and a test of the marker:

In preparation for painting:

Painting - first layer:

Second layer:

Well... you get the drill:

Btw, the drying intervals between any two layers is no less than two hours :)

So, three layers later, I decided to try how the handwriting upon the painted plastic would look like. A white marker, which works well on that kind of a surface is surprisingly hard to find, and the only one I managed to get turned out being very thick:


It was okay-ish on the front face:

...but the other side was incredibly ugly...

... because I wanted to put some detailed instructions on that side, in a neat table...
So it became clear that I can't do this, this should be the job of the printing professionals, with the labels printed by a machine.

The extension

In the meantime, I did some work on the software. Having the discharge function up and running, I decided to throw in a voltage logger, and transfer-to-PC capability (the transfer is done using the PICKit2 - it has an UART tool mode). So I can get the exact discharge curves, and an approximate capacity measurement in mAh. In the end, it turned out to be a functional battery analysis tool - for example, here are some discharge curves:

Nokia BL-5C:

4xAA Eneloops (the label says 1800 mAh minimum, 2000 mAh typical).

Here's a comparison between the Nokia battery and a Canon dSLR battery (the latter has two cells, so its voltage is divided by two in the graph):

The software grew up signigicantly, to the point it did not fit in the program memory anymore. I decided it would be just better to replace the PIC chip with a bigger one (16F690->16F1829).

The finalization

Back to the enclosure thing. There are a few possible ways to paint labels on a small, dark, plastic box: screen printing, laser engraving, offset printing...
Fortunately for me, a kind person that does this sort of stuff stepped in and offered me to do a screen printing of the box for me. However, I was curious enough to try the laser engraving as well (while waiting for the screen-printed version to become ready). So, I ended up in a laser engraving studio with two boxes to be printed on. One was the red-painted one, only sanded down and repainted clean from scratch; the other one was a new box without any surface treatment.

We first tried the laser on the painted one (I hoped it would turn out good, even though the guys weren't so optimistic). Indeed, the laser only does a temperature-induced displacement of the paint, and it is very sensitive to the paint thickness. The back side came out somewhat acceptable:


The other one was not so well, though:

The unpainted box came out a lot better, using the laser in low-power mode only:

There's a room for improvement in terms of contrast, but otherwise it's great, the fine detais are very crisp.

The other one is the one from the professionalist (Lubo):

The finalists (before adding varnish)

After the varnishing:

I'm not kidding. It's just that the engraving disappeared (quietly, quickly and irreversibly) on the first varnish spraying. Have you ever played with Paint/Photoshop/GIMP and tried the rubber tool? Well, the feeling was just like it :)

The label is absolutely unintelligible now:

And here's the improvised spraying station:

In the end: two scrapped boxes, and one surviving one, done entirely by a professional. Making enclosures sucks!

It's time for the last changes on the sandwich:

While it looks like someone took a bite, it's really a broken off edge, which otherwise interfered with the box and the sandwich wouldn't fit. I also replaced the push button with a taller one.

Time to put it into the box for the last time:

The finished product


I have:

You can see it in action here:
Also, a local copy (H.264)

The future

I'm going to buy a huge arsenal of batteries next week, of all brands I'm able to find (AAAs, AAs, 9-volts). Then check them and find out which one gives off most mAh for the bucks :)

If anyone has an idea of anything further to be tested with the unit, don't hesitate to put it in the comments!

Posted in category Hardware -- clock 17 Apr 2012, 13:06, 9 comments


Mission Accomplished


Posted in category Images -- clock 4 Apr 2012, 20:02, 0 comments




Open source


+ 2008 (9)
March '08 (2)
April '08 (2)
May '08 (2)
October '08 (1)
December '08 (2)
+ 2009 (8)
January '09 (2)
March '09 (1)
August '09 (2)
September '09 (1)
November '09 (1)
December '09 (1)
+ 2010 (9)
January '10 (1)
April '10 (2)
June '10 (1)
July '10 (1)
September '10 (1)
November '10 (1)
December '10 (2)
+ 2011 (10)
January '11 (3)
February '11 (1)
August '11 (2)
September '11 (2)
October '11 (2)
+ 2012 (14)
January '12 (3)
March '12 (1)
April '12 (2)
May '12 (3)
August '12 (1)
September '12 (1)
November '12 (1)
December '12 (2)
+ 2013 (1)
March '13 (1)
+ 2014 (3)
September '14 (3)
+ 2015 (5)
January '15 (1)
March '15 (3)
May '15 (1)
+ 2016 (4)
June '16 (1)
July '16 (1)
November '16 (1)
December '16 (1)

Last comments:

30 May 2017, 02:02 by anrieff
26 May 2017, 01:00 by Mathew
30 Mar 2017, 13:59 by antfarmer
26 Dec 2016, 17:52 by Private
19 Dec 2016, 23:01 by ицаци
16 Dec 2016, 19:50 by Антон

Valid XHTML 1.0 Strict


linkJoel on Software
linkRidiculous Fish
linkXKCD blag