3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

High Voltage Switch Mode Power Supply (SMPS)/Boost Converter for Nixie Tubes

Step 5Firmware

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 (http://www.instructables.com/ex/i/6D80A0F6DA311028931A001143E7E506/?ALLSTEPS ).

Basic operation:

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.

v_ref
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.

supply_ratio
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".

osc_freq
Simply the oscillator frequency. I use the 12F683 internal 8Mhz oscillator, so I enter a value of 8.

L_Ipeak
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".

fb_value
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.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
128
Followers
30
Author:ian(DangerousPrototypes.com)