Introduction: High Voltage Switch Mode Power Supply (SMPS)/Boost Converter for Nixie Tubes
This SMPS boosts low voltage (5-20 volts) to the high voltage needed to drive nixie tubes (170-200 volts). Be warned: even though this small circuit can be operated on batteries/low voltage wall-worts, the output is more than enough to kill you!
EagleCAD CCT & PCB files
MikroBasic Firmware Source
Step 1: How Does It Work?
This design is based on the Microchip Application Note TB053 with several modifications based on the experience of Neonixie-L members (http://groups.yahoo.com/group/NEONIXIE-L/ ). Get the app note - it's a nice read of only a few pages :
The illustration below is excerpted from TB053. It outlines the basic principle behind the SMPS. A microcontroller grounds a FET (Q1), allowing a charge to build in inductor L1. When the FET is turned off, the charge flows through diode D1 into capacitor C1. Vvfb is a voltage divider feedback that allows the microcontroller to monitor the high voltage and activate the FET as needed to maintain the desired voltage.
Step 2: Inductor Characteristics
Though very nice, the Microchip app note seems a little backwards to me. It begins by determining the required power, then chooses an inductor charge time without concern for available inductors. I found it more useful to choose an inductor and design the application around that.
The inductors I used are "C&D Technologies Inductors RADIAL LEAD 100uH" (Mouser part 580-18R104C, 1.2 amp, $1.40), (Mouser part 580-22R104C, 0.67 amp, $0.59). I chose these inductors because they are very small, very cheap, yet have decent power ratings.
We already know the max continuous rating of our coil (0.67 amps for the 22R104C), but we need to know how long it will take to charge (rise time). Rather than use a fixed charge time (see equation 6 in TB053) to determine the required coil amps, we can interrogate equation 6 and solve for rise time: (note: equation 6 in TB053 is wrong, it should be L, not 2L)
(Volts in/Inductor uH)*rise_time=Peak Amps
(Inductor uH/Volts in) * Peak Amps = rise time.
-using the 22R104C with a 5 volt supply gives the following-
It will take 13.5 uS to fully charge the inductor coil at 5 volts. Obviously, this value will vary with different supply voltages.
As noted in TB053:
"The current in an inductor cannot change instantaneously. When Q1 is switched off, the current in L1 continues to flow through D1 to the storage capacitor, C1, and the load, RL. Thus, the current in the inductor decreases linearly in time from the peak current."
We can determine the amount of time it takes the current to flow out of inductor using TB05 equation 7. In practice this time is very short. This equation is implemented in the included spreadsheet, but will not be discussed here.
How much power can we get out of a 0.67 amp inductor? Total power is determined by the following equation (tb053 equation 5):
Power=(((rise time)*(Volts in)2)/(2*Inductor uH))
-using our previous values we find-
-convert watts to mA-
mA=((Power Watts)/(output volts))*1000
-using an output voltage of 180 we find-
9.31mA = (1.68Watts/180volts)*1000
We can get a maximum of 9.31 mA from this coil with a 5 volt supply, ignoring all inefficiencies and switching losses. Greater output power can be achieved by increasing the supply voltage.
All of these calculations are implemented in "Table 1: Coil Calculations for High Voltage Power Supply" of the spreadsheet included with this instructable. Several example coils are entered.
Step 3: Driving the SMPS With a Microcontroller
Now that we have calculated the rise time for our coil we can program a microcontroller to charge it just long enough to reach its rated mA. One of the easiest ways to do this is to use the hardware pulse width modulator of a PIC. Pulse width modulation (PWM) has two variables outlined in the figure below. During the duty cycle the PIC turns on the FET, grounding it and allowing current into the inductor coil (rise time). During the remainder of the period the FET is off and current flows out of the inductor through the diode to the capacitors and load (fall time).
We already know the required rise time from our previous calculations: 13.5uS. TB053 suggests that rise time be 75% of the period. I determined my period value by multiplying the rise time by 1.33: 17.9uS. This is consistent with the suggestion in TB053 and ensures that the inductor stays in discontinuous mode â€“ discharging completely after each charge. It is possible to calculate a more exact period by adding the calculated rise time to the calculated fall time, but I have not attempted this.
Now we can determine the actual duty cycle and period values to enter into the microcontroller to get the desired time intervals. In the Microchip PIC Mid-range manual we find the following equations (http://ww1.microchip.com/downloads/en/DeviceDoc/33023a.pdf ):
PWM Duty Cycle uS =(10 bit Duty Cycle Value) * (1/ oscillator Frequency) * Prescaler
If we set prescaler to 1 and beat this equation with an algebra stick we get:
10 bit Duty Cycle Value = PWM Duty Cycle uS * Oscillator Frequency
Substitute the Duty Cycle uS for calculated rise time, and assume a 8 Mhz oscillator frequency:
107 = 13.5uS * 8Mhz
107 is entered into the PIC to get a duty cycle of 13.5uS.
Next, we determine the PWM Period Value. From the Mid-Range Manual we get the following equation:
PWM period uS = ((PWM period value) + 1) * 4 * (1/oscillator frequency) * (prescale value)
Again, we set prescaler to 1 and harass the equation for PWM period value, giving us:
PWM period value = ((PWM Period uS/(4/Oscillator frequency))-1)
Substitute Period uS for (1.33*rise time), and assume a 8 Mhz oscillator frequency:
35 is entered into the PIC to get a period of 17.9uS. But wait! Isn't the period shorter than the duty cycle? No - PICs have a 10 bit duty cycle register and a 8 bit period register. There is more resolution for the duty cycle value, thus its value will sometimes be larger than the period value - especially at high frequencies.
All of these calculations are implemented in "Table 2. PWM Calculations" of the spreadsheet included with this instructable. Several example coils are entered.
Step 4: PCB Design
PCB & CCT are in EagleCad format. Both are included in the ZIP archive.
I looked at several existing designs when making this PCB. Here are my notes re:important design characteristics:
1.I followed the Microchip APP note and used a TC4427A to drive the FET. This A) protects the microcontroller from flyback voltages coming off the FET, and B) can drive the FET at higher voltages than the PIC for faster/harder switching with better efficiency.
2.The distance from the PWM of the PIC to the FET is minimized.
3. FET, inductor, capacitors packed really tight.
4. Fat supply trace.
5. Good ground between FET and wall-wort connection point.
I chose the PIC 12F683 microcontroller for this project. This is a 8 pin PIC with hardware PWM, 4 analog to digital converters, 8Mhz internal oscillator, and 256 byte EEPROM. Most importantly, I had one on had from a previous project. I used the IRF740 FET because of its high acclaim on the Neonixie-L list. There are 2 capacitors to smooth the HV supply. One is a electrolytic (high temperature, 250 volts, 1uF), the other is a metal film (250 volts, 0.47uf). The latter is much larger and more expensive ($0.50 vs $0.05), but necessary to get a clean output.
There are two voltage feedback circuits in this design. The first allows the PIC to sense the output voltage and apply pulses to the FET as needed to maintain the desired level. "Table3. High Voltage Feedback Network Calculations" can be used to determine the correct feedback value given the 3 resistor voltage divider and desired output voltage. Fine tuning is done with the 1k trimmer resistor.
The second feedback measures the supply voltage so the PIC can determine optimal rise time (and period/duty cycle values). From the equations in step 1 we found that the inductor rise time is dependent on the supply voltage. It is possible to enter exact values from the spreadsheet into your PIC, but if the power supply is changed the values are no longer optimal. If running from batteries, the voltage will decrease as the batteries discharge necessitating a longer rise time. My solution was to let the PIC calculate all of this and set its own values (see firmware).
The three pin jumper selects the supply source for the TC4427A and inductor coil. It is possible to run both from the 7805 5 volt regulator, but better efficiencies and higher output is achieved with a bigger supply voltage. Both the TC4427a and the IRF740 FET will withstand up to ~20 volts. Since the PIC will calibrate for any given supply voltage it makes sense to feed these directly from the power supply. This is especially important in battery operation - no need to waste power in the 7805, just feed the inductor directly from the cells.
The LEDs are optional, but handy for trouble shooting. The 'left' LED (yellow in my boards) indicates that HV feedback is under the desired point, while the right LED (red in my design) indicates it is over. In practice you get a nice PWM effect in which the LEDS glow in intensity relative to the current load. If the red LED turns (solid) off it indicates that, despite its best effort, the PIC can't keep the output voltage at the desired level. In other words, the load exceeds the SMPS maximum output.
DONT FORGET THE JUMPER WIRES SHOWN IN RED!
C1 1uF 250V
C3 47uF 50V
C4 47uF (50V)
C7 4u7 (50V)
D1 600V 250ns
IC5 7805 5volt regulator
IC7 PIC 12F683
L1 Inductor (22R104C)
R3 1K Linear Trimmer
R4 330 Ohm
R6 330 Ohm
SV1 3 Pin Header
X2 3 Screw Terminal
Step 5: Firmware
The firmware is written in MikroBasic, the compiler is free for programs up to 2K (http://www.mikroe.com/ ).
If you need a PIC programmer, consider my enhanced JDM2 programmer board also posted at instructables (https://www.instructables.com/ex/i/6D80A0F6DA311028931A001143E7E506/?ALLSTEPS ).
1.When power is applied the PIC starts.
2.PIC delays for 1 second to allow voltages to stabilize.
3.PIC reads the supply voltage feedback and calculates optimal duty cycle and period values.
4.PIC logs the ADC reading, duty cycle, and period values to the EEPROM. This allows some trouble shooting and helps diagnose catastrophic failures. EEPROM address 0 is the write pointer. One 4 byte log is saved each time the SMPS is (re-)started. The first 2 bytes are ADC high/low, third byte is lower 8 bits of duty cycle value, fourth byte is the period value. A total of 50 calibrations (200 bytes) are logged before the write pointer rolls over and starts again at EEPROM address 1. The most recent log will be located at pointer-4. These can be read out of the chip using a PIC programmer. The upper 55 bytes are left free for future enhancements (see improvements).
5.PIC enters endless loop - high voltage feedback value is measured. If it is below the desired value the PWM duty cycle registers are loaded with the calculated value - NOTE: the lower two bits are important and must be loaded into CPP1CON 5:4 , upper 8 bits go into CRP1L. If the feedback is above the desired value, the PIC loads the duty cycle registers with 0. This is a 'pulse skip' system. I decided on pulse skip for two reasons: 1) at such high frequencies there isn't a lot of duty width to play with (0-107 in our example, much less at higher supply voltages), and 2) frequency modulation is possible, and gives a lot more room for adjustment (35-255 in our example), but ONLY DUTY IS DOUBLE BUFFERED IN HARDWARE. Changing the frequency while the PWM is operating can have 'strange' effects.
Using the firmware:
Several calibration steps are required to use the firmware. These values must be compiled into the firmware. Some steps are optional, but will help you get the most out of your power supply.
const v_ref as float=5.1 'float
const supply_ratio as float=11.35 'float
const osc_freq as float=8 'float
const L_Ipeak as float=67 'float
const fb_value as word=290 'word
These values can be found at the top of the firmware code. Find the values and set as follows.
This is the voltage reference of the ADC. This is needed to determine the actual supply voltage to include in the equations described in step1. If the PIC is run from an 7805 5volt regulator we can expect around 5 volts. Using a multimeter measure the voltage between the PIC power pin (PIN1) and ground at the screw terminal. My exact value was 5.1 volts. Enter this value here.
The supply voltage divider consists of a 100K and 10K resistor. Theoretically the feedback should equal the supply voltage divided by 11 (see Table 5. Supply Voltage Feedback Network Calculations). In practice, resistors have various tolerances and are not exact values. To find the exact feedback ratio:
1.Measure the supply voltage between the screw terminals.
2.Measure the feedback voltage between PIC pin 7 and ground at the screw terminal.
3.Divide Supply V by FB V to get an exact ratio.
You can also use "Table 6. Supply Voltage Feedback Calibration".
Simply the oscillator frequency. I use the 12F683 internal 8Mhz oscillator, so I enter a value of 8.
Multiply the inductor coil uH by the maximum continuous amps to get this value. In the example the 22r104C is a 100uH coil with a rating of .67amps continuous. 100*.67=67. Multiplying the value here eliminates one 32 bit floating point variable and calculation that would otherwise have to be done on the PIC. This value is calculated in "Table 1: Coil Calculations for High Voltage Power Supply".
This is the actual integer value the PIC will use to determine if the high voltage output is above or below the desired level. Use Table 3 to determine the ratio between the HV output and feedback voltage when the linear trimmer is in the center position. Using the center value gives adjustment room on either side. Next, enter this ratio and your exact voltage reference in "Table 4. High Voltage Feedback ADC Set Value" to determine the fb_value.
After you find these values enter them into the code and compile. Burn the HEX to the PIC and you're ready to go! REMEMBER: EEPROM byte 0 is the log write pointer. Set it to 1 to begin logging to byte 1 on a fresh pic.
Because of the calibration, the FET and inductor should never become warm. Nor should you hear a ringing sound from the inductor coil. Both of these conditions indicate a calibration error. Check the data log in the EEPROM to help determine where your problem might be.
Step 6: Improvements
A couple things could be improved:
1.Put the screw terminal closer to FET for better ground path.
2.Fatten the supply trace to the capacitors and inductor.
3.Add a stable voltage reference to improve operation from batteries and supply voltages less than 7 volts (where the output of the 7805 dips below 5 volts).
4.Use the upper 55 EEPROM bytes to log fascinating bit of useless data - total run time, overload events, min/max/average load.
Participated in the
The Instructables Book Contest