# PWM / AD0 question

Discussion in 'General Electronics Chat' started by Klipeti, Dec 10, 2013.

1. ### Klipeti Thread Starter New Member

Nov 25, 2012
18
0
Hello!
I am using Ecio40p microcontroller to control voltage with PWM / AD ports.
I attached a picture of how I connected the ports.

My question is, that where/how I use the controlled voltage? Voltage is measured over C1, controlling voltage works like charm.
Do I connect the led or something right after C1, but before ground?

File size:
28.9 KB
Views:
22
2. ### tubeguy Well-Known Member

Nov 3, 2012
1,157
197
You could connect an LED with a series current limiting resistor directly between the AD0 output and ground provided the MCU output can provide enough current and voltage. But your circuit uses a 4.7k resistor which will not provide enough current to turn on an LED. You could modify your circuit with a proper size (smaller value resistor) to drive the LED.

What is the MCU power supply voltage?
How much current can the MCU port supply?
Do you know how to calculate LED current limiting resistors?

A better way is to use a buffer circuit like this op-amp voltage follower. The voltage follower can provide additional current and isolates the voltage input from the load (LED for example). With a buffer, the voltage range of your existing circuit can be maintained.

Last edited: Dec 10, 2013
3. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
The problem with such a simple RC low-pass filter is that it can only drive a very high resistance load. If the load is a high impedance compared to 10k (the R in the RC), then the voltage out is proportional to the duty-cycle of the pwm waveform. The ADC input resistance is high enough for it to work.

However, if you shunt the C (to ground) with a low impedance (like a LED and current limiting resistor), then that will interfere with the proportionality described above.

As pointed out, an Op-Amp connected as a voltage-follower (look it up) will drive the LED without the input of the voltage follower loading the RC network.

4. ### Klipeti Thread Starter New Member

Nov 25, 2012
18
0
This is just simple test of voltage controlling with PWM and RC filter.
I thought about making something which is controlled by voltage reference.
Connecting LED was just an example

MCU uses +5V, but I'm not sure about the current, I didn't check it out.
I know how to calculate LED resistors, I just wanted to ask that how do I put the voltage to use.

5. ### tubeguy Well-Known Member

Nov 3, 2012
1,157
197
Do you have something in mind ?

Is the function of the buffer circuit clear to you ?

6. ### Klipeti Thread Starter New Member

Nov 25, 2012
18
0
Not yet :/

Well, not exactly. In my knowledge it goes between two circuits and transfers voltage or current from first circuit to second.
In my case it's voltage, right?