Sunday, November 22, 2009

Plans for the battery management and gauge system

People might think that electric car conversion is a bleeding-edge activity.  Not so!  I fact I'm going to leverage some hard work done in the past with some futuristic technology for my battery management gauge system.

First, we start with the PakTrakr.    I don't know why they hate the letter c so much; must have had a bad Sesame Street experience...  This device measures the voltage on each battery in the system, battery pack temperature, current draw while in use and alerts when any reading goes out of spec.  These are all of the values you need to know your % of charge and, after a few trips, your full-charge driving range and remaining driving range.  The unit comes with a dashboard mounted display that does the job, but screams out for a sweeter display.


Where the awesomeness really comes in, is the PakTrakr has a serial port output.  It spits out a CSV (comma separated values) data stream each second, with all of the relevant data.  If I had a computer of some kind that read the data and displayed some graphs, that would be perfect.  I did some investigation of "car PC" equipment and found most people go for a tiny PC with an LCD display.  Of course, these car PCs normally have music, GPS, video, cellular telephone and other features included.  I wasn't sure I wanted a dedicated, expensive device so I started thinking about using one of the new generation smart phones as my computer.  Most phones have a USB connection and I can easily convert the PakTrakr's serial cable to USB.  Writing an app that reads the USB port, parses the data and displays the graphs gets me what I want.  There is one downside - I would have to plug the USB cable in each time, and hack the wire to deliver +5V to keep the phone charged.  I suddenly realized that smart phones have a wireless Bluetooth facility, and I found serial-cable-to-Bluetooth adapters on the web.  So all I need to do now is to write code that reads the Bluetooth connection, and I don't have to be hardwired into the car!

Now what phone to get.  iPhone is the obvious choice due to market popularity, but frankly there are a couple of problems writing apps for the iPhone.  First, you have to develop your code on a Mac, nothing else.  I don't have a Mac or Mac development skills, but I'm willing to leverage my Java skills to get me where I need to be.  The second problem is the bizarro-world of iPhone app approval.  I don't like the way Apple is handling this, in typical mysterious we-know-what's-best-for-you style.  So iPhone is out.


This leaves an Android-based phone.  Android is Google's open-source Linux-based smart phone operating system and development platform.  The whole operating system is completely open source, apps are written in Java, and there is no "approval process" for apps that developers write.  Sounds like this solution is for me!  There are several Android-based phones on the market now, and the latest is Verizon's Droid phone.  I played with it at the store the other day and it's just beautiful and feature-packed.  I installed the Android 2.0 development kit and there is support for reading Bluetooth serial port sockets.  Now I just have to switch from T-Mobile to Verizon, sign up for the plans and get a Droid.


The heart of the code will be parsing the PakTrakr's CSV data stream.  I read about Doug Teeple's Sharp Zaurus project where he did the same thing I want to do, but on an older PDA device.  Doug's web site shows off his Karmann Ghia electric car conversion efforts.  In the spirit of community I emailed Doug and asked him if he would be willing to accelerate my development by contributing his CSV parser code he's already written.  He quickly wrote back to say he would do so.  It's in C, so I'll easily translate it over to Java, and then write the rest of the app around it.  I will make the final application and all of the source code available for free download here. Stay tuned for updates in this area.