# Electric Heart

Back to project overview

A dual analog SMPS using components that the average maker is likely to have lying around

• 1
Assess and Plan

Before you begin building this device, figure out what you're going to use it for. What voltages should it output? What current level? What will the variation be in the load you are driving? Is this going to be a general lab power supply, or are you planning on sticking it in a device and leaving it there? What are you going to power it with?

After you've done some thinking and assessing, try to figure out the following:

• Vin minimum____
• Vin maximum____
• Iin min___
• Iin max___
• Vout min___
• Vout max____
• Iout min____
• Iout max____

From there, first make sure that your Vin minimum * Iin minimum is at least 2.4 times your Iout maximum * Vout maximum, then think about a few other design considerations:

• Response time: If your device is prone to sudden extreme current draws, ensure that your power supply can intervene fast enough to compensate before the smoothing capacitors are exhausted.
• Available components: You probably don't live down the street from Digikey's warehouse, so unless you want to wait for component delivery, see if you can build your device from components on hand. Figure out what devices you have, and look up their datasheets for things like switch-on times and voltage drops.
• Switching Frequency: Ideally your switching frequency should be at least 14.77 (2 * e^2) times faster than your response time, but you may have to change it to compensate for RF interference or ripple current concerns, component limitations, or self-inductance/resistance/capacitance of the circuit.

With all this information in hand, it's time to move on to the next step...

• 2
Math

With the information from the previous step in hand, you'll now need to calculate your oscillator frequency. In order to do so, you'll need to calculate the minimum possible frequency with the equation

which rearranges to

and the maximum possible frequency, using the equation

To select a frequency between these, you'll also need to be familiar with the frequency calculation for your multivibrator,

and find values within the above frequency range that you can achieve with the components you have on hand. As a general rule, try to keep R values high and the C values low.

• 3
Build the multivibrator

The multivibrator is the actual "heart" of the circuit (and the source of this project's name), because it has four "chambers" like a human heart with complementary outputs (i.e. when Q1's collector is low, its base is high and Q2 is in an opposite state). Below is a diagram of the basic design of a multivibrator:

[will add diagram in next update]

• R2 and R3 need to be at least ten times the values of R1 and R4, respectively
• The total frequency of the circuit is equal to
which simplifies to if R1 = R4 and R2 = R3.
• As a general rule, try to keep R values as high as possible (which will put C values as low as possible) in order to keep total current losses to a minimum
• 4
Build the feedback circuits

The next step is to build the feedback circuit that determines what voltage will trigger the MOSFETs in the switching circuit. You want to ensure that the duty cycle of the switching cycle never reaches 100%, or even gets close enough that the MOSFET won't have time to cut current off completely.  [ T(1 - D) <= T_{switch}], and preferably doesn't go above 75% to reduce the likelihood of both circuits drawing at the same time. It is, however, perfectly okay (and sometimes preferable) to allow the duty cycle to drop to 0%, as this will essentially force the switching circuit to "sleep" for a cycle or two, and save quite a bit of power.

To accomplish this, we'll form a voltage divider circuit with R_n and R_n2 with a total resistance of N, and then add the output of the second-stage op-amp, such that an op-amp outputting full rail voltage plus the voltage divider will sum to (v), and if the amp outputs ground voltage, the total voltage will be (v2). In the sample circuit below, I used values (put values here).

• 5
Build the switching circuit

The switching circuit is relatively simple, but you have a few options for features to add to it. At its heart, the switching circuit is simply a circuit that allows voltage to flow when the output from the triangle wave generator is above v_feedback, and blocks current flow when the triangle wave falls below v_feedback.

If you only need to step voltage up, use a simple boost configuration in which Qn alternately grounds L1's far side with the output of IC1, and diode D1 prevents voltage from reversing itself. If you have a spare P-channel MOSFET, you can get a bit more oomph out of the circuit by using it in place of a D1 with no extra driving circuitry, since L1

If you are only stepping voltage down, use a buck configuration in which Q1 alternately allows voltage to flow from the source to the near end of L1, with no block on the far end and D1 allowing current to backflow from ground during the Q1's off-state. Note the driver transistor that reverses the output of IC1, since P-channel MOSFETS become conductive with a reduction  in voltage.

If you need to alternately increase and decrease voltage (like driving a variable load 5v circuit with 6v of battery power) then use a boost-buck configuration as below, with both the boost and buck elements in place. You can elect to either use diodes or alternating transistors as backflow blockers, depending on what you have on hand. Both methods are shown below.

• 6
TEST. TEST. TEST.

ALWAYS test your power supply with a dummy load before hooking it up to anything you care about -- a math error or a defective component will easily ruin your day. You can make a simple dummy load with a relay, a pair of resistors, a capacitor, and a button (or, in a pinch, a jumper wire), as illustrated below. Make sure that your circuit stays within acceptable levels of voltage, ripple, and noise using a multimeter or oscilloscope.

• 7

There are a few more advanced configurations you can add into this circuit in order to expand its abilities:

• Proportional feedback: You can change the comparator configuration of the feedback system to a proportional amplification system to allow more precise feedback and reduced output ripple. An example circuit diagram is below:

[diagram]
• PID feedback: Going even further, you can implement Proportional-Integral-Derivative feedback using a circuit like the one below
[circuit diagram]
to further reduce output ripple and keep the system more precisely controlled under changing loads.
• Additional outputs: You can use the triangle waves from the multivibrator to drive multiple PWM outputs at once, assuming that the draw from the multiple circuits does not exceed the maximum power draw outlined in step 1.
• Solar MPPT and battery charger: You can use the PWM feedback system combined with a solar panel to implement Maximum Power Point Tracking, and use the second side of the output to drive a charge controlling system (with a possible third output driving a microcontroller as below). I haven't tested this configuration yet, use at your own risk; I'll post another project when I'm ready to test this configuration.
[extremely complicated circuit diagram goes here]
• Transformerless AC Adapter: If you are EXTREMELY CAREFUL and are trained and experienced in handling and working with high voltages/currents and RF emission safety, you can use a circuit like the one below to step down mains current to downconvert 120V input into a voltage safe for use with DC electronics. However please don't do this unless you are familiar with using mains voltage in projects and know how to safely handle it, and have someone around to perform CPR on you just in case you make a mistake anyway.