Cheap cable reused to add USB to your project

You get what you pay for. [Jkx] wanted to see how a USB to RS232 cable could be sold for just $1.70 and found out that it’s not actually RS232 compliant. The cable communicated as TTL levels, not the 12V expected of RS232 (although it can handle 12V incoming). He didn’t really want to use them for their intended purpose anyway. By betting rid of the DB9 plug and reusing the enclosed circuit board he now has a really cheap way to interface a microcontroller with the Universal Serial Bus. He worked out a couple of short subroutines that take care of receiving and sending data over the connection.

Comments

  1. RobThePyro says:

    I did this too! :D

    http://rambo.co.za/?p=65

  2. fluidic says:

    Cheap and easy, just how I like my prototyping.

  3. chris says:

    since Uarts are almost ubiquitous on embedded processors and most PC don’t have serial ports now a days… hasn’t just about anyone who messes with micro controllers done something similar?

  4. Dekar says:

    I don’t see how this is any special. He uses a cheap usbrs232 adapter which of course only supplies 5v peak TTL levels and thus bitbangs 5v-rs232 on his µC side. So why did he even bother ripping the cable apart? Many µCs come with USB these days and I heard some have even software implementations bitbanging it. Native USB is far more flexible than abusing rs232 (over USB) for binary communication anyway. I might be biased since I only recently started working with µCs and I’ve only had some stm32 (arm cortex m3) so far, which are pretty powerful and have easy to use native USB…

    Greetings from Germany,
    Dekar
    This is pretty lame IMHO.

  5. Matthew says:

    Don’t mean to be a spellchecker, but “betting”->getting ;)

  6. BeagleBreath says:

    I did this too! :-) also did this with XBee-to-USB then had XBee-to-µController on the other end. The USB provided power to the XBee after running through three 1N4001 in series to knock to voltage down to 3.3ish.

  7. CH says:

    Tell me if I’m wrong, but a search for ‘usb’ and ‘ttl’ bring up some pretty cheap usb-to-ttl modules already; I think finding one with pretty mature drivers would be the best bet (prolific?). Though not all uCs come with uart, and even fewer USB.

  8. Trollicus says:

    A max232 connected to your uart would work. The values are 3v to 15v(logic 0) and -3v to -15v(logic 1) for true RS232.

  9. Trollicus says:

    The above values are for data, the control lines are the opposite -3v to -15 for logic 0.

  10. octel says:

    DE-9

  11. You know, if you look for them, many modern Mothers still come with serial ports. My latest has one, but I’ll need to pull the signal lines outside the case. (the MoBo also came with PS/2 ports. No adapter needed for my Model-M!)

    (now I’ll need to check to make sure I’m really getting +/- 3 to 12 volts from the MoBo)

  12. your mom says:

    Congratulations @Dekar, you are now in the lead for the “Douchebag of the Thread” award. Will there be any challengers?

  13. Drone says:

    Everyone together now… Been There Done That!

  14. Aaron says:

    I think the point is that this was this guys first time working with a serial port and found a really cheap way of making it work. If that’s the case than great job guy!

    I’m not following why he could not use the UART in the Arduino though.

    Aaron

  15. osgeld says:

    been there done that (though I used a old compaq PDA cradle cable)

    and yes its not uncommon for open architecture boards to have 1 serial port still, and pci cards cost less than 20 bucks shipped that give you 2 more and an extra parallel port too

    please, PLEASE “hackers” quit buying a HP down at walmart on your mom’s credit card and you will get basic functionality from your pc

  16. Jon Chandler says:

    You can buy USB – UART adapters from ebay. Here’s a forum post about 2 styles, one with a cable and one with header pins. The second one is great because it will supply 5v or 3.3v to power the circuit.

    http://digital-diy.com/forum/viewtopic.php?f=19&t=519

  17. Erdem U. A. says:

    I am using prolific 2023 cable for ages for this job :)

  18. Funny how everyone just ignores the hack itself…

    I think it’s quite nice, especially if you have a laptop as your primary workstation (just like myself)…

    Try and find a NEW laptop with serial port ^^

    Thumbs up, it’s a nice hack, I just ordered to of these cables from Ebay for $3.44 or so…

  19. piku says:

    > You know, if you look for them, many modern Mothers still come with serial ports.

    What you saying about my mother?

    ;)

  20. NEWFOUND says:

    Don’t quite understand the negative reaction myself. Sure, it is hardly new or used to those of us who have FTDI 232R, prolific 2303 and silabs CP201x chips, cables and modules littering the floor and our own CDC-ACM stacks written in assembler just to up the “snob” factor.

    What I found interesting was the PRICE such a USB-RS232 bridge could be had for. This was an eye opener as my standard rule of thumb was $20USD.

    Also the fact that some cheaper cables do NOT have any true RS-232 level shifting but have the inverted polarity was completely new to me and this will really change some of the advice I offer on some of the electronics forums.

    One other thing I would point out is that there are some micros that allow the polarity of the UART to be inverted. This hack then would allow the hardware UART to be used without having to add a “MAX232″ etc. Many of the newer PIC chips have this feature.

    All in all, I found it an interesting hack.

  21. strider_mt2k says:

    Nice hack!
    I wasn’t aware that they weren’t 100% compliant!

    This might come in handy while servicing some of the 20-year-old and over industrial PC systems that have started finding their way to my bench at work.
    (read: I was the dope who spoke up about using the old machines and now I have to remember what the HELL I was doing with these things back then!!)

    Soo, as someone who hasn’t been there and my soon be doing that I say THANK YOU!

    Good information and a cool hack.

  22. jkx says:

    @strider_mt2k, the cheap (around 2$) aren’t RS232 compliant, but I think the more expensive (~10) are.

    Bye

  23. rs232 is +/- 15v, not 12v!

    dekar, of course more powerful (and more expensive) uC’s do have some kind of usb or are able to handle software implementations. but if you are working with a controller that has only 4kb of rom and not that many resources to use native usb is not an option because you dont want your controller to do usb and then have no resources to do a real task. so this is a cheap and easy solution to add (kind of) usb support to a project. i’ve got one cable like this (bought it very cheap from china) lying around that didnt work for rs232. i thought it was just crap and doesnt work at all, but now i might try it with ttl level devices. nice.

    greetings,
    a monkey from germany ;)

  24. Nathan Zadoks says:

    Nothing new, I’ve been using this for ages. (should have sent it here, but I wasn’t expecting something as simple as this to reach hackaday)
    And, DB9 *does not exist*. This is what a DB9 would look like: http://nathan7.eu/stuff/db9.png
    It’s a DE9. A D-subminiature plug with an E-size shell and 9 pins.

    –Nathan

  25. HaDAk says:

    s/betting/getting/

  26. cde says:

    It depends on the chip and on the configuration.

    The elcheapo COB chip they used in his converter might only be ttl, but a pl2303 can do 3v, 3.3v, 5v, and 12v without needing an extra chip, just by how one pin is wired (to gnd, v+, or floating.

    Cell usb/serial cables tend to have pl2303 chips wired for 5v but can be modded.

  27. Whatnot says:

    Basically he invented an arduino, but uhm didn’t somebody already invent that?

  28. Ugly American says:

    For classic 8 bit machines 5v TTL is better anyway.

  29. nes says:

    These $2 USB UARTS do in fact report themselves as PL2303. I found to get the TTL levels back round the right way, the simplest way to do it is with a couple of logic level FETs. The tx line needs no pull-up resistor and the rx line only needs one if you can’t get your microcontroller to use it’s internal pull-up. Not a problem with AVRs, but is with some ARMs.

  30. badpixel says:

    I use the FTDI FT232R chips exclusively, there is nothing that comes close for the price. They are dependable, cheap, and have excellent driver support. Provides 3.3V from 5V for other devices, has internal security for dongle devices, hardware xon/xoff, and supports, 1.8, 2.8, 3.3 and 5V logic .It also does RS422/485 in addition to RS232 in the same chip. It also doesn’t require any external parts for 95% of uses.

    http://www.ftdichip.com/Products/ICs/FT232R.htm

    Arduino doesn’t use the atmel chips with native USB support. The USB is supported by the FTDI chip on the board.

  31. MoJo says:

    There are some real asshats on here.

    A request to HAD though. When doing posts like this it would help if you spend a bit of time looking into it yourselves and then presenting more detail and a bit of an overview. That would stop people moaning and make HAD a much more useful resource.

    ATM you basically just post a bunch of links every day. Anyone can do that. Electronics Lab at least filter their posts so we only get the really good stuff that actually presents something new. I’m not saying be just like them, but if you did more editing and editorial I think it would improve HAD a lot.

    On the subject of USB->RS232 one of the best options is a Nokia CA-53 cable. They all use the same PL2303 chip (drivers built in to Windows 7 and Linux) which is a pretty good little device. It is 5V tolerant even though it runs on 3.3V. The DA-53 cables usually have everything contained in the USB end and you can either crack it open and solder on directly or cut the Nokia end of the cable off and use that.

    With AVRs you might not even need a level shifter, especially if all you want to do is receive. The AVR’s inputs have diode clamps anyway. In fact Atmel have an app note where they connect 240V mains directly to a pin with only a 1M resistor to limit the current! A similar resistor, say 10k, works well with RS232. Many USB converters and motherboard serial ports will work with TTL levels for reception too so you may get two way comms for the price of a couple of resistors.

  32. Scott says:

    I think a lot of people who suggest alternatives to this (FTDI chips, phone cables, etc) are missing the point. This USBSERIALMCU adapter is $1.99 on eBay (shipping included), and is one of the cheapest ways to get a microcontroller to talk to a PC which might not even have a serial port. Appreciate it for what it is.

    Similarly, I agree it’s far from novel (most of us have done something similar at some point), and I concur that HAD should use more intelligence in writing their blurbs. Some of the descriptions are insulting/embarrassing. The first sentence of this description makes me sad. This is an amazing hack, and this hacker got *WAY* more than he paid for (that’s what hacking is!)

  33. taylor alexander says:

    Honestly, I’m starting to wonder why we ever bother with serial anymore.

    I’m beginning to look into ARM based processors, and I’m finding that they all have builtin USB and its not that tough to use. You can get 55MHz ATMEL SAM7s processor for $2 in an easy to solder package (SMT soldering is NOT hard! I just learned it from watching youtube videos).

    There are already EAGLE footprints for some nice mini USB connectors in the SparkFun Library, and there are a few Atmel libraries that contain the SAM7 parts on the EAGLE website. Then you can send your PCB off to batchPCB for a few bucks and get yourself a very nice, easy to use board.

    There are some examples on the web for how to start off with them just acting like a USB COM port, so you can still code for the PC the same way, but there’s actually less stuff to solder. USB only requires two resistors, and they usually recommend one cap on the power line. Those SAM7 ARM chips don’t have much to hook up in EAGLE and you can get an example schematic from OLIMEX.

    I haven’t had a lot of time lately but I’m pretty much convinced that I’m ending my use of 8 bit processors as soon as I start my next project. 32 bit just isn’t that complicated anymore.

    Maybe I’ll write a tutorial. I really want to teach! Don’t wait for that though, just follow my advice here!
    -Taylor

  34. taylor alexander says:

    Oh! ATMEL’s USB microcontrollers don’t require a programmer either. You can program via USB out of the box!
    Sooo easy!
    -Taylor

  35. jethomson says:

    @Scott A Nokia cell phone cable is ~$3. It’s output is low voltage TTL which means it can be used with 3.3V and 5V signals. Plus, it’s output isn’t inverted, so you can use the microcontroller’s normal Rx and Tx pins.

    This hack requires you to have an off-spec USB to RS232 dongle, use up two pins on your uc, and write your own serial functions. Furthermore it requires you to give money to manufacturers of a device that doesn’t meet the specifications, thereby encouraging them to continue to do this.

  36. Chad says:

    These Chinese factories really wouldn’t care about the spec unless it hit them on the head hard enough to make them forget how to design a circuit in the first place. ;)

    If you can get one the MSP430 launchpad has exposed TTL serial ports that can probably be hooked up to something completely different.

    And for slightly more hacking one can use an ATtiny w/vUSB.

  37. studioeng says:

    I’m intrigued, with a Nokia CA-53 cable, is it just a simple case of connecting it to the RX, TX and 5V points on a (non USB) Arduino? It can’t be that easy… I know I’m just being simple. Could someone point me to where I can get more info?! I’ve got a couple of DIY Arduino ATmega168 boards which would be great if I could use a USB cable. Thank you :D

  38. Jon says:

    Two purpose-built USB-UART adapters are shown here:

    http://www.clever4hire.com/throwawaypic/useful-bits

    This is exactly the same concept as the CA-53 cable. Four connections make it work – power, ground, Tx and Rx. If the board is powered already, don’t connect the power lead.

    There’s also some discussion of adapters including pictures of them in use here:

    http://digital-diy.com/forum/viewtopic.php?p=3485#p2703

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 96,357 other followers