Projects   /   Development Boards & Kits

Simple RS232 to logic level converter for PIC microcontroller

The circuit shown will convert logic level voltages to and from RS232 serial voltages levels.

Tags: #converter
Published

At a glance

CategoryDevelopment Boards & Kits
IncludesDownload files
Reading time~3 min

Summary of Simple RS232 to logic level converter for PIC microcontroller

This article describes a simple, low-cost circuit for converting logic-level voltages to RS232 serial levels, specifically designed for Microchip PIC microcontrollers. Operating between 3.3V and 5V, the circuit parasitically generates the required negative voltage from the host's transmit line using a capacitor and diode. While effective for half-duplex communication or specific data streams, it has limitations in noisy environments or during simultaneous full-duplex transmission due to potential voltage drops on the storage capacitor.

Parts used in the Simple RS232 to Logic Level Converter:

  • Microchip PIC microcontroller
  • 100nF capacitor
  • 1N4148 diode
  • RS232 serial port (host computer)

For basic serial comms between a Microchip PIC and a PC or other device you generally only need to connect the Gnd, Txd and Rxd lines.

This little circuit will work with a supply voltage of 3.3v to 5v making it ideal for interfacing with a PIC 

logic level converter

It derives the negative supply for the RS232 transmit data from the serial RS232 receive data line in a parasitic fashion.  This means that the device it's connected to must use voltage levels within the RS232 specification. You can't for example connect two of these back to back since nothing is supplying the negative voltage.

The RS232 physical specification gives a logic 1 at the receiver input as -3 to -25 volts and logic 0 as +3 to +25 volts.  You may find that the reliable transmission over long cables, especially in electrically noisy environments with a 3.3v supply is not possible.

We've successfully used this circuit to transfer a 1.6Mb Linux kernel to a router at 115Kbs using a 3.3 volt supply without any errors through several metres of cable.

Operating notes

The 100nF capacitor is used to generate the -12V supply for transmitting data back to the host.  It is charged from the host computers transmit signal coming into the adapter via the 1N4148 diode. 

This can cause a few issues:

  1. If data is being transmitted and received simultaneously, the voltage on the 100nF capacitor may drop below the minimum required by the RS232 standard and this will cause problems receiving data sent from the adapter to the host.
  2. Since the capacitor is connected via the diode directly the hosts transmit signal, at high bit rates the 100nF capacitor may cause the signal to be distorted to such an extent that it can't be received correctly, in which case try changing the 100nF capacitor to a 47nF or even 22nF.  If communication is strictly half-duplex you may not need the capacitor at all.
  3. If the host transmits a lot of zero (null) data in a stream, the capacitor will discharge because in RS232 zero bits are sent as a positive voltage and ones as a negative voltage.  Since the circuit needs the negative voltage to charge the capacitor, this will also cause problems when transmitting data back to the host.

For many applications this is a quick and simple way to interface to an RS232 port, however it isn't a universal solution, therefore if it works for you all's well and good, if not time for a MAX232 or a similar.

 

For more detail: Simple RS232 to logic level converter for PIC microcontroller

  • What is the primary function of this circuit?
    The circuit converts logic level voltages to and from RS232 serial voltage levels.
  • Can this circuit operate with a 3.3v supply?
    Yes, the circuit works with a supply voltage ranging from 3.3v to 5v.
  • How does the circuit generate the negative supply voltage?
    It derives the negative supply parasitically from the serial RS232 receive data line using a capacitor and diode.
  • Can two of these circuits be connected back to back?
    No, you cannot connect two of these back to back because neither device supplies the necessary negative voltage.
  • What voltage ranges define a logic 1 and logic 0 in RS232?
    A logic 1 is -3 to -25 volts, and a logic 0 is +3 to +25 volts.
  • Why might transmission fail over long cables with a 3.3v supply?
    Reliable transmission may not be possible in electrically noisy environments over long cables when using a 3.3v supply.
  • What should be done if high bit rates distort the signal?
    You can try changing the 100nF capacitor to a 47nF or 22nF capacitor.
  • Does the circuit require a capacitor for strictly half-duplex applications?
    If communication is strictly half-duplex, you may not need the capacitor at all.
Development Boards & Kits · PIC18F4520

Voltage Measurement with A PIC Microcontroller

Voltage Measurement with PIC Microcontroller articulates a methodical framework for facilitating analog voltage measurement using the PIC18F4520, an advanced member of Microchip’s...

Development Boards & Kits

Ultra-Low Power: Microcontroller Standby Current to 130uA with OPEnS Power Control Board

At the OPEnS Lab, a key focus for our projects is achieving exceptionally long battery life. This was particularly true for the...

Development Boards & Kits

An Integrated Approach to Developing Applications with Microchip PIC Microcontrollers

1. Introduction In our daily lives, a variety of devices such as telephones, household appliances, and cars incorporate "smart" electronics, typically manifested...

Development Boards & Kits

Microcontroller-Driven AC Voltage Control with Soft Start Feature

1. INTRODUCTION PWM-based AC voltage controllers find extensive application in uninterruptible power supplies (UPS) and high-power flexible AC transmission systems. This variable...

Development Boards & Kits

PIC Microcontroller-Based IC Tester for Efficient Integrated Circuit Verification

1. INTRODUCTION Within the electronics industry[1], as circuit complexity undergoes a drastic increase and the demand for higher reliability rises, a significant...

Development Boards & Kits · PIC16F887

Hands-On Microcontroller Projects: BK300 Development Board Featuring PIC16F887 Chip Lab

1. INTRODUCTION The study of microcontroller systems is experiencing a global surge across various fields within science, engineering, and technology departments of...

Ibrar Ayyub

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough...