PWM and N channel MOSFET

Thread Starter

arhem

Joined Dec 6, 2013
19
Hi, everyone
I have an arduino uno, and a transistor N-MOSFET.
I wante to make the MOSFET as a variable resistor. fo that i have to controle the gate pin of transistor by varying the voltatage(0 to 5v step by step) between it.
the question is : can i use for this analogwrite PWM?
if the answer yes, how can i do it ?
 

shteii01

Joined Feb 19, 2010
4,644
Yes, you can use PWM.

PWM can be used to produce dc voltage. The longer the duty cycle, the higher the dc voltage.

Here is Arduino article about it: http://arduino.cc/en/Tutorial/PWM
So basically, when you send 0 you get 0 volts.
When you send 127, you get 50% duty cycle which is 2.5 volts.
When you send 255, you get 100% duty cycle which is 5 volts.
And anything in between.
 
Last edited:

GopherT

Joined Nov 23, 2012
8,009
thank you,
without making filter?
Using a filter is fine for a type D audio amplifier but unfiltered PWM is so great for a dc motor because you always have full voltage applied and you get much better control at low speeds. Adding capacitors to PWM removes that benefit as voltage is ramped.
 

ErnieM

Joined Apr 24, 2011
8,377
I once used a PWM output of a micro to directly drive a small speaker; it was not loud, it was not high fidelity, but it was quite surprisingly intelligible.
 

Thread Starter

arhem

Joined Dec 6, 2013
19
In my project i have solar cell and i want mesure I-V caracteristic, for that i need a varaible resistor (MOSFET as a load ), to change the value of the resistor, i need produce a dc voltage (0 to 5volt), i make the source pin in the negative of solar cell , the drain pin in the positive of solar cell and the gate pin to PWM, i want to varying the pwm step by step and i will take the I-V in each points.
 

GopherT

Joined Nov 23, 2012
8,009
In my project i have solar cell and i want mesure I-V caracteristic, for that i need a varaible resistor (MOSFET as a load ), to change the value of the resistor, i need produce a dc voltage (0 to 5volt), i make the source pin in the negative of solar cell , the drain pin in the positive of solar cell and the gate pin to PWM, i want to varying the pwm step by step and i will take the I-V in each points.
In that case, a filter capacitor will be useful. You can calculate the cap size with the formulas listed for power supply decoupling capacitors. Since you are supplying a mosfet that draws no current, you will want a small dummy load (10k ohm or so) to ground to allow the filter cap to drain. Use the drain resistor value to calculate current for the filter capacitor calculation.

If you have an ADC on your micro, you can measure voltage and control PWM as a feedback and step through the voltage range.
 

MikeML

Joined Oct 2, 2009
5,444
In my project i have solar cell and i want mesure I-V caracteristic, for that i need a varaible resistor (MOSFET as a load ), to change the value of the resistor, i need produce a dc voltage (0 to 5volt), i make the source pin in the negative of solar cell , the drain pin in the positive of solar cell and the gate pin to PWM, i want to varying the pwm step by step and i will take the I-V in each points.
Wont work. The power dissipation in the NFET will be huge. Read and follow the advice I gave in these two threads. Start here and continue here. Read all the way through...

When you understand the "back end", I can help you automate "turning the pot" using PWM out of the Arduino.
 

Thread Starter

arhem

Joined Dec 6, 2013
19
thank's for all,
my probleme is just if i can produce un dc signal(exmple:0v,0.1v, 0.2v, 0.5v, 1v, 2.4v, 3.6v) from the PWm, if i can, tell me how?
 

Alec_t

Joined Sep 17, 2013
14,280
my probleme is just if i can produce un dc signa
Don't think so.
Low pass filtering will give you the DC average of a PWM signal but, as MikML says, if you use that on the gate of your FET the power dissipation will be huge. THEN you will have your problem.
 

ian field

Joined Oct 27, 2012
6,536
Hi, everyone
I have an arduino uno, and a transistor N-MOSFET.
I wante to make the MOSFET as a variable resistor. fo that i have to controle the gate pin of transistor by varying the voltatage(0 to 5v step by step) between it.
the question is : can i use for this analogwrite PWM?
if the answer yes, how can i do it ?
If you make the MOSFET as a variable resistor - it isn't PWM.
 

Thread Starter

arhem

Joined Dec 6, 2013
19
so i think to produce a digital signal, and i make a DAC to converte it to analog signal,
it's the one solution!
 

shteii01

Joined Feb 19, 2010
4,644
so i think to produce a digital signal, and i make a DAC to converte it to analog signal,
it's the one solution!
Or you can use pwm do the same thing.

Your Uno does not have DAC, but it does have pwm.

Are you going to build the DAC circuit?
 

MikeML

Joined Oct 2, 2009
5,444
Arhem, you are not listening!

No matter how you create a DC voltage proportional to a numerical value inside your Arduino, you still have the problem of dealing with up to hundreds of Watts of dissipation in the NFET(s).

Go read the threads I linked you to, and just maybe, you will understand...
 

shteii01

Joined Feb 19, 2010
4,644
no, i think to by dac 1 channel
but if there are solution to build the dac with PWM, tell me how?
You either do not read or do not understand what you read.

1) You don't use PWM to make DAC. So there is nothing to tell. I already linked the Arduino tutorial about the use of PWM, in that tutorial there is a link to an example on how to setup PWM. You, obviously, did not read either. I don't see a point in continuing participating here.

2) MikeML seem to think that there are other issues. I am not sure what exactly it is, but he seems to think that NFET will produce so much power that it will burn itself out. I don't have a hands on experience working with MOSFET, so I can not advise on this issue.
 
Top