Saturday, June 18, 2011

Keypad Controller Demo Video & Walk-through

Video Walk-through: 

Demo: Power-on the phone, then wait to boot.  Next, dial 0-1-2-3-4-5-6-7-8-9-#-* then key down, down, down, down, up, down, OK, wait a couple of seconds, then cancel.  Repeat dial sequence two more times.  Then power key again to turn it off.  Then a quick tour of the hardware...

Tour of the hardware:  The phone is an LG "Flare" (LX165) from Virgin Mobile.  There are 24 keypad buttons on this phone.  The phone is wired with two Cat5 wire bundles because I had some handy and I like the easily identified wires all nicely bundled together.  However, instead of using 48 wires and 24 relays to control the 24 buttons, I use only 14 wires.  These wires are soldered to specific phone keypad conductors that I determined to make up the "rows" and "columns" of  the keypad matrix.  I connected these wires to a cross-point switch circuit on my board.  For the cross-point switch, I am using 6 Vishay ILQ2 quad opto-coupler ICs instead of relays.  When compared to relays, like the OMR-C-105H used for the power control, the opto-couplers are more compact and cost about half as much per switch.  To control the opto-couplers I am using three 74HC138A ICs which are 3-to-8 bit decoders with complementary outputs.  From the decoders there are 6 wires to the Arduino UNO board.

I have posted schematics for the board design.  Click the "Appendix" tab (above).

The real trick to the entire hack is reverse-engineering the phone's keypad.  I will publish a separate post on that topic later.

What's Next?

For the most part, I think the hardware to control the phone finished.  Now I have a bunch of software to write.  To start, I am going to work on composing text messages.  To do this, I'm going to figure out how to interactively control the phone thru my PC or some other means.  I am thinking of reverse-engineering an IR remote control for this.  I know.  It is more than a little ironic.  But, since the phone's keypad is now useless,  I can no longer use it to play around with the phone and figure out how to navigate through the menus and compose text messages.  This will be much faster if I can do it interactively.


  1. On HaD it looked like you had an Arduino connected to it. Here's a quick Python script to get serial coms with the Arduino working

    That's simple coms.

  2. i was trying to do the exactly same thing. =)

    great to use with phones that dont suport At commands or use some other complicated protocol. =p

    (My response to a HAD comment)

    Actually, I had drafted serial control as an alternative switch controller design. By my analysis with 74HC595 shift registers, I would need 5 pins for *full control* of the serial chain. This would include OE_B and SRCLR_B, in addition to SRCLK, RCLK and SER (data) pins. I know all I *need* is the last three, but that has drawbacks. In particular, it makes dealing with power-on indeterminate state trickier. For instance I want the phone to be powered-up when I set it, not because the I/O pulled-it down during power-up. Hence, the desire to control OE_B and SRCLR_B. Another drawback of the serial chain approach is the serial control software is more complex than a simple parallel write. (Even with the Arduino's nativele serialized write functions.) Don't get me wrong, if/when I run out of I/Os (like if I port it over to an MSP430 Launchpad) I may revisit the serial approach. But, for the time being, I'd like to keep it simple and move forward with the overall project.

  4. Oh yeah... featured on Hack-A-Day (HAD) today... Awsome!

  5. Neat! You use 3 3-8 decoders.With the optocouplers being diodes anyway, couldn't you build a matrix of the optocouplers? A 74HC238A to pull a single row of optocoupler strings to '+' and a 74HC138A to pull a single column of optocoupler strings to '-'? That would give 8x8=64 keys, but you'd have to use output 8 of each to indicate 'no key pressed', so you have 7x7=49 keys available.

  6. hey man, great hack! and gj getting featured on HAD.
    alternatively, u can connect to the phones Serial diag port to send commands that will simulate key presses. ie. "20 00 33 EF C6 7E" sent as a byte array to the phone, the responds by pressing the key "3". 8) fyi, virgin firmware usually locks down access to the serial port.

  7. mmm delicious wire porn!

    Saw your hack via HaD but thought it more respectful to comment on your own blog. What I wanted to know is did you have a specific goal for this project? I mean, automated SMS alerts or calls or something?

    Rather than reversing the IR protocol, would it be easier to knock up a little keypad from microswitches and daisy chain it into your board for manual override?

    Oh and finally, are the opto couplers necessary or could you wire directly to the phone?

    Sorry for the inquisition :) this looks like a really fun project!

  8. @raphael: I did not even know AT commands worked with cell phones until one of the comments from the HaD posting. But, as you can appreciate, this is not a universal feature. I'm glad you like this alternative.

    @_gl.tch: The "bigger" project will use the phone for SMS based on data collected monitoring input signals from another system. (I'll be adding posts on that over time.)

    I've already backed away from the IR idea for the time being and I am now controlling the phone with the Arduino serial monitor tool. It was much easier than I thot it would be.

    RE: Wiring directly to the phone

    An advantage of the approach I have taken is that I preserve much of the original electrical properties and operation of the phone. So, less risk of introducing hard-to-find (and fix) bugs into the hardware design.

    If that is not enough, here's a more "Paranoid" worst-case-scenario take:

    This _could_ cause problems since it is a different electrical system that we have limited visibility into the physical layout of the power distribution. Here's what I know, the phone uses approx 3V from a Li-Ion battery vs 5V from Arduino board. The Arduino power is from a regulator that accepts 5V from a USB port or a 9V battery. (There are on-board circuits to prevent both voltages form being applied to the regulator input at the same time.) Furthermore, I plan to interface with a 12 V system. In my experience, when dealing with different voltages on the same board it is best to keep the "power loops" isolated in order to prevent the chances of having higher-voltages inadvertently applied to low-voltage circuits. When I have control over the design this is easy. Now, some optimists say that all you need to do is tie the grounds together. Ground is ground, right? Theoretically, we can just pick a point to be ground. But, in practice, ground is not the same everywhere unless it is designed properly. (Here I'm talking DC ground. AC grounding is another beast, but it is a concern when dealing with high-frequency (>100MHz) and/or fast-switching circuits.) Not knowing the internal wiring of the phone, I did not want to risk inducing ground loop currents that in the least may interfere with the functionality of the build, but may also damage the phone.

    For instance, you may screw up the phone's radio if you choose a ground point that is actually at a different voltage than the radio. I'm not saying the hack won't work. It likely will, at least for a while. But mis-wired power connections may drain the battery faster or even damage the phone.

    If I were not to use optocouplers, I'd go with relays. Some have used discrete MOSFETs. IMHO, the quad optocouplers I've used are a better choice from a cost perspective as well as electical and mechanical properties.

  9. hey, I really liked your hack. I am new to circuit level electronics stuff. I love working on things but still learning. People like you are doing really great by publishing your hacks. I have seen some really hardcore electronics comments on this page. Half of them I don't even understand :( but anyways one day I'll get there.

    Is there any possibility that I can ask you some more questions regarding the keypad hack plz. I'll really appreciate it.