How to wire CH340 for USB-to-serial converter

Looking into this cheap alternative for FTDI, and figuring out how to wire it to talk with AVR.

Datasheet

If you can call it that.

CH340DS1

Wiring

Seeedstudio sells this converter board and along with it comes schematic;

http://www.seeedstudio.com/wiki/USB_To_Uart_5V/3V3

USB_To_Uart_5V_3V3_v1

Does not seem to require practically any components. Oddly enough requires external crystal. And apparently they cannot use language English very good:

connects of VCC to input outside power while 3.3V, connects of 0.01uF decoupling capacitance outside while 5V

Make no sense. Connect VCC to input outside power while 3.3V? Could probably mean nothing or something. Cannot trust these at all.

Copied from http://binglongx.com/2011/10/26/arduino-serial-port-communication/ :

The fact that the UART in ATmega328 uses only 2 pins means no hardware flow control based on RTS/CTS or DSR/DTR is available. The USART0 in ATmega48/88/168/328 has a 2-character FIFO receive buffer and a Receive Shift Register, effectively providing a 3-char FIFO buffer.

And ready wiring seem to be available at: http://fobit.blogspot.fi/2014/11/ch340g-in-eagle.html

9uj3tQ3

And the Seeedstudio board:

snap1025

Also because it is theoretically possible that this chip need to be used (in my design) while power is not delivered via USB (e.g. when we want to use host-mode), we need to have capability to switch the IC power between USB and battery power so this circuit will be used:

YFqhV

Enhancement-mode MOSFETs are the common switching elements in most MOS. These devices are off at zero gate–source voltage, and can be turned on by pulling the gate voltage either higher than the source voltage, for NMOS, or lower than the source voltage, for PMOS. In most circuits, this means pulling an enhancement-mode MOSFET’s gate voltage towards its drain voltage turns it ON.

https://electronics.stackexchange.com/questions/96059/switch-between-battery-and-usb-power-no-microcontroller-circuit

So when battery is connected to source and the main supply to the gate, the device turns on when the main supply goes off and the resistors pulls the device lower than the source (battery).

Mixed voltages problems

While the CH340 is now capable of powering from USB, battery and also from the tertiary power supply, the problem became that the chip uses different configuration when operating from 5V, than what it does when using 3.3V. So the problem is that while USB is 5V the battery is 3.3V. Also problems do not end there because the battery is not guaranteed 3.3V but the system is specified to work as low as 3.0V, which is 300mV less than what CH340 requires.

Ideally now I would like to find small low current IC where everything is integrated and with one resistor I can set the desired output voltage.

All this will of course extend the functionality of that board but it will also increase the complexity because all these devices need to have the capability to be turned off.

Examining the Li-ion discharge once more

I already have done this but to find out if I can change the specification and consider the battery dead at 3.45V (3.3V + LDO voltage drop) I need to check more graphs.

Curve 1

18650-2200mAh-discharge-curve

Curve 2

Li_Ion_DiscGph

Curve 3

li_clip_image002_0005

Curve 4

discharge.2002-11-09

Conclusions

Curve 3 is the odd ball but everything else seem to drop off the cliff right around and after 3.3V or thereabouts. And more importantly than the voltage drop is the charge used. So if the regulator would have small 150mV drop then the CH340 would only stop operating after about when there would only be about 20% charge left. And with 20% charge left, the original idea was, that at that point everything would turn off to protect the battery.

Solution

Looking at following device (XC6210B332MR-G) from Torex Semiconductor with excellent specs and with competitive price ($0.60):

XC6210

I had now these devices can come with enable pin. This will make the design job a lot simpler and help me keep within the specification.

snap1027

My device will operate well below 100mA so the dropout will be negligible.

Too many power sources

I am having problems with power losses because I have three separate possible sources of power and the diode drops are quite large.

One possible solution would be to use specialized devices such as LTC4117 with three power sources:

2821 (1)

But the price is beyond belief and $6 is way too high.

Solution

Solution was found and I will wr

Capacitors

While arranging components it came to my mind that in which order should I place the capacitors. After several failed Google attempts, one site was following me in results, and it clearly gives answers to this very question:

fig_9_capacitors_in_ascending_order

Read the whole article here: http://blog.optimumdesign.com/how-to-place-a-pcb-bypass-capacitor-6-tips

Also prior to this some capacitors were already changed to tantalums, and were used to replace all the other electrolytics, but since this power board is now taking more general look, those larger, less expensive electrolytics will be added as a main storage site right next to power pins.

The original design was made for 400µA average current and peak of about 20mA but as this is more general, that 20mA may not be adequte for all applications.

Attachments