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 3Driving the SMPS with a Microcontroller

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= ((17.9/(4/8))-1)

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.
« 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)