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.
Previous article:Microcontroller tutorial 1 LED water lamp
Next article:C51 Programming Specifications
Recommended ReadingLatest update time:2024-11-22 12:34
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Teach you to learn 51 single chip microcomputer-C language version (Second Edition) (Song Xuefeng)
- Hand-drawn pictures reveal the secrets of the electronic world
- Hand-drawn illustrations revealing the secrets of communication circuits and sensor circuits (Mims III)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Vicor high-performance power modules enable the development of low-altitude avionics and EVTOL
- Chuangshi Technology's first appearance at electronica 2024: accelerating the overseas expansion of domestic distributors
- Chuangshi Technology's first appearance at electronica 2024: accelerating the overseas expansion of domestic distributors
- "Cross-chip" quantum entanglement helps build more powerful quantum computing capabilities
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Europe's three largest chip giants re-examine their supply chains
- Europe's three largest chip giants re-examine their supply chains
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Qorvo announced the acquisition of Active-Semi. Will Qorvo take off in areas such as 5G?
- Sun goods + 2 sets of Wei Dongshan suits
- 20-bit single-chip audio digital-to-analog converter PCM63P
- Lead Angle/Conduction Angle of Brushless DC Motor
- Analog electronics elective test + DC and AC parameters
- Can anyone confirm what device this is? Thanks!
- Toshiba Photo Relay TLP3547 Evaluation Report
- Understanding TMS320C6000 gel files
- NASA is going to build Wi-Fi on the moon? What do you think?
- How much does it cost to learn microcontrollers?