Controlling a Motor With Your Computer Part IV: The Hardware Side

I have documented how to take your computer, stuff a five byte data packet and send it serially to your microcontroller through your serial port. Awesome! But wait! Computers just don’t have a serial port any more. How useless can this information then be?

Yes, it is true. A trendy computer from the present will most likely ship without a Serial COM Port. In fact, a computer with an actual RS232 Com Port smells of obsolescence. Even opening it up to install a PCI or PCI-e card is an insult to modern computing. What if you have a laptop? PCMCIA?

Don’t worry! I bet most of you already know all of these suggestions are absurd as what most of people today use is a handy USB to UART chip such as the FTDI232RL. There are a gazillion solutions out there revolving around an USB connector, a few passive components, the aforementioned USB chip and a connector to send signals into the microcontroller of your own choosing. Heck! Even the Arduinos come already packed with this block so you can quickly connect the AVR microcontroller to the nearby USB port.

I usually build my boards with this block so I don’t have to be connecting wires and there, so I have a few designs in which there is an USB chip directly interfacing to an MSP430 MCU. What I am about to document works with any microcontroller with an UART. So yes, RS232 may be obsolete, but the UART is definitely not. Mind you that RS232 stands for a hardware implementation of an UART in which a logic HI is denoted by any voltage ranging from -3V to -15V and a logic LO by any voltage in the range of 3V to 15V. If you are interested in understanding the actual RS232, you may want to check its WIKI, although it is truly not necessary to understand this protocol.

In fact, to understand the hardware aspect of serial communications, you don’t even need to understand the serial protocol of an UART either. I would recommend for you to try to familiarize with it, though, as to troubleshoot this hardware block without knowing how it works is as brilliant as a car with no tires. At some point in time you will need to understand why on Earth is this frigging piece of evil not responding as it should. Is it the BAUD rate? Is it the parity? Is it the number of bits? How could you know if you don’t even understand what these are? I will not go into documenting the aspects of an UART as I assume you can readily find this information anywhere else.

To connect your computer to the microcontroller, the USB chip takes USB data and transforms it into UART data. This data will come out of the TX pin (transmit) and you will feed it into your microcontroller RX pin (receive). Conversely, your microcontroller may decide to send some data to the computer and it will do so through its TX pin which is connected to the USB Chip’s RX pin. Simple stuff! And it looks like this:

And my friend, that is it! There is no need for resistors, caps, inductors, flux capacitors, time portal inducers or terramorphic extrapolators. It just couldn’t be simpler. There are a few other connections we need to study, though, if we want to fully power the FTDI chip.

USB Chip Hardware Implementation

USB Chip Hardware Implementation

OK, maybe I lied. You do need a small ferrite bead and two caps to offer some 5V and 3.3V rail coupling. I still think this is super easy stuff! Notice we will use the 5V from the USB connection. This is one of the goodies associated with USB devices: they are powered by the computer. The FTDI chip will also pack an internal LDO which will give us 3.3V we can use with out microcontroller. As much as 50 mA are provided, but with nowadays micro, this is a sun’s worth of power.

The differential USB communication lines go from the connector to the USB chip and we get our two TX and RX lines which go into the micro. The US chip has a gazillion other signals often used with serial ports which require hardware control. I have never used these, so they are left disconnected. Most of the modules out there do not use them either, so it is fairly safe to ignore them. They are available, however, in case you do want to take advantage of this resource.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.