PWM output - sink our source? (Or both?)

Hi all,

Looking at making a circuit using a single PWM output, but need the pin to source current when at +V and also be able to sink current when at 0V.

It ideally would be able to sink and source the same current into the same impedance, in a balanced manner as my circuit would be easier to create with an element of symmetry.

Is this how the AnalogueWrite function works, or does it source when high, then just float?

Cheers, Scott.

A PWM enabled output is configured as a push-pull output. It can source and sink current.

That's fab, thank you very much! That'll make life straightforward.

Cheers, Scott

How much current does Your device need fro, the PWM output?

Not a lot, only in the region of 1mA.

The PWM signal will be filtered, generating a 400Hz sine wave approximation. (Stepping through an array form 0 to 360 degrees to control the output PWM amplitude).

From the PWM pin, I will be using a series resistor, then a capacitor down to 0V, with another capacitor up to +5V, the central point between them will (hopefully) drive the bases of both a PNP transistor and an and NPN transistor simultaneously.

The aim is so that the two transistor emitter or collector currents are roughly sinusoidal and in antiphase to each other.

Cheers, Scott.

Schematic please. That sounds "iffy". A differential pair might be better. Also 400 Hz is far too close to the PWM frequency to be adequately filtered in most applications...

mAmp is fine. An UNO gives 20mA, top 40 mA.
@aarg I missed the need for filtering. Where did You read it?

Here is the idea I was playing with. The two LED's are elements of opto couplers.

The opto couplers transistor outputs will be used to drive two sides of a complimentary pair PNP / NPN H-bridge to roughly create a sine wave into a motor coil.

I'm using optos because the H bridge is at a higher voltage, and I like segregating inductive loads from the microprocessor side.

It has to be 400Hz as this is the motors frequency. What are the possible PWM frequencies? I've not found a simple answer yet online sine you mentioned it.

Glad you raised that point, thanks, instead I could simply generate a 400Hz square wave, and convert it to a sine wave using RC network as such:

As long as I can make this drive the bases of the two transistors, and optos.

Cheers, Scott.

Fine! Go ahead and disrecard help You have not been asking for. Sometimes ambitious people want to take over the entire proj.

Railroader:
mAmp is fine. An UNO gives 20mA, top 40 mA.
@anon57585045 I missed the need for filtering. Where did You read it?

It's implied. analogWrite() was mentioned, and there is a low pass filter in the schematic.
The PWM frequencies used by analogWrite are documented here:

As you can see, the PWM frequencies are very low, ~500-1000 Hz. If you modulate the PWM value at 400Hz you are going to see some wicked beat interference and not much useful signal. That will be the case no matter what filter time constant you use.

OP, the transistor biasing is all wrong - in your diagram, both transistors will be forward biased all the time, and will probably self destruct due to excessive base current.

Thank you for the support,

I'd edited my last post to include:

"
Glad you raised that point, thanks, instead I could simply generate a 400Hz square wave, and convert it to a sine wave using RC network as such:

As long as I can make this drive the bases of the two transistors, and optos.
"

I had assumed the PWM freq would be much higher.

Yes you can use such a circuit but the output impedance is high - you need to buffer it before feeding the output to any load like an opto for instance.

An op amp implementation avoids that problem and performs better.
http://www.ti.com/lit/an/sbfa003/sbfa003.pdf
That circuit is tuned, but you can also just cascade two integrators.

scottbouch:
From the PWM pin, I will be using a series resistor, then a capacitor down to 0V, with another capacitor up to +5V, the central point between them will (hopefully) drive the bases of both a PNP transistor and an and NPN transistor simultaneously.

There's no point to the 2 capacitors like that, you just need 1 capacitor of twice the value to 0V. From an AC point of view 0V and +5V are shorted together, the AC, and so the capacitors, don't see them as any different. I think you are confused with a resistive divider.

Motor, H-bridge, 400Hz.

Seems you just can use the toneAC() function, set to 400Hz, and feed that directly into the H-bridge.
Leo..

PerryBebbington:
There's no point to the 2 capacitors like that, you just need 1 capacitor of twice the value to 0V. From an AC point of view 0V and +5V are shorted together, the AC, and so the capacitors, don't see them as any different. I think you are confused with a resistive divider.

That too.

PerryBebbington:
There's no point to the 2 capacitors like that, you just need 1 capacitor of twice the value to 0V. From an AC point of view 0V and +5V are shorted together, the AC, and so the capacitors, don't see them as any different. I think you are confused with a resistive divider.

Hi, the theory was to simply mirror the normal single ended way of doing it with a single NPN (not thinking potential divider), but I'm very rusty on proper electronics (hence why I'm doing this project), so will gladly take your advice with thanks! I can see what you're saying about one capacitor, thanks!

I've just initially set my UNO up to provide a 400Hz square wave for playing around with these circuit ideas, but my control of the output pins will be done a little bit smarter as I also need a second output offset by -90 or +90 degrees to this first signal, but the second signal needs a variable amplitude, which may be harder than I anticipated now I've found out about the PWM frequency..

I'll have to adjust the mark-space ratio of the second signal myself to get this to work.

Shame as I really wanted to apply a sine wave to this motor (to mimic it's original control gear), it probably will work ok with a square wave, in fact I could even just go to Mosfets too for efficiency if I'm just using square waves.

If I had access to 400Hz instrumentation transformers I may be able to turn the square into a sine that way, but hey ho, that's life, we make do.

The motor is made my Smiths Instruments, and dates from the early 60's. It's a quadrature phase type, it has two coils, rated 400Hz 115Vac. The first coil, "Reference", takes a permanent supply at full voltage, but the second coil, "Control", takes the +/-90 deg signal, of varying amplitude to result in direction of rotation and speed.

Cheers for the help.