PWM and analog ouput

Hi,

in a design I must provide both 8 PWM channels and 8 analog outputs (related to the others). Instead using a DAC I'd use a LPF to obtain analog output from each PWM channel.

Some details:

PWM: 500 Hz < f < 5 KHz (to be determined), TTL output analog: -5V +5V, 20 mA for each output

The MCU provides signals between 0V and 3V3. Hence, for PWM I'd use a darlington array at 5V. But I don't see how to convert the PWM 0-3V into a analog signal -5V/+5V.

Please note I must save space on the board and I can't use SMD parts.

A way might be translate PWM to -5V/+5V and then filter with a MFB op-amp low-pass filter.

Any ideas? Are there IC to filter PWM?

Thanks, Marco / iw2nzm

Reply to
Marco Trapanese
Loading thread data ...

The most efficient way is to use an LPF on the PWM to produce your signal in the range 0-3.3V, and then input this into an opamp translator and buffer, possibly with additional filtering, to convert the 0-3.3 input range to a -5V to 5V output range. The algebra here is Vout=[(5--5)/3.3]xVin-5V or 3.03xVin-5, where 0--+--> Vout . | +-------|-/ | . === | |/| | . CF | | | | . | | V- | . --- | | . /// +----[R3]-----' . | . | . [R2] . | . | . --- . /// . . . . . R3=2.03 x (R1||R2) . . . R1 (V+ x 2.03) - 5 . -- = --------------- . R2 5 . .

Reply to
Fred Bloggs

Ramp and hold with opamp level shifter? Convert to pcm with a counter and to analog with a DAC? Your output signal requirements are ill defined. Is a staircase ok?

Bob

Reply to
sycochkn

sycochkn ha scritto:

I guess this solution need more parts than I can fit on the board.

Marco / iw2nzm

Reply to
Marco Trapanese

Fred Bloggs ha scritto:

[cut]

Yummm... I like very much that way! Should I add a capacitor on the feedback path (// R3) to provide additional filtering?

Thanks! Marco / iw2nzm

Reply to
Marco Trapanese

You might look at integrated circuit analog switches - some of them switch between up to +/-15V analog power rails under the control of a digital signal. Farnell has a couple of pages of integrated circuit analog switches and analog multiplexers.

Linear Technology - amongst others - sell integrated circuits designed to allow you to implement relatively high order low pass filters, which might be useful in converting PWM into analog, but they aren't all that good for this sort of work. The two amplifier version of the two-pole Sallen and Keys low pass section works pretty well - with two amplifiers you can use identical capacitors in your RC pairs and do all the tuning by picking your resistor values out of the E96 range.

-- Bill Sloman, Nijmegen

Reply to
bill.sloman

See figure 1 for the 2nd order configuration that applies here:

formatting link

Reply to
Fred Bloggs

It is not necessary to switch for +/-5V, it's just more parts in addition to a LPF/buffer. It's better to just run the 0/3.3 into the LPF/buffer. The slight drawback of ripple amplification by 9dB can be overcome by a slightly lower cut-off frequency for the LPF, about 1/3 the cutoff for your approach with a single pole, or 0.6 for two pole, or up the PWM frequency correspondingly.

Would be nice if the OP mentions the kind of analog BW he wants to produce...

Reply to
Fred Bloggs

Fred Bloggs ha scritto:

Ok, thank you. I'll build a test circuit on a breadboard to see the output signal in both cases.

Thanks, Marco / iw2nzm

Reply to
Marco Trapanese

Fred Bloggs ha scritto:

Doh! I forgot to mention! I'm sorry. The maximum analog BW will be lower than 10 Hz, typically about 3-4 Hz.

Marco / iw2nzm

Reply to
Marco Trapanese

Unless that MCU is doing stuff like driving LEDs and you also require decent precision-- is this a 1% or 0.1% thing or a few percent thing? Sourcing or sinking a bunch of current from other MCU port pins will affect the voltage on the PWM outputs a bit.

There's not enough swing at a 3.3V CMOS output to reliably drive a cheap 4000 series switch (a 74HCT40xx might be okay).

It might be easier to dedicate a MCU to the PWM in that case rather than f*rting around.

Best regards, Spehro Pefhany

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

I'm not familiar with all the PIC stuff. Are you saying that those parts with the PWM feature do not use a freerunning subcircuit that does not require ALU intervention?

Reply to
Fred Bloggs

Of course, you can make them with software, but it's hard to find uC with 8 hardware PWMs. Most AVRs/PICs come with 1 or 2. Some LMIs come with 6. Perhaps other posters can suggest some uCs.

Reply to
linnix

Spehro Pefhany ha scritto:

Yeah, that is what I'm doing. I use a Rabbit module for the hard things and then a small AVR to generate 8-bit, 8-channel software PWM. The Rabbit talks with AVR through SPI several times per second.

Marco / iw2nzm

Reply to
Marco Trapanese

PICS? I was speaking generally, but yeah, they do (although the non-atomic update of the 10-bit PWM has to be synchronized to avoid glitching the lower two bits on the low end models), and usually there's only a few independent channels.. enough to do 3-phase PWM, for example. I was speaking more of DC shifts in pin voltage due to currents flowing in or out of other port pins and affecting the internal Vdd or GND bus relative to the external voltages, but it appears he's dedicating a part to the purpose so the other currents (supply current and some transient currents from the communication) should be negligible.

Best regards, Spehro Pefhany

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

It is useful to get the high and low levels of the PWM waveform away from the digital power and ground rails - both tend to be noisy, and I once ran into a situation where inept layout meant that the point that was setting the analog 0V for a fairly sensitive circuit was some

100mV more positive than the ground tracks for the rest of the circuit

- that was extreme, and easily fixed, but smaller voltage gradients along tracks are common, and can be a nuisance.

-- Bill Sloman, Nijmegen

Reply to
bill.sloman

input the PWM into a Op-amp that is being supplied from a +/- rail supply. Off set the input using one input of the op-amp and the other input will derive it's signal from the PWM output.. Basically, the offset is a REF that will be joined into a common mode configuration of an op-amp. you must keep the PWM at 50% duty for 0 volts.

Place a cap on the feed back to help filter the PWM.. you can use 2 quad op-amp chip packages to suit your needs.

I did 4 channels with a uC project using the LM324 variety once.

--
http://webpages.charter.net/jamie_5"
Reply to
Jamie

that's not a problem.. You just set the time event at maximum speed and have scaled variables.. It works fine.. It does how ever cut into the resolution of the output and all of that must be calculated. In most cases a modus uC will handle that just fine with good results. in the case of resolution, dithering methods increases over all precision greatly.

--
http://webpages.charter.net/jamie_5"
Reply to
Jamie

dont use the sallen-key filter. in theory its great, in practice not so great. the problem is the feedback capacitor C1. Because you are filtering a PWM waveform, the edges are very fast - it depends on your digital logic, but I would expect to see edge transitions in the 10s of ns (its unlikely to be any slower, and may be a lot faster).

at the frequencies contained in these sharp edges (rough calc: F ~ pi/Tedge) the output impedance of the opamp can be extremely high. In this case, the feedback doesnt really work, and C1 provides an HF bypass, allowing the edges to appear at the output. ultimately you get a voltage divider, between the impedance of C1 and the output impedance of the opamp.

one way to fix this is to use a suitably fast opamp. brute force, but workable. Build the SK filter with an LM324, and you *will* see exactly what I am talking about. then change the opamp to, say, LMV824 and watch the output get a lot better.

another method is to split R1 in half, and bung a cap to 0V in the center. this cap filters out the edges, allowing you to use a slower opamp.

the multiple feedback filter of fig. 2 is a lot better in this regard. R1 & C2 form a low-pass filter, regardless of the opamp. this will attenuate those nasty edges *before* they get to the opamp - just like the modified Sallen-Key circuit.

Cheers Terry

Reply to
Terry Given

Not really, the divider is between the series combination of input R+C1 and the output impedance, no need to fly into a panic over a uV step...

These channels are driving output lines of unknown impedance and capacitance. The OP may just dominant pole the feedback at the output with a largish capacitor and eliminate several problems at once...

Reply to
Fred Bloggs

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.