Another Ben Heck Show Appearance

Well, this will be a quick little post, mostly for a location to drop some files.  I made another Ben Heck Show appearance, this brings me up to 3.  The video can be seen here

 

All the videos can be seen here

http://www.youtube.com/playlist?list=PLty7pvZZzbVi8Ud1Tei8N7pI25UojzUFa

 

 

It was a cool experience as it always is.  Some guys from Engadget were there to film as well and it was cool to talk with them.  Also Ben and I got in an abbreviation contest which was fun. VHDL stands for VHSIC Hardware Description Language, with VHSIC standing for Very High Speed Integrated Circuit.  That is the coolest one I know.

 

Anyways, a few people have asked for the code and such so I will embed it at the bottom.  I have the Android code and the TI Launchpad firmware code, both in separate zips.  The Android code was written for either Jellybean or ICS, don’t remember which, and that was for the rotate command, like the pot stir app.  The APK is in the zip file.  I didn’t take the time to really document as I’ve been a busy guy.  Hopefully I’ll get to do a life update and an update on my ShapeOko CNC machine shortly.

 

Anyways, here you go

Android SANTA Project

TI Arduino Code Files

Getting More out of USB Car Chargers

I’ve done this little “hack” twice now and figured others would benefit from it as well.

 

Have you ever noticed your phone/tablet charges slower from USB than from the wall socket?  Many of these devices have a USB charging mode and an AC charging mode.  This is because USB has a limit to what current it can supply unless the device negotiates with the port for more current.

USB car chargers can usually supply more current than the standard USB charging level, but if your device thinks its charging from USB instead of from an AC adapter it will only charge at the lower rate.  So how do you trick it into thinking its hooked to an AC adapter?

Well, that’s pretty easy.  For most mobile devices nowadays, short the USB Data- and Data+ pins together.  Apple has their own methods using specific voltage levels on those pins.  For an example for an iOS device, see Ben Heck’s Universal Wall Wart episode

http://revision3.com/tbhs/earth-day

 

First, here is my charger, it is manufactured by Rosewill, I bought it from Newegg

 

There are two USB ports and the charger says it supports up to 1A total

 

I took the charger a part and this is what was inside

 

It is a basic switching circuit, probably a buck topology as your car battery is always (hopefully) going to be higher than your USB voltage.  A fuse was contained on the front end.  More info about buck converters here

http://en.wikipedia.org/wiki/Buck_converter

 

What I’m interested in is the bottom of the board, where the USB connector is soldered

I shorted the Data+ and Data- pins together as you can see above.  I also tried removing the resistors near the pins but they are glued to the board.  I think those are the resistors for iOS devices I mentioned earlier.  After looking at them, I can see their values are high, about a 52k equivalent resistance across the 5V and GND lines, meaning very minimal current draw because of them, so I can leave them in.

I tested the device before and after, and before I achieved about 200mA of charging current.  Afterwards, I achieved 400-500mA.  I’m guessing each channel can do a maximum of 500mA to get the 1A total.  I also checked the voltage level it was supplying.  Many of these cheaper chargers are super noisy, here is a scope picture

Pretty good clean signal.  Also, I should take a scope picture class so I remember to actually have some useful info on the right side of the scope and not the display controls 😀

I’ve done this once before with similar results.  It’s a great way to get more out of your USB car chargers, especially if your phone is a battery hog like my Galaxy Nexus, that before could drain the battery while charging if using navigation.  Now I can at least break even, and maybe even get a charge.

Ben Stur

The Build:

I went to Ben’s to get a PS3 controller to assist him with a controller mod and he mentioned working on an upcoming Android episode. I told him I had a little experience with Android and bluetooth control and I offered my assistance. He came up with an idea of making a remote pot stirrer so you can stir and monitor your cooking from another room. We talked throughout the week about the basic look and he gave me some graphics to use.

As I was busy most of the week, I ended up doing the program Friday night. I had some sample code from my other apps, but strange Android errors still made it take me until 3AM before I finished a working product. I had weird layout issues, it seemed to be something to do with the main.xml file. I would move something and I’d get casting errors that crashed the program when it ran on the phone. I’d delete a few objects and re-add them, doing nothing in the java code, and the problem would go away. The biggest offender was the image button. I could not line the device id textview up with it otherwise I’d get one of those crashes. When doing the layout xml’s, I made it specifically for my phone, which included editing some of the graphics. I figured I’d port the program to Ben’s nook or phone the next day.

I showed up on Saturday for taping. Ben had the hardware for the stirrer complete.  It was an arm on a stand that moved a spoon back and forth using continuous rotation servos and limit switches.  As we had discussed the protocol over email, the firmware was pre-coded and working from a terminal.  I also had my app working with a terminal.

Despite having both of our devices working separately, getting them to work together didn’t work straight out of the box. First, our baudrate on the Arduino was incorrect. We were using the Roving Networks RN41 module and those modules default at 115,200 which I forgot. After we figured that out, we had to get our continuous rotation servo working correctly. We simplified our code to just send exactly what the android phone sends, to the arm via pwm, so 0-180 with 90 being stop. This fixed that issue.  And of course whenever you have an issue, you ended up “fixing” everything else until you find the real problem and have to go “unfix” what you had changed.

When trying to get this ported to the nook, I had problems. First of all, I needed to find usb dev drivers for the nook, not too bad. Then the version of Android I developed for 4.03 or Ice Cream Sandwich, was too new for the nook. I revered the project to 2.3, or Gingerbread, but then I had to take out the rotates as Gingerbread didn’t support the imagview.rotate command. I also had to change the layout a lot to get things to line up. I had edited Ben’s files to work on my phone and I had to edit them back to what he originally made.

Once I got it installed, I tried to get the bluetooth working. It would not, the nook, no matter what I did, would talk to the module. It couldn’t even pair. It would fail and give an error. Without even a successful pair, it was dead in the water.

Next, I tried Ben’s phone. This was harder, the drivers were not readily available to connect for development. I had to put his phone into recovery mode first, which windows then took over and installed the drivers. The phone took forever to reboot and I was worried I had broke it as I had to take out the battery to get it to leave recovery mode. It finally did boot though.

I tried to send the apk to the phone through eclipse. It didn’t work. No matter what I did, it couldn’t see his device as a target even with USB debugging enabled. I ended up having to put his phone into mass storage mode and dropping the apk on there. I got it installed on the phone and gave it a try. It would pair to the Roving Networks module, but would never connect. I’m not sure if it supports SPP or Serial Port Profile, which is a Bluetooth mode, kind of like HID or audio protocol. In the end I had to use my phone. We had to fix a few code problems on the receiver side and then we were up and running, except for the thermistor. We only worked half a day so Ben said he’d add the thermistor code that night and I would port the program back to my phone and re-add the rotate command for ICS.

I came in on Sunday for a few hours to finish up. Ben added the thermistor code and we started getting some sending errors back to the phone. We removed the old sending code, which sent the speed value received as a temp, it was a debugging tool of ours and no longer needed, and then it appeared to work on the terminal. I was still getting erratic behavior on the device when I plugged into Ben’s universal wall wart. I thought the previous day we had used a 5V supply, but apparently we must have used the 12V line to power the Arduino board. With the drop caused by the regulator, the Arduino wasn’t getting enough power to work correctly. After that fix, everything was working great. We finished taping the function and that was that. Not without problems, but definitely not as hectic as Robot Luggage.

Program Information:

I wrote this program based on some samples of previous programs I’ve written for Bluetooth Control.  Much of the Bluetooth code was used and Adapted from the book “Programming Android”.

 

AboutInfoActivity- This file is all about showing the “About” section when you hit the options key.  It just shows information I put in the about.xml file explaining the protocol

DeviceListActivity- This pertains to choosing a bluetooth device.  After you hit the sync button, a screen comes up letting you connect to a bluetooth device.

BtHelperHandler and BtSPPHelper- These are the bluetooth control classes.  They are pretty much exactly from “Programming Android” except I had to add some code to allow me to receive data.  These codes I believe were adapted from the bluetooth chat example on Google’s code database.

BenSturActivity- This is the main activity.  It is what you interface with for the program.  It controls the other activities, uses the bluetooth, reads the seekbar and button inputs, and sends the bluetooth information every 250mS by use of a thread.  You sync with a device and it will show the Device ID, you know its connected when the temperature changes from — to a number.  Then you slide your finger back and forth on the slider in the upper right to move the arm.  Releasing puts the position back to 90, or off.  That’s about it.

Protocol- Its a pretty simple protocol with everything sent in Ascii.  I did this because I was having trouble getting useful Byte data from the bluetooth helper classes but strings worked fine.

Sending- Start character – Three digits of position, always 3 digits, padded with 0’s when neccessary

ex- !090 (stop)    !180 (full CW)   !000 (full CCW)

Receving- Start character – One to Three digits of temperature, does not need to be 0 stuffed

ex-  !99  !120

 

Known Issues- When coming back from a screen off condition (like a sleep), the program often crashes from an inflater error.  Something about unknown class.  I’ll see if I can fix it, but I’m not an Android nor Java king.  If anyone else looks at this code and fixes it, let me know so I can update it.

 

Older Support- Because of the ImageView.rotate command, this is ICS and above only.  Remove the ImageView rotation command and then configure the project for an older version of Android to work on older phones.  Also remember to update the Minimum Version in the Android Manifest !

 

Eclipse Project file and APK is attached:

BenStur Files

 

Android Market Link:

Ben Stur