Now Reading
githublog/building-a-jank-uart-cable-from-scavenged-parts.md at important · francisrstokes/githublog · GitHub

githublog/building-a-jank-uart-cable-from-scavenged-parts.md at important · francisrstokes/githublog · GitHub

2023-03-03 03:34:29

My residence “lab” is, sadly, a manifestation of the unwinnable, uphill battle in opposition to entropy. The newest sufferer to the sprawl of boards, prototypes, and different miscellanea was my little Adafruit CP2104 USB to serial converter. So far as I can inform, it has actually dropped off the face of the earth. That is notably irritating as I am in the midst of one other venture for an upcoming video on the channel, and wanted that precise serial converter to check the implementation of a significant part in a system I am constructing.

After all, the very first thing I did was hop on-line to order a brand new converter. Shortly thereafter, nonetheless, I got here to the sudden realisation that that is one thing I ought to be capable to make myself. I imply, whats the purpose in having a lab within the first place if you happen to’re not going to make use of it for this sort of factor! It is a yak that merely must be shaved.

What even is a USB to serial converter?

Possibly I ought to contextualise this for a minute. What even is a serial converter? The excessive stage overview is that “serial”, or UART (Common Asynchronous Obtain and Transmit) is a protocol for exchanging information between two programs over two impartial wires, with both sides in a position to transmit and obtain concurrently, with out these two strains essentially being synchronised (therefore “Asynchronous” within the title). This easy system has existed since no less than way back to the Sixties, and continues to be ubiquitous within the embedded world. A big a part of that longevity is that it is such a easy protocol, from each a software program and a {hardware} perspective.

The factor is, our fashionable computer systems cannot communicate UART immediately. They used to although; Earlier than USB grew to become the one port accessible in your laptop computer, RS-232 serial ports have been extraordinarily frequent (even my earliest computer systems had these ports, and I am not that previous). However despite the fact that USB is in every single place now, it is truly a fairly complicated beast. Most microcontrollers do not provide any sort of USB peripheral assist out of the field (although superior initiatives like TinyUSB might help with that), however the issue of wanting to attach embedded gadgets to computer systems simply and cheaply nonetheless very a lot exists. That is why firms like FTDI exist.

FTDI make an entire vary of various chips which are in a position to take easy information streams like UART, and wrap them up into the complicated world of USB. Even if you happen to’re not deep into embedded or electronics, you would possibly recognise the title FTDI from their pretty poor-taste scandal from a few years back. Nonetheless, they are not the one ones out there; Silicon Labs make the CP2104 I discussed earlier, and the CH340 from Chinese language producer WCH can also be fairly frequent.

These sorts of chips are in much more gadgets than you would possibly realise. In any case, they’re the one of many easiest methods to make your machine person pleasant, and infrequently run on customary USB drivers.

Salvaging components

I occurred to have this previous Arduino Duemilanove board simply laying round, gathering mud, which has an FT232RL chip from FTDI to transform serial UART to USB. The FT232RL is without doubt one of the easiest and most typical USB to UART chips on the market, and is what the Arduino makes use of, along with the famed Arduino bootloader, to make it simple for individuals to add code to the board with the push of a button.

The very first thing I did was fireplace up the hot-air rework station in an effort to desolder the chip, together with the 2 capacitors simply above it. That is primarily a machine that may blow sizzling air out of a nozzle at a exactly managed temperature (a number of hundred levels), and a exactly managed movement charge. This sizzling air is ready to warmth up all the pins of the chip directly, melting the solder. To assist the method alongside, I added some flux to all the pins to get the solder to soften and movement higher. Then it was a easy case of swiftly grabbing it with some tweezers and setting it apart. Flux is sort of nasty, and leaves the half sticky. I cleaned it up with a cotton bud and a few alcohol.

As a facet notice, these teeny-tiny capacitors act as a buffer for the facility provides that comes into the chip. If there are any ripples or disturbances on the road, they clean these irregularities out, and supply a clear energy sign. Since it is a story about constructing a jank cable, I did not find yourself utilizing them. If I encounter any issues sooner or later, I would stick them again in.

You might need observed that is an SMD chip, which makes strapping a number of pin headers to it just a little difficult. That is the place these superior little SMD breakouts are available in. A set of those is comparatively cheap, and so they mainly help you flip any random chip right into a dev board, which is fairly cool.

The FT232RL is a 28-Pin SSOP chip, or “shrink small-outline package”. That is the sort of factor you simply be taught to identify after some time, however you may all the time discover this info within the chips datasheet. Or in a pinch, simply line it up with the varied sizes on the breakouts till you discover one that matches!

To solder the chip to the board, I might have used solder paste and the hot-air rework station, however I do not even have any solder paste available proper now. So as a substitute, I put a wonderful tip on the soldering iron, and channeled my interior Voultar. This type of comparatively low stakes operation with a fine-pitch half is de facto nice for bettering method. You begin by actually taking a while to line the chip up with the pads on the board, then with a extremely tiny quantity of solder on the iron, fastidiously tack one nook pin to its corresponding pad. At this level, if something is unaligned, you may simply hit it with the iron once more and reposition, till it is tacked down and completely in place.

Once I had one nook down, I did the others in the identical approach. For the remainder of the pins, I used some flux, and a drag soldering method to get good contact with the pins to the pads. This primarily includes placing just a little solder on the iron, and thoroughly “dragging” it throughout the pins, forwards and backwards, till the solder is evenly distributed. The flux helps to direct the solder to the pins, however with such a wonderful pitch, solder bridges can simply kind. Fortunately, they’re simply as simple to take away by cleansing the iron off, including extra flux, dragging and forth once more. Rinse and repeat.

With the chip properly soldered, the subsequent step was getting a USB cable hooked up. In non-jank UART to USB converters, you will typically discover just a little micro USB port port on board as a way to carry your personal cable to the occasion. I did spend a couple of minutes enthusiastic about ways in which I would be capable to get a micro USB port rigged up, I rapidly dismissed them in favour of merely chopping down an previous USB cable and attaching the wires on to the breakout.

By having a look on the datasheet for the FT232RL, I used to be in a position to find the USB Knowledge plus and minus alerts on pins 15 and 16 respectively. The opposite alerts of curiosity for this utility are:

  • TXD on pin 1, the transmit pin
  • RXD on pin 5, the obtain pin
  • VCCIO on pin 4, which is a reference voltage. The voltage on this pin shall be used on TXD and RXD for information switch. That is helpful as a result of it means the machine can speak to 5V and three.3V logic, each of that are frequent in electronics.
  • VCC on pin 20. That is the principle energy provide for the chip, and may be something from 3.3V to five.25V. Since USB already features a 5V energy rail, it made sense to energy the chip from it.
  • GND, which seems on a number of pins. This gives a reference which different voltage ranges are taken in opposition to.

You may discover there are a bunch of extra alerts on this chip. A few of them are used for extra complicated serial communication, and a few are configurable programmable pins that may used for further performance. I do not actually need any of that although.

For those who do not know, in its easiest kind, USB information is transferred over a differential pair of twisted wires, that transmit the identical sign, however with reverse polarity. That is vital for conserving the sign integrity excessive, and is completed with just about each excessive velocity signalling answer. Be aware that it is a single sign transmitted throughout two wires, not a transmit and obtain pair, like in UART.

I had a USB charging cable that somebody had given me a while in the past, which I believe was from a some sort of sensible watch. It appeared to have all 4 strains linked, and I wasn’t going to make use of it for it is meant goal, so it appeared like an excellent candidate for salvage.

After chopping the cable, I stripped again the insulation and shielding, and thoroughly uncovered the internals of every of the wires, after which tinned them with just a little solder.

The colors of the wires are customary. Pink and black are energy and floor, and inexperienced and white are information plus and information minus. Ratcheting up the soldering problem just a bit extra, I soldered the 2 wires immediately to the pins of the chip. Now, you are most likely pondering to your self: “Why would you not simply solder to the great, massive, extensively spaced holes for the pin headers?”, which is a good query. I suppose this the one place I opted for rather less jank. You see, differential pairs truly require the size of wires and sign traces on a PCB to be fastidiously managed. In principle, if the plus wire was just a little longer than the minus wire, the 2 alerts would arrive on the chip at very barely totally different occasions. That will mess up the sign integrity, and perhaps even forestall the machine from working. All of that mentioned, I am virtually sure that this wasn’t required in any respect. There is a marcan quote on the market someplace, the place he talks about having the ability to run slower velocity USB alerts over a pair of moist noodles, and I could not assist however consider that right here. Nonetheless, good soldering observe (these pads are 0.65mm aside)!

See Also

On the reverse facet of the breakout board, there’s a footprint for a bigger 28 SOP-type chip, which is after all wired to the identical pins as those the FT232RL is hooked up to. I fed the facility and floor cables to that facet of the board and soldered them to the bigger pads.

All the different alerts of curiosity are on the left facet of the chip, so I soldered in some common 2.54mm pitch pin headers to have the ability to attain the TX and RX alerts, in addition to the VCCIO, and a floor connection to share with no matter machine this one shall be speaking to.

At this level, I had checked that nothing was shorted utilizing continuity mode on my multimeter, and tried plugging it in to my laptop computer. After working lsusb, which lists the linked USB gadgets, I noticed this:

No magic smoke, and the sixth entry confirmed that it was working! After all, I wished to test that the precise UART communication was operational too, so I wrote the shortest Arduino sketch I might consider:

uint8_t worth = 0;

void setup() {
  Serial.start(115200);
}

void loop() {
  char charToSend = 'A' + worth;
  Serial.print(charToSend);

  if (++worth >= 26) {
    worth = 0;
  }

  delay(1000);
}

After connecting the cable as much as an Uno board, I ran display screen /dev/ttyUSB0 115200 8N1 to hook up with the UART serial port, and was greeted by:

Discover the kapton tape and sizzling glue mess. That is actually there to re-enforce the flimsy solder connections, and to cease something from shorting afterward, but it surely undoubtedly helps with the scavenged look.

So the jank cable was a hit! I am nonetheless completely satisfied {that a} professionally made adapter is coming within the subsequent few days, however rattling if it does not really feel cool to know that I can whip up my very own instruments in a pinch.

And if you happen to’re on the lookout for some UART coolness

James Sharman has a superb video sequence the place he each explains and builds a UART implementation in {hardware} utilizing discrete logic chips. James’s channel is actually criminally undersubscribed. All of his stuff is nice.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top