USBSerial: Difference between revisions

From Rev0 Wiki
Jump to navigation Jump to search
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:


[[File:Usbser_top_assembled.jpg|thumb|right|Assembled USB to serial adapter board, top view.]]
[[File:Usbser_top_assembled.jpg|thumb|right|Assembled USB to serial adapter board, top view.]]
[[File:Usbser_bot_assembled.jpg|thumb|right|Assembled USB to serial adapter board, bottom view.]]


==List of Features==
==List of Features==
Line 12: Line 13:


==Electronics==
==Electronics==
===Buck Converter (Charger)===
The full board schematic is shown in the image below. The circuitry contains basic rBOM for the CH340G chip, 2 adjustable LDOs with slide switches for voltage selection (feedback ground side resistor selection), and buffers/level translators.
A simplified schematic of the buck converter that charges the 18650 from a 6-12V supply is shown in the thumbnail below:


[[File:Ccr_v20_buck_simple.png|thumb|center|400px|Simplified buck circuit schematic for the CCR v2.0.]]
[[File:Usb-ser-sch.png|thumb|center|400px|Full schematic for the USB to serial adapter board.]]


The input is decoupled with 220uF of electrolytic capacitors for each cell, total 440uF, plus 10uF of MLCCs for each cell. This is switched through an NCE30P12S P-channel MOSFET rated for up to 12A drain current, <25mOhm resistance at 4.5Vgs, and up to 3W power dissipation. Current is then supplied through 2 SS54 diodes in parallel during the off state, for up to 10A rated current at ~0.4Vf at 3A. The output is then filtered through another 440uF of electrolytic capacitors plus 10uF of MLCC.
The PCB is laid out with 2 headers, one for the main Tx/Rx/GND/Pwr outputs, and another for the less commonly used CTS/DSR/RI/DCD//DTR/RTS/R232 signals and GND. 4 M3 mounting holes are available in the corners of the board, with separation of 0.85" on the short side, and 1.6" on the long side.


===Boost Converter (Discharger, regenerative)===
[[File:Usb-ser-brd-1up.png|thumb|center|400px|Top/bottom side routing for the USB to serial adapter board.]]
A simplified schematic of the boost converter that discharges the 18650 into a 6-8.4V buffer pack is shown in the thumbnail below:


[[File:Ccr_v20_boost_simple.png|thumb|center|400px|Simplified boost circuit schematic for the CCR v2.0.]]
The board was then manually panelized into a 6-up board to fit within the 100x100mm "$2" PCB size for fab by JLCPCB.


The input is decoupled with 440uF of electrolytic capacitors plus 10uF of MLCC. This is switched to ground through an AO4406AL N-channel MOSFET rated for up to 13A drain current, <15.5mOhm resistance at 4.5Vgs, and up to 3W power dissipation. Current is carried through 2 SS54 diodes in parallel during the off state, for up to 10A rated current at ~0.4Vf at 3A. The output is then filtered through another 440uF of electrolytic capacitors plus 10uF x2 of MLCC.
[[File:Usb-ser-brd-6up.png|thumb|center|400px|6-up panel for the USB to serial adapter board.]]


===CCR v1 Performance Evaluation===
===PCB testing/evaluation===
[[File:CCR_v1_Efficiency.png|thumb|center|400px|Buck (charging)/Boost (discharging) converter efficiency for the CCR v1.0.]]
UART SI was measured using a 100MHz oscilloscope (Rigol DS1102E) at a 0.1" header. Signal shows sharp edges and correct IO voltage levels. No measurable crosstalk (down to 10mV) was detected on the adjacent Rx line during Tx.
[[File:Thermal_4V-1p5A.JPG|thumb|right|Boost (discharging) mode operation at 1.5A, showing peak external transistor temperature of 57.8 C.]]


===Constant Current Load (v2 Discharger, resistive)===
[[File:Uart-a-3mbaud-allvoltages.png|thumb|center|600px|UART Tx line letter "a" sent at 3Mbaud, at varying IO voltage levels (1.8V left, 2.5V, 3.3V, 5V right).]]
A simplified schematic of the MOSFET + Op-Amp based circuit that discharges the 18650 is shown in the thumbnail below:


[[File:Ccr_v20_disch_simple.png|thumb|center|400px|Simplified FET-based discharger schematic for the CCR v2.0.]]
The CH340 12 MHz crystal output was measured, which shows a relatively clean sine wave with little visible distortion.  


The input is decoupled with 440uF of electrolytic capacitors plus 10uF of MLCC. This is discharged to ground through an IRF3710 N-channel MOSFET rated for up to 57A of drain current, ~17mOhm resistance at 4.5Vgs, and up to 200W power dissipation (limited to 21W for single channel based on 100x40x20mm heatsink + 40x40x20mm fan). Current measured across a 10mOhm shunt resistor is fed back to the Op-amp which compares it to a filtered PWM output from the STM32 microcontroller to control the current of the 18650. There is an additional input to the Op-amp to override the feedback and bias the MOSFET off (e.g. during charge or disconnected modes). The original circuit is credited to Youtuber VoltLog ([https://www.youtube.com/watch?v=KYncNH8_m70 video link]) who reverse engineered a commonly sold "60W" constant current load and provided a detailed schematic. This circuit was prototyped on a proto board and then made into 2 standalone PCBs, one for through-hole kit form, and another small version using SMD parts.
[[File:Ch340-Xtal.png|thumb|center|400px|12 MHz oscillator output measured at XO test pad next to crystal.]]
 
===Microcontroller===
The CCR uses an STM32F103C8T6 microcontroller in the form of a "blue pill" board, which includes crystals, header pins, USB plug, and other supporting circuitry, and allows for the MCU to be swapped out in case of damage. Critically, the STM32F103 supports 8 12-bit ADC channels with fast read rate, 6 PWM channels operating at up to 360 kHz with 100 step PWM resolution, and built in USB PHY for communicating via virtual COM port to the PC.
 
===CCR v2 Performance Evaluation===
[[File:Current_ramp_0-1A.png|thumb|center|400px|Charging mode ramp from 0 to 1A (CC).]]
[[File:IR_current_pulse.png|thumb|center|400px|Discharge current pulse of 1A for measuring cell IR.]]
 
The CCR v2 was assembled 2/15/19 and checked for basic operation cycle testing a Samsung 25R. Charging current is limited to approximately 2A due to power dissipation of the SOIC-8 P-channel MOSFETs. This may improve slightly with proper airflow routing using a 3D printed enclosure. Transient performance and current regulation were measured with a Rigol DS1052E. Discharge shows an overshoot of approximately 18% for 580us, and regulation of +/-3.8% at 1A. Charge shows no overshoot, and regulation of +/-3.9% at 1.5A.
 
[[File:CCR_v2_Thermal_Charging3p5A180k.JPG|thumb|center|400px|Thermal image of the P-channel MOSFET at 180kHz switching frequency, 3.5A charging. Peak was 103 C from 12V supply.]]
 
Further investigation showed the MOSFET driver was not able to produce sharp edges, causing higher switching losses at 360 kHz. Changing the code to operate the MOSFETs at 180 kHz allows charging at up to 3.5A.


===Hardware Revisions===
===Hardware Revisions===
====Revision 1.0====
====Revision 1.0====
[[File:Ccr-v10_sch.png|thumb|right|The complete system schematic for the CCR v1.0.]]
[[File:Ccr_both.png|thumb|right|The PCB layout (Gerber view from JLCPCB) for the CCR v1.0.]]
This is the first revision of the CCR, which only natively supports regenerative discharging mode.
'''Errata:'''
* Pin A11 was used for the P-channel MOSFET control on cell 2, which is not usable for this function (pin is natively used as USB D+).
* There are no pull-up/pull-down resistors to keep the buck/boost converter "safe" when in programming mode (IO in Hi-Z) or when no power is applied to USB
* There is no power applied to the MCU when there is no USB plugged in
* There is no PTC protection for the cell
* Output of op-amp for voltage reading is 5V capable but going into 3.3V only ADC pin, needs series resistor to prevent damage
====Revision 2.0====
[[File:Ccr-v20_sch.png|thumb|right|The complete system schematic for the CCR v2.0.]]
[[File:Ccr-v20_both.png|thumb|right|The PCB layout (Gerber view from JLCPCB) for the CCR v2.0.]]


This is the second revision of the CCR, which supports regenerative discharging mode (optional) as well as constant current discharging mode, and increased current capability of up to 3A in charge, and 5A (single channel)/3A (dual channel) in discharge.
This is the first revision of the USB to serial adapter board.  
 
'''Change List:'''
* Added pull up/pull down resistors to "safe" the device when power is removed or reprogramming is taking place
* Added PTCs to cell and buck circuit to prevent shoot through or shorting of the cell which led to many N-channel MOSFETs being destroyed on the prototype
* Thermally isolated temperature sensor NTC from PCB ground plane by thin traces and cutout
* Added silkscreen below SMD cell holder for better reliability against cell shorting of bare cells
* Added pads and BOM option for external voltage sense wires for better accuracy in high current operation
* Added SOIC-8 MOSFET placement options for higher current FETs to accommodate 3-6A charge capability
* Added cutouts for a lever to pop the 18650 out of the cell holder
* Added option for second thermistor (e.g. allowing 2 isolated heatsinks for significantly higher power capability in discharge)
* Changed to WS2812B digitally controlled LEDs with option for external LED strip(s) or array


'''Errata:'''
'''Errata:'''
* Wrong silkscreen designator for C27 (reads R42)
* None known
* Output of op-amp for voltage reading is 5V capable but going into 3.3V only ADC pin, needs series resistor to prevent damage
* No pull down on fan control MOSFET causing fan to turn on during programming/reset
* PB2/boot1 pin location on STM32 blue pill footprint is not correct, offset by about 1 pin width.


====Revision 2.0====
====Revision 2.0====
[[File:Ccr-v21_sch.png|thumb|right|The complete system schematic for the CCR v2.1.]]
[[File:Ccr-v21_both.png|thumb|right|The PCB layout (Gerber view from JLCPCB) for the CCR v2.1.]]


This is a minor update to the second revision of the CCR, to fix the errors found in V2.0 and add the option to chain 2 cells in parallel or link both slot chargers/dischargers to power a single cell at up to 7A (or 6A for discharge).
N/A


'''Change List:'''
'''Change List:'''
* Fixed C27 silkscreen
* Add ESD diodes to inputs/outputs and USB lines (todo)
* Added series resistor on Op-amp output to protect ADC input of STM32 module
* Fixed PB2 pin location (offset in v2.0)*
* Added pull down on fan control pin
* Added pads to select single cell high power or 2 cell parallel operation*


'''Errata:'''
'''Errata:'''
* ...
* None known


====PCB Files====
====PCB Files====
Here is the Eagle schematic file for the CCR v1.0: http://rev0proto.com/files/tbd.sch
* Here is the Eagle schematic file for the USB to serial adapter board v1.0: http://rev0.net/Files/adp_v10.sch
Here is the Eagle board file for the CCR v1.0: http://rev0proto.com/files/tbd.brd
* Here is the Eagle board file (1-up) for the USB to serial adapter board v1.0: http://rev0.net/Files/adp_v10.brd
 
* Here is the Eagle board file (6-up) for the USB to serial adapter board v1.0: http://rev0.net/Files/adp_v10_panels.brd
Here is the Eagle schematic file for the CCR v2.0: http://rev0proto.com/files/tbd.sch
* Here are the gerber files (6-up panel) for the USB to serial adapter board v1.0: http://rev0.net/Files/adp_v10_panels.zip
Here is the Eagle board file for the CCR v2.0: http://rev0proto.com/files/tbd.brd


==Enclosure==
==Enclosure==


The enclosure for the CCR v2.0 was created in Fusion 360 and is made up of x pieces which can be 3D printed and assembled with M3 screws.
The enclosure for the USB to serial board was created in Fusion 360 and is made up of x pieces which can be 3D printed and assembled with M3 screws.
 
Here are the Fusion 360 files for the CCR v2.0 enclosure: http://rev0proto.com/files/tbd.zip
 
==Code==
 
Full source code for the project can be found here: http://rev0proto.com/files/x.zip


==Videos==
Here are the Fusion 360 files for the USB to serial board enclosure: http://rev0proto.com/files/tbd.zip
<HTML5video type="youtube" width="400" height="300" autoplay="false">1SHY4jAfTcM</HTML5video>
 
==Photos==
<gallery widths=180px heights=120px perrow=4>
File:CCR_v1_Regen.jpg|CCR v1 prototype in regenerative configuration
File:CCR_v1_Regen.jpg|...
</gallery>


==Total Project Cost==
==Total Project Cost==
Line 137: Line 72:
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|OPA335 Zero-Drift Amplifier (qty 2)
|CH340G
|$2.42
|$0.29
|[https://lcsc.com/product-detail/Others_Texas-Instruments-TI-OPA335AIDBVR_C364887.html LCSC]
|[https://lcsc.com/product-detail/USB_CH340G_C14267.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|MCP1402 MOSFET Driver (qty 4)
|Slide switch (SP3T)
|$1.83
|$0.21
|[https://lcsc.com/product-detail/MOS-Drivers_MICROCHIP_MCP1402T-E-OT_MCP1402T-E-OT_C128573.html LCSC]
|[https://lcsc.com/product-detail/Toggle-Switches_Korean-Hroparts-Elec-K3-2346D-K1_C145839.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|STM32F103 "Blue Pill"
|LD1117
|$1.82
|$0.08
|[https://s.click.aliexpress.com/e/cWPSibTi Aliexpress]
|[https://lcsc.com/product-detail/Low-Dropout-Regulators-LDO_LD1117AG-AD-AA3-A-R_C7916.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|NCS199A1 Current Sense Amplifier (qty 2)
|NL17SZ125 Buffer/Level Shifter (qty 2)
|$1.45
|$0.07
|[https://lcsc.com/product-detail/General-Purpose-Amplifiers_ON-Semicon_NCS199A1SQT2G_ON-Semicon-ON-NCS199A1SQT2G_C179595.html LCSC]
|[https://lcsc.com/product-detail/Logic-ICs_ON-Semicon_NL17SZ125DFT2G_ON-Semicon-ON-NL17SZ125DFT2G_C97774.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|18650 SMT Holder (qty 2)
|12 MHz Crystal
|$1.23
|$0.05
|[http://s.aliexpress.com/nuqmae6r Aliexpress]
|[https://lcsc.com/product-detail/49S_Yangxing-Tech-X49SD12MSD2SC_C16369.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|N-channel MOSFET 13A 11.5mOhm SOIC-8 (qty 4)
|500mA 1206 PTC (qty 2)
|$0.52
|$0.05
|[https://lcsc.com/product-detail/MOSFET_Alpha-Omega-Semicon_AO4406AL_Alpha-Omega-Semicon-AOS-AO4406AL_C35349.html LCSC]
|[https://lcsc.com/product-detail/PTC-Resettable-Fuses_TLC-Electronic-TLC-NSMD050_C261952.html LCSC]
|- style="color:gray;text-align:left;"
|- style="color:gray;text-align:left;"


|rBOM (under $0.41)
|rBOM (passives) (under $0.08)
|$4.76
|$0.10
|LCSC
|LCSC
|- style="color:green;text-align:left;"
|- style="color:green;text-align:left;"


|PCB
|PCB
|$2.00
|$0.16
|JLCPCB
|JLCPCB
|- style="color:purple;text-align:left;"
|- style="color:purple;text-align:left;"


|Assembly
|Shipping
|$7.10 - $31.70
|$0.05
|PCBgogo
|LCSC
|- style="color:black;text-align:center;"
|- style="color:black;text-align:center;"


|'''HW Component'''
|Total Price (Per board, qty. 60, incl. extras from MOQ)
|'''Cost'''
|$1.09
|'''Source'''
|- style="color:blue;text-align:left;"
 
|100x40x20 Aluminum Heatsink
|$3.02
|[https://www.ebay.com/itm/5pcs-Aluminum-Heat-Sink-100X40X20MM-100-40-20MM/163423637602?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649 eBay]
|- style="color:blue;text-align:left;"
 
|40x40x20 5V Fan
|$1.60
|[https://www.ebay.com/itm/10-Pcs-5V-40mm-x-20mm-Cooling-Case-Fan-40x40x20mm-PC-Computer-Cooler-3D-Printer/251791125294 eBay]
|- style="color:blue;text-align:left;"
 
|Misc HW (Under $0.22)
|$0.42
|Aliexpress/eBay
|- style="color:red;text-align:left;"
 
|Total Price
|$52.41 (Assembly cost $317, batch qty 10)
|
|
|-
|-


|}
|}

Latest revision as of 20:33, 20 March 2019

This is a project to create a low cost and versatile USB to serial adapter board based on the CH340G, with selectable (via slide switch) power and IO voltages (1.8, 2.5, 3.3, and 5V for both). Input and output protection is also provided via PTC fuses and series resistors + IO buffers.

Assembled USB to serial adapter board, top view.
Assembled USB to serial adapter board, bottom view.

List of Features

  • Supported Baud Rates: 50, 75, 100, 110, 134.5, 150, 300, 600, 900, 1200, 1800, 2400, 3600, 4800, 9600, 14400, 19200, 28800, 33600, 38400, 56000, 57600, 76800, 115200, 128000, 153600, 230400, 460800, 921600, 1500000, 2000000, 3000000 (not officially listed in datasheet, but tested functional)
  • Output Voltage (PWR pin): 5V, 3.3V, 2.5V, 1.8V
  • Output Current (PWR pin): 500mA
  • I/O Voltage (Tx pin): 5V, 3.3V, 2.5V, 1.8V
  • Input Voltage (Rx pin): 1.65 to 5.5V

Electronics

The full board schematic is shown in the image below. The circuitry contains basic rBOM for the CH340G chip, 2 adjustable LDOs with slide switches for voltage selection (feedback ground side resistor selection), and buffers/level translators.

Full schematic for the USB to serial adapter board.

The PCB is laid out with 2 headers, one for the main Tx/Rx/GND/Pwr outputs, and another for the less commonly used CTS/DSR/RI/DCD//DTR/RTS/R232 signals and GND. 4 M3 mounting holes are available in the corners of the board, with separation of 0.85" on the short side, and 1.6" on the long side.

Top/bottom side routing for the USB to serial adapter board.

The board was then manually panelized into a 6-up board to fit within the 100x100mm "$2" PCB size for fab by JLCPCB.

6-up panel for the USB to serial adapter board.

PCB testing/evaluation

UART SI was measured using a 100MHz oscilloscope (Rigol DS1102E) at a 0.1" header. Signal shows sharp edges and correct IO voltage levels. No measurable crosstalk (down to 10mV) was detected on the adjacent Rx line during Tx.

UART Tx line letter "a" sent at 3Mbaud, at varying IO voltage levels (1.8V left, 2.5V, 3.3V, 5V right).

The CH340 12 MHz crystal output was measured, which shows a relatively clean sine wave with little visible distortion.

12 MHz oscillator output measured at XO test pad next to crystal.

Hardware Revisions

Revision 1.0

This is the first revision of the USB to serial adapter board.

Errata:

  • None known

Revision 2.0

N/A

Change List:

  • Add ESD diodes to inputs/outputs and USB lines (todo)

Errata:

  • None known

PCB Files

Enclosure

The enclosure for the USB to serial board was created in Fusion 360 and is made up of x pieces which can be 3D printed and assembled with M3 screws.

Here are the Fusion 360 files for the USB to serial board enclosure: http://rev0proto.com/files/tbd.zip

Total Project Cost

EE Component Cost Source
CH340G $0.29 LCSC
Slide switch (SP3T) $0.21 LCSC
LD1117 $0.08 LCSC
NL17SZ125 Buffer/Level Shifter (qty 2) $0.07 LCSC
12 MHz Crystal $0.05 LCSC
500mA 1206 PTC (qty 2) $0.05 LCSC
rBOM (passives) (under $0.08) $0.10 LCSC
PCB $0.16 JLCPCB
Shipping $0.05 LCSC
Total Price (Per board, qty. 60, incl. extras from MOQ) $1.09