Electronic – how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller

microcontroller

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

Best Answer

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