Showing posts with label Droid phone. Show all posts
Showing posts with label Droid phone. Show all posts

Thursday, December 29, 2011

First Bluetooth Data!

My Android app to read the PakTrakr data is complete, except for the actual reading of the battery data - kind of an important feature to get working!  I can pair the phone to the Bluetooth transmitter and open a connection in software, but can't get the code to read the data stream - nothing shows up.  I confirmed this with an Android Bluetooth testing app called Bluetooth SPP.  It will connect, but no data flows.

The Bluetooth transmitter has multiple switches and software settings and I tried every combination I could think of.  I know the PakTrakr serial port is working since I can plug it into the COM port of my laptop and see the data streaming through.  So the problem is the link between the PakTrakr serial cable and the Bluetooth transmitter.

I got a pointer from Steve Dolan, a potential user of my app with an awesome electric catamaran, to a similar project for PakTrakrs and Windows CE devices called EVDashboard.  The directions say to solder a wire from pin 4 (DTS) to pin 7 (RTS).  In desperation I did it this afternoon and BINGO!  I see the PakTrakr data flowing in the Bluetooth SPP app!  Thanks a million Steve!  You win 100 Internets!

Serial ports, formally known as RS-232, are a 40-year old technology with most of the behaviour shrouded in mythology and magic.  I believe this fix has something to do with constantly signaling that data is ready to flow.  I don't really care why this works, but it does, so I can move forward by finalizing the data reading and handling in the app.  I hope Ken Hall will offer a USB connector or a native Bluetooth solution so developers and users don't have to go through this pain.

Here are the components of the PakTrakr - Serial Cable - Gender Changer - Bluetooth Transmitter - Android phone data flow.  I can't support any other combination of parts or settings, unless you prove it and I can easily recreate it.  I'd love to avoid soldering the wire so anything that avoids that is greatly appreciated.
  • Buy a "Serial Bluetooth Adapter" from USConverters.com
    • Note that the IOGear Serial to Bluetooth unit is popular but I wasn't able to find a supplier and have no experience or advice on using it.
  • Set the following switches on the Serial Bluetooth Adapter
    • DCE - DTE switch to DTE (Data Terminal Equipment)
    • N/G - G switch to N/G (Non-Group)
    • S - M switch to S (Slave)
  • Buy a DB9 Male-To-Male gender changing adapter from Radio Shack
  • Gently pop the two sides of the PakTrakr serial cable connector apart
  • Solder a single small wire into the PakTrakr serial port circuit board as shown in the picture below.  This will connect Pin 4 (DTR) to Pin 7 (RTS).  We benefit from the Pin 4 circuit coming through the circuit board to the leg of the chip, and just jumper from there to the connector's Pin 7.  If you aren't confident with soldering the wire, contact me and we can work something out.


Here's a closeup of the jumper in place.  The angle is deceiving - it comes up from the pin of the chip and loops back down to Pin 7 - it's not touching the next pin on the connector.


Snap the two sides of the connector back together again.  Put the three parts together into a sandwich.  I don't trust the ridiculously tiny and hard to turn screws built into the parts, so I used two small zip-ties to hold the three pieces together, then two more around the assembly which pulls the zip-ties tighter and locks everything together.  You should end up with something that looks like this.  Boy would a single cable with Bluetooth be a great PakTrakr option!


Place this assembly into the vehicle and run power to it, and set the power switch appropriately.  I used the USB hub I installed earlier to drive power to it with the supplied USB-to-MiniUSB cable.

When you run the app, you'll see the blue Status LED flash then go solid once the Android phone is paired.  More info to come once I debug the data stream handling.

Sunday, November 27, 2011

PakTrakr Next Steps and USB Device Power

With the PakTrakr remotes installed and tested, it's time to add the current sensor.  The opening in the sensor is not big enough to pass a lug or battery cable through, so I used the copper bar provided in the kit, and bolted it in.  The sensor's data cable runs through the firewall and in behind the dashboard for its ultimate home in the PakTrakr dashboard display unit.


With that done, it's time to clean up the wiring.  Each PakTrakr remote has a generous amount of wire to run to each battery.  With the help of some butt terminals and zip ties, the wiring is now nice and tidy.

Here's the front battery pack.


Here's the mid battery pack:


Here's the rear battery pack:


and here are the saddlebags:


The final component to go into the PakTrakr system is the serial port output cable.  I've got it lined up here next to the serial port Bluetooth transmitter device which provides the path to the Bluetooth receiver in my Droid Bionic.  This delivers the data stream from the PakTrakr to the Android app I'm desperately trying to finish up, which will run in the phone as I drive down the road.


The Bluetooth transmitter needs power and conveniently it will take power via a USB cable.  My Droid Bionic also will take power via a USB cable.  I also plan to mount a GoPro video camera which recharges with USB power.  See a pattern developing?  With three USB devices, I looked around for a USB hub with 4 ports (for future use or passenger's device) and high-power delivery a la USB 3 at 900ma.  It has to take 12VDC so I don't have to have a separate power regulator.  I came on this sweet device, the awkwardly-named USBG-3X4M.  Notice the green 12V power connector.


Here it is mounted up under the dashboard.  The BlueTooth transmitter powers up no problem, but my Droid Bionic won't recognize any power coming from the unit, no matter what USB cable or port I try.  I've emailed the vendor and hopefully they'll have a suggestion.

Saturday, July 10, 2010

Buying the remaining conversion components

Since we're so close to getting the car back and getting the electric conversion kit, I'm ordering the final components I'll need in the conversion process.

First up is a great piece of kit, a replacement fusebox from JWest Engineering.  The original fusebox uses Good-And-Plenty shaped fuses that are held in place by a tiny amount of friction.  The new fusebox has modern blade fuses, and bolts directly in place of the original.  For only $105, it's a great product that brings the electrical system up to modern standards.

Next is the PakTrakr battery monitoring system.  As I've written before, I've chosen this product to monitor the battery pack and have written a custom application for my Droid phone to display the data generated by the PakTrakr in a graphical manner, while tracking real-time trip distance and remaining miles on the charge.

As I've also written before, I'm abandoning the spare-tire-air-pressure-windshield-washer system.  I spent many hours trying to retrofit a tiny electric switch where the washer fluid valve was mounted in the windshield wiper / blinker mechanism inside the steering column.  Trying to make a tiny yet strong custom bracket just wasn't working out, so I started searching around for a Porsche 924 mechanism, which includes the electric upgrade.  I grabbed one for $50 on eBay, which is a great deal.  As a bonus it looks like the horn contacts are in great shape too.

I ordered a strip of basketweave material for restoring the dashboard.  The dashboard in my car has been hacked over the years, so this should give a nice clean look.

In the near future I'll be buying a Kenwood KDC-BT945U stereo.  I've chosen this unit because it has a USB cable that I can connect to my Droid.  This will allow the stereo to play the songs stored in the phone, and keep it charged while driving.  It also has a Bluetooth connection to allow me to make hands-free calls, with the caller's voice coming through the speaker system.

Saturday, January 9, 2010

Launch of Development of the PakTrakr application

Sorry for the long wait between posts.  I spent a week at the insanity called Disneyland, then had a very relaxing week between Christmas and going back to work on January 4.  I didn't do any physical work on the car in that time, but I did spent a lot of time on the development of of a program that reads the data out of the PakTrakr battery monitoring system that I'll be buying later on in the process.  The PakTrakr has a small dashboard display, but it also outputs a data stream each second on a serial port.  My idea is to read that raw data and build an application that would show the data in an improved manner, and also derive important user information like distance to "empty".

See this blog post for the details on my choice of device.

I first had to download and install the free software development kit.  Then I started playing with sample code, and slowly build up the features of my application.  After a couple of weeks of learning, searching and experimentation, I've got a lot of stuff done.  I ported the PakTrakr parsing code from Doug Teeple.  I then built the application skeleton based on a series of tabs.  The first tab will exploit the GPS and mapping functionality to track the progress of each trip:


The next tab will show the readings of the battery pack as a whole, in analog gauge format.  I couldn't find any gauge controls in the Android toolkit or on the web, so I wrote my own.  There's a Percentage of Charge gauge, pack temperature, pack voltage and another custom gauge I wrote that shows the flow of current into the pack during charging, or out of the pack during driving:


The next tab will show the details on each battery in the system, with voltage readings and any errors:
The next tab will show a list of current and past problems with the batteries.  I'm still working on that so there's nothing to show.


The last tab will show the settings controls.  Right now, most are used only during development of the code, but others will be used in the course of running the app during driving and charging.


More updates on the code as things progress.

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.