Hello and welcome back. Continuing our discussion on RS232 serial communication in this part we will make a RS232 level converter. In the last tutorial we saw that how RS232 level signals differs from normal logic signals. So to interface RS232 level signals to our MCUs we need a "Level converter". And in this tutorial we will make one.
What a level converter will do is to convert RS232 level signals (HIGH=-12V LOW=+12V) from PC to TTL level signal (HIGH=+5V LOW=0V) to be fed to MCU and also the opposite.
![]() |
Fig - Working of RS232 level converter |
|
As RS232 is such a common protocol there is a dedicated IC designed for this purpose of "Level Conversion". This IC is MAX232 from Maxim. By using charge pumps it generates high voltages(12V) and negative voltages(-12V).
Now lets make it!
Things you need
S.No |
Item |
Value |
Qty |
1 |
1 |
||
2 |
Capacitors |
1uF |
4 |
3 |
10uF |
1 |
|
4 |
DB9 Female Connector |
1 |
|
5 |
General Purpose PCB |
1 |
|
6 |
Some Wires |
- |
- |
![]() |
Fig - Stuffs required for RS232 level converter. |
|
Now having all the stuffs in our working table lets begin.
The Schematic
Fig - Schematic for RS232 level converter. |
|
Assembly
Assemble the circuit according to the schematic on a small piece of general purpose PCB. Take out two wires for the power supply(5V) and two wire that connects to the MCUs RX/TX lines. Connect a DB9 female connector with longer wires because it connects to your PC. But don't make it too long keep it within 1.5 meter to 2 meter that will be enough.
Take care while connecting the DB9 connector wire must be connected to proper pins as shown above. To help you the connector has pin numbering on it.
|
Fig - DB9 PIN Configuration. |
|
After soldering wires put the plastic covering.
|
Fig - DB9 with Cover |
|
Now the connector can be easily connected to your PC's COM port (Serial Port).
|
Fig - Fully assembled level converter. |
|
Testing
It is always better to check each module separately. So we will test our converter to see if its working fine. For testing we will use a Hyperterminal a Windows software that can be quickly used to open COM ports and send and receive textual data. Right now you don't need a MCU or any MCU programming. The theory of testing is that we will connect output (RX/TX) together so any data written to COM port enters our circuit get converted to TTL level and loops back and enter MAX232 get converted to RS232 level and enters COM port, that's it.
![]() |
Fig - Loop back testing. |
|
Now open hyperterminal from Start Menu (All Programs>Accessories>Communication>Hyperterminal)
- Enter the name of connection say "testing" and select any icon for it.
![]() |
Fig - Hyperterminal Main Window |
|
2. Select your COM port in the "Connect Using Drop Down List". Note your PC might be having more than one COM port but commonly only one is available outside the rest are connected internally to modems etc.
![]() |
Fig - Select COM port. |
|
3) Select
Bits Per second = 9600
Data Bits = 8
Parity = None
Stop bits = 1
Flow control = None (important)
To know what they mean see previous tutorial ().
4) Now the HyperTerminal is ready. Make sure that Hyperterminal has the input focus and type something on the keyboard, they should echo on screen. Now disconnect the RX from TX and do the same. This time you should not see any thing on screen. Now your circuit is ready and working correctly.
If the characters are not echoing to screen your circuit is not working as expected. Check your connections and try changing the COM port in Hyperterminal.
Note: the circuit should be powered up(by 5V supply) during testing.
Other Parts of this Tutorial
- RS232 Communication – The Basics
- RS232 Communication – The Level Conversion
- Using the USART of AVR Microcontrollers.
- Using the USART of AVR Microcontrollers : Reading and Writing Data
- Visualize ADC data on PC Screen using USART – AVR Project














Why??
Had i said something wrong?
Controller Area Network (CAN)
Please sir..i would be highly obliged…
Hi Avinash, I want to write a c code (instead of using a 3rd pirty software) for serial(rs232) comunication with atmega32. I am using a laptop and it dosen’t have a serial port so I have bought USB to RS232 converter from your website. Can you provide me c code example to do so.
Thank you in advance.
Hello Avinash,i have a digitizer board (Lectra systeme) manufactured by lockheeds and calcomp,it is designed to plot co-ordinates for clothing design patterns, with the aid of pc software. Unfortunetly i dont have any cables and not quite sure what cable specification should be, after endless searching and buying various cables and adapters i am no further with getting it up and running. If i send more information and photos from the ports can you advise me? thanks brian
Hello. Great Tutorial
Thanks for the effort.
I just have a (very) basic question
I built the circuit as you showed, and i am now connecting it to a PC. I want to perform the autotest (pins 13 and 14 connected) to see if it is working, so I run the hyperterminal.
at this point, what is what I should see in the hyperterminal to know it is working or not. COuld you specify please?. I ve tried both cases (pin 13 and 14 connected and disconnected) and the behavior is the same. I just type stuff and it appears in the screen.