Personal tools
You are here: Home Documentation How-tos Serial RS232 Connection How-to
Document Actions

Serial RS232 Connection How-to


This How-to is intended for: Electronics Hackers

A step by step process of setting up a serial interface to your make controller

Problem

    You want your controller to have a serial interface for either talking directly with a computer or listening to devices such as a handheld GPS receiver.

Solution

    This tutorial assumes you are using a DE-9 connector, which is the standard connector found on current day serial devices. You can recognize this type of connector, because it has 9 pins on it. I cannot take responsibility if you make a short on your board, or hook something up the wrong way and fly a circuit, so take your time with this and make sure you know what to hook up.
Before you begin, it helps to understand a little about serial. Below is a link to a tutorial that I found helpful.

http://www.arcelect.com/rs232.htm

    The first thing you will need is an RS 232 shifter. This important piece of hardware converts signals which may be anywhere in the range of -12V to 12V into a signal that is within the range of our SAM 7 chip on our controller, and is vital to making the serial port work. It is possible to make the controller work without this piece of equipment, but it will make your life much easier if you pay the small price and buy this nice little piece of equipment. I got my shifter through a site called Sparkfun.com. Below is a link to what I used.

http://www.sparkfun.com/commerce/product_info.php?products_id=449


    Once you get this piece in the mail, all you have to do is hook it up. But before you hook it up, there is something you should know. On the shifter mentioned above, the TX-O on the shifter needs to be wired into the RX on the make controller, and the RX-O on the shifter needs to be hooked up to the TX on the make controller. To me, this seemed backwards, but if you do not hook it up this way, your device WILL NOT WORK. Trust me on this one; I spent more than enough time debugging this stupid problem. I can’t speak for other shifters since I have not worked with them, so your results may vary if you bought something else. Consult their support staff if you have issues.
Now that you have connected the shifter to your make controller and soldered the wires to ensure a good connection, it is time to test your new shifter. Take a short piece of wire, and connect pins two and three of the serial port. This will create a loop back; meaning anything you send on your serial port will also be received. If everything is hooked up properly, you should be able to send serial characters using the OSC command

/serial/char <some number>


where <some number> is a number between 0 and 255. Then if you type in

/serial/char


OSC should return a character (in character code format) in the order that it was originally sent.

if this works then congratulations, you have successfully set up the serial port.


Discussion

     As a little side note, this shifter mentioned above (serial type DCE) is designed to work with a personal computer (serial type DTE). You should be able to connect this shifter directly via a standard serial cable to your computer, and have the make controller and the computer talk. However, if you want the Make Controller to be able to listen to other devices such as a GPS (serial type DCE) receiver, then you will need to purchase a null modem adapter. This small device crosses up pins two and three, and allows the two DCE or DTE devices to successfully talk/listen to one another.

    If you want to learn how to make your own shifter, there are tutorials out on the web on how to do it. It doesn’t seem too complicated, but it was something that I did not have time to do.

Troubleshooting

    Here are some helpful steps in trouble shooing problems.

    First make sure that the serial port on the Make Controller is working. You can do this by connecting TX and RX with a wire, creating a loop back on the board. If it works, then the problem is not your Make Controller.

    Next connect pins 2 & 3 on the serial port, create a loop back, and see if that works. If it doesn’t work, but one of the little LEDs blinks when you send a character, check to make sure you hooked it up properly. Try and switch up the TX and RX wires on the shifter (this solved one of the problems I had). If the feed back loop works, you may need a null modem adapter. This cheap little part can be found at most any radio shack or other electronics store. See the discussion section above for more information. If you are still having problems, read the serial tutorial, it is really helpful and helped me solve my problems.

    Finally, check to make sure the port settings are correct.  By port settings I mean the Baud, the # of stop bits, the parity, the # of bits per character, and whether or not you need handshaking.  As of the writing of this document, Handshaking has not been implemented.  You can learn how to set these by typing in


/serial

in the OSC command line.