- Published: Saturday, 04 April 2009
- Written by Digital DIY
- Hits: 10081
I have done an example earlier utilizing the DS275, it does the same job, but does not require any additional components. The MAX232 requires 4 external capacitors, but is much cheaper than the DS275. A great benefit is that the Pins that require capacitors are usually 3 pins apart, allowing easy installation of the capacitors - even on protoboards.
The DS275 is $3.75, where as the MAX232 is $0.93 (prices are from Core Electronics). The external capacitors are very cheap, in fact, they are only $0.07 each for electrolytic.
Connect the capacitors and PIC micro to the MAX232 like the following diagram *** EDIT; The 4.7K to 10K resistor was added as I have found in practical experiences that the MAX232 is very noise sensitive, and a pull-up resistor helps keep data integrity!
Be sure to connect 5V to Pin 16 and Earth to Pin 15 on the MAX232. Note that the shaded parts of the capacitors are the negative terminals.
As you can see, the capacitors are no hassle, as they all line up to pins that are 1 or 2 apart. Make sure you get the polarity right on Pin 2 and 6, they can be misleading.
Something to be aware of here is that different types of MAX232 chips require different external capacitors. This example covers the MAX232, but if your using a MAX232A, then 0.1uF capacitors are required.
Here's a picture of a COM port on the back of your PC. The following diagram identifies the Pin numbers,
Cut off Pins 6 to 9 on your PCB DB9 adaptor (The Pins that go to the PCB - not the ones inside the adaptor). They are not required. Now your DB9 connector can be used on any protoboard/breadboard. Some super/hot glue might be required if your going to be unplugging it all the time (just a little bit placed under the front part to give it more stability)
If your not sure what Pin does what on the end of your COM lead - check it first before wiring. Your could damage your motherboard or MAX232 chip. Grab a multimeter and throw it on resistance, now you can be sure you have the right pin on the other end. Making your own DB9 connectors is just as easy. Grab a Female Ribbon Cable Connector and a Male Cable Connector
You can get ribbon cable from almost anywhere, but you will need to modify the cable to fit in the above connector if it is not 9 wires. Simply remove the unrequired wire by peeling the strands off. Now make sure that you have the 9 cores lined up (no need to pull them apart - they sit 'as is' in the adaptor), and then press down firmly on the clamp - you may (will) need to use pliers, and carefully push them together.
If you have the soldering skills for solder cups, then you can use normal hook-up wire, and will only require 3 leads from each adaptor.
Every Windows XP comes with HyperTerminal, but can also be downloaded here. HyperTerminal is found in your start menu via, "Start Menu", "Accessories", "Communications", "HyperTerminal". At the bottom of this guide, there is a video which shows how to use it.
RS232 holds its power by using a single wire each directional data line. Why is this handy? Well when your program is bit crouching, you can easily send "Debug" information out with a simple command (in this case USART.Write(data)). For example, your program seems to stop and you have no idea why, well if you put a Debug line before every loop, you could easily identify where your program gets "stuck". Eg,
The ",13, 10" sends an Enter key ASCII code, followed by the Line Feed ASCII Code. For more
information, have a look at the Swordfish plug-in for ASCII codes.
When your using the USART commands in Swordfish, be sure to include the file "USART.bas" at the start of your program. Now you have all the USART commands at your disposal, and to send data to your PC is as easy as;
If you want to send variables to your PC, you first have to convert them into ASCII (string) data. So be sure to include the file "CONVERT.bas" at the start of your program;
The PC would receive and display the data as shown below