THIS PROJECT HAS RISK OF SHOCK AND FIRE!
The electric light bulb is an essential device for our life. The incandescent light bulb and the fluorescent bulb were typical light bulbs for household lighting equipments. For industrial and public use, such as street lighting, large interior lighting, sports arena lighting and anything outdoor, HID (High Intensity Discharge) lamps are widely used in addition to those light bulbs. Typical HID lamps for such use are high pressure sodium-vapor lamp, metal halide lamp and mercury-vapor lamp. The last one has been banned by 2021 for the Minamata Convention on Mercury.
The luminaires of incandescent light bulb and the fluorescent bulb used for household lightings for long time got outdated within 10 years of widespread of LED lamps and currently only light bulbs are supplied for the replacement. Also low wattage HID lamps are gradually being replaced to th LED lamps. High wattage HID lamps still occupy the mainstream of large scale lightings because the less advantage of LED lamps in this class. As many LED freaks did, I also built an LED luminaire because of its rarity, but when it becomes a commonplace, it is no longer interesting. On the ohter hand, my nostalgia for the glass tubes disappearing from our life increases and I have begun to collect the HID lamps as a light bulb maniac. However, there is no sense in having only light bulbs. Lamp ballasts rated for each bulb are needed in order to light the HID lamps. Therefore, I designed and built an electronic HID ballast that can light the various HID lamps.
In order to light the discharge lamp, an impedance element called electrical ballast is needed to regulate the current through the arc tube. This is the same reason as inserting a resistor in series with the LED. In the case of a arc tube, it is driven by an AC power supply, so as shown in Figuer 1a, a choke coil (inductor) is used for the impedance element to reduce the resistive loss and stabilize the arc. The electronic ballast replaces the current control function of choke coil with a compact and lightweight electronic circuit.
Figure 1b shows the typical configuration of electronic HID ballast. The boost converter in the first stage boosts the voltage of power input to the sufficient voltage, 300 V or higher, to drive the HID lamp. The boost converter usually has a PFC (Power Factor Correction) feature. The next stage is a buck converter to control the lamp current be constant. Since all HID lamps for general lighting are driven in AC, the output current of the buck converter is converted to a square wave AC current in 100 to several hundreds Hz by an inverter and supplied to the HID lamp. The igniter generates high-voltage pulses of several kV at startup, which is required to start the discharge of the lamp.
There is a simple high-freqency drive method that is a common technology in fluorescent lamp ballasts. Unfortunately, HID lamps with high arc tube pressure has a problem of acoustic resonance phenomenon that sound waves from an AC arc form a standing wave in the arc tube and the arc is distorted and fluctuated as shown in this video. This cause flickering of light, extinction of arc and rupture of the arc tube in worst case. Therefore HID lamps need to be driven at low frequency lower than 1 kHz or DC. In '90s, many reserches on the high-freqency drive were done but nothing succeeded for practical application in the end.
The basic function follows that of a generic electronic ballast. The maximum output power is 100W that corresponds to small lamps with medium base. Basically, this is a project for the light bulb maniacs who light the light bulbs for their fun :-). Unlike ready-made lamp ballast in fixed output power, the lamp ballast to build needs to drive various wattage of HID lamps. For this reason, the HID ballast is in digital controlled, aka digital ballast, and working parameters preset for each lamp type and wattage can be selected with a rotaly switch. The digital ballast in early days are controlled with DSP (Digital Signal Processor), but recent products is in cheap MCU that has sufficient performance for ballast control. In this project, a generic MCU sold for only $0.8 is used. The specifications of the built electronic ballast in this project is shown in Table 1.
Lamp Type | High-pressure mercury-vapor lamp, Metal halide lamp, High-pressure sodium-vapor lamp (Low-pressure sodium-vapor lamp, Fluorescent lamp) |
Lamp Wattage (Po) | 20-100W, It can be in 10 presets. |
Lamp Current (Io) | 1.5A max |
Open-circuit Voltage (Vo) | 360V |
Ignition Pulse (Vp) | >= 4 kVPK |
Controller | STM32L010 |
Input Voltage (Vi) | 90 to 250 VAC, 50/60Hz |
Efficiency (η) | ~93 % (Vi=115 V, Po=100 W, Measured) |
Power Factor (PF) | >= 99 % (Vi=115 V, Po=100 W, Measured) |
The lamp types in parentheses are not HID lamp and have very different characteristics with HID lamp, but since the ballast is to drive many type of discharge lamps, I added it to the supported lamp type. Since the ballast has an igniter in it, the supported lamps need to be without built-in starter.
The electronic ballast in this project is divided into three functional blocks (boost converter (PFC control), buck converter (current control) and inverter (DC-AC conversion)). Since the PFC feature is not the essence of electronic ballast and it can be in generic PFC IC, but there is much room of processing resource and I decided to implement PFC feature to the MCU to study about PFC. The PFC and other features are completely independent of each other, so that they are explained in following two chapters.
The voltage waveform of the mains is almost a sine wave, and the frequency is 50Hz or 60Hz. When the connected load is a linear load such as incandescent light bulbs or induction motors, the current waveform will be a sine wave that is almost the same as the voltage waveform, regardless of whether the power factor is good or poor (Figure 2a). However, some type of loads are non-liniear and this type of load creates harmonic current in addition to the mains frequency. For example, conventional SMPS unit in capacitor-input creates a non-sinusoidal input current as shown in Figure 2b. Non-sinusoidal current waveform contains harmonic components depends on the degree of distortion, and the harmonic component do not contribute to real power. This meams that the harmonic current lowers the power factor, but it is not the only problem. As the number of such loads increases, the harmonic current emitted into the mains is getting to cause various problems.
At present, EMC Directive and JISC list standards IEC 61000-3-2 and JIS C 61000-3-2 respectively. These standard define classification of equipment, limitting values and measurement method to limit the emissions of harmonics into the mains for low-voltage equipments connected to the public mains.
The harmonic current cannot be eliminated by a reactance element as conventional PFC for linear load. To meet the standard, the harmonic current needs to be reduced in some method. A passive method that blocks harmonic current with a line filter in LC network had been used in past days, but it is not applicable to the small electronic equipments, because the line filter for low frequency range requires a large and heavy choke coil. Therefore, the PFC circuit in small equipment is almost in active method that forms the input current waveform with an electronic circuit.
Figure 3 shows a typical configuration of the active PFC circuit, in which a boost converter is placed between the rectifier bridge and the filter capacitor of the capacitor input load. To keep the input current under control of boost converter all time, output voltage, often referred VBUS, needs to be set higer than input peak voltage. The optimum output voltage is 200 V for the 120 V mains and 400 V for the 220 V mains in consideratin of efficiency, but it seems to be often fixed to around 400 V for universal input voltage and some reasons of load circuit design.
The boost converter is in current mode control as shown in the figure. However, unlike a generic current mode converter, the instantaneous value iIN of the input current is controlled to be a value of the current command multiplied by the instantaneous value vIN of the input voltage. This makes iIN proportional to vIN in steady state, as the result the PFC circuit behaves as a pure resistive load.
There are two conduction modes how the current flows through the inductor. The one is continuous conduction mode (CCM) in which the current flows continuously over the switching cycle. The another one is discontinuous conduction mode (DCM) in which the current stays zero in a part of switching cycle. (Figure 4) CCM tends to be used in relatively high-power circuits, and DCM tends to be used in low-power circuits, but each has its own features and the use is not that clearly determined.
Since the transfer function (response of the converter output current to the control input) of the converter differs between CCM and DCM, feedback loop needs to be compensated in proper parameters according to the conduction mode. However, CCM transitions to DCM when the output current lowers, so it is difficult to design the feedback loop to control it with good performance over a wide range of loads. In synchronous rectification converter, it operates always in CCM regardless of the load current.
Actually, there is yet another mode that operates at the transition point between CCM and DCM. I found it is referred in varoius words in various thesises, shch as critical mode (C-CCM), transition mode (TCM) and boundary mode (BCM), but here I will refer to it as critical mode. In order to keep the operation in C-CCM, the switching frequency changes as variation of operating conditions (Figure 5a-b).
The advantage of C-CCM over CCM is that it can reduce diode conduction loss and transistor switching loss. The reason for reducing diode loss is that C-CCM and DCM switch at zero current, so slow FRD (usually lower VF) can be used. The reason why the switching loss can be reduced is due to valley switching, which is a feature of C-CCM. It enables to switch at low VDS (nearly ZVS at boost ratio of 2 or higher) by a resonance produced by stray capacitance on the switch node, as shown in Figure 5c. The disadvantage is that the peak current and ripple current are larger than the CCM, but not so large as DCM, which increases the size of inductor and a little difficult to filter the ripple current.
In the PFC circuit, C-CCM is chosen for output power of up to 100-150W and CCM for above it in trade-off between cost and efficiency. It seems there is no PFC circuit that operates at only DCM (if it exsists, it will be in quite low power). This project chose C-CCM for the special control method described below.
In C-CCM boost converter, the peak current of the inductor is controlled by the current command, and the average input current becomes half of the peak current. In the switching cycle, when the transistor turns on, the inductor current iL rises linearly while the transistor is on. When the inductor current reaches the commanded value, the transistor turns off and the inductor energy is transferred to the output. In the typical PFC controller, inductor current is detected by a shunt resistor inserted at the source terminal of the transistor. However, the general-purpose MCU used in this project does not have any peripheral suitable for switching power supply, so I tried current control without current detection instead.
What this means is that if the input instantaneous value vIN and the inductance L is known, the transistor on time corresponds to the peak inductor current can be estimated by a digital processing from:
iL = vIN * t / L
; where iL is inductor peak current, t is transistor on time. This is applicable to C-CCM and DCM, where the inductor current becomes zero within each PWM cycle. However, this is difficult to do it in CCM, because the estimation error accumulates cycle-by-cycle.
iL is not that exactly proportional to the t. A line filter is placed at input section of the converter in order to prevent leakage of switching current into the mains, and it has high impedance at switching frequency range. For this reason, a bypass capacitor CIN is placed at close to the boost inductor. When it assumes that the switching current is supplied from the CIN only, the inductor current iL corresponds to t becomes:
iL = vIN * sqrt(CIN / L) * sin(t / sqrt(CIN * L))
I applied it to the operating conditions of the actual circuit. The peak current will become approx. 4% lower than the ideal value under the condition where t is the largest possible, but actually, the error does not become so large as this calculation and it can be considered that iL is in almost direct proportion to the t.
Typical C-CCM PFC controller IC detects end of the discharge (iL falls to zero) with an auxiliary winding of LBOOST, and start next cycle. Also the auxiliary winding acts as an auxiliary power supply for the PFC controller. In this project, the auxiliary power is supplied from an off line regulator, so that the boost inductor does not have an auxiliary winding. Therefore, the discharge time needs to be estimated without inductor current sensing. The discharge time can be obtained in:
tDC = tON * (vIN / (vOUT - vIN))
Additionally, the ring-down time (half cycle of ringing) will need to be added to achive the valley switching.
The switching frequency lowers at the peak of vIN and rises at the valley. This effect increases as the current command becomes lower (high input voltage or light load). Since the switching frequency cannot be risen witn no limit, the conduction mode will transition into DCM when the switching frequency hits the upper frequency limit. In DCM, the average input current does not become as commanded current, so input current waveform distorts like a triangle wave. It can also be compensated by a calculation for DCM, but the distortion is not so high to exceed the limit and calculation requires a sqrt() that consumes much CPU resource, so I decided not to take any compensation for DCM.
On the other hand, when the current command gets higher (low input voltage or heavy load), peak input current will be limited at maximum inductor current and the input current waveform becomes like a trapezoid wave. Thus, when the range of input voltage and output power are too wide, it will be difficult to achieve a complete power factor correction over the working conditions.
I created a spreadsheet pfc1.xlsx to calculate the behavior of the C-CCM PFC. The input parameters are input/output voltages, inductor value, maximum inductor current, maximum switching frequency and current command. The outputs are the input current waveform, switching frequency and output power over the half input cycle. The current command is given not in peak current but transistor on time. This is because the real implementation works so from the fact that the current command and the on time are equivalent.
The voltage feedback control is the major control loop and it controls the output voltage of the PFC circuit to be constant. In the basic PFC, the bandwidth of the voltage control is set to about 10Hz, and the load/input step response time reaches 200 to 300ms. The reason why the condtol bandwidth is limited so narrow is that the ripple voltage (2 * fIN) comes from input frequency appears on the output must not be supressed by voltage control. The ripple voltage appears as the result of the proper PFC function, and the ripple voltage VRIPPLE in peak to peak is:
VRIPPLE = IOUT / (2π * COUT * fIN)
If it controls to suppress the ripple voltage, the PFC function will be impaired and the input current will be distorted. The ripple voltage can be reduced by increasing the value of COUT, so that it is determined from according to the ripple voltage that load circuiit allows.
To improve the step response, there is only increasing the control bandwidth or adding load feedforward compensation. The former one is proposed and applied into the practical system with adaptive dead-band or adaptive notch filter to remove the ripple component in the feekback voltage. The latter one seems to not be adopted in the generic PFC
In this project, I tried a method that combined adaptive comb filter with gain-band control. I found that FIR low-pass filter with rectangular window, aka moving avarage, has notch points at integer multiple of fundamental frequency, so that I used it instead of comb filter. It can be implemented as easy as comb filter and it is suitable for cheap MCUs.
Figure 6 shows the system diagram of the implemented PFC feature. These controls are driven in an interval timer (LPTIM1) in 31.25 kHz. To reduce the processor load, PFC process is divided into two phases, current control and voltage contrl, so PFC control is updated at 15.625 kHz, but still sufficient rate for PFC function.
Since the core processor integrated in STM32L010 is Cortex-M0+ which does not have FPU even divide instruction. The software implemented division consumes much CPU resource and it may be a problem for real-time controls, so that I needed to replace constant divisions with multipy and right-shift in order to minimize the number of divisions. There is another problem in built-in division routine that the execution time drastically varies depends on the input values. This characteristic becomes an issue in real-time process, so that I worte a constant time division function in assembler.
Figure 7 shows the schematic of the PFC part. The red and blue symbols in the schematic correspond to the probe point in the screenshots shown in this document. STM32L010 has only four timer units in total. TIM2 is used for step-up PWM, TIM21 is used for step-down PWM, LPTIM1 is used for controls of both converters, and SysTick is used for the supervisor, so there is no timers left. Every features I wanted could be implemented and all I/O pins are occupied for each feature.
L3 is the boost inductor wound in EER28L(PC40) core with 0.5mm gap and 80 turns. I used UEW in 3 strands and 0.5mm dia for the winding, but a litz wire would be better if it is available. The power supply for the control circuit is generated with an off line regulator (LNK304D), so it is always stable even if PFC is disabled for program debugging.
I saied it is without a current sensing, but a shunt resistor is used by a gate driver with trip feature (IR2127S). This is to protect the circuit from an overcurrent due to a transient, a program bug or some malfunctions. The trip feature does not work in normal operation. Also the timer unit of the STM32L010 has pulse-by-pulse trip feature, but it requiers some external components, so I used a useful gate driver instead.
Figure 8 shows the waveforms of input voltage and input current at full load. (Ch1:Point-C, Ch2:Point-B, Ch4:Point-A) The input voltage is slightly distorted probably due to hysteresis of the isolation transformer, but current waveform exactly reflects it. This means the PFC circuit is working as a pure resistive load. Figure 9 shows the dynamic performance at the load transient. (Ch1:Point C, Ch4:Point A) Unlike conventional PFC there is no large overshoot or undershoot, and settling time seems to be 20 to 30ms, which is far sufficient for the PFC in the electronic ballast.
VIN=115 V, POUT=50 W | Cycle | Zoom 1 | Zoom 2 |
VIN=115 V, POUT=100 W | Cycle | Zoom 1 | Zoom 2 |
VIN= 90 V, POUT=100 W | Cycle | Zoom 1 | Zoom 2 |
VIN=115 V, POUT=0 W | Cycle | Zoom 1 |
Table 2 shows the waveforms under some working conditions. (Ch1:Point F, Ch2:Point E, Ch4:Point D) From the switching waveforms, it can be seen that the valley switching is performed stably. At the maximum input current (full-load with 90 V input voltage), it can be seen that the peak of input current is flatten due to the limitation of the inductor current. In this condition, the THD of the input current is slightl worse. At the no load, it turns into intermittent operation, and conduction mode becomes DCM with hard switching. From the ringing frequency, stray capacitance on the switch node can be estimated about 160pF. The control_log.xlsx is a control log output from the MCU to examine how the PWM timing varies over the input half cycle, and it seems to work well as expected.
The efficiency of valley switching seems to be quite good, the transistor Q1 with a small heatsinkonly slightly warm up at full-load. On the other hand, the most heat-dissipating component is the diode bridge, which seems to occupy the most of the loss. For this reason, advanced PFC circuits replace the diode bridge with transistor switch to improve the efficiency.
Figure 10 shows the voltage-current characteristics of HID lamp. This is a well seen characteristics of a discharge tube, but the breakdown voltage of HID lamp is higher than vacuum lamp such as fluorescent lamp, because the gas pressure of HID lamp (about 0.1 atom) is mush higher than vacuum lamp (about 0.0001 atom). The breakdown voltage VB of HID lamp is about 1 kV for DC, 2 to 3 kV for pulse.
There are various starting methods of HID lamp. For the magnetic ballasts, they can be devided into probe start and pulse start. The former one is found in mercury-vapor lamps, which can be started at the mains voltage by an additional starter electrode. The another one is found in metal halide lamps and high-pressure sodium-vapor lamps, which does not have starter electorde to improve some characteristics and started by applying high voltage pulses to the lamp. The pulse start lamps can be devided into two types whether the starter is built-in the lamp or not. The electronic ballast itself has a starter in it, so it supports only external starter type lamps.
The technical requirements for metal halide lamps are listed in IEC 61167 and JIS C 7623, so the control strategy and operating parameters of the ballast can be determined with this specifications.
Figure 11 shows the start-up sequence of HID lamp. VL is the lamp voltage, and IL is the lamp currrent.
Apply a voltage higher than 300 V that sufficient for the take-over (go over the right peak in the Fig. 10 and begin arc discharge). However, the HID lamp is still insulated, so high voltage pulses are superposed to make electrical breakdown in the arc tube (go over the left peak in the Fig. 10).
After a discharge began, a suffcient current (make the power higer than quarter of rating but not exceed two times of lated current) neededs to be supplied. The lamp impedance in glow discharge is 1kΩ or higher, so the lamp voltage considerably higher than the rated voltage is required. When a hot spot is formed on the electrode and arc discharge began, the lamp impedance drops drastically. If the take-over failed and the discharge extinguished, high voltage pulses will be applied agan. This process goes on almost instantly.
After the arc discharge began, lamp impedance is as low as some ten Ω, rated power cannot be supplied to the lamp due to the current limitation (two times of lamp rating or ability of ballast). As the temperature rises, the materials (mercury, metal halides, sodium amalgam, etc.) in the arc tube vaporize and it begin to emit intense light from the excited metal atoms. As the vapor pressure rises, the lamp impedance rises and so the lamp power rises. After it reached to the rated power, the control get into the constant power mode, however the lamp impedance continues to rise and the current decreases.
After a few minutes, the lamp will reach thermal equilibrium and also lamp impedance will become stable. The lamp voltage at stable state depends on each specification, mostly about 85 to 115 V.
The gas pressure of HID lamp reaches 1 atom to several atoms while is in work. After the lamp is turned off, the gas pressure and also breakdown voltage still high for a while, so it cannot restart until the lamp tempearature drops to sufficient level to re-strike. The re-strike time depends on the thermal design of lamp and luminaire, several minutes to over ten minutes for mercury-vapor lamps and metal halide lamps, less than a minute for high-pressure sodium-vapor lamps.
Figure 12 shows the schematic of driver block. The red and blue symbols in the schematic correspond to the probe point in the screenshots shown in this document.
At the beginning, I had been planning to make it work in C-CCM, but the large ripple current froces the inductor be large in size to satisfy the requirement of working conditions, so I calculated and examined with a spreadsheet buck.xlsx, and filally decided to employ CCM for the buck converter. Due to the hard switching at several hundred volts, the power dissipation at Q2 got quite large, 3 W maximum. I replaced the freewheel diode D10 from FRD to SiC SBD and it decreased the power dissipation two thirds.
When the low-side switch is a diode as this configuration, the floating supply of the high-side driver cannot be charged at the initial state and when no load. For this reason, a charge register R9 and a bleeder register R7 are placed to ensure an initial charge on start-up and freewheel operation (switch node drops to 0 V) after the start-up even if no load.
Figure 13 and Figure 14 show the block diagram of lamp controls and working waveforms respectively (Ch1:Point H, Ch2:Point J, Ch4:Point G). The buck converter is controlled in constant power, so it feedsback not only output current buf also output votage. The current control loop, the minor loop, needs to be controlled in optimum response, so PID parameters are configurable for each lamp configuration. The power control loop is the major loop, which does not need to be controlled so quickly (if it is too fast, it interferes the current control and causes lamp flicker), so it is controlled only in I term. These control parameters can be preset and selected with a thumb wheel switch.
The DC output from the buck converter is converted into a squarewave AC current with an H-bridge inverter and supplied to the HID lamp. In order to avoid acoustic resonance phenomenon, the drive frequency below 1 kHz is chosen in most case. In this project, the lamp is driven at 200 Hz.
The output voltage sticks about 360 V at no load (before the discharge begins). Ignition chapacitors C30 and C31 are charged in voltage doubler. When the capacitor voltage reaches the breakdown voltage of GDT (SG1), approx. 600 V, the GDT conducts and a pulse current drains via the primary winding of ignition transformer T1 and a high voltage pulse on the secondary winding will applied to the lamp repeatedly. There is no on/off control for the ignitor, but the generation of pulses stops when the discharge begins and the lamp voltage drops.
T1 is the ignition transformer made of three junk troidal cores obtained somewhere in 5 turns (6.7μH) for primay winding and 40 turns (430μH) for secondary winding with teflon insulated wires. Figure 15 shows the waveform of the ingition pulse at no wire connection. It reads the 6 kV of peak voltage and very fast transient, 80 kV/μs, so tracings on the board needs to be in a special attention. I have not encountered a malfunction of MCU, but some transistors and gate driver in the H-bridge are sometimes failed by the high volatege pulse discharged and went somewhere on the board. Since the pulse voltage is attenuated by the stray capacitance of the cable to the lamp, the maximum cable length (often 1.5 to several meters) is set in the specifications of the electronic ballast.
HID lamps can exhibit abnormal behavior at the end of life. If it get into this situataon, the lamp ballast must safely stop the operation. To ensure the start of discharge and monitor the lamp operating status, a state diagram is defined as shown in Figure 16.
Waiting for power-good. Both converters are disabled. It always enters this state on power-on or BOD. When VIN gets in the working voltage range, the boost converter will start and when VBUS reaches the specified voltage, CT1 and CT2 are cleared and go to IGNITION stage.
Start the buck converter and inverter and apply ignition pulses to the lamp. If the ignition and take-over succeed, clear CT1 and go to RUNNING state. If it does not succeed and T1 time erapses, increase CT1 and go to WAIT state if CT1 < N1, or the ignition fails (end of lamp life or open circuit) and go to FAULT state.
After the discharge start, the lamp will reach thermal equilibrium within several minutes. When the lamp voltage get into the rated range and T3 time elapse, the lamp is considered in stable state and CT2 is cleared. If an extinction, an abnormal lamp voltage or a short circuit is detected, exit this state. The abnormal lamp voltage is a state that the lamp voltage is out of rated range for T2 time. It is due to low lamp voltage caused by leakage of arc tube, warm-up failur caused by leakage of outer tube or high lamp voltage caused by end of life. When it exit this state, CT2 is increased. If CT2 < N2, go to IGNITION state, or it is considered that it is unable to get into stable state and go to FAULT state.
Inverter is disabled to prevent to output the ignition pulses continually. Wait for T4 time and go to IGNITION state.
An insanity is detected. All functions are shutdown and keep this state until power off or BOD.