fairly new to Arduino and all things relating to it. I have tried searching for the answer but to no avail. At least, it wasn't in terms that I could grasp.

I have a circuit that I want to be able to change the voltage via an arduino. The power source is is approximately 3.7v with 20A of power. Basically, I don't know what the correct component to use with this amount of amps. I though I could maybe use a digital potentiometer, but it doesn't seem that it is the correct part because there is too much current.

I know you can use a MOSFET as a switch. I was wondering if it is possible to turn the switch on and off with PWM and use that to change the voltage. So for example, if I had a duty cycle of 50%, the voltage across the cicuit would be 1.85V. Is this possible or is this even remotely the correct way to do this? Any help would be appreciated.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Just FYI: the amp is not a unit of power. \$\endgroup\$ – circuitbird Jul 29 '17 at 22:06
  • \$\begingroup\$ Are you trying to build an e-cigarette? \$\endgroup\$ – Dampmaskin Jul 29 '17 at 22:19
  • 1
    \$\begingroup\$ You can always put more MOSFET's in parallel. It's like putting resistors in parallel, you reduce the overall resistance and increase the overall contact area with the air to cool it further. However, this question of yours is screaming of "XY problem" in my face. So please give us the X, which I'm referring to with the link. Also, your schematic makes close to no sense. \$\endgroup\$ – Harry Svensson Jul 29 '17 at 22:24
  • \$\begingroup\$ @Harry Svensson it is not as easy. Why? Most of the heat comes when the mosfet is switching. Its resistance changes from almost infinitive to the very low one and back. During this period the losses of power are significant. So we try to make this transition period as short as possible. Because of the gate capacitance we need to supply the significat current to load it or to discharge it. If we have more MOSFETs in parallel that capacitance will be multiplied by the number of transistors. So if the charging current is constant the power losses will increase significantly with the sw. time \$\endgroup\$ – 0___________ Jul 29 '17 at 22:50
  • \$\begingroup\$ @PeterJ My bad, I didn't know we had an expert on switching power losses. That's right everybody, you should never put transistors in parallel. -- VashTheStampede hasn't named any switching frequency, and what you are talking about PeterJ greatly depends on the switching frequency. Sure, when you switch there's twice the capacitance which roughly doubles the switching time. But hey, there's two transistors, so they still halve the resistance. So during the switching it's as if it's just one transistor. One transistor with a lot of surface area. \$\endgroup\$ – Harry Svensson Jul 29 '17 at 23:14

I know you can use a MOSFET as a switch. I was wondering if it is possible to turn the switch on and off with PWM and use that to change the voltage. So for example, if I had a duty cycle of 50%, the voltage across the cicuit would be 1.85V

You can do something like this, but you have to consider the characteristics of the load.

Suppose the load is a resistor, or an LED & resistor, or something else where it's actually okay to apply the full voltage and you just care about the output power. In that case, you can just PWM, and this is a common way to vary brightness of a light. But more complex loads actually need a stable voltage. How do you produce a smoother voltage out of PWM input? You add a capacitor.

But then the output voltage on that capacitor will not be 50% of input — it will depend on the capacitor's charging curve and how much the load is drawing from the capacitor. So you need to vary your PWM duty cycle based on the voltage/charge on the capacitor — a feedback loop.

Now what you have is better known as a switch-mode power supply (SMPS). There's one more detail — you also need an inductor, which is used to avoid the losses which result from abruptly connecting a capacitor to a voltage source.

It is tricky to build a stable and efficient SMPS, and you should not try to build it using your Arduino as the controller. Instead, buy a premade module — you can find ones with voltage adjustment inputs. SMPSs are called either buck converters or boost converters depending on whether they lower or raise the input voltage, respectively. In your case you want a buck converter.

  • \$\begingroup\$ Now that is an awesome answer. Thank you for laying it out clearly. \$\endgroup\$ – VashTheStampede Jul 30 '17 at 12:39

Yes, I am trying to build an e-cig.

That's what I thought.

Measuring and/or control

You don't have to worry about feeding a specific voltage, power or current to the coil. All you need is the ability to decrease or increase the "oomph". You can do that by varying the PWM duty cycle.

If you need to know the output voltage, current or power, you can measure the output. If you want to be able to set exact values, you can take this value and make a control loop.

But even measuring the output can get complicated real fast, not to speak of making a control loop and a user interface for it. So if I were you, I would leave the measuring and/or controlling part out for now. You can always add it to a later project.

A simple potentiometer connected to an analog input of the Arduino can serve as a dumb "volume button" for your mod.

MOSFET gates and Arduino outputs

The outputs on the Arduino are too weak to drive a normal powerMOSFET directly with PWM. They're strong enough to turn a logic-level MOSFET on and off slowly (for instance when the user presses a button), but if you want to drive the MOSFET at PWM frequencies, the MOSFET will require a higher gate current than the Arduino can provide.

Solution: Choose a suitable MOSFET driver, or design your own, and place it between the Arduino and the MOSFET.

It is probably a good idea to take some time to read more about MOSFETs and MOSFET drivers in general, before you choose which MOSFET you want to use, and how you want to drive it.

Output smoothing/protection

For an e-cig you probably don't need to smooth the output power in any way.

"Rattlesnaking" is not an issue with modern low resistance builds because of the high thermal mass of the coil. Even with thin wire, a PWM frequency of more than a couple hundred Hz will practically eliminate anything noticable.

A flyback diode won't hurt, but I don't know if it will be necessary. The inductance of an e-cig coil is probably negligible.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.