Mosfet with Arduino

How I can control the duty cycle of a Mosfet with arduino , actually I want to design boost converter so I need mosfet to generate PWM (switch) .. any help with the code please !!

[u]analogWrite()[/u] is [u]PWM[/u].

Exactly what are you trying to do? Most "boost converters" don't need software. And, usually the switching MOSFET (or transistor) is built-into the specialized chip.

Why do you want to design one? They are many chips available that do the job. If you want to do it as
a challenge that's fair enough, but otherwise you may be making more work for yourself than you need to
(xyproblem territory).

MarkT:
Why do you want to design one? They are many chips available that do the job. If you want to do it as
a challenge that's fair enough, but otherwise you may be making more work for yourself than you need to
(xyproblem territory).

I'm working on a circuit called active power factor correction using boost converter . actually I have no idea about
arduino so I'm trying to learn about it to use it in my project

DVDdoug:
[u]analogWrite()[/u] is [u]PWM[/u].

Exactly what are you trying to do? Most “boost converters” don’t need software. And, usually the switching MOSFET (or transistor) is built-into the specialized chip.

I’m working on active power factor correction if you know it . so I think i need to control the switch by using arduino

omaromar:
I'm working on active power factor correction if you know it . so I think i need to control the switch by using arduino

I think you need to vary the PWM over each 1/2-cycle to manage the power factor.

An Arduino should be able to drive a MOSFET with varying PWM for this, but I think the code would be a bit tricky and you would probably have to setup the hardware timers and PWM mode yourself.

However, if you have no experience with Arduino's, nor any software experience, nor any idea of how to wire up a MOSFET, then I think trying to design a boost converter might be a bit beyond you at the moment.

Maybe start with something like the tutorial on Fading

Yours,
TonyWilk

I'm working on active power factor correction if you know it . so I think i need to control the switch by using arduino

I don't know anything about that, but I'd be surprised if it requires a programmable microcontroller. For example, switching power supplies use something like PWM, but the pulse width is controlled by a feedback circuit (there's no microcontroller or software) and the pulse width is not quantized. It's possible to use feedback with the Arduino by using analogRead(), but you'd have to figure-out the details and it might not be fast-enough for you. (The default PWM frequency is slow compared to a switching supply and it takes time to execute program instructions.)

Anyway, I told you about analogWrite() and PWM. [u]Here is a MOSFET motor driver[/u] (and it works fine with PWM) but you probably need something different.

DVDdoug:
I don't know anything about that, but I'd be surprised if it requires a programmable microcontroller. For example, switching power supplies use something like PWM, but the pulse width is controlled by a feedback circuit (there's no microcontroller or software) and the pulse width is not quantized. It's possible to use feedback with the Arduino by using analogRead(), but you'd have to figure-out the details and it might not be fast-enough for you. (The default PWM frequency is slow compared to a switching supply and it takes time to execute program instructions.)

Anyway, I told you about analogWrite() and PWM. [u]Here is a MOSFET motor driver[/u] (and it works fine with PWM) but you probably need something different.

yes exactly I need feedback to generate PWM
OK thank you for your help , i will keep looking about it

I don't know what kind of MOSFET you're working with, but I NEVER, absolutely NEVER, use the signal the Arduino generates directly into the MOSFET.

I always use a push-pull configuration with BJTs. It has unitary voltage gain, but low output impedance thus high current gain. Since the MOSFET has a high capacitive factor (the channel and all that theory whatnot), it works pretty fine, with a speedy response in time domain.

With that, you have enough power to safely and properly turn on power MOSFETs and so on.

nathan_maruch:
I don't know what kind of MOSFET you're working with, but I NEVER, absolutely NEVER, use the signal the Arduino generates directly into the MOSFET.

Wow.
I suppose you also use a sledgehammer to crack your eggs.

I always calculate the needed gate drive current, and go from there.
Leo..

nathan_maruch:
I don't know what kind of MOSFET you're working with, but I NEVER, absolutely NEVER, use the signal the Arduino generates directly into the MOSFET.

Even MOSFETs in inputs of other ICs?

We are talking power electronics here, the context is clear!

My question is this: active power factor correction is a mains thing. Boost converters increase voltage,
so we seem to be talking about a circuit whose input is 110 or 220V and outputing a higher voltage?

If so why are we talking about MOSFETs at all? IGBTs rule the roost at these voltages.

Actually I suspect we just haven't been given enough information still...

MarkT:
We are talking power electronics here, the context is clear!

nathan_maruch:
NEVER, absolutely NEVER

I am not a native speaker but for me "absolutely NEVER" does not mean "only when not dealing with high power". Wawa's approach seems more reasonable.

MarkT:
My question is this: active power factor correction is a mains thing. Boost converters increase voltage,
so we seem to be talking about a circuit whose input is 110 or 220V and outputing a higher voltage?

My (admittedly little) understanding is that PFC attempts to make a PSU look like a resistive load instead of the pulses of current at the peaks you get with a usual bridge->Cap front end.

To do this you have a pre-converter which takes current throughout the mains cycle; since most of each 1/2-cycle is below the peak, you boost convert to a given voltage which might be at or above the cycle peak whilst maintaining a constant V/I. You then have, say, a common buck converter after that.

Yours,
TonyWilk