Design and production of simple RS232C/TTL level conversion and serial port power supply circuit

Publisher:创新火花Latest update time:2018-01-05 Source: eefocusKeywords:RS232C Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Many microcontroller applications use serial ports to connect to computer serial ports for data transmission or control command sending and receiving. A large part of microcontroller serial ports use TTL level standards (PIC can be directly connected to computer serial ports), its logic 1 level is 5V, logic 0 level is 0V, while computer serial ports use RS232C level standards, its logic 1 level is -3V--12V, logic 0 level is +3V-+12V. The level ranges of the two are very different, so a level conversion circuit is needed when connecting. There are many such circuits. Generally speaking, commercial products will use MAX232, DS275 and other dedicated RS232, TTL level conversion integrated circuits. For ordinary electronics enthusiasts, using such devices is not easy to buy, and secondly, it increases the cost of production. So what kind of circuits can replace them? This is also one of the problems I encountered when I first made microcontrollers combined with computers. Later, I found some related circuit information and solved these problems. Below I will introduce these circuit materials based on my experience in actual design and application, and also introduce some of my own experience in the design and application of serial port power supply circuits.

Figure 1 is a level conversion circuit built with low-power transistors, using an NPN tube and a PNP tube respectively. The NPN can use the commonly used 9014 or BC547, and the PNP can use the commonly used 9012 or BC557. The circuit is divided into two parts: transmission and reception, which are separated by dotted lines in Figure 1. They can be used separately or together. The transmission circuit uses a PNP tube. When the TxD signal of the microcontroller is a logic high level, Q1 is turned off, and the TxD ( PIN 3) of RS232C provides about -9V (the actual voltage varies depending on the serial interface chip used on the computer motherboard) to the RxD (PIN2) of RS232C. When the TxD signal of the microcontroller becomes a logic low level, Q1 is turned on, and about +5V is transmitted to the RxD (PIN2) of RS232C. When transmitting data in this way, the TxD (PIN3) of RS232C must be stable at about -9V.
  The receiving circuit below the dotted line converts the RS232C level into a TTL logic level. When the PC sends data to the RS232C TxD (PIN3), the logic 1 level is -9V, Q2 is turned off, and the RxD of the microcontroller is about +5V. When the RS232C TxD is the logic low level, it is +9V, Q2 is turned on, and the RxD of the microcontroller is about 0V.
  I often use the circuit in Figure 1 to replace chips such as MAX232 and DS275 in my own microcontroller applications. It can not only be used alone for transmission or reception, but also work well in some projects that require bidirectional transmission. I usually use 9600 baud rate, but it can actually work at a higher baud rate. It can also be soldered to a small 8-pin IC socket or PCB to directly replace DS275 (see Figure 2 for the pin function description of DS275).

Figure 3 is another RS232/TTL level conversion circuit. For the receiving circuit, it is the same as the circuit in Figure 1. This circuit uses two NPN low-power transistors . The transfer circuit does not need to reference a negative voltage from the RS232C TxD. In this way, when the microcontroller TxD is high, the RS232C RxD is 0V (not around -9V as in Figure 1), and when it is low, the RS232C RxD is +5V. Obviously, this is different from the RS232C standard, but most PC serial ports can accept such a level range. This circuit can be used to replace the DS275 chip directly as in Figure 1.
  The transistors in these two circuits can be replaced with most commonly used low-power transistors. I usually use 9012, 9014, BC547, and BC557, and they all work well. It should be noted that the level range they generate is not the standard RS232 level, so it cannot reach the nominal transmission distance of RS232.
  In some small applications, usually only a 2051 or PIC chip and a few small components are used. Their power consumption is very small, usually more than ten milliamperes are enough. In my own PC remote control project, I use an AT89C2051, an integrated infrared receiver and a small LED , a few resistors and capacitors and the transmission part of the circuit mentioned above. The total power consumption is only a little more than ten milliamperes. I use the circuit in Figure 4 to steal power directly from the PC serial port, and the effect is very good. It can provide 5V and more than 20 milliamperes of current . You can also use the circuit in Figure 5. But it should be noted that both circuits require the upper software to make the 7 and 4 pins of the serial port high level before they can normally draw power, otherwise they cannot steal the required voltage from the serial port.


Keywords:RS232C Reference address:Design and production of simple RS232C/TTL level conversion and serial port power supply circuit

Previous article:Microcontroller tutorial 1 LED water lamp
Next article:C51 Programming Specifications

Recommended ReadingLatest update time:2024-11-22 12:34

Basic circuit diagram of TTL inverter
From the previous analysis, it is known that the dynamic performance of the BJT inverter with a resistive load is not ideal. Under the premise of keeping the logical function unchanged, several components can be added to improve its dynamic performance, such as reducing the delay caused by the charge storage effect of
[Analog Electronics]
Basic circuit diagram of TTL inverter
STM8 serial communication debugging summary (TTL)
1. Hardware Connection   1. GPIO and USART1 initialization structure variable definition /* Debug serial port Pin and configuration */ #define DEF_UBR_BAUDRATE 115200      #define DBG_UART USART1 #define DBG_UART_CLK CLK_Peripheral_USART1  #define DBG_UART_TX_PIN GPIOC, GPIO_Pin_2 #define DBG_UART_RX_PIN GPIOC
[Microcontroller]
STM8 serial communication debugging summary (TTL)
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号