TB3102 Boost Converter Using the PIC12F1501 NCO Peripheral Author: PERFORMANCE SPECIFICATIONS Mihnea Rosu Microchip Technology Inc. Electrical specifications over operating range: 3V ≤ VDD ≤ 5V. INTRODUCTION TABLE 1: ELECTRICAL SPECIFICATIONS This technical brief describes a digitally-controlled boost power supply based on the PIC12F1501. The implementation has very good efficiency at light loads, hardware overvoltage protection and uses a very small number of components. Input Voltage Range The peripherals needed for the application are: • • • • • Two 10-bit ADC channels One Fixed Voltage Reference (FVR) One Comparator (COMP) One Numerically Controlled Oscillator (NCO) One Complementary Waveform Generator (CWG) The peripherals are internally connected through firmware, reducing the number of external pins to just three. FIGURE 1: 3-5 Volts DC 5 Volts DC Output Current 2 Amperes Output Power 10 Watts Code Size 452 Words Ram Size 31 Bytes Efficiency 86.8% Output Voltage Measured at 2A Available Code Size 572 Words Available RAM Size 33 Bytes BLOCK DIAGRAM The output voltage and current are regulated using a proportional control loop. Output values are read using two ADC channels and the control signal is adjusted accordingly. The NCO uses fixed-on-time pulses with variable frequency to adjust the duty cycle Pulse Frequency Modulation (PFM). Figure 1 illustrates the block diagram of SMPS. BLOCK DIAGRAM VBAT Load CWG CWG1A PIC12F1501 OV prot VOUT-div COMP NCO FVR ADC Isense SW Control Button 2013 Microchip Technology Inc. DS90003102A-page 1 TB3102 The NCO control signal is routed through the CWG, so that the auto-shutdown feature can be used together with the comparator to provide hardware overvoltage protection. The control loop update rate is limited because of the ADC conversion speed and computational power. FIGURE 2: EFFICIENCY 94.00 % 92.00 % 90.00 % 88.00 % 4V Input 86.00 % 3V Input 84.00 % 82.00 % 80.00 % 50 100 250 500 750 1000 1200 1400 1600 1800 2000 mA mA mA mA mA mA mA mA mA mA mA FUNCTIONAL DESCRIPTION The power supply uses the PIC12F1501 NCO and ADC to implement a proportional control loop. For each of the two ADC channels (voltage and current), four samples are taken on each measurement. The values are used to adjust the NCO frequency in order to adjust the converter output. The NCO functions in Pulse Frequency mode, having a “fixed-on-time” of 2 us. The operating frequency is limited in firmware to about 275 kHz, resulting in a maximum duty cycle of 55%. For a 16 MHz clock source and a 2 us pulse length, the NCO offers 15 bits of duty cycle resolution with a 16 Hz frequency step. Since only one control loop is running for both voltage and current regulation, a special function decides on each update which of the two needs to be regulated. In normal operating conditions, the control loop tries to match the output voltage to the reference value. If the output current goes over the limit, the loop tries to match the output current to the maximum allowed value by reducing the output voltage. A special counter prevents erratic behavior when transitioning from one mode to the other. The input voltage is connected to the microcontroller using a small diode and is bootstrapped to the output. This way, when the output voltage rises, it will power the microcontroller and MOSFET driver. This is more efficient because a higher VGS improves RDS(ON) and the interval below 4.5V is problematic for most power transistors. This also makes the FVR the only stable reference available, and requires a few changes in the way the output regulation is achieved. Instead of reading the output voltage through the divider, the FVR is read internally with the output voltage as a reference (connected to VDD). The divider is still used for hardware overvoltage protection and is calculated to trip the comparator just above the desired output voltage. The FVR voltage is used as a reference for the comparator. It is important to mention that the boost topology has a clear DC path from the power source to the output, through the rectifier diode, even if the switching transistor is blocked. The current limiting loop can only prevent overcurrent until the switching frequency becomes zero. From this point on, catastrophic shortcircuit events can occur without an additional protection switch. A second transistor can be placed on the output low side to cut off the load if a short circuit occurs. DS90003102A-page 2 2013 Microchip Technology Inc. TB3102 FIGURE 3: DUTY CYCLE vs. FREQUENCY USING FIXED ON TIME )UHT N+] 'XW\&\FOH )L[HGRQWLPH XV XV 3XOVH)UHTXHQF\PRGH 1&22XWSXW APPLICATIONS The proportional control loop regulating the output has an update rate of only 4 kHz, which makes it slow to respond to sudden load variations and input voltage changes. For this reason, the output voltage is clamped by a very fast comparator-based, overvoltage protection mechanism. On the other hand, this is a digitally-controlled power supply which offers huge advantages. Output voltage and current can be modified during run-time by the application and complex algorithms, like multi-step battery charging, it can be easily implemented. The NCO peripheral allows 15 bits of duty cycle resolution for the transistor control signal, which in turn allows very fine control of output voltage and current. The main application areas of this type of power supply are battery chargers, LED drivers with current mode dimming, thermoelectric cell drivers, programmable bias generators and others. With an accurate voltage reference, the circuit is more than adequate for charging sensitive Li-Ion batteries. 2013 Microchip Technology Inc. DS90003102A-page 3 TB3102 MCU PERIPHERAL CONFIGURATION DRAWING The application needs only two analog channels. One is for the output current and one is for the hardware overvoltage protection. The output voltage ADC channel is read internally from the FVR. The input-only digital pin, MCLR, can be used for a button or a similar purpose. During run-time, the programming clock and data I/O pins (PGC and PGD) are free for user-specific functionality (see Table 2): TABLE 2: Pin No. PIC12F1501 PERIPHERAL CONFIGURATION Name Function 1 VDD Supply voltage 2 RA5 CWG output – transistor control signal 3 AN3 Analog input (COMP) used for clamping output voltage 4 RA3 Digital input (BUTTON) – can be used to turn output on or off 5 AN2 Analog input (ADC) used for reading the current value on the shunt 6 PGC Programming clock 7 PGD Program data 8 VSS Ground reference FIGURE 4: PERIPHERAL CONFIGURATION CWG RA5 CWG1A PFM AUTO SHUTDOWN NCO COMP (PFM) RA4 2.048V OV PROTECTION FVR FIRMWARE FVR 2.048V ADC AN2 DS90003102A-page 4 RA2 ISENSE 2013 Microchip Technology Inc. TB3102 SCOPE PLOTS OF KEY PARAMETERS FIGURE 5: Table 3 contains some characteristics of the charger obtained with an input of 3V and an output of 5V. OPERATING FREQUENCY vs. LOAD CURRENT 300 kHz 250 kHz 200 kHz TABLE 3: POWER SUPPLY CHARACTERISTICS 150 kHz 4V Input 3V Input 100 kHz Output Current (mA)(2) Sw. Frequency (kHz)(3) 0 0.1-0.5 50 80.7 85.7 100 157.4 88.1 250 229.1 90.7 500 233.0 91 750 236.5 90.4 1000 239.3 89.5 1200 241.1 89.1 1400 244.5 88.5 1600 247.3 87.8 1800 250.6 87.3 2000 243.8 86.8 Efficiency (%)(1) 50 kHz 0 kHz 50 mA 100 mA 250 mA 500 mA 750 1000 1200 1400 1600 1800 2000 mA mA mA mA mA mA mA Figure 5 shows the converter operating frequency for 3V and 4V input at different output currents. Once the inductor current becomes continuous, the frequency/ duty cycle changes very little, only to compensate for component power losses. The power loss becomes very easy to see on the efficiency graph (see Figure 2). Note 1: Efficiency is calculated including power loss on current shunt. 2: At 2A, the converter is running in Current Limiting mode. 3: PWM is fixed-on-time (2 µs) with variable frequency. 2013 Microchip Technology Inc. DS90003102A-page 5 TB3102 This algorithm is run 3906 times per second (TIMER0 overflow period) to regulate the power supply output voltage and current. For each step, a decision is made to regulate either current or voltage, since the values cannot be over the set point, at the same time. In this way, only one proportional control loop is used, reducing the computational requirements. For seamless transition between voltage limiting and current limiting, a debouncing counter has to go down FIGURE 6: to zero in order to change from voltage to current limiting. Overvoltage changes the working mode to voltage limiting immediately. For a better understanding of the implemented algorithm, please see the following flowchart diagram (Figure 6). REGULATION ALGORITHM START Read ADC iout vout iout > iref cmode = 1 iout > iref (de-bouncing) OR vout > vref Regulate Current pid(iout, iref) vout > vref cmode = 0 Regulate Voltage pid(vout, vref) STOP GLOSSARY TABLE 4: PWM ACRONYMS Pulse-Width Modulation ADC Analog-to-Digital Converter DAC Digital-to-Analog Converter NCO Numerically Controlled Oscillator PID Proportional Integral Derivative CWG Complementary Waveform Generator FVR Fixed Voltage Reference DS90003102A-page 6 2013 Microchip Technology Inc. TB3102 APPENDIX A: FIGURE A-1: SCHEMATIC 2013 Microchip Technology Inc. DS90003102A-page 7 Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. • Microchip is willing to work with the customer who is concerned about the integrity of their code. • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.” Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act. Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, dsPIC, FlashFlex, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC, SST, SST Logo, SuperFlash and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MTP, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries. Analog-for-the-Digital Age, Application Maestro, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, SQI, Serial Quad I/O, Total Endurance, TSHARC, UniWinDriver, WiperLock, ZENA and Z-Scale are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. GestIC and ULPP are registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries. All other trademarks mentioned herein are property of their respective companies. © 2013, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 9781620777527 QUALITY MANAGEMENT SYSTEM CERTIFIED BY DNV == ISO/TS 16949 == DS90003102A-page 8 Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified. 2013 Microchip Technology Inc. Worldwide Sales and Service AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://www.microchip.com/ support Web Address: www.microchip.com Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Austin, TX Tel: 512-257-3370 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Cleveland Independence, OH Tel: 216-447-0464 Fax: 216-447-0643 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Novi, MI Tel: 248-848-4000 Houston, TX Tel: 281-894-5983 Indianapolis Noblesville, IN Tel: 317-773-8323 Fax: 317-773-5453 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 New York, NY Tel: 631-435-6000 San Jose, CA Tel: 408-735-9110 Canada - Toronto Tel: 905-673-0699 Fax: 905-673-6509 2013 Microchip Technology Inc. Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8569-7000 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hangzhou Tel: 86-571-2819-3187 Fax: 86-571-2819-3189 China - Hong Kong SAR Tel: 852-2943-5100 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8864-2200 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-3019-1500 Japan - Osaka Tel: 81-6-6152-7160 Fax: 81-6-6152-9310 Japan - Tokyo Tel: 81-3-6880- 3770 Fax: 81-3-6880-3771 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Dusseldorf Tel: 49-2129-3766400 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Germany - Pforzheim Tel: 49-7231-424750 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Italy - Venice Tel: 39-049-7625286 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Poland - Warsaw Tel: 48-22-3325737 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-5778-366 Fax: 886-3-5770-955 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 Sweden - Stockholm Tel: 46-8-5090-4654 UK - Wokingham Tel: 44-118-921-5800 Fax: 44-118-921-5820 Taiwan - Kaohsiung Tel: 886-7-213-7830 Taiwan - Taipei Tel: 886-2-2508-8600 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 10/28/13 DS90003102A-page 9