AN1372 Automotive Headlamp HID Ballast Reference Design Using the dsPIC® DSC Device Author: Jin Wang Microchip Technology Inc. INTRODUCTION In recent years, High Intensity Discharge (HID) lamps have been accepted as a good lighting source for automotive headlight applications. However, the startup process of an automotive HID lamp is complex. It consists of six stages and each stage presents different characteristics, which need different control strategies. Compared with conventional halogen lamps, Xenon lamps have features of high luminous efficacy, low power consumption, good color rendering and long lamp life. Xenon lamp automotive headlamp systems greatly improve the safety of driving at night. FIGURE 1: VOLTAGE AND CURRENT OF HID LAMPS AT STEADY STATE V A digitally controlled ballast has many advantages over the traditional analog approach: • Convenient implementation of sophisticated control algorithms • High performance operation • Effective protection • Very robust • Low cost This application note focuses on the implementation of an automotive HID electronic ballast using a Microchip GS-series 16-bit Digital Signal Controller (DSC). HID Lamp Gas is a good insulator under normal conditions. However, special conditions such as a strong electric field, x-ray radiation, ion bombardment, and high temperature heat could lead to ionization of gas molecules and produce free-charged particles. These charged particles can conduct current under an electric field, which is known as gas discharge. The light source made by this principle is called a gas discharge lamp. A HID lamp is one kind of gas discharge lamp. Others include high-pressure mercury lamps, high-pressure sodium lamps, metal halide lamps and some rare gas lamps, such as Xenon and Krypton lamps. HID lamps have many advantages over incandescent and fluorescent lighting, such as long lamp life, high efficiency, high brightness and low power consumption. They are widely used in factory buildings, airports, stadiums and square-shaped lighting fixtures. In addition, Xenon lamps are widely used in automotive applications. © 2011-2012 Microchip Technology Inc. I HID Electronic Ballast HID lamps present a negative resistance characteristic, which is shown in Equation 1. EQUATION 1: NEGATIVE RESISTANCE CHARACTERISTIC dV lamp ----------------- < 0 dI lamp This means the ballast is unstable if the lamp was directly connected to a voltage source. A series positive impedance is needed to ensure the ballast has a positive resistance characteristic, as shown in Equation 2. This is the basic ballast principle. EQUATION 2: POSITIVE RESISTANCE CHARACTERISTIC dV system --------------------- > 0 dI system DS01372B-page 1 AN1372 A traditional inductive ballast shown in Figure 2 has many problems such as large bulk capacitors, low Power Factor (PF) and difficulty reigniting. An electronic ballast is used to control the lamp current and lamp output power. Instant start-up, small size, high PF, and high efficiency can be achieved using an electronic ballast. FIGURE 2: INDUCTIVE BALLAST L AC IN Good electronic ballasts must have the following important features: • High power factor, greater than 0.9 at the ballast input • THD should be limited below 33% • No flicker during the lamp start-up process • High power efficiency • No acoustic resonance Technical Background of Automotive HID Ballast The start-up process of automotive HID lamps is quite complex. Figure 3 shows the working profile of HID lamp voltage and current during the start-up process. This is the inherent characteristic of an HID lamp and the ballast must be designed to meet this profile; otherwise, the HID lamp will not operate as expected. Lamp C AUTOMOTIVE HID LAMP VOLTAGE AND CURRENT(1) FIGURE 3: on rnTu 30 ms itio Ign n r ve eo k Ta -up rm a W 50 ms Vlamp(2) e tat y-s d a Ste p n-u Ru 6s-8s 65V-105V 20V-65V 20V-40V -400V 25 kV 2.5A(max) Ilamp 2.5A~0.41A 0.41A (@85V,35W) 0A -12A max Note 1: 2: -2.5A (max) The data presented in this figure depends on the lamp part number and working conditions. Vlamp in the turn-on stage is high-frequency AC; in this instance only its profile is illustrated. • Turn-on: Before ignition, the lamp’s equivalent impedance is considered as infinite, so the ballast is treated as an open circuit. In this stage, the ballast produces adequate voltage. In this stage, the voltage generated by the ballast is fed to the igniter circuitry to ignite the lamp. • Ignition: Automotive HID lamps are high pressure gas lamps. During this stage, the igniter circuitry generates a high voltage pulse across the lamp and the lamp transfers from isolation status to current conductive status. As the result, an arc is established in the tube and visible light is generated. The required ignition voltage for a hot lamp is around 25 kV. For a cold lamp, the voltage is around 10 kV. • Takeover: After successful ignition, the lamp requires a large current (takeover current) to sustain the arc. The output capacitance and auxiliary current circuit can provide this high magnitude current before the DC/DC converter delivers enough power to the lamp. DS01372B-page 2 • Warm-up: In this stage, the DC/DC converter provides a certain amount of current, depending on the lamp condition to sustain the arc. The converter works as current mode, and generates a square wave AC current. As the frequency is small (20 Hz) when compared to steady-state, it’s also called DC status. • Run-up: This is the key stage of the start-up process. In order to meet the SAE J2009 and ECE Reg. No 99 specification for the light output versus time, the start transient power of the lamp is much higher than the steady state. Then, the ballast controls the lamp power to ramp down to the normal level. • Steady State: The lamp voltage is ~ 85V, and the lamp current is ~0.4A, depending on lamp conditions. But the lamp power is recommended to be 35W, ±1W. This helps to ensure better output light performance and longer lamp life. © 2011-2012 Microchip Technology Inc. AN1372 The ballast in this reference design consists of four sections, as shown in Figure 4: • • • • High frequency DC/DC converter Low frequency DC/AC inverter Ignition circuit Digital Signal Controller FIGURE 4: The DC/DC converter boosts the battery voltage (9V16V) to a high level for the ignition circuit first, and then drops to ~85V for steady state operation. The DC/AC inverter converts the DC current to a square wave current to energize the two lamp electrodes equally. The high voltage igniter generates high voltage pulses to strike the lamp. Both The DC/DC converter and the DC/AC inverter are controlled by a single digital signal controller. BLOCK DIAGRAM OF THE DIGITAL REFERENCE DESIGN AUTOMOTIVE HID BALLAST Igniter Battery Lamp DC/DC Converter DC/AC Inverter Vlamp Ilamp PWM signal © 2011-2012 Microchip Technology Inc. Inverter signal Digital Signal Controller DS01372B-page 3 AN1372 AUTOMOTIVE HID BALLAST DIGITAL DESIGN System Design Specifications Table 1 lists the system specifications used for the automotive HID ballast digital design. TABLE 1: SYSTEM DESIGN SPECIFICATIONS Characteristic Input Voltage Specification Nominal 13.5V Operation 9V-16V Temperature Range Operation -40ºC to 105ºC Transient Maximum input current Cold lamp: 12A Hot lamp: 4A Maximum output current Maximum input power Maximum output power Steady Conditions — 2.5A 13.5V, 25ºC 115W 9V-16V, -40ºC to 105ºC 13.5V, 25ºC 75W 9V-16V, -40ºC to 105ºC Light output Meet ECE R99 13.5V, 25ºC Input current 3.5A maximum 13.5V, -40ºC to 105ºC Output power 35W ±1W 9V-16V, -40ºC to 105ºC Time of steady light output ≤ 150s 13.5V, 25ºC Efficiency > 85% 13.5V Acoustic Resonance — No acoustic resonance Flicker — No flicker Reliability Restrike 100% Successive operation Input Protection Output Protection 100 times turn-on/off 3000 hours Undervoltage protection 9V Overvoltage protection 16V Short-circuit protection Yes Open circuit protection Yes — Dimension — ≤10 mm * 60 mm * 80 mm EMI — Meet ECE R10 (error < 20%) DS01372B-page 4 — © 2011-2012 Microchip Technology Inc. AN1372 DC/AC CIRCUIT Hardware Topology Selection DC/DC CIRCUIT The DC/DC converter is the key stage to implement the control of the lamp voltage, lamp current, and lamp power. The performance and efficiency of the ballast are dependent on this stage. As introduced previously, this stage must have a boost function and large voltage output capability for open load. The flyback topology shown in Figure 5 is selected for the minimum number of components. In addition, voltage and current stress on the switch is decreased due to the boost function of the flyback transformer. However, the leakage inductance of the transformer will generate a highvoltage pulse on the switch, which affects system power efficiency. A full-bridge inverter is selected for this stage. Figure 6 shows the full-bridge inverter topology. The operation frequency of the inverter is dependent on the lamp state. Before ignition, the inverter runs at a frequency of 1 kHz for the turn-on and ignition stages. After ignition, the operation frequency is only 20 Hz for the warm-up stage. When the warm-up stage is over, the inverter operates at 200 Hz. FIGURE 6: FULL-BRIDGE INVERTER Vdc Load FIGURE 5: FLYBACK DC/DC CONVERTER Vout IGNITION CIRCUIT Vin The automotive HID ballast adopts an ignition circuit, which is driven by a dual-frequency inverter, as shown in Figure 7(B). Compared to a conventional ignition circuit with a voltage doubler, which is shown in Figure 7(A), it has two main advantages: the first is that the large ignition capacitor, C1, can be replaced by a much smaller one (C3 ≤ C1/10), and the second is it can generate a higher power pulse. This improves the ignition success rate especially for a hot lamp strike. FIGURE 7: IGNITION CIRCUITS C1 C2 C3 C4 Voltage Doubler Dual-frequency Inverter (A) (B) © 2011-2012 Microchip Technology Inc. DS01372B-page 5 AN1372 DIGITAL SIGNAL CONTROLLER Table 2 shows the dsPIC usage and Table 8 shows the block diagram of the digital signal controller. The dsPIC DSC detects the lamp voltage and lamp current through the Analog-to-Digital Converter (ADC) pair 0 (AN0 and AN1). Then, the current reference of the DC/DC converter is calculated according to the lamp voltage. The controller adjusts the PWM duty cycle of the DC/DC converter to control the lamp current. Meanwhile, several fault signals are monitored by the digital signal controller. Open circuit protection and short circuit protection need rapid response, so the internal comparators (CMP1D and CMP2D) are selected to implement these two protections. At the same time, the digital signal controller measures the battery voltage through the ADC pair 1 (AN2). If the battery voltage is outside the normal operation range, the ballast will stop working. In addition, Timer2 of the DSC is used to control the operation frequency of the full-bridge inverter, and the inverter drive signal is produced through the I/O port, RB14. FIGURE 8: TABLE 2: dsPIC® USAGE Feature Description System clock Internal FRC Oscillator Input voltage protection ADC pair 1; Timer2 for trigger DC/DC Converter control PWM1 Open and short circuit protection CMP1D; CMP2D Lamp current and voltage ADC pair 0; PWM1 for sample trigger Full-bridge inverter drive signal Timer2; RB14 Fail ignition protection Timer2 Delay function Timer1 Indication LED RB4 BLOCK DIAGRAM OF THE DIGITAL SIGNAL CONTROLLER Ballast Circuitry Vin Indication LED RB4 PWM1H AN2 Full-Bridge PWM Signal AN1 AN0 Vlamp Ilamp PWM Ierr Iref PI CMP1D CMP2D Vmin < Vin < Vmax Fault RB14 DS01372B-page 6 DAC Output Timer2 DAC Output © 2011-2012 Microchip Technology Inc. AN1372 (lamp gas switches from isolation to current conductive state), the ballast should respond quickly and provide sufficient current to maintain the arc. Constant voltage control is replaced by constant current control at the warm-up stage, as shown in Figure 10(B). Finally, at the run-up stage and steady state, the ballast works in power control mode. When the lamp voltage exceeds 30V, it enters into the run-up stage. The ballast should control the lamp power from a high level (~75W, depending on the lamp status) to a low level (35W) until steady state. During this stage the decreasing power control mode is selected. When the lamp voltage exceeds 65V, the lamp enters into a steady state. The ballast operates at constant power control to maintain the lamp power at 35W, ±1W. The steady state schematic is illustrated in Figure 10(C). Control Strategy and Control Loop Design CONTROL STRATEGY DESIGN As introduced in the section “Technical Background of Automotive HID Ballast”, the start-up process of the automotive HID lamps consists of six stages. It needs different control strategies in every stage and the timing control is very strict. Figure 9 shows the timing flowchart of the control strategies. At the turn-on stage, the ballast should boost the battery voltage to a proper level. This voltage is maintained for a period of time to fully charge the igniter capacitor, until the lamp gas switches from isolation to current conductive state. The DC/DC stage works in constant voltage control in this mode, as shown in Figure 10(A). Immediately after successful ignition St at e R St ea dy un -u p W ar m -u p Ta ke ov er Ig ni tio n TIMING FLOWCHART OF THE CONTROL STRATEGIES Tu rn -o n FIGURE 9: r C on s C tan on t P tro o l we er ec re C asin on g tro P l ow t D C N on o tro l C C on C urr sta on en n tro t t l C N on o tro l C o Vo ns C lta tan on g t tro e l Vlamp Note: FIGURE 10: This figure shows the “as is” magnitude profile of the lamp. Its direction is not illustrated here. VOLTAGE, CURRENT AND POWER CONTROL DIAGRAMS (A, B, AND C) Co Co K1 Verr ko (B) K2 Ierr Vlamp Gi Constant Voltage Control Mode (A) ko Vref Ilamp Gi Constant Current Control Mode Iref Co K1 (C) K2 ko Perr Gi Power Control Mode © 2011-2012 Microchip Technology Inc. MULT Plamp Pref DS01372B-page 7 AN1372 Three different control modes (voltage, current, and power) are needed during the start-up process, which makes the software quite complex. However, the features of the dsPIC DSC minimize the complexity of the software design. For example: • Interrupt driven control with multiple priorities • Intelligent peripherals to minimize software overhead • High performance math and DSP engine to efficiently perform complex calculations • Built-in comparators to provide high-speed, reliable protection • Simultaneous sampling ADC for accurate power measurements In addition, there are two transitions between two control mode changes in the process. The first transition is between the voltage control mode and current control mode. This may delay the current response of the DC/DC converter after ignition, which may lead to the lamp arc becoming extinguished. The second transition is between the current control mode and power control mode, which will lead to instability of the lamp current. Considering this, the control mode is optimized in this reference design. Only current control mode is employed for the entire start-up process. An advanced scheme is implemented using the dsPIC DSC, which achieves the various control modes without the drawbacks of unstable lamp current or extinguishing of the ignition arc. First, the constant voltage control mode in the turn-on stage is replaced by the constant current control mode. The maximum output voltage of the DC/DC converter is limited by the cycle-by-cycle Current-Limit function of the digital signal controller’s PWM module. The limited voltage value should be set for the ignition circuit (somewhere between 360V to 400V for igniter circuitry components tolerance). This accelerates the current response of the DC/DC converter, and contributes to a high ignition success rate. Also, the takeover current supplied by the auxiliary current circuit is reduced; therefore, the auxiliary current capacitor can be a smaller one. EQUATION 3: CURRENT REFERENCE FORMULA P ref I ref = -------------V lamp Where: Iref is the lamp current reference Pref is the lamp power reference Vlamp is the lamp voltage During these two stages (Run-up and Steady), the power reference is determined by lamp voltage sampled by the digital signal controller’s ADC module. The relationship between the power reference and lamp voltage is shown in Figure 11. FIGURE 11: POWER REFERENCE AND LAMP VOLTAGE Pref 58W 35W 30V Where: 65V Vlamp Pref is the lamp power reference Vlamp is the lamp voltage As discussed previously, the current reference of the regulator during the entire start-up process is shown in Figure 12. Next, the power control mode is replaced by the current control mode in the run-up stage and steady state. When the start-up process enters into the run-up stage from the warm-up stage, there is no control mode transition, which may lead to instability of the lamp current. In this way, we can control the lamp current to achieve lamp power control. The current reference in these two stages is calculated, as shown in Equation 3. DS01372B-page 8 © 2011-2012 Microchip Technology Inc. AN1372 St at e R St ea dy un -u p W ar m -u p Ta ke ov er Ig ni Iref tio n CURRENT REFERENCE Tu rn -o n FIGURE 12: 1.8A 0.8A 0.41A t CURRENT CONTROL LOOP DESIGN EQUATION 4: The full-bridge inverter converts the DC voltage into low-frequency square wave AC in a fully symmetrical pattern. Therefore, the small signal modeling of the ballast will only be conducted on the flyback converter. As introduced in the section “Control Strategy and Control Loop Design”, there is only a current loop in this reference design. Figure 13 shows the block diagram of the current loop. G ( s ) = Gm ( s ) ⋅ Gp ( s ) ⋅ H ( s ) Where: Gm(s) is PWM generator function Gp(s) is the power stage function H(s) is the feedback function Table 3 lists the design parameters of the current loop at steady state. TABLE 3: Value Output Power Po = 35W Output Current Io = 0.41A Input Voltage Vi = 13.5V fs = 180 kHz Operation Frequency Current Loop Sampling Frequency f = 180 kHz Primary Inductance Lp = 3.47 µH Duty Cycle D = 0.51 Turn Ratio n=6 fsw = 200 Hz Current Loop Bandwidth FIGURE 13: Iref The PWM generator function Gm(s) = 1/8. The feedback function consists of two parts, one is the sample resistance (0.68Ω) and the other is the proportional amplifier (gain is 2). Therefore, the value of H(s) is 1.36. The power stage function, Gp(s), is calculated by the flyback small signal module as shown in Figure 14. CURRENT LOOP DESIGN PARAMETERS Design Parameter ORIGINAL TRANSFER FUNCTION CURRENT LOOP BLOCK DIAGRAM + Ierr Compensator (GI) Vc PWM Gm(s) d Power Stage Gp(s) Lamp I H(s) © 2011-2012 Microchip Technology Inc. DS01372B-page 9 AN1372 FIGURE 14: SMALL SIGNAL MODEL OF THE FLYBACK CONVERTER L Ig(t) (Vg+V/n) * d(t) + I(t) 1:D 1-D:n V(t) R C Vg(t) I * d(t)/n Ig d(t) – Based on Figure 14, the power stage function, Gp(s), is calculated in Equation 5. As a result, the entire original transfer function is calculated, as shown in Equation 6. EQUATION 5: POWER STAGE TRANSFER FUNCTION Lp D′----– -------------- s V D D′ ⋅R o v ( t )G p ( s ) = -----------= ------ ⋅ -------------------------------------------------------2 R ⋅ dt Vg (t)= 0 R 2 2 n Lp 2 n L p Cs + ----------- s + D′ R EQUATION 6: Where: Vo = the input voltage D = the duty cycle D' = (1-D) R = the lamp equivalent resistance Lp = the primary inductance ENTIRE ORIGINAL TRANSFER FUNCTION Lp D′ ------ – -------------s Vo 1.36 D D′ ⋅ R - ⋅ ---------G ( s ) = G m ( s ) ⋅ G p ( s ) ⋅ H ( s ) = ------ ⋅ -------------------------------------------------------2 8 R n L 2 2 2 p n L p Cs + ----------- s + D′ R EQUATION 7: Where: Gm(s) = PWM module transfer function H(s) = Feedback circuitry transfer function CURRENT ERROR COMPENSATOR The transfer function for the current error compensator is given by: k Ii 1 + T co ⋅ s G I ( s ) = k pi + ------ = k pi ⎛------------------------ ⎞ ⎝ T co ⋅ s ⎠ s Where fz = 20 Hz, which is the location of zero for the current PI controller and, 1 T co = ---------- = 0.00796 2πf z ′2 2 1 + T co ⋅ s nL p CD R f sw 8 G I ( s ) = ------------------------------------ ⋅ ---------- ⋅ ⎛⎝------------------------ ⎞⎠ T co ⋅ s Vo Lp 1.36 1 + 0.00796 ⋅ s ⇒ G I ( s ) = 0.1162 ⋅ ⎛----------------------------------- ⎞ ⎝ 0.00796 ⋅ s ⎠ 14.59 ⇒ G I ( s ) = 0.1162 + ------------s Based on Equation 7, kpi = 0.1162 and kIi = 14.59/Sampling Frequency = 0.00008. DS01372B-page 10 © 2011-2012 Microchip Technology Inc. AN1372 Figure 15 shows bode plots of the original transfer function and compensated transfer function. FIGURE 15: ORIGINAL AND COMPENSATED BODE PLOTS Original Functions (Gain Margin 33.83 dB, Phase Margin 15.2º) Compensated Functions (Gain Margin 48.43dB, Phase Margin 101.7°) © 2011-2012 Microchip Technology Inc. DS01372B-page 11 AN1372 SOFTWARE DESIGN Figure 16 shows the control flowchart of the system. FIGURE 16: CONTROL FLOWCHART Initialization Yes Vin < 9V or Vin > 16V? Turn OFF Converter No Turn ON Converter and Control the Output Voltage at 360V Timer1 Start to Count No Ignition successful? No Yes Exceed 10 seconds? Yes DC Operation Yes Constant Power Control Vlamp > 65V? No Decreased Power Control DS01372B-page 12 No Open or Short Circuit? Yes © 2011-2012 Microchip Technology Inc. AN1372 Timing Logic for Software Implementation Timer1 runs at a frequency of 1 kHz. It is the time base for the delay subroutine function, which is used in the ignition failure detection. Timer2 is used for the fullbridge inverter drive signal and runs at a different frequency. PWM1 runs at 180 kHz. It also triggers ADC pair 0 every eight cycles. Lamp voltage and lamp current are sampled by ADC pair 0. An ADC interrupt is served on every trigger. In the Interrupt Service Routine (ISR), the digital signal controller reads the ADC result, checks the lamp status, executes the compensator, and then updates the PWM duty cycle to deliver proper power to the lamp. The timing diagram is illustrated in Figure 17. Before ignition, Timer2 runs at a frequency of 2 kHz to charge the igniter capacitor. After ignition, Timer2 runs at 40 Hz to warm-up the lamp electrode. After the warm-up stage, Timer2 runs at 400 Hz and remains at this frequency. In addition, Timer2 triggers ADC pair 1 every period to sample the battery voltage. FIGURE 17: TIMING LOGIC Timer1 Counter 1 kHz Timer2 Counter 2 kHz 40 Hz 400 Hz Trigger ADC Pair 1 PWM1 © 2011-2012 Microchip Technology Inc. 180 kHz DS01372B-page 13 AN1372 If the ignition flag = 0, the program flows into the ignition check function. If the ignition is detected, the ignition flag is set. The Timer2 period is reconfigured to 40 Hz for warm-up operation. Then, the program flows into the warm-up function. If the ignition is not detected, the program jumps to the open loop control flow. Software Flow The software flow is shown in Figure 18. At power-up, all of the variables and peripherals are initialized. PWM1 is configured to run at 180 kHz. Timer1 and Timer2 are configured to 1 kHz and 2 kHz separately. On every period, Timer2 generates an interrupt. Output pin RB14 is toggled in the interrupt service routine to provide the PWM for the Full-Bridge MOSFETs. Ignition time-out and warm-up completion detection is also implemented in this interrupt service routine. ADC pair 1 is also triggered by Timer2. However, its result is read and checked in background to detect whether the battery voltage is in the expected range. If the ignition flag = 1, warm-up code is executed. After the warm-up stage the lamp voltage is checked. If the lamp voltage is larger than 65V, the program jumps to the constant power control flow. A fixed power reference (35W) is divided by lamp voltage. The result is fed to the current compensator as the current reference. If the lamp voltage is smaller than 65V, the program flows to decreased power control flow. A variable power reference, as illustrated in Figure 11, is divided by the lamp voltage. The result is feed to the current compensator as the current reference. The compensator is then executed, and feeds its result to the PWM module. On every PWM cycle, PWM1 triggers ADC pair 0 to sample the lamp current and voltage, and most of the control algorithm is implemented in the ADC pair 0 interrupt service routine. An ignition success flag is checked at the entrance of the interrupt service routine. FIGURE 18: SOFTWARE FLOW Initialize Compensators Initialize Peripherals Reset e gg Tri D rA air Cp 0 Turn ON PWM1 Module Wait for ADC0 Interrupt Turn ON Timer2 Trigger ADC pair 1 VIN DS01372B-page 14 Wait for Timer2 Interrupt Check Input Voltage © 2011-2012 Microchip Technology Inc. AN1372 FIGURE 19: TIMER2 INTERRUPT SERVICE ROUTINE (ISR) FLOW Timer2 Interrupt Toggle Inverter Drive Signal Check End of Warm-up Stage © 2011-2012 Microchip Technology Inc. Check Ignition Failure DS01372B-page 15 AN1372 FIGURE 20: ADC INTERRUPT SERVICE ROUTINE (ISR) FLOW Ignition Flag = 0 ADC0 Interrupt Ignition Flag = 1 Startup_Phase_Operation: Open_Loop: g! =2 Decreased_power_control: Warm-up Stage Current Compensator Calculate Iref PWM Current Loop Compensator Filter Lamp Voltage Feedback Signal Vlamp Vlamp < 65V Calculate Iref Decreased_Voltage_control: Bu s_ Wa rm Update Inverter Frequency St Confirm_Ignition: Co V ns la ta nt mp > _c on 65V tr ol _O pe ra ti on : PWM Bus_Warmup_Success_Flag = 2 up _S uc ce ep ss_ _u F la p: Ilamp > 0.3A Ila Ope mp < 0 .3 n_C ont A rol : Ignition Check Voltage Loop Compensator Ilamp Filter Lamp Current Feedback Signal Ilamp Current Loop Compensator PWM Legend: Text in red indicates labels in the Assembly code. Text in black indicates jump conditions. DS01372B-page 16 PWM © 2011-2012 Microchip Technology Inc. AN1372 Functions Used in Software The functions listed in Table 4 and Table 5 are used in software for implementing the various stages of the automotive HID lamp ballast. TABLE 4: SOFTWARE FUNCTION File Name main.c Function Name Description Digital signal controller frequency configuration. main() Auxiliary clock configuration. PWM, CMP, and ADC configuration. Compensator initialization. Enable the PWM and ADC. Enable the full-bridge drive. Check the input voltage fault. init.c init_FlybackDrive() PWM1 module configuration. init_CMP() CMP1D and CMP2D configuration. init_ADC() ADC pair 0 and ADC pair 1 configuration. init_FlybackCurrentCtrl() Initialize flyback compensator. Delay_ms Time delay configuration. init_Timer2_full_bridge_drive() Full-bridge inverter drive signal configuration. isr.c Init_Variables() Reset variables and flags. Init_IO() Initialize RB14 as output for full-bridge PWM signal. T1Interrupt() Increment interrupt counter. T2Interrupt() Toggle I/O. Ignition time-out check. End of warm-up check. FlybackCurrentCntrl() isr_asm.s TABLE 5: Refer to Table 5. isr_asm.s FUNCTION File Name isr_asm.s Flyback compensator. Section Label Description Startup_Phase_Operation Filter lamp current. step_up Warm-up current control. Decreased_power_control Filter lamp voltage. Provide current reference by lamp voltage condition. Decreased_current_control Run-up stage current loop control. Power_Control_Operation Current reference calculation. Power loop control. Open_Loop Ignition success check. Open_control Open voltage control. Confirm_ignition Set ignition success flag. Configures DC operation frequency. Filters initialization. © 2011-2012 Microchip Technology Inc. DS01372B-page 17 AN1372 HARDWARE DESIGN Power Stage Parameter Design System Block Diagram TABLE 6: Figure 21 shows the system circuit diagram of the reference design. As introduced in the section “Hardware Topology Selection”, the design consists of four major sections. In addition, the design also includes several auxiliary circuits. An EMI filter at the input side attenuates the Electromagnetic Interference (EMI). At the same time, a reverse input-voltage protection circuit is also at the input side. Moreover, an RCD auxiliary current circuit before the full-bridge inverter provides the major takeover current before the response of the converter. A signal filter adjusts the lamp voltage and current signals before the ADC. Finally, the auxiliary power system supplies the digital and analog ICs on the board. FLYBACK DESIGN DATA Design Parameter Rated input voltage Vin = 13.5V Minimum input voltage Vin_min = 9V Maximum input voltage Vin_max = 16V Rated output voltage Vo = 85V Minimum output voltage Vo_min = 30V Maximum output voltage Vo_max = 102V Rated output current Maximum output current Rated output power Maximum output power Operation frequency DS01372B-page 18 Value Io = 0.41A Io_max = 1.8A Po = 35W Po_max = 75W fs = 180 kHz System efficiency η = 85% Diode forward voltage Vf = 1V © 2011-2012 Microchip Technology Inc. SYSTEM CIRCUIT DIAGRAM T1 EMI Filter Aux. Power R4 R1 D1 V in Auxiliary Current Circuit D3 C3 12V R4 D2 Q5 D6 C4 Q4 Q6 D5 R6 Q2 Reverse Protection Vlamp Ilamp PWM Signal dsPIC® PWM Driver DSC Lamp Arc gap T2 C5 D4 R5 R3 R5 Vin Inverter Driver Signal Ignition Circuit Q3 Q4 Q5 Q6 In this design, the input inrush current at the start of ignition is not controlled. To reduce this inrush current, it is recommended to use the internal comparator of the dsPIC device. The comparator should be set as the trigger source of the PWM Current-Limit mode. AN1372 DS01372B-page 19 Note: Q3 D7 C2 R2 Q1 Vdc Driver © 2011-2012 Microchip Technology Inc. FIGURE 21: AN1372 CALCULATION OF THE TRANSFORMER TURNS RATIO n EQUATION 8: MAXIMUM DRAIN-TOSOURCE VOLTAGE Vds_max OF MOSFET V ig V ds_max = V in_max + ------- + V′ n Where: EQUATION 10: CURRENT PARAMETERS OF THE PRIMARY INDUCTOR According to the power conservation, the average input current is: Po I in_ave = ---------------V in ⋅ η Where: Rated output power: Po = 35W Rated input voltage: Vin =13.5V Output voltage for ignition circuit: Vig = 360V System efficiency: η = 85% Max input voltage: Vin_max = 16V The average current during the on period is: Overshoot voltage: V’ ≈ 15V I in_ave I ave_on = --------------D Max drain-to-source voltage of MOSFET: VDSS = 100V Max drain-to-source voltage: Vds_max = 90% * VDSS = 90V Based on Equation 8, the transformer turns ratio is n = 6. Where: Duty cycle: D = 0.51 The peak current of the primary inductor is: ΔI I L_pk = I ave_on + -----2 CALCULATION OF THE PRIMARY INDUCTOR Lp EQUATION 9: VOLTAGE RATIO Vin/Vo OF THE CONVERTER AT RATED OPERATION Where: Assumed inductor ripple current: ΔI = 11A The RMS current of the primary inductor is: n ⋅ V in ⋅ D V o = -----------------------1–D Where: Rated input voltage: Vin = 13.5V Rated output voltage: Vo = 85V Duty cycle: D Calculated turns ratio: n = 6 Based on Equation 9, the duty cycle at rated operation D = 0.51. D I L_rms = I L_pk ⋅ ---3 Based on Equation 10, the average input current Iin_ave = 3.05A, the peak current of the primary inductor IL_pk = 11.48A, and the RMS current of the primary inductor IL_rms = 4.73A. EQUATION 11: VALUE OF THE PRIMARY INDUCTOR V in ⋅ t on L p = ------------------ΔI The flyback converter works at CCM mode at rated operation. Where: Rated input voltage: Vin = 13.5V Turn on time: ton = D * (1/fs) = 2.83 µs Inductor ripple current: ΔI = 11A Based on Equation 11, the primary inductor Lp = 3.47 µH. DS01372B-page 20 © 2011-2012 Microchip Technology Inc. AN1372 SELECTION OF THE PLANAR CORE The magnetic core cannot be saturated; therefore, the worst conditions (i.e., Vin = 9V; Po = 75W; Vo = 30V) should be considered. Based on Equation 9, the duty cycle at the worst condition Dw = 0.357. Based on Equation 10, the average input current Iin_ave_w = 9.8A, and the average on current Iave_on_w = 27.46A. EQUATION 12: THE INDUCTOR RIPPLE CURRENT AT WORST CONDITION ΔI w V in_min ⋅ D w = -----------------------------fs ⋅ Lp Comparing the Magnetics planar cores, FR43208EC and FR43208IC are selected for the flyback transformer, as shown in Equation 14. EQUATION 14: 4 AP = A w ⋅ A e = 0.767cm > 0.72cm 4 Where: Aw = 58.99 mm2 Ae = 130 mm2 CALCULATION OF THE PRIMARY AND SECONDARY TURNS EQUATION 15: Where: Minimum input voltage: Vin_min = 9V PARAMETERS OF THE SELECTED PLANAR CORES THE PRIMARY AND SECONDARY TURNS The primary turns is: Duty cycle at worst condition: Dw = 0.357 L p ⋅ I L_pk_w N p = --------------------------ΔB ⋅ A e Operation frequency: fs = 180 kHz Primary inductor: Lp = 3.47 µH Where: Based on Equation 12, the inductor ripple current at the worst condition ΔIw = 5.14A. Based on Equation 10, the peak current of the primary inductor at the worst condition IL_pk_w = 30.03, and the RMS current of the primary inductor at the worst condition IL_rms_w = 10.36A. The primary inductor: Lp = 3.47 µH The peak current of the primary inductor at worst condition: IL_pk_w = 30.03A Saturation magnetic induction: ΔB = 0.3T Ae = 130 mm2 The planar core is selected using the AP calculation method, as shown in Equation 13. The secondary turns is: EQUATION 13: Where: THE VALUE OF AP The primary side AP is: Ns = n ⋅ Np Turns ratio: n = 6 2 8 6.33 ⋅ L p ⋅ d p ⋅ 10 4 AP p = ---------------------------------------------- ( cm ) ΔB Where: The primary inductor: Lp = 3.47 µH The primary wire diameter: d2p = 1.816 mm Based on Equation 15, the primary turns Np = 2.65, the selected Np = 2, and the selected second turns Ns = 12. CALCULATION OF THE TRANSFORMER GAP EQUATION 16: TRANSFORMER GAP Saturation magnetic induction: ΔB = 0.3T 2 The second side AP is: L gap APs ≈ ( 2 ∼ 3 ) ⋅ AP p μ0 ⋅ Np ⋅ Ae = --------------------------Lp Where: The entire AP is: AP = AP p + AP s Based on Equation 13, the entire AP = 0.72 cm4. The primary turns: Np = 2 Ae = 130 mm2 The primary inductor: Lp = 3.47 µH Based on Equation 16, the transformer gap Lgap = 0.19 mm. © 2011-2012 Microchip Technology Inc. DS01372B-page 21 AN1372 POWER COMPONENTS SELECTION Ignition Circuit Parameter Design • MOSFET Q1 for input voltage reverse protection The selected ignition circuit is driven by a dualfrequency inverter, the design parameters are shown in Table 7. EQUATION 17: CALCULATION OF THE MAJOR MAXIMUM PARAMETERS The maximum RMS drain current is: I D_rms_max = I L_rms_w = 10.36A TABLE 7: IGNITION CIRCUIT DESIGN PARAMETERS Design Parameter Value Rated input voltage Vig = 360V Based on Equation 17, FDD8896 is selected for Q1, VDSS = 30V, Rds_on = 5.7 mΩ. Breakover voltage of the gas discharge tube • MOSFET Q2 for flyback converter Ignition pulse voltage value EQUATION 18: CALCULATION OF THE FLYBACK MOSFET MAXIMUM PARAMETERS The maximum drain current is: I D_max = I L_rms_w = 10.36A The maximum drain to source voltage is: V ig V ds_max = V in_max + ------- = V′ = 90V n Based on Equation 18, FDB3652 is selected for Q2, VDSS = 100V, Rds_on = 16 mΩ. CALCULATION OF THE FLYBACK DIODE MAXIMUM PARAMETERS The maximum forward current is: I L_pk_w I F_max = ----------------- = 5A n Tw > 0.5 µs Inverter frequency for ignition fig = 1 kHz IGNITER CAPACITOR AND RESISTOR Considering the ignition energy, the resonance capacitance C4 = 33nF/630V. EQUATION 21: T discharge ≈ T charge = 5 ⋅ C5 ⋅ R5 The charge and discharge period is: 1 T ig = ----f ig Where: Inverter frequency for ignition: fig = 1 kHz In addition, the charge time and C5 should meet: T ig T charge < ------2 V R_max = V ig + V in_max ⋅ n = 504V • MOSFET Q3-Q6 for full-bridge inverter EQUATION 20: CALCULATION OF THE FULL-BRIDGE MOSFET MAXIMUM PARAMETERS V ds_max C4 C 5 ≤ -----10 CALCULATION OF TRANSFORMER EQUATION 22: CALCULATION OF TURN RATIO N V ig_pulse n > -------------------V break I D_max = I o_max = 1.8A V ig = ------- = 180V 2 and Based on Equation 21, the selected pump capacitance C5 = 33nF/630V and the selected charge resistance R5 = 1k/3W. The maximum drain current is: The maximum drain to source voltage is: CALCULATION OF PUMP CAPACITANCE C5 AND CHARGE RESISTANCE R5 The charge and discharge time are almost the same: The maximum reverse voltage is: Based on Equation 19, RHR660 is selected for D3, VR_max = 600V, IF(AV)_max =6 A, Qrr = 45 nC. Vig_pulse > 25 kV Ignition pulse width • Diode D3 for flyback converter EQUATION 19: Vbreak = 600V Where: Ignition pulse voltage value: Vig_pulse > 25 kV Breakover voltage of the gas discharge tube: Vbreak = 600 Based on Equation 19, FCD7N60 is selected for Q3Q6, VDSS = 650V, ID_rms_max = 7A, Rds_on = 0.53Ω. DS01372B-page 22 © 2011-2012 Microchip Technology Inc. AN1372 Based on Equation 22, the turns ratio n > 41.7. Considering the parasitic parameters, the selected turns ratio n = 80. FIGURE 22: EQUATION 24: RMS IGNITION PULSE WIDTH THE POWER OF THE 15V AUXILIARY POWER CIRCUIT 2 1 P = --- L p_leak ⋅ I L_pk ⋅ f s 2 Where: sin ( Wd ⋅ t ) = 0.707 The leak inductor of the primary inductor: Lp_leak = 0.1 µH The peak current of the primary inductor: IL_pk = 11.48A Operation frequency: fs = 180 kHz Based on Equation 24, the power of the 15V auxiliary power, P = 1.18W. FIGURE 23: AUXILIARY POWER SYSTEM CIRCUITS MCP1703 Vbat EQUATION 23: CALCULATION OF THE PRIMARY INDUCTOR Lp 3.3V Cin Cout The RMS ignition pulse width is shown in Figure 22. sin ( Wd ⋅ t ) = 0.707 Where: 3.3V Auxiliary Power Circuit 1 Wd = --------------------L p ⋅ C4 T1 the resonance frequency is: ⇒ Wd ⋅ t 1 = 0.24π, Wd ⋅ t 2 = 0.76π 15V and the ignition pulse width is: 0.76π – 0.24π T w = t 2 – t 1 = ---------------------------------- > 0.5μs Wd Based on Equation 23, the primary inductor Lp > 0.28 µH, the selected Lp = 0.28 µH, and the selected Ls = 1.78 mH. 15V Auxiliary Power Circuit System Auxiliary Circuits Design AUXILIARY POWER SYSTEM DESIGN There are two auxiliary powers, one is 3.3V which supplies the digital signal controller and the op amp. The other is 15V, which supplies the full-bridge MOSFET driver. Figure 23 shows the circuit of the auxiliary power system. The power of the 15V circuit is calculated by Equation 24. © 2011-2012 Microchip Technology Inc. DS01372B-page 23 AN1372 MOSFET DRIVER DESIGN SIGNAL FILTER DESIGN There are five drive signals in the design, one is the flyback MOSFET drive signal and the other four are the full-bridge inverter MOSFETs. A MCP1407 IC is used to drive the flyback MOSFET. A IR2453 IC is used to drive the four full-bridge MOSFETs. The dead time is fixed at 1 µs. Figure 24 shows the two drive circuits. An op amp is used the amplify and filter the lamp voltage and current feedback signals. Figure 25 shows the two signal filters. Equation 25 calculates the transfer function of the two filters. FIGURE 24: MOSFET DRIVER CIRCUITS VCC VCC Rt Vbat 1 Digital Controller Signal Digital Controller Signal VDD VDD Input OUT OUT NC GND GND MCP1407 Drive Signal HO1 HO1 VB1 VS1 VS1 LO1 Ct LO1 HO2 HO2 VB2 SD Flyback MOSFET Driver Circuitry GND VS2 VS2 LO2 LO2 IR2453 Full-bridge MOSFETs Driver Circuitry FIGURE 25: SIGNAL FILTER CIRCUITS Lamp Voltage Sample Signal Vi R1 C1 + R2 R6 Vo Lamp Current Sample Signal Vo + C2 Vi Lamp Voltage Feedback EQUATION 25: R5 - R3 R4 C3 Lamp Current Feedback THE TRANSFER FUNCTION OF THE TWO FILTERS The voltage filter transfer function is: Vo 1 ------ = -----------------------------------------------------------------------------------------------2 Vi C1 C2 R1 R2 ⋅ s + ( C2 R1 + C2 R2 ) ⋅ s + 1 The current filter transfer function is: R5 + R6 Vo 1 ------ = -----------------⋅ ----------------------------R5 Vi C3 R3 ⋅ s + 1 DS01372B-page 24 © 2011-2012 Microchip Technology Inc. AN1372 GETTING STARTED Application Code Programming Figure 26 shows an overhead view of the demonstration panel. Inside the demonstration case, there is a 12 VDC/6.5 AH gel cell battery as well as a battery charger, which enables stand-alone operation. The MPLAB® ICD 2, MPLAB ICD 3, PICkit™ 3, and MPLAB REAL ICE™ in-circuit emulators may be used along with MPLAB IDE to debug and program your software. MPLAB IDE is available for download from the Microchip web site. 1. 2. 3. Xenon HID lamp. Igniter. dsPIC33FJ06GS202 Digital Ballast Board: Special software interacts with the MPLAB IDE application to run, stop, and single-step through programs. Breakpoints can be set and the processor can be reset. Once the processor is stopped, the register’s contents can be examined and modified. For more information on how to use MPLAB IDE, refer to the following documentation: A green LED on the Ballast Board, when lit, indicates that the 3.3V control circuitry power is available. A red LED on the Ballast Board, when lit, indicates that the battery voltage is too low to support board operation. When this occurs, set the power ON/ OFF switches to the OFF position and connect a power cord to the battery charger socket. Note: 4. 5. 6. • “MPLAB® IDE User’s Guide” (DS51519) • “MPLAB® IDE Quick Start Guide” (DS51281) • MPLAB® IDE Help The dsPIC33FJ06GS202 Digital Ballast Board does not control the Hi/Lo beam function. AC power input socket. Power ON/OFF switch. Beam HI/LO switch. FIGURE 26: DEMONSTRATION PANEL AND COMPONENTS 2 4 3 1 5 © 2011-2012 Microchip Technology Inc. 6 DS01372B-page 25 AN1372 Programming the Application Complete the following demonstration board: 1. 2. steps to Running the Application Demonstrations program the Make sure that the Power ON/OFF switch is in the OFF position. Connect the emulator header to the 6-pin connector labeled ICD_1. FIGURE 27: EMULATOR CONNECTOR POSITION This section describes two different automotive headlight demonstrations: • HID lamp operation with full digital control • Hi/Lo-beam operation Both of these demonstrations can be run either simultaneously or separately using the following steps (refer to Figure 26 for switch locations): 1. To operate the HID lamp, use the Power ON/ OFF switch. When the lamp is switched on, a high-pitched buzzing noise may be present at the start of ballast operation. This is normal and is not a cause for concern. 2. 3. 4. 5. 6. 7. 8. 9. Set the Power ON/OFF switch to the ON position. Start MPLAB IDE and open the HID Ballast demonstration project by double-clicking the .mcw file. The remaining steps take place within MPLAB IDE. Build the project by selecting Project > Build All. Choose the desired programmer, such as MPLAB ICD 3, by selecting Programmer > Select Programmer. Program the device by selecting Programmer > Program. After the device has been programmed, set the Power ON/OFF switch to the OFF position. Disconnect the emulator header from the 6-pin connector labeled ICD1_1. The HID Ballast board is now programmed and ready to run the demonstration. Note: When debugging the HID Ballast with the emulator, the connection between the PC and the board can be lost due to noise interference from lamp ignition. Therefore, it is recommended to use Programming mode. DS01372B-page 26 3. 4. To check hot lamp operation, do the following: a) Run the lamp for at least one minute to bring the lamp to a high temperature. b) After one minute, turn the HID lamp off by setting the Power ON/OFF switch to the OFF position. c) Wait for a few seconds and then set the Power ON/OFF switch to the ON position. The lamp should light immediately. To check cool lamp operation, do the following: a) Make sure the HID lamp is cold. The lamp should be switched to the OFF position for at least 10 minutes. b) Set the Power ON/OFF switch to the ON position. The lamp should light immediately. To run the Hi/Lo-beam demonstration, simply toggle the Hi/Lo-beam ON/OFF switch. Warning: When the lamp is lit, the light emitted is very strong, which may cause physical harm to your eyes. In addition, the lamp tube may rise to a very high temperature in just a few seconds. Do not touch the lamp or allow any flammable objects to come in contact with the lamp tube. FAILURE TO HEED THESE WARNINGS COULD RESULT IN PROPERTY DAMAGE OR BODILY HARM. © 2011-2012 Microchip Technology Inc. AN1372 LABORATORY TEST RESULTS AND WAVEFORMS Table 8 summarizes the resources required by the HID Ballast design in terms of memory size, peripherals, MIPS, etc. TABLE 8: dsPIC RESOURCE USAGE Resource Value Program Memory 2409 bytes Data Memory 48 bytes PWM 1 channel ADC 3 channels Comparator 2 channels MIPS 33.6 I/O TABLE 9: 2 channels The final prototype of the automotive HID ballast was tested according to the technical requirements. The test results are shown in Table 9. The testing conditions are as follows: • Test lamp: Xenon HID lamp, 35W, color temperature 6000K. • Ambient temperature: 25ºC, ±5ºC • Test input voltage: 9V-16V • Rated voltage: 13.5V • Oscilloscopes: YOKOGAWA DLM2024 • Voltage source: Chroma 62024P-80-60 Figure 28 through Figure 37 show the various waveforms including lamp current, voltage and power from the turn-on stage to the steady state, and provides a magnified view in every stage. In addition, the ignition curve and the input current curve are shown to verify the reference design. TEST RESULTS Characteristic Input Voltage Temperature Transient Test Result Comments Nominal (13.5V) Operation (9V-16V) Passed Passed — Operation (-40ºC to 105ºC) Passed — VIN = 9.4V-16V VIN = 9.4V Maximum Output Current 1.8A Maximum Input Power 101W Maximum Output Power Light Output Steady Input Current Output Power Time to reach steady light output Efficiency Acoustic Resonance 82.5W 78W 83.5W 70.2W 67.2W 3A 35W Passed 85.91% No Flicker Restrike Reliability Successive Operating Undervoltage Protection Overvoltage Protection Short Circuit Protection Passed 9.4V 16V 3A Open Circuit Protection 360V Input Protection Output Protection © 2011-2012 Microchip Technology Inc. 100% — VIN = 13.5V VIN = 16V VIN = 9.4V VIN = 13.5V VIN = 16V VIN = 13.5V VIN = 13.5V ≤ 150s VIN = 13.5V — — — — — — — DS01372B-page 27 AN1372 FIGURE 28: IGNITOR OUTPUT VOLTAGE WAVEFORM Voltage scale: 10kv/div FIGURE 29: INPUT CURRENT DURING START-UP PROCESS ON A COLD LAMP Current scale: 2A/div DS01372B-page 28 Time scale: 500ns/div Time scale: 2s/div © 2011-2012 Microchip Technology Inc. AN1372 FIGURE 30: OPEN VOLTAGE WAVEFORM AND IGNITION FAILED PROTECTION Voltage scale: 100V/div FIGURE 31: Time scale: 200ms/div, 5ms/div DC BUS VOLTAGE (SUCCESSFUL IGNITION) OF BREAKOVER POINT Voltage scale: 100V/div Time scale: 1s/div, 10ms/div © 2011-2012 Microchip Technology Inc. DS01372B-page 29 AN1372 FIGURE 32: LAMP POWER WAVEFORM OF COLD LAMP Power scale: 30W/div FIGURE 33: LAMP POWER WAVEFORM OF HOT LAMP Power scale: 30W/div DS01372B-page 30 Time scale: 2s/div Time scale: 500ms/div © 2011-2012 Microchip Technology Inc. AN1372 FIGURE 34: CURRENT FOR COLD LAMP; ZOOM OF THE TAKE-CURRENT Current scale: 1A/div FIGURE 35: Time scale: 2s/div, 500us/div CURRENT AND VOLTAGE FOR COLD LAMP; ZOOM OF THE DC WARM-UP CURRENT Voltage scale: 100V/div Current scale: 1A/div © 2011-2012 Microchip Technology Inc. Time scale: 2s/div, 10ms/div DS01372B-page 31 AN1372 FIGURE 36: CURRENT AND VOLTAGE FOR COLD LAMP; ZOOM OF THE RUN-UP STAGE Voltage scale: 100V/div FIGURE 37: Time scale: 2s/div, 10ms/div CURRENT AND VOLTAGE FOR COLD LAMP; ZOOM OF THE STEADY STATE Voltage scale: 100V/div DS01372B-page 32 Current scale: 1A/div Current scale: 1A/div Time scale: 2s/div, 10ms/div © 2011-2012 Microchip Technology Inc. AN1372 SUMMARY The reference design presented in this application note shows a complete fully digital controlled HID ballast design with simple circuitry and fast response. The Microchip dsPIC DSC device used in this reference design provides all of the necessary features and peripherals to implement a high-performance HID ballast. Its 40 MHz DSP engine is fast enough to implement real-time power loop control. Together with the on-chip Intelligence power peripheral modules (High-Speed ADC, Comparator, PWM), different control loops combined with precise timing control was easily implemented. Fast and smooth transition between different loops was also developed. The initial arc was successfully detected, and the subsequent fast response was provided to maintain it. In addition, system diagnose and fault protection can also be implemented without extra components. Note: Future plans for this application note include the addition of MATLAB modeling information. Please continue to check the Microchip web site for updates. © 2011-2012 Microchip Technology Inc. DS01372B-page 33 AN1372 APPENDIX A: SOURCE CODE Software License Agreement The software supplied herewith by Microchip Technology Incorporated (the “Company”) is intended and supplied to you, the Company’s customer, for use solely and exclusively with products manufactured by the Company. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. All of the software covered in this application note is available as a single WinZip archive file. This archive can be downloaded from the Microchip corporate Web site at: www.microchip.com APPENDIX B: REVISION HISTORY Revision A (March 2011) This is the initial released version of the document Revision B (April 2012) This revision includes the following updates: • The “Getting Started” section and the Ballast Schematic (see Figure C-1) were updated to reflect hardware changes made to the reference design • In addition, formatting and text changes were incorporated throughout the document for clarification purposes DS01372B-page 34 © 2011-2012 Microchip Technology Inc. © 2011-2012 Microchip Technology Inc. APPENDIX C: FIGURE C-1: SCHEMATICS AND BOARD LAYOUT BALLAST SCHEMATIC D1 400V RHR660 C2 C1 FCD7N60 Q1 3.3uF/400V HO2 C6 0.1n/1000V R2 150R/2W R5 499R/1W C10 R47 20k OUT1 1n/1000V VS2 BLM31PG121SH1 FCD7N60 Q4 D4 100n/500V OUT2 L2 C11 100n/500V HO1 LO2 FR1M R50 20k C14 1n/1000V C13 1.0n/1000V FCD7N60 Q2 R48 20k C5 1n/1000V L3 C52 0.1n/1000V C53 BLM31PG121SH1 C12 0.1n/1000V 1.0n/1000V LO1 FCD7N60 Q3 VS1 C15 1n/1000V R49 20k Ilamp+ R10 R330/1W Fault R12 R330/1W 13.5V L1 Battery+ 1u C4 100u/25V R1 10K D3 C8 104/25V 15V Q5 Battery- C3 10n/100V 1 VCC 2 FDD8896 C7 C47 2:12 D6 15V 47u/25V 104/25V DS01372B-page 35 100u/25V C17 104/25V PWM R11 10k 1 2 3 4 U1 VDD VDD Input Out NC Out Gnd Gnd MCP1407 8 7 6 5 *4 FDB3652 10K 3R3/0.25W AN1372 R9 13.5V 3 Q6 R3 C16 T1 D5 * SS14 R4 680R/0.25W dsPIC® DSC DEVICE SCHEMATIC AN1372 DS01372B-page 36 FIGURE C-2: U2 Vlamp Ilamp Vin Voltage limit Current Protection MCLP C44 © 2011-2012 Microchip Technology Inc. 104/25V 2 3 4 5 6 7 10 9 1 C45 105/25V C28 102/25V 8 19 AN0/CMP1A/RA0 AN1/CMP1B/RA1 AN2/CMP1C/CMP2A/RA2 AN3/CMP1D/CMP2B/RB0 AN4/CMP2C/RB9 AN5/CMP2D/RB10 OSCO/CLKO/RB2 OSCI/CLKIN/RB1 MCLR TMS/RB11 TCK/RB12 PWM2H/RB13 PWM2L/RB14 PWM1H/RA4 PWM1L/RA3 AVSS AVDD PGD2/EMUD2/DACOUT/INT0/RB3 PGC2/EMUC2/EXTREF/RB4 VDD PGD3/EMUD3/RB8 PGC3/EMUC3/RB15 TDO/RB5 PGD1/EMUD1/TDI/SCL/RB6 PGC1/EMUC1/SDA/RB7 VSS VSS VCAP 11 12 13 14 15 16 17 18 PWM R15 0R L4 R52 1k 3.3V DS2 Red EMUD EMUC 20 C32 dsPIC33FJ06GS202 FB Control 21 22 23 24 25 26 27 28 104/25V C33 100uF/6.3V C26 104/25V 3.3V C27 104/25V AN1372 FIGURE C-3: POWER SUPPLY SCHEMATIC MCP1703 GND Vout C19 C29 U3 Rsc1 L5 0R1/1W 22uH/0.5A 104/25V FIGURE C-4: place close to VDD (pin13 of dsPIC) C46 C18 104/25V 100uF/6.3V 1 13.5V 3.3V 3 Vin 2 R51 104/25V 1k C21 DS1 C31 105/25v 100u/25V Green MOSFET DRIVER SCHEMATIC 4 FB Control 3 3.3k R21 20k R20 1k HO2 CT VB2 102/25V SD 2 © 2011-2012 Microchip Technology Inc. HO1 VB1 13 14 VS2 LO2 R14 22R/0.25W HO1 C22 RT C24 5 NPN8050 IC1 VS1 LO1 R17 Q7 VCC C20 105/25V COM R13 7.5k 1 VCC 12 6 9 10 8 7 IRS2435D 2.2u/50V R16 22R/0.25W R19 22R/0.25W C48 C49 2.2u/50V 2.2u/50V VS1 LO1 HO2 C25 C50 C51 2.2u/50V 2.2u/50V 2.2u/50V VS2 LO2 R23 22R/0.25W DS01372B-page 37 AN1372 FIGURE C-5: DEBUGGER, INPUT VOLTAGE, AND OVERCURRENT SCHEMATICS Debugger MCLP R27 4.7K 3.3V ICD C34 VPP VDD VSS DAT CLO NC 105/25V EMUD EMUC Header 6H Input Voltage 13.5V R29 R32 Vin 20k 1k 2k R35 C37 104/25V Overcurrent R30 Fault Current Protection 2k C36 DS01372B-page 38 104/25V © 2011-2012 Microchip Technology Inc. AN1372 FIGURE C-6: LAMP VOLTAGE AND LAMP CURRENT SCHEMATICS Lamp Voltage 400V R28 R34 C39 103/25V R37 470k/0.25W 5.1K/0.25W C41 220p/25V U5:1 2 R44 100k R45 1 A 3 100k 8 3.3V 750k/0.25W Vlamp MCP6002 C40 220p/25V 4 R26 Voltage limit 3K/0.25W Lamp Current R46 R33 R41 Ilamp+ 2k C38 10k 104/25V 6 5 MCP6002 U5:2 7 B C43 104/25V 3.3V C42 © 2011-2012 Microchip Technology Inc. Ilamp 4 R39 10k 8 10k 105/25V DS01372B-page 39 AN1372 FIGURE C-7: IGNITER CIRCUIT SCHEMATIC C1 P1 2 1 R1 1K/3W OUT1 P2 OUT2 D1 D3 D2 SG R2 6.8M R3 6.8M 1 2 600V Connect to Lamp T1 C2 330n/630V R4 6.8M DS01372B-page 40 Trans © 2011-2012 Microchip Technology Inc. AN1372 FIGURE C-8: BALLAST BOARD LAYOUT - TOP LAYER © 2011-2012 Microchip Technology Inc. DS01372B-page 41 AN1372 FIGURE C-9: DS01372B-page 42 BALLAST BOARD LAYOUT - MIDDLE LAYER 1 © 2011-2012 Microchip Technology Inc. AN1372 FIGURE C-10: BALLAST BOARD LAYOUT - MIDDLE LAYER 2 © 2011-2012 Microchip Technology Inc. DS01372B-page 43 AN1372 FIGURE C-11: BALLAST BOARD LAYOUT - BOTTOM LAYER DS01372B-page 44 © 2011-2012 Microchip Technology Inc. AN1372 FIGURE C-12: BALLAST BOARD LAYOUT - TOP SIDE © 2011-2012 Microchip Technology Inc. DS01372B-page 45 AN1372 FIGURE C-13: BALLAST BOARD LAYOUT - BOTTOM SIDE DS01372B-page 46 © 2011-2012 Microchip Technology Inc. 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, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC 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, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA 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. All other trademarks mentioned herein are property of their respective companies. © 2011-2012, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 978-1-62076-213-4 QUALITY MANAGEMENT SYSTEM CERTIFIED BY DNV == ISO/TS 16949 == © 2011-2012 Microchip Technology Inc. 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. DS01372B-page 47 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 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Japan - Osaka Tel: 81-66-152-7160 Fax: 81-66-152-9310 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 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 Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Indianapolis Noblesville, IN Tel: 317-773-8323 Fax: 317-773-5453 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509 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 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 China - Hangzhou Tel: 86-571-2819-3187 Fax: 86-571-2819-3189 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 Taiwan - Hsin Chu Tel: 886-3-5778-366 Fax: 886-3-5770-955 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 Taiwan - Kaohsiung Tel: 886-7-536-4818 Fax: 886-7-330-9305 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 DS01372B-page 48 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Japan - Yokohama Tel: 81-45-471- 6166 Fax: 81-45-471-6122 11/29/11 © 2011-2012 Microchip Technology Inc.