Android Talks Pulsewave

Serial communications are a mainstay of digital computing. They don’t require much physical infrastructure and they exist in variations to fit almost any application. The behaviour of serial communications lines, varying from high to low voltage in a timed pattern, is analogous to a 1-bit DAC. Using a whole DAC for serial communication would be a waste in most cases, but the [RobotsEverywhere] team found an exception which you may have encountered already.

Since the audio output of the Android is accessible and addressable, [RobotsEverywhere] wrote source code to use the left and right channels as separate serial communication lines. This circumvents the need to bust into the device and muck about with the hardware which is great if you want a no-risk hack that allows communications to an RS232 port. Any hardware on which you can write to the DAC (and control the sampling rate) is a potential target.

There are some external electronics required to convert the audio signal to TTL, but it’s not very complicated–a couple of comparators and change. You can see it in action after the break.

As a bonus, when you’re done for the day you can plug in your headphones and listen to the soothing poetry of pulse waves all night long.

Comments

  1. hey this is very cool!

  2. Owen says:

    I’d like to see this take a step back to the 80s next, with that audio recorded onto cassette tapes…

    I’ve started myself wishing that I still had my old Amstrad CPC to play Head Over Heels on, even if it did take forever to load.

  3. smoker_dave says:

    An Op-amp without using feedback?

    It might work, but it’s not correct!

  4. MJD says:

    I’m pretty sure its common practise to use an op-amp without feedback as a comparator, its just a differential amplifier with very high gain, so any difference between the inputs pegs the output to one supply or the other (if its a rail-to-rail output op-amp).

  5. fartface says:

    Wow horribly designed circuit. Example of a N00b that knows nothing about op amps using them wrong.

    Please get a feedback resistor in there.

  6. Spiritplumber from Robots Everywhere here. I have a degree in electrical engineering. Not using a feedback resistor is actually what lets you have a rise/fall time that is fast enough to make some finicky serial inputs accept the signal at all, at least when using a LM324, which isn’t a great op-amp to start with.

  7. Also, I know this has been done before — the idea here was to reduce parts count and CPU overhead on the phone, and increase baud rate.

  8. Patrick says:

    smoker_dave >> the Op-Amps are used as comparators here, no feedback necessary (or even recommended). The whole point is to have them saturate as fast as possible.

  9. kingkaiserking says:

    Why is it that some people are trying to be all-knowing of somebody’s design?

    Giving comments like that without proving something by themselves hah…

    Great design by the way and a lot of possibilities…

  10. Springuin says:

    The opamp is used as a comparator, there is no need for feedback resistors.

  11. Thanks for putting it better than I would have :)

  12. 256byteram says:

    There are comparator chips designed specifically to work in open-loop mode, such as the LM339. LM324’s running as comparators are painfully slow.

  13. Fallen says:

    agreed, its used as a comparator

  14. Erik Johansson says:

    What’s those the HDR1x2 and HDR1x3 in the schematic stands for?

  15. Header (1×2 pins) and header (1×3 pins), it just means “this is where you connect stuff to”.

  16. Lars says:

    Would like to see a port to iOS!

    I wonder if the mic-in can be used as a serial input, too. with some software processing on the input signal (software-comparator..) that should be possible?

  17. I’m working on serial input — it’s doable, and right now I have it running at 9600bps, but it requires the phone to do nothing else in the meantime (so everything freezes, etc. it will not even ring if there’s a call). That’s not really real-world usable, so I’ll keep messing with it for a while before I release anything :)

    Agreed on the 324 not being very good as a comparator. However, it’s easy to find (Radio Shack still has them in their parts bins). If you look at my other schematic I try to prioritize part availability over efficiency, unless it’s something I am selling prebuilt.

  18. michael says:

    For those who don’t like the opamp I got this to work using an optocoupler which gives you that nice feeling of being electrically isolated.

    Michael

  19. He also did it way before me albeit at lower baudrate. Mike, am I crediting you visibly enough in the app?

    Again, the choiche of a LM324 was simply due to the fact that it’s possible to go out and buy one without having to order it.

  20. Necromant says:

    @spiritplumber
    Well, looks like I’ll go port your sources to plain C ASAP. I have an old HP VectraPC (i486DX2@66Mhz+8mb ram) running linux from 4GB CF card, stuffed with 2 LPT ports, 4 RS232, 10mbit network card, and I still have 2 ISA slots free. This may add some more TTL level uarts there definetely, since I have several ISA sound cards lying around. Really looking forward for your input handling code. Thanks.

  21. For a PC of that vintage, I’d also look into joystick ports if you want analog in, if you have any in your scrap bin. IIRC you get four 8-bit analog ins and 4 ttl digital ins.

  22. js says:

    What are you going to call your invention?

    How about “modem” which stands for modulator-demodulator.

    :)

  23. This doesn’t really modulate anything (other than to fool the phone’s DAC into behaving). I am working on a version that does modulate a standard Hayes 300bps signal to be used with packet radio, though.

  24. Brent says:

    That’s really amusing. I’d look at old tarbell tape interfaces before I tried anything like this, too. Hahahah.

    Spiritplumber: you should be able to find an LM339 anywhere (Radio Schack) you can find an LM324 for sale retail. A tiny bit of feedback to create hysteresis is good idea in general in comparator circuits to prevent “motorboat” oscillations but you probably won’t have any trouble in this specific application since I assume you’re just cleaning up and level-translating a square wave?

    Necromant: you can probably get all kinds of wild ISA multi-port RS232 cards, digital I/O cards, data acquisition cards, etc on ebay for less money and hassle that it would take to try and rig sound cards as general purpose I/O.

  25. Necromant says:

    @ spiritplumber

    Yep, I’ve already hooked those and have a full-blown software stack running in it, supporting most of the hardware. And still 3.5mb memory free. The PC is headless with klone for the web-based ui and some wrapper scripts on my main pc) (eg. remote-avrdude)
    However there’s a real shortage in uarts, since the existing ones are already used for several programmers, DIY lab power supply, and etc.
    And I’m too lazy to reconnect that, when I need something else. Since old sound cards acually have a plenty of outputs and inputs that can be selected. (CD-IN, AUX-IN, etc) this can really extend the interfaces of this unit.

  26. Necromant says:

    @Brent I have a sh*tload of ‘em around, I got them for free several years ago. If you live somewhere near Moscow/Russia – I can even share some.
    It’s just the pc that doesn’t work with more than 2 LPT ports (1 internal and 1 on the expansion card) and 4 RS232 (2 internal + 2 external). I can use jumpers to configure LPTs as LPT1, LPT2, LPT3 and BIOS even thinks that’s OK, but just linux doesn’t see one of the ports then and I cannot actually use it, so that looks like the max.
    I’ll do more testing, this hack is still work in progress… May be I’ll even take some photos and send ‘em to HaD someday.

  27. smudgeface says:

    Hey let’s send serial data over lines designed to carry audio. We could even modulate it in such a way as to provide error recovery by using coding techniques…
    …I bet this has never been done before :/

  28. itwerx says:

    Wonder if the opto-coupler approach could be used with an analog phone line to do DTMF…? (Need the mic in as well of course). “Ana-droid-a-log” phone anyone? :)

  29. DTMF was done — with a few changes in my app, you can also output modem tones directly, only up to 300bps though.

  30. michael says:

    I love the idea of dtmf exceptI I can’t find a good source of decoder chips and am unwilling to write the dtmf decoding code on an arduino (I’m lazy).

    when the code is so simple why not use the builtin uart system, its got buffers and everything you need!

  31. Simon says:

    thanks a lot hackaday for posting this article and even a bigger thank to robotseverywhere. i tried to build and program the connection to arduino over sound by myself but gave it up. now i can use this easy solution. thanks a lot!

  32. M H says:

    So, could you use something like this, paired with an appropriate circuit on a line in or microphone in to talk to something like a 1-wire bus?

    (Specifically thinking of an XO-1, which is lacking in things like I/O ports. Thought it might be interesting if a simple circuit and some software would let you set it up to talk to sensors.
    Make a nice little data logger/display.)

  33. I’m messing with the line-in stuff. Don’t expect anything for a while because NASA has my development phone for a few days. :)

  34. Xenon says:

    I have built the circuit and try to test it using the wav file in http://www.flakelabs.com/. but i just get a mess of word… i would like to how what is the detail procedure to adjust the resistor. thanks

  35. To adjust the resistor, just set it a little above zero. Email me for surce code!

  36. apolo8 says:

    Sorry,no PCB for noobs?

    -Fascinating the idea of programing devices without a pc…

    -Simply Amazing…Thanks robotseverywhere

  37. This works differently than what flakelabs did — a lot fewer parts for one. You can get the serial port demo app on android market by searching “serial out”, it’ll be in the first five results.

  38. Neo says:

    @spiritplumber
    Great and cheap solution.
    I am just new with electronics and need help.
    S you are saying that only this circuit that you have given in the link below can be used with some device .
    like i want to use it with arduino UNO.
    Please reply i really need this

  39. kay says:

    This circuit will work with the arduino uno, yes

  40. Neo says:

    Yes it works great .made it then used it in many of my apps where ever i needed just the TX from android.
    take a look http://mzubair.com/getting-serial-output-from-androids-audio-port/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 97,706 other followers