# Positive and Negative Voltage Level from MCU PWM

Discussion in 'General Electronics Chat' started by Enforcer83, Dec 29, 2014.

1. ### Enforcer83 Thread Starter Member

Oct 29, 2010
25
0
I would like to use the PWM output on a MCU to give me a plus and minus voltage for use in controlling a Variable gain amplifier. Is this as simple as using totem pole transistors with the source/emitter of the P-type connected to +5V and the source/emitter of the N-type connected to -5V so when Duty Cycle (D) is roughly equal to 50% (taking dead time requirements into account) the output after the Low Pass filter is 0V?

2. ### ronv AAC Fanatic!

Nov 12, 2008
3,657
2,800
I don't think so, but you might check out a comparator. It might be the easiest.

3. ### ScottWang Moderator

Aug 23, 2012
5,477
864
If the current of the variable gain amplifier just need a little then maybe you could using an op amp to amplifying the pwm signal, let's say 2 times for amplifying, and the power of op amp that you may using >±7V, or choosing a rail to rail op amp then the power just using ±5V.

4. ### jpanhalt AAC Fanatic!

Jan 18, 2008
5,699
912
I know nothing about variable gain amplifiers, but as to the part of your question about using the PWM from an MCU to generate a negative voltage, a charge pump will do that.

John

5. ### ScottWang Moderator

Aug 23, 2012
5,477
864
I think the TS want a pulse 0~5V converting to a ±5V pulse, it just like a pulse from function generator, do you think you give him a negative voltage, does it going to work?

6. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,071
En,

What positive power supply(s) do you have available? You need a positive supply of >= +5V to do this. (> +8V makes it easier)

What negative power supply(s) do you have available? You need a negative supply of <= -5V to do this. (< -8V makes it easier)

7. ### Enforcer83 Thread Starter Member

Oct 29, 2010
25
0
I have + and - 5V supplies.

To clarify, the variable gain amplifier has an analog pin called VGAIN centered on VCOM which is VDD/2 for single rail and GND for dual rail supply. To control the gain of the VGA, VGAIN accepts a voltage between VCOM - 0.7V and VCOM + 0.7.

Since my VCOM is at GND, the VGAIN pin varies from -0.7V to +0.7V. I have provided a circuit schematic of what I am trying to accomplish. The waveforms located left of the gate driver inputs, MCU_PWM_OUT and MCU_PWM_COMP, are configured for what I believe is a 0V value. Notice how I have already configured them with a dead band. The MCU I intend on using can insert a dead band prior to outputting the signal. The PWM of the MCU can also do complementary outputs.

The duty cycle (D) is small, as can be calculated using the below information, so achieving the levels I need will be easy with the supply rails I am providing.

$D=\frac{T}{P}\cdot100%$, where $P=\frac{1}{f}$, $T=\frac{V_{OUT}}{V_{DD}}$, $f=2 MHz$, $V_{DD}=5V$, $0\le V_{OUT}\le 0.7V$, f has been arbitrarily selected and will depend on the capabilities of the MCU.

Please note the area with the dashed box is conceptual only right now. I am still attempting to design an offset and gain circuit to provide the PWM with feedback via the MCU's onboard ADC.

Edit: Modified attachment 12/30/14 1530

• ###### Vgain.pdf
File size:
9.5 KB
Views:
32
Last edited: Dec 30, 2014
8. ### ronv AAC Fanatic!

Nov 12, 2008
3,657
2,800
This won't run at 2 Mhz, but maybe it will give you some ideas. I set it up for 50Khz.

File size:
83.8 KB
Views:
51
9. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,071
Seems too complicated. Why not just use a single PWM output. Set it up so that if the PWM is 50% duty cycle, the output is 0V. If the Duty cycle is higher, say 90%, the output is +0.7V. If the duty cycle is lower, say 10%, the output is -0.7V.

How much ripple filtering would you need to convert the PWM to the control signal?
What is the PWM rate?

10. ### Enforcer83 Thread Starter Member

Oct 29, 2010
25
0
Mike,

Your right, that would be a lot simpler. I have redesigned the system using your suggestion and have attached the result; the redesign has not been simulated yet since I am redesigning and posting this from work and do not have access to a PSPICE simulator.

I am still working on the filter design but I have initially designed the system using a 2 pole filter with the following criteria where ζ is the dampening factor:

The transfer function of the filter is:
$H(s)= \frac{V_{OUT}(s)}{V_{IN}(s)}=\frac{\omega_n^2}{s^2+2 \zeta \omega_n s+ \omega_n^2}$
$f_C = 10 kHz
\omega_n=2 \pi f_C = \frac{1}{sqrt{L01 \cdot C01}}
\zeta = \frac{R01}{2} \cdot sqrt{ \frac{C01}{L01}}
0.707 \le \zeta \le 1$

so
$2.25 \le R01 \le 3.18$

• ###### Redesign.pdf
File size:
8.5 KB
Views:
30
Last edited: Jan 2, 2015

Sep 17, 2013
7,095
1,478

12. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,071
The effective output impedance of the PWM port is unknown, and much higher than 2.2Ω, so I would recommend a simple RC filter, followed by a Sallen-Key 2pole low-pass with some gain.

13. ### MrAl Distinguished Member

Jun 17, 2014
3,721
789
Hi,

A question i have is what are the specs of the controlling voltage source. In other words, what is the max voltage needed and what is the min needed, and what impedance does it have to be (low, med, high is ok).

For example, if the controlling source has a passive RC output filter with 10k and 0.01uf, is that good enough or do we have to lower the impedance and so use 1k and 0.1uf, or even lower with 100 ohm and 1uf, just for example.

Alternately, what does the controlling voltage have to feed.