Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Please help me at how to generate a variable analog signal(0-5V) from a in-built AVR microcontroller's PWM(0-5V). I am doing a project on I-V data logger.I am using a MOSFET as variable load & want to drive the gate voltage(Vgs) of MOSFET by a variable voltage which comes from pwm of microcontroller. I would be very happy if somebody come up with answer. Thanks in advance.

Nagu Bhanoth

share|improve this question

2 Answers

you need a resistor, a capacitor and an opamp.

opamp is not really necessary when you are driving a mosfet, but will make life a bit easier.

enter image description here

just be aware, that this dac will be quite noisy or/and slow. The bigger cap/resistor values, quiter and slower the output.

another thing to be aware is that you better use 16bit pwm, as 8 bit pwm will give you only 256 discrete values - that could be enough or too coarse, depends on your application, of course.

just google "PWM DAC" for more info and calculations.

EDIT

one more thing - you could put several resistor/capacitor stages in series to improve on the noise side:

enter image description here

share|improve this answer

Create a Low-Pass RC filter that will filter out the frequency of your PWM. The cutoff frequency should be at least 10 times lower than the frequency of your PWM. A lower cutoff frequency will reduce the voltage ripple in the output signal.

Cutoff frequency is determined by:

f = 1/(2πRC)

Further reading:

http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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