Using the HT45FH5N in Type-C Quick Charge Power Bank ...Using the HT45FH5N in Type-C Quick Charge...
Transcript of Using the HT45FH5N in Type-C Quick Charge Power Bank ...Using the HT45FH5N in Type-C Quick Charge...
AN0456E V1.00 1 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
D/N: AN0456E
Instruction Quick charge technology now exists as a mature technology resulting in huge improvements
to mobile phone charging speeds. The Type-C interface provides a bidirectional power supply
function, which allows power bank applications to charge or discharge via a single port.
Additionally, quick charge technology has an improved effect on the charging/discharging
current. Holtek’s special purpose power bank management ICs provide solutions for all of
these functions. This text will initially introduce the power bank charge and discharge
principles after which it will explain the control flowchart for each process, allowing users to
have a deeper understanding of Holtek’s power bank management ICs.
Functional Description
Power Bank Charge Functional Description
USB interfaces all require a 5V operating voltage However Lithium batteries, which are
the usual type of battery used in power banks, have a voltage of 3.7V, a buck converter is
required to implement the voltage reduction when using external USB power sources to
charge the power bank battery. This voltage conversion buck converter management is
implemented using the device’s integrated PWM function. The integrated OUVP and
OCP functions within the device also provide further over/under voltage protection and
over current protection during the charging process. There are three charging control
modes, trickle current charge mode, constant current charge mode and constant voltage
charge mode. The required charging voltages and currents for these modes differ
according to different user designs. These charging modes are described below.
Trickle Current Charging Mode: used for completely discharged batteries which have a
voltage of less than 3V. In this mode the battery will be pre-charged using a typical
0.1C(Note) constant trickle current during this first stage of charging.
Constant Current Charging Mode: when the battery voltage is greater than 3V, the charging
current will then switch to a typical 1C(Note) constant current during this second charging
stage.
AN0456E V1.00 2 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Constant Voltage Charging Mode: once the battery voltage has exceeded 4.1V, it will be
charged using a constant voltage during this third stage. The charge current decreases
gradually as the constant voltage charge time increases. Typically, the constant voltage
charge stage is completed when the charge current reduces to a value of less than 0.1C.
Note: taking a 1000mAh Li-battery as an example, a value of 0.1C means charging the battery
using a 100mA current and 1C means charging the battery using a 1000mA current.
Power Bank Discharge Functional Description
The power bank system includes a detection circuit to identify whether any external
devices such as a mobile phone is inserted or not. As the power bank USB interface
output voltage is 5V but as the Li-battery voltage is only 3.7V, a voltage boost conversion
process is required to implement the discharge process. This voltage boost conversion
management is implemented using the device’s integrated PWM function. The integrated
OCP function also provides over current protection for this process. There are two
discharge control modes, constant voltage discharge mode and constant current
discharge mode, which will be described below.
Constant Voltage Discharge Mode: the internal PWM function is used to control the
voltage boost circuit to ensure a constant 5V output. In this stage, current detection is
implemented to monitor the present discharge status. If the output current is too small, the
system will conclude that the mobile phone or other connected device has been removed
and will consequently switch off the power bank. If the output current is too large, the
system will switch to the constant current discharge mode to avoid any current overload
conditions.
Constant Current Discharge Mode: when the output current is too large, the system will
maintain a constant current output to avoid overload conditions. In this stage, current
monitoring is continued. Under normal conditions, the mobile phone or other connected
device will conclude that the current is fixed and will not further increase the loading.
However, if under abnormal conditions the mobile phone or other connected device
continues to increase the load resulting in a large current output, this will be detected by
the power bank system resulting in the corresponding protection function being
implemented.
Power Bank QC and MTK Discharge Functional Description
During discharging, the power bank will implement a quick charge recognition operation
on the connected device. If the connected device contains a quick charge function, the
power bank will supply a corresponding voltage output of 5V~12V according to the
device’s requirement.
AN0456E V1.00 3 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Hardware Block Diagram
HT45FH5N Type-C Quick Charge Power Bank Hardware Block Diagram
1. As the Type-C IN/OUT interface and the USB IN/OUT interface both operate at 5V
but as the power bank battery voltage is 3.7V, a voltage conversion operation is
required. Management of this voltage conversion is implemented using an MCU
together with an output complementary PWM circuit to control the PMOS+NMOS
power transistors and inductor components to form the charging buck and
discharging voltage boost conversion circuit.
2. Regarding the internal OUVP circuit, during normal operations the OUVP pin input
voltage is sampled by the ADC and controlled by the charge buck control management
system. When an over/under voltage situation occurs, the MCU will respond
immediately to disable the PWM outputs to protect the battery.
3. Regarding the internal OCP circuit, during normal operations the sensor current is
input via the corresponding OCP pin, amplified by an OPA and then sampled by the
ADC. When an over current situation occurs, the MCU will respond immediately to
disable the PWM output to protect the battery.
4. Battery Voltage Detection: during charging, the charge mode will be determined to be
either a trickle current, constant current or constant voltage mode, according to the
present battery voltage condition. During discharging, the remaining battery capacity
will be determined and discharging will cease if the power level is too low.
5. LEDs and Buttons: use a button as the power bank on/off control and use four LEDs
to display the present battery capacity level, 25, 50, 75 or 100%.
AN0456E V1.00 4 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Hardware Circuit
HT45FH5N Type-C Quick Charge Power Bank Circuit
MCU Operating Conditions Sleep status: VDD =3.0V~4.2V, Work status: VDD=5V
Oscillator: 8MHz
Low Voltage Reset: 2.55V
Watchdog Timer timeout: 500ms
Software Description Program Memory: 4K×16 -- uses 3201×16, usage: 78%
Data Memory: 256×8 -- uses 122×8, usage: 47%
ADC: used for voltage and current sampling during charging/discharging
PWM: used to control boost and buck circuits during charging/discharging
PWM ADJ: PWM duty auto adjustment by the hardware during discharging
AN0456E V1.00 5 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Timer: use the STM as a Timer Counter to generate an interrupt every 4ms and set a
variable to increment by one each time an interrupt is generated.
4ms: update the LED power capacity display
8ms: set the D_stateCheck_f flag for QC discharge recognition
8ms: set the Check_Mtk_f flag for MTK discharge recognition
8ms: set the TYPEC_Check_f flag for Type-C recognition
8ms: set the Check_Vin_f flag for input voltage monitoring
8ms: set the Det_Out_f flag for load detection
8ms: set the Det_Cap_f flag for battery capacity detection
1s: set the Usb2_in_Time flag for QC discharge recognition
500ms: Type-C detection count flag
Software Main Flowchart Description
HT45FH5N Type-C Quick Charge Power Bank Software Main Flowchart
AN0456E V1.00 6 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
1. Initialisation: RAM clear, pin function initialisation, WDT setup, OUVP calibration.
2. Sleep flag judgement: when the Sleep_f flag is set, operations such as stopping the
PWM function, turning off the charge/discharge port, configuring the pin function and
clearing the Data Memory will be implemented before entering the sleep mode. If the
Sleep_f flag is “0”, go to the next process.
3. Key scan: to determine whether the key is pressed continuously. Setup a parameter
Key_OFF_Cnt and start counting. This value will then be compared with the
parameter value preset by the software. If these two values are equal, I/O pin PB6 will
be configured as an output to control the flashlight on/off function.
4. Timer count: determine if the time interrupt 8ms flag is set. If it is high, setup the
corresponding charge/discharge flag. If it is low, skip this step.
5. LED power capacity display: use LEDs to display the battery capacity. Update and
indicate the present battery capacity during charging or the remaining capacity during
discharging.
6. Work status judgement: determine the software parameter Work_Status value. Enter
the charge mode if it is “0” or enter the discharge mode if it is “1”.
7. Battery capacity detection: time interrupt will set the Det_Cap_f flag to “1” every 8ms.
If this flag is high, the battery capacity detection process will be activated, the
charge/discharge power comparison will then be executed. More details are described
below.
Charge power comparison: in the charge mode, use the ADC (OVP00) to measure
the present voltage which is then compared with the parameter values preset by
the software. When the measured value matches a preset value range, in the next
charge power update process the corresponding power level will be displayed
using LEDs. The software power comparison is divided into three levels, as shown
below.
Power: 3.00~3.82(V) - Chavol_table[0] defined in RXX.C
Power: 3.82~4.00(V) - Chavol_table[1] defined in RXX.C
Power: 4.00~4.15(V) - Chavol_table[2] defined in RXX.C
Discharge power comparison: in the discharge mode, use the ADC (OVP00) to
measure the present voltage which is then compared with the parameter values
preset by the software. When the measured value matches a preset value range, in
the next discharge power update process the corresponding power level will be
displayed using LEDs. The software power comparison is divided into three levels,
as shown below.
Power: 4.15~3.85(V) - Chavol_table[2] defined in RXX.C
Power: 3.85~3.65(V) - Chavol_table[1] defined in RXX.C
Power: 3.65~3.45(V) - Chavol_table[0] defined in RXX.C
AN0456E V1.00 7 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
8. Load detection: a time interrupt will set the Det_Out_f flag high every 8ms, the load
detection process will be activated when this flag is high. Use the ADC(OTI-1, INI) to
measure current which is then compared with the parameter value preset by the
software to determine if the charge/discharge port is in an unloaded status.
9. Type-C recognition: a time interrupt will set the TYPEC_Check_f flag high every 8ms.
The Type-C recognition will be processed when this flag is high. If Type-C is in a
charge status, the charge flag DPF_IN_f will be set to “1” while the discharge flag
UPF_IN_f will be set if Type-C is in a discharge status.
Software Charge Subroutine Description
HT45FH5N Type-C Quick Charge Power Bank Charge Subroutine Flowchart
1. OPA calibration: the OCP OPA should be properly calibrated when entering the
charge mode at the first time. After the OPA calibration is complete, the OFF_Set_f
flag will be set, which indicates such an operation is not required during later
processes unless the power bank enters the sleep mode and clears this flag.
2. Input voltage determination: determine if the Micro-B and Type-C have a voltage
input by checking MIRC_IN_PIN(PA4) and TYPE_C_PIN(PA3). If both pins are high,
AN0456E V1.00 8 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
indicating that there is no input voltage access, the Sleep flag will be set. If any of
them are low, the program flow will continue to determine whether it is a Micro-B
voltage input or a Type-C voltage input. If the MIRC_IN_PIN(PA4) is low, the PA6 pin
output will be controlled to turn on the MOS to implement a Micro-B charge input. If it
is high, the PC5 output will be controlled to turn on the MOS to implement a Type-C
charge input.
3. Input voltage detection: use the ADC (OVP01) to read the input voltage which is then
compared with the parameter value preset by the software. When the ADC sampled
value is less than the preset value, the charge process will cease. The preset
parameter value can be set by V_IN_4V3 defined in the head.h file.
4. Charge management: execute the complete charge modes, including trickle current
charging, constant current charging and constant voltage charging modes, which will
be described later.
HT45FH5N Type-C Quick Charge Power Bank Charge Subroutine Flowchart
AN0456E V1.00 9 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
1. Battery insertion determination: setup a Bat_Ok_f flag using the software and
executea battery insertion detection process when this flag is “0”. Determine whether
it is a Micro-B input or a Type-C input and turn on the corresponding charge input
port. During the battery insertion detection, use the ADC(INI) to read the input current
which is then compared with the parameter value preset by the software. When the
ADC sampled value is greater than the preset parameter value, indicating that the
battery is properly inserted, the Bat_OK_f flag will then be set. The parameter value
can be set by CUR_200mA defined in the head.h file.
2. ADC read battery voltage: use ADC(OVP00) to read the battery voltage which is then
compared with the parameter value preset by the software to determine which
charge mode is required at the present time. The charge modes include trickle
current charge, constant current charge and constant voltage charge modes, which
are described below:
Trickle current charge: when the ADC sampled voltage value is less than the preset
parameter value of 3V, the trickle current charge flag will be set and the battery will
be charged using the constant current charge mode procedure with a trickle charge
current of 200mA. The voltage value of 3V can be set by BATV_3V while the current
value 200mA can be set by CUR_200mA. These two parameters are defined in the
head.h file.
Constant current charge: when the ADC sampled voltage value matches the preset
voltage value range of 3V~4V, the power bank will enter the constant current charge
mode, the procedures for which are described in detail in the following flowchart. The
voltage parameter value of 4V can be set by BATV_4V defined in the head.h file.
Constant voltage charge: when the ADC sampled value is greater than the preset
parameter value 4.2V, the constant voltage flag will be set. The corresponding
execution procedures are described in detail in the flowcharts shown later. The
voltage parameter value 4.2V can be set by BATV_4V25 defined in the head.h file.
3. Battery full flag judgement: when the battery is fully charged, the battery full flag
Bt_Full_f will be set high and the charge process will then cease.
AN0456E V1.00 10 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Software Constant Current Charge Subroutine Description
HT45FH5N Type-C Quick Charge Power Bank Constant Current Charge Subroutine Flowchart
1. Start charge flag determination: setup a Start_Cha_f flag, this flag will be set high in
the initialisation procedure and a QC charge recognition will process to enable the
PWM function.
2. Trickle current charge flag determination: set the charge current as 0.2A when the
flag Trickle_Charge_f is high and start the trickle current charge. The parameter
value of 0.2A can be set by CUR_200mA defined in the head.h file.
3. Supply limit voltage: during charging, the maximum supply limit should be set as 4.4V,
which can be set by V_IN_4V4 defined in the head.h.
4. Supply limit voltage determination: use the ADC(OVP01) to read the input voltage,
which is then compared with the supply limit voltage value preset by the software.
When the ADC sampled value is less than the preset supply limit value, the
corresponding flag Limi_PWM_f will be set high and vice versa. The PWM will be set
to reduce the duty instead of increasing duty.
5. ADC read Input current: use ADC(INI) to read the input current which is then
compared with the charge current value preset by the software. When the ADC
sampled value is greater than the preset charge current value, the PWM will be set to
reduce the duty, while the duty will be increased if the sampled value is less.
6. Start charge flag determination: setup a Start_Cha_f flag, this flag will be set high
during the initialisation process to enable the PWM function.
AN0456E V1.00 11 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Software Constant Voltage Charge Subroutine Description
HT45FH5N Type-C Quick Charge Power Bank Constant Voltage Charge Subroutine Flowchart
1. Supply limit flag determination: determine the supply limit flag Limi_PWM_f status.
When this flag is high, the PWM will be set to reduce the duty.
2. ADC read battery voltage: use ADC(OVP00) to read the battery voltage which is then
compared with the preset parameter value 4.2V. When the ADC sampled value is
less than the preset parameter value, the PWM will be set to reduce the duty, while
the duty will increase if the sampled value is greater than the preset value.
3. ADC read input current: use ADC(INI) to read the input current which is then
compared with the parameter value 0.2A preset by the software. If the ADC sampled
value is greater than the preset parameter value, clear the constant voltage charge
flag CV_Mod_f, if the ADC sampled value is less, set the battery full flag Bt_Full_f.
AN0456E V1.00 12 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Software Discharge Subroutine Description
HT45FH5N Type-C Quick Charge Power Bank Discharge Subroutine Flowchart
1. Micro-B input voltage determination: in the discharge mode, if a Micro-B input voltage
is detected, it will switch to the charge mode.
2. Type-C charge/discharge flag determination: in the discharge mode, if the Type-C
charge flag DPF_IN_f is high and the Type-C discharge flag UPF_IN_f is low, it will
switch to the charge mode.
3. Output current flag determination: when the output current is less than the preset
parameter value, the CC_OUT_f flag will be low for Type-A while the CC_OUT_f1
flag will low for Type-C, which will activate the voltage boost output process. If the
flag is high, the PWM duty will be reduced.
4. Voltage boost output: except for the 5V output, the discharge mode also contains
high pass QC discharge recognition and MTK discharge recognition. Details are
described below:
High pass QC: the output voltage is adjusted according to the recognition with an
output voltage range of 5V~12V.
MTK: the output voltage can be 5V, 7V, 9V and 12V according to the recognition.
AN0456E V1.00 13 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
5. Type-C discharge flag determination: determine the discharge flag UPF_IN_f. The
Type-C discharge output will be turned off if this flag is low. When the flag is high, the
Type-C will be turned on only if the QC flag QC_HiVol_f and MTK flag MTK_MODE_f
are both low.
6. Type-A discharge flag determination: determine the Det_Short_f flag. If this flag is
low, turn on the Type-A output; If it is high, turn off the Type-A output and set the
Sleep_f flag.
7. Output current detection: in the initial processes, the maximum output current is set
as 3A. The maximum output current parameter value should be set as 2.1A for 9V
output voltage and 1.6A for 12V output voltage. After this, use the ADC(OTI-1, INI) to
read the output current which is then compared with the preset maximum output
current parameter value. When the ADC sampled value is greater than the preset
value, the CC_OUT_f flag will be set for Type-A and the CC_OUT_f1 will be set for
Type-C. When the ADC sampled value is greater than the result of the maximum
preset current value added to 0.2A, the Det_Short_f flag will be set. Additionally, use
ADC(OVP01) to measure the output voltage which is then compared with the
parameter value 3.5V preset by the software. If the ADC sampled value is less, which
indicates a short circuit condition, the Type-A and Type-C discharge outputs will both
be turned off while the Det_Short_f flag will be set. The preset current parameter
values of 3A, 2.1A and 1.6A can be setup by the OUTPUT_3A, OUTPUT_2A1 and
OUTPUT_1A6 while the 3.5V voltage parameter value can be set by the
V_OUT_3V5. These parameters are defined in the head.h file.
8. QC recognition: determine if the connected device contains the high pass quick
charge function, whose result will be recorded. The corresponding voltage will be
output to discharge on the connected device during the next voltage boost process.
9. MTK recognition: determine if the connected device has an MTK quick charge
function, whose result will be recorded. The corresponding voltage will be output to
discharge on the connected device during the next voltage boost process.
AN0456E V1.00 14 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Operating Description
Demo Board Operating Description
1. BAT+, BAT-: the positive and negative ends of the Li-battery are connected to BAT+
and BAT- respectively.
2. LEDs: used for the display which indicates the remaining capacity and
charge/discharge power display.
3. Button: press to display the power level.
4. Flashlight: press continuously to turn on the flashlight.
5. Micro-B Input: external power input to charge the power bank
6. Type-C Input/Output: external power input to charge the power bank or supply power
for external mobile phones.
7. Type-A Output: to supply power for external devices
Conclusion
This application note has introduced how to use the HT45FH5N for quick charge power
bank applications as well as describing power bank charge/discharge principles and
related application software control flows. With regard to the power bank
charge/discharge management, a synchronous rectification function has been
implemented for better efficiency and lower standby current. The integrated OVP, UVP
and OCP functions reduce the requirements for large numbers of external components
resulting in reduced PCB area. All voltage and current thresholds for the charge and
discharge modes have been parameterized, making it more convenient for threshold
adjustment during product development.
AN0456E V1.00 15 / 15 April 25, 2017
Using the HT45FH5N in Type-C Quick Charge Power Bank Applications
Version and Modification Information
Date Author Issue
2017.4.12 李振榮 First Version
Reference Files
Reference file: HT45FH5N Datasheet
For more information, refer to the Holtek official website http://www.holtek.com/en/
Disclaimer
Disclaimer
All information, trademarks, logos, graphics, videos, audio clips, links and other items
appearing on this website ('Information') are for reference only and is subject to change at
any time without prior notice and at the discretion of Holtek Semiconductor Inc. (herein
after 'Holtek', 'the company', 'us', 'we' or 'our'). Whilst Holtek endeavors to ensure the
accuracy of the Information on this website, no express or implied warranty is given by
Holtek to the accuracy of the Information. Holtek shall bear no responsibility for any
incorrectness or leakage.
Holtek shall not be liable for any damages (including but not limited to computer virus,
system problems or data loss) whatsoever arising in using or in connection with the use of
this website by any party. There may be links in this area, which allow you to visit the
websites of other companies. These websites are not controlled by Holtek. Holtek will
bear no responsibility and no guarantee to whatsoever Information displayed at such sites.
Hyperlinks to other websites are at your own risk.
Limitation of Liability
In no event shall Holtek Limited be liable to any other party for any loss or damage
whatsoever or howsoever caused directly or indirectly in connection with your access to
or use of this website, the content thereon or any goods, materials or services.
Governing Law
The Disclaimer contained in the website shall be governed by and interpreted in
accordance with the laws of the Republic of China. Users will submit to the non-exclusive
jurisdiction of the Republic of China courts.
Update of Disclaimer
Holtek reserves the right to update the Disclaimer at any time with or without prior notice,
all changes are effective immediately upon posting to the website.