Converter USB-UART to CH340G: modifying to RS232TTL, testing, comparing. Com adapter

The device was taken for delivery when buying a charger.
The kit includes an adapter board and four 20 cm long wires with connectors at the ends.



The board is tightened into a transparent heat-shrink tubing, the functions of the terminals are indicated on the back.


The adapter is based on the PL2303HX microcircuit and is defined by Win7 / x64 OS as a virtual COM3 port.
The adapter can be connected to the Imax B6 charger to build the battery discharge curve.
from Habrahabr:
- In the charging itself, the menu turns on here: User set program -\u003e USB / Temp select -\u003e USB Enable


+5 volts need not be connected, they are only needed to power the sensor. TX is connected to the RX (receive) adapter, GND, respectively to the ground. The speed is 9600, but LogView knows it himself.


We go to and download the latest version there.
However, the program with the update already installed can be downloaded by.


Here, open the Graphic - Open graphic draft. Graphic - Save graphic draft to install by default on every startup.


Any log can be saved with File - Save As, and then open and work with it further - adjust display parameters and make a picture from it. The program is not very complicated, you can figure it out in an hour by typing. There is a Russian translation (I don’t remember where I found it, I already have it under my link), but it’s not complete. And English too - in the menus you often come across originally German words that you already had to learn - Entlaned - discharge, Laden - charge. Zyklus is a cycle.

I plan to buy +33 Add to favourites Review liked +20 +54

Almost all microcontrollers have a serial port on board - UART... It works according to a standard serial protocol, which means it can be easily connected to a computer on COM port. But there is one problem here - the fact is that the RS232 he takes for logical levels +/- 12 volts, and UART operates at five-volt levels. How to combine them? For this, there are several options for level converter circuits, but the most popular is still on a special converter RS232-TTL... This is a microcircuit MAX232 and its analogues.
Almost every company makes its own converter, so here it will fit and ST232and ADM232and HIN232... The circuit is as simple as three kopecks - input, output, power supply and strapping of five capacitors. Capacitors are usually installed 1uF electrolytes, but in some modifications 0.1uF ceramics. I soldered everywhere 0.1uF ceramics and usually it was enough. :) Works like a clock. If it fails at high speeds, then it will be necessary to increase the capacity.

By the way, there is also MAX3232 it is the same, but the output is not 5 volts TTL, but 3.3 volts TTL. It is used for low voltage controllers.

I made myself one such universal cord so that it was convenient to cling to the controllers. UART... For overall compactness, the entire circuit was pushed straight into the connector, since I had ST232 in the soic corps. The scarf turned out to be no more than a ruble coin. Since there were no small SMD capacitors at hand, I had to solder the conductors from above, who in what way. The main thing works, although it did not turn out very nicely.


If you doubt that you will get such a small installation, then I put the board into a standard PDIP case. It will be the size of a matchbox, but you do not need to grind it.


After assembly, the check is simple:
Plugs into connector COMport. Provides 5 volts of power to the circuit, and then you close Rx on Tx (I have green and yellow wires).

Then you open any terminal, though Hyper Terminal, you cling to the port and start sending bytes, they should be returned immediately. If this does not happen, check the circuit, where is the jamb.

If it works, then everything is simple. The wire that goes from leg 9 of the microcircuit MAX232 this is transmitting output, get him on his feet RxD controller. And the one with a leg 10 - receiving, boldly put him on the conclusion TxD controller.

When developing various kinds of electronic devices using microcontrollers, it is very often useful to connect them to a personal computer via a serial port. However, this cannot be done directly, since according to the RS-232 standard, the signal is transmitted at levels -3 ..- 15 V (logical<1>) and +3 .. + 15V (logical<0>). To convert RS-232 levels to standard TTL logic levels, special converter chips are usually used. However, it does not always make sense to put a level converter in the circuit of the designed device, since it often happens that communication with a computer is needed only at the stage of manufacturing and debugging the device, and there is no need for it for the final product. A logical way out in this situation can be the manufacture of a separate RS-232 to TTL level converter, a diagram of one of the possible variants of which is given below:

The basis of the proposed converter is the widely used MAX232A level converter microcircuit from Maxim (U1), which also has many analogs from other manufacturers (Analog Devices, LG, etc.). This microcircuit is designed for a supply voltage of 5V and has a built-in doubler and voltage inverter on switched capacitors to obtain the +10 V voltage required to work with RS-232 signals. The microcircuit requires 4 external capacitors (C1, C2, C3, C4) with a capacity of 0.1 μF, which are used in the voltage converter. In addition, to simplify use of this converter, it provides power directly from the serial port, eliminating the need for external power supplies. The 5 V supply voltage is created by a low-power linear voltage regulator LM78L05 (U2), the input of which is connected to the storage capacitor C6. Capacitor C6 is diode charged from the Data Terminal Ready signal (DTR, pin 4 of the 9-pin RS-232 connector). Diode D1 can be of any type (the author used a diode in a surface mount package, soldered from a burned-out motherboard). For normal operation of such a power converter, the DTR signal must be logic zero most of the time. This must be provided by the terminal program or user program being used.

The use of the converter described above turns out to be convenient in those cases when the possibility of communication with a computer is not required during the operation of the device, but it is needed at the stage of debugging or manufacturing the device. A typical example of this is, for example, a device with flash or EEPROM memory that requires initial initialization. In addition, it is often very convenient during the development process to output various kinds of debugging information to the serial port, which sometimes makes it possible to do without hardware emulators.

List of radioelements

Designation A type Denomination number NoteScoreMy notebook
U1 RS-232 interface IC

MAX232A

1 Into notepad
U2 Linear regulator

LM78L05A

1 Into notepad
D1 Diode 1 Into notepad
C1-C5 Capacitor0.1 uF5 Into notepad
C6 Electrolytic capacitor4.7 uF1

Microcontrollers in Arduino (ATmega328, 168, 2560) use, among other interfaces, a hardware-based serial interface (UART). The ATmega2560 (Arduino Mega) has four UARTs at once. The interface uses two wires - RX (receive) and TX (transmit), where the digital signal encodes the bit values \u200b\u200b"0" and "1" by the voltage on the wire. The value "0" corresponds to 0V, and the value "1" is the operating voltage of the integrated circuit (5V or 3.3V, depending on the model and operating mode of the MC). This type of coding is also called transistor-transistor logic (TTL), because the voltage on the wire directly affects the state (on / off) of the transistors that provide the digital signal transmission and reception.

The serial port of the computer (COM port), which is less and less often seen in modern models of compact computers, operates according to the old telecommunication standard RS232, where the signal coding is different: the value "0" is encoded with a voltage from + 3V to + 25V, and "1" - negative voltage from -3V to -25V. COM ports of personal computers usually have + 13V and -13V voltages.

The large voltage difference makes the RS232 connection more immune to interference, however, modern digital devices often use a TTL-compatible serial port, or USB, a much more modern and high-speed interface.

For comparison, the figure shows the TTL serial and RS 232 signals taken when transmitting a value of one byte.

To convert the RS232 signal to TTL and vice versa, you need to invert it (although this can be done in software) and convert the voltage. Usually microcircuits of the MAX232 type are used for this. Sometimes they use simplified home-made circuits that provide signal inversion and voltage conversion or resort to software and hardware solutions (software inversion, hardware voltage change).

In the case of Arduino (Uno, Mega, etc.), a USB-TTL serial controller is used, which provides work with the MC through a TTL-compatible serial interface. In the old models, the FTDI FT232 chip was used for this, in the new ones - the ATmega8U or ATmega16U. The serial pins of the MK are also available for direct connection. For Uno, these are pins D0, D1, and the Mega model has several serial interfaces at once. You cannot connect the RS232 port to these pins - it will not be able to work correctly due to a different type of coding, and high voltage can damage the MC.

It is convenient to use a USB-TTL serial adapter to connect to a TTL-compatible serial port from a computer. However, general-purpose USB-TTL serial adapters are sold only in specialized stores and, often, at an unreasonably high price. At the same time, USB-RS232 adapters are much more popular (and cheap). Upon closer examination, any USB-RS232 adapter contains two main components - microcircuits USB-TTL serial adapter and RS232-TTL serial converter.

I found a USB-RS232 adapter, the circuit of which was hidden in an easily disassembled case of a DB9 connector (sometimes the case is molded and it is more difficult to get to the circuit). The adapter turned out to be built on the popular Prolific PL2303 (USB-TTL serial adapter) and Zywyn ZT213 (RS232-TTL adapter) chips. Looking at the PL2303 specification, I found out that I needed pins 1 (TX) and 5 (RX), to which I soldered the wires, without changing the circuit in any way (so the RS232 part remained functional). I took the ground from the 5th pin of DB9 so as not to touch the 7th pin of the microcircuit.

The result is a cheap and angry USB-TTL serial adapter. In the screenshot: Serial monitor from Arduino IDE is connected via USB, and realterm is connected directly to D0, D1 via USB-TTL serial adapter.

I heard that many data cables for mobile phones also contain USB-TTL serial controllers, although an increasing number of modern models connect directly to the USB interface without requiring special adapters. Many microcontrollers are equipped with a USB interface, in particular the ATmega8U and ATmega16U, which are used in the Arduino as USB-TTL serial controllers, giving access to the ATmega328, which does not have a USB interface.

PL2303HX is a small USB to Serial converter with built-in RS232 transceiver (UART interface). The microcircuit creates a virtual COM port on the computer through which you can flash microcontrollers, as well as restore routers, set-top boxes.


Technical specifications

Supply voltage: 5V (from USB)
Interface 1: USB
Interface 2: TTL (0 to 5, Rx and Tx)
Output voltage, V: 3.3 and 5 (separate outputs)
Dimensions: 50mm x 15mm x 8mm
Operating system support: Windows XP / 7/8 / 8.1 / 10.

General information about PL2303HX

The main microcircuit for the module is PL2303HX, which until 2012 was produced by Prolific Technology. In fact, this is a USB to UART interface converter with TTL, CMOS logic levels (0 V… +5 V). On the one hand, there is a USB connector for connecting to a computer, and on the other, a five-pin UART connector (RX, TX and power pins for + 5V and + 3.3V), for protection against short circuits, the module is placed in a transparent heat-shrinkable tube, the PL2303HX schematic diagram is shown in the figure below.

Purpose of LEDs:
P (Power) - power (permanently on)
R (RxD) - received data
T (TxD) - transmitted data

It can be seen from the electrical diagram that the power to the + 5V output comes directly from the USB port, without protective elements, and the power to the + 3.3V output comes from the PL-2303 internal stabilizer, which can withstand a current of up to 150 mA. The official Prolific driver for Windows 7, 8 and 10 does not work since. checks the originality of the PL-2303 chip, but it is possible to fix everything by looking at this.

Testing

For testing, you can use " Terminal1_9_b», You can download this program in this article.

Install the driver
Launch "Terminal1_9_b" on behalf of the administrator.
In the upper corner, select “ COM Port"(Can be viewed in the device manager) and click" Connect»

At the bottom, enter an arbitrary value and click " -\u003e Send“, The TxD LED will flash briefly with each press.
Short the TxD and RxD pins together and press "-\u003e Send", two LEDs, TxD and RxD, will briefly light up with each press, and the program will display the sent command.
3.3V and 5V voltage can be checked with an ordinary multimeter

Links
PL2303HX Documentation
Driver for