0
\$\begingroup\$

What I'm trying to achieve:

I have a 5V PWM signal that either needs to be left as-is, or converted into an analog 0-5V signal.

How am I planning to achieve this?

The PWM to analog conversion is done through an RC circuit using a 4.7K resistor and 0.1uF ceramic capacitor.

To switch between the signal being digital or analog, another input alternates the voltage at the base of a PNP transistor, which short-circuits the RC circuit, allowing the original PWM signal through. If the transistor is off, the output signal takes an analog form filtered by the RC circuit.

It kind of works. A PWM duty of 33% should produce an analog signal of 1.65V. With the transistor off, this works as expected with an analog output signal of 1.65V. With the transistor ON, a PWM signal is passed through but at a voltage of 2.5V instead of the expected 5V.

I'm expecting a very small voltage drop through the transistor which should be negligible. However I'm seeing this is not the case.

I have a basic understanding of transistors but I think I'm probably doing something obviously wrong here.

Perhaps there's a better way of approaching the problem. I thought about using relays to short-circuit the RC circuit, but there must be a "simpler" way of using semiconductors to do the job.

Any help appreciated!

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Where did you find this circuit? \$\endgroup\$ – Ignacio Vazquez-Abrams May 5 '14 at 13:02
  • \$\begingroup\$ I came up with it lol - why? \$\endgroup\$ – Ibraheem May 5 '14 at 13:05
  • \$\begingroup\$ It's not surprising that it doesn't work. You could replace the transistor with a diode and it would do the same thing. \$\endgroup\$ – Ignacio Vazquez-Abrams May 5 '14 at 13:13
2
\$\begingroup\$

If I assume that that the X junction is connected, then when the PWM signal is "high", the output is indeed high, however when it is low, the transistor is 'off' and the capacitor discharges through the resistor.

You really have to disconnect the capacitor to get this to work. A simple 4000-series analog switch would work beautifully (eg. 74HC4053)- you could simply multiplex between the PWM signal and the analog signal (the 4.7K resistor won't affect the digital signal unduly, but the capacitor will).

enter image description here

schematic

simulate this circuit – Schematic created using CircuitLab

I guess you could simulate an analog switch by adding another transistor (NPN) driven with the opposite logic, but you will still have the capacitor connected to the logic signal, which will affect the waveform greatly.

\$\endgroup\$
  • \$\begingroup\$ Yes the X junction is connected. So just to understand the problem properly, when the PWM is low and control signal is HIGH (i.e transistor is OFF), C1 is discharging through R1? \$\endgroup\$ – Ibraheem May 5 '14 at 13:15
  • \$\begingroup\$ Thank you for the suggestion, I'll take a look at analog switches! \$\endgroup\$ – Ibraheem May 5 '14 at 13:15
  • \$\begingroup\$ Yes to your first question. If you were able to disconnect the capacitor then the output would follow the input with alternately a transistor or 4.7K in series, not great, but it would work. It's bad to connect a large grounded capacitor to a logic output directly, it will draw large pulses of current every time the output switches. \$\endgroup\$ – Spehro Pefhany May 5 '14 at 13:45
  • \$\begingroup\$ Thank you I've been investigating the 4053 and it looks perfect! \$\endgroup\$ – Ibraheem May 5 '14 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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