SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By landon
#65241
I had a need to create a long serial cable that terminates with USB on one end and a microcontroller's TTL serial on the other. It needed to be installed in a fire engine (many of them) so it needed to be easy to route through headliners or floor boards as well as be tough and water resistant.

Using a couple of Sparkfun parts, here's what I came up with:

http://sawdust.see-do.org/serial/files/ ... Cable.html

It's a pretty low-tech solution, but thought this might be useful to someone here who had a similar environment to contend with. So far it has proven to work well.

Image
By n1ist
#65315
I'm not sure I like the idea of passing TTL-level signals up a long cable in a noisy environment and expecting the data to be reliable. At least you should take advantage of the twisted pairs in the cable to offer some shielding. It looks like you have TXD and RXD twisted together - a perfect way of getting crosstalk.
By landon
#65321
Good suggestion - it was a nice mechanical fit between the breakouts I went with it....and I didn't think of the twisted pair mapping, so thanks for pointing that out. I expect I'm getting away with it in this application because the speeds are so slow - gps / 4800 baud. It is working fine in over 20 installs so far...that's not to say I won't hit one in the future that fails for noise reasons, but so far so good.

Thanks for your response.
By Philba
#65333
why not use something designed for electrically noisy environments like RS485?
By landon
#65336
In my case, I had a limited budget for a solution and I had to get from TTL of my microcontroller to the USB port of in-cab Toughbook.

I do like the looks of this RS485 to 5V TTL device but it's only part of the solution I needed.

Are you aware of any device combination that can go from TTL serial to RS485 for a long-run and terminate in USB (cheaply)? I'd be very interested in that as I'm pretty sure this won't be the last time I need something like this. Just the TTL to RS485 device above is $55...that's just one end.

Granted the solution I came up with won't work for every environment and I don't claim to know the distance and noise limitations of it, but fortunately it worked for what we needed and was cheap. Per install, I spent $14 for the SFE USB to serial converter, $3.50 for the RJ45 connector and breakout, maybe a $1 in polyurethane to harden it, and about $10 for a terminated CAT5 cable. The entire solution was about $28.50 in parts per install and it worked fine.

I'd love to find a better, comparably priced solution to go from TTL to USB over a relatively long run. Any other ideas or products to look at?

Thanks for the comments.
By reklipz
#65347
A widely-used rule-of-thumb indicates that cables more than 50 feet (15 metres) long will have too much capacitance, unless special cables are used.
(en.wikipedia.org)
Four (4) conductor shielded 24AWG cable
$39.75 per 10 feet
$39.75 * (20feet / 100 feet) = $7.95
(www.mouser.com)

Add the price of a male header, or even a polarized mated connector (for board->cable and cable->board mating), tops $4 more per install, for a total savings of $4 to $7 per install . However, depending on the run, you may need a serial level shifter (max232 or similar) and an associated power supply.

IMO, this is the proper way to do this, as it is installed in an emergency service vehicle. But, as it doesn't seem like a critical feature (at least I hope it isn't), then this is an area I'd rather not get into.

If you really wanted ruggedness, you could get a differential converter setup and utilize the twisted pair, then it would be as immune (as you would ever need) to noise.

Glad it works though!
-Nate
By landon
#65352
The low-end XPorts are definitely in the same price range as my solution and the in-cab Toughbooks are generally not using their hardline ethernet connection.

After thinking about it though, part of the problem is the mapping software on the Toughbook assumes GPS NMEA coming in via a serial port. I doubt it could have dealt with an IP connection for NMEA - unless there's a VCP that converts IP to serial to fake the mapping client into thinking it's talking to a serial port.

Without a VCP for IP to serial on the PC side, I would have to convert it back to USB on the Toughbook anyway, so the costs would still be quite a bit higher. Do you know of any virtual comm port drivers on a PC that can make an IP address look like a serial port (the way an XPort makes an IP address look like a serial port?)

It's kind of a tricky problem given the various constraints - technical and budgetary.

Again, I appreciate everyone's thoughts - I can see some improvements and possible new solutions for next time if the constraints were to change.
By Philba
#65354
landon wrote:In my case, I had a limited budget for a solution and I had to get from TTL of my microcontroller to the USB port of in-cab Toughbook.

I do like the looks of this RS485 to 5V TTL device but it's only part of the solution I needed.

Are you aware of any device combination that can go from TTL serial to RS485 for a long-run and terminate in USB (cheaply)? I'd be very interested in that as I'm pretty sure this won't be the last time I need something like this. Just the TTL to RS485 device above is $55...that's just one end.

Granted the solution I came up with won't work for every environment and I don't claim to know the distance and noise limitations of it, but fortunately it worked for what we needed and was cheap. Per install, I spent $14 for the SFE USB to serial converter, $3.50 for the RJ45 connector and breakout, maybe a $1 in polyurethane to harden it, and about $10 for a terminated CAT5 cable. The entire solution was about $28.50 in parts per install and it worked fine.

I'd love to find a better, comparably priced solution to go from TTL to USB over a relatively long run. Any other ideas or products to look at?

Thanks for the comments.
What you probably don't understand is that RS232 and 485 are essentially voltage standards. Where as async (ttl serial) and USB are different protocols. So, a 485 driver can convert a ttl level signal to the 485 voltage spec and back again. RS232, for reference is basically the same usually using the ubiquitous max232 chips - you feed in ttl async and get RS232 out. 485 is a differential standard that is designed specifically for electrically noisy enviroments.

There are lots of 485 (also 422) drivers out there and I recall seeing completed modules but haven't really paid attention to details like signal level input (ttl or 232 or ...). I'd be surprised if there wasn't a good selection. I can't say the same for low price, though.
By landon
#65356
Thanks for the info. So, to make sure I understand what you're saying, use a RS485 line driver (something like a MAX3080) on both ends of a long run. Then depending upon what's on each end, take the resulting TTL to the micro or to a USB to serial converter for the PC.

The basic chain looks like this:

uC TTL Serial<->MAX3080 RS485<->CAT5<->MAX3080 RS485<->TTL<->USB

Definitely a little more involved, but as you said, much more immune to noise problems.

You guys are inspiring me to look at some interesting topics - I found "How a Wire Picks up Noise" in a section in the book "Serial Port Complete" in coverage of RS485 as well as numerous circuits for working with RS485.

Thanks again for all the feedback.
By reklipz
#65360
It seems as though you were looking for an off the shelf solution, which you achieved rather easily.

If you were going for a custom solution, using an RS485 transceiver (or receiver/transmitter) would be a far better solution indeed. And, it would have the added benefit of probably costing less (depending on how/who you had fabricate them, but for the 20+ you are doing, this is probably a non issue).

That chain looks right, however, if you were using a MAX3080, it may cheaper still to use some twisted pair other than ethernet cabling, but who knows, cat5/5e/6 are pretty cheap nowadays.
By landon
#65363
reklipz wrote:It seems as though you were looking for an off the shelf solution, which you achieved rather easily.
It's true, at the time I didn't have time for a full custom solution, but the truth is, this conversation and the feedback everyone has provided has enlightened me. I appreciate it. While my solution is working well, I think I got lucky (20X) with slow baud rates and cable lengths that were still short enough (even though long by USB standards.)
ohararp wrote:This VCP is free from lantronix and makes the serial port connection easy. It is very reliable.
Most excellent. Then I think the low-end XPort solution would work as well for roughly the same cost as mine.

Thanks again for everyone's ideas - very helpful.
By VStar650CL
#65365
What makes RS-485 different (and better) than RS-232 is that RS-485 doesn't crank up the voltage like RS-232. It's actually sensing differential current, so the Vdrop on long lines doesn't effect it... current is still current on both sides of the line. That's what the little bridge R's you see across RS-485 lines are doing, and it gives it enormous noise advantages over other methods and algorithms.

One of the clients where I work recently did a lab-slapdown between RS-232, I2C and RS-485 in a particularly noisy industrial environment. The RS-485 (just cheap little Max drivers) intact-packet rate never fell below 85%, while RS-232 was the clear loser, falling way under 50%. I2C (predictably, with all its redundant error-checking) fell in-between the two, but if you compare the complexity of the I2C algorithm to RS-485, I'd say it's easy to pick a winner.

:wink:
By macegr
#65381
Hmmm...for programming complexity alone, you would need to factor in whether your microcontroller has a hardware UART or not, and a hardware TWI interface or not. I would say I2C is still easier to implement purely in software than RS232. Certainly less timing critical. However, I2C signal extenders are still pretty expensive, as they are not as common as the SN75176 for example. With only a couple feet to travel and no hardware UART, I'll definitely use I2C (or SPI). For longer distances it's worth it to use RS485, it's been rock solid for me. I've also used differential pair ICs to transmit TTL signals over long distances, the DS8921 is dead simple to use and got TTL RC servo signals through hundreds of feet of CAT-5 easily.