0
\$\begingroup\$

The process: I want to do a on-board-in-loop test. From simulink I want to send data via serial to ATmega 128, which will generate a PWM at 4kHz. This PWM will pass through a low-pass-filter so that the voltage across the capacitor will give the mean value of the PWM as output. This mean will be read by a data acquisition card (DAQ card) by simulink thus completing the loop.
The DAQ can read a maximum of 10V.

The low pass filter is simulating acuator dynamics, which has some settling time after application of PWM (settling time - time required for the voltage across it it to become 99% of mean of applied voltage)

The problem: The low pass filter has a ripple voltage.

Ripple voltage: voltage by which the final output of the low pass filter will oscillate about the mean of the PWM which is given at input. This ripple voltage is basically noise.

The ripple voltage comes to be of the order of the order of 1e-3V if the RC ratio is about 1e-3.

In the beginning of the simulation, the mean of the PWM voltages from my ATmega are about 1V. It then keeps decreasing till it becomes really low, of the order of 1e-5V(by keeping a really low duty cycle). I need to capture this entire range(the DAQ is capable).So I will need to amplify the PWM.

My question: Will a non-inverting OPAMP be able to do it? Asking this as an OPAMP has a slew rate (0.5V/microsecond). So will it be hampered when the PWM signal goes from LOW to HIGH or HIGH to LOW? If you can suggest any other way to achieve this, that would also help.

Edit 1: If I keep the RC product of the low pass filter as 40, I get a ripple voltage as low as 1e-6V. But is it advisable to build such a filter?

Website used for filter simulation: http://sim.okawa-denshi.jp/en/PWMtool.php

Edit 2: I want the settling time of the low pass filter to be around 400ms.

\$\endgroup\$
  • \$\begingroup\$ I don't get what "Voltages from my ATmega are of the order of 1e-5V" means. Are the PWM you are giving of that mean value? Or that is digital output? The high voltage of PWM should still be close to V+ and low close to 0. else your atmega is faulty. \$\endgroup\$ – udiboy1209 Dec 15 '16 at 11:01
  • \$\begingroup\$ edited. I meant mean. \$\endgroup\$ – sixtyTonneAngel Dec 15 '16 at 11:02
  • \$\begingroup\$ Can't you just output a higher voltage in PWM (program V*100 to be PWM output)? Why amplify? A PWM mean this low is bound to give you errors. And an op-amp won't amplify PWM before low-pass-filtering (It will try to amplify the high V+ , and get cut off). \$\endgroup\$ – udiboy1209 Dec 15 '16 at 11:12
  • \$\begingroup\$ The pwm mean varies between 1V to 1e-5V. Also, a non inverting OPAMP won't saturate if I set its gain correctly. Original Post has been edited. \$\endgroup\$ – sixtyTonneAngel Dec 15 '16 at 11:47
  • 1
    \$\begingroup\$ Also, please don't write 1e-3 V. Write 1 mV. Besides, is your 0-10 V interface even capable of capturing sub mV signals? \$\endgroup\$ – winny Dec 15 '16 at 15:00
1
\$\begingroup\$

It's not clear exactly what you're doing, but it seems the problem is that there is still too much PWM ripple left on a filtered PWM signal.

If so, then the answer is simple: Filter it more aggressively.

Before you design any filter, you have to decide how fast you want the result to settle, and how much noise you can tolerate, neither of which you specified. It is therefore impossible to recommend a specific filter since we don't know what specs it's supposed to meet.

However, here is a example. You don't say what voltage this PWM is, so I'll assume 3.3 V. You say the PWM frequency is 4 kHz, so that's what we have to attenuate to oblivion. Let's say that "oblivion" is 10 µV or less in this context. So, you have 3.3 V in and want 10 µV out at 4 kHz. That's attenuation by 330 k.

Let's see how a simple passive RC filter could accomplish this. A factor of 330 k is way too much for a single pole, so lets look into 3 poles. The cube root of 330 k is 69. Therefore placing 3 poles at (4 kHz)/69 = 58 Hz would do it. Whether you can live with the settling time, only you can say.

A single RC low pass filter with 58 Hz rolloff can be achieved by a 10 kΩ resistor in series followed by 274 nF to ground, so 300 nF it is. So here is a filter that will achieve what we specified:

There will be minimal interaction between the individual filter poles at the frequency of interest of 4 kHz since the capacitors will have much less impedance than the resistors. Each stage is essentially fed by a low impedance source.

The overall output of this filter may be too high impedance to be useful directly. If so, you can follow it with a unity gain buffer.

Again, you have to look at the step response and decide whether it's fast enough for your purposes. If not, you have to use more poles, a higher PWM frequency, or a different filter topology altogether. The advantage of simple RC filters in series like this is that they have no corner cases you have to worry about, are inherently stable, and quite tolerant of part value variations.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The PWM is between 0 to 3.3V. I want to get as output the mean of the PWM signal. For this I use low-pass filter. But at times, the mean is very low (about 1e-5 V). The low pass filter introduces a ripple voltage of around 1e-3V, which is undesirable. So if my mean is much greater than 1e-3V, the output will be acceptable. But if the mean is 1e-5V and ripple voltage is 1e-3V, the ripple voltage will mask my mean. Hence I will need to amplify my PWM signal in order to amplify it's mean. \$\endgroup\$ – sixtyTonneAngel Dec 15 '16 at 12:22
  • \$\begingroup\$ I want the settling time of the low pass filter to be around 400ms. \$\endgroup\$ – sixtyTonneAngel Dec 15 '16 at 12:31
  • 1
    \$\begingroup\$ Then the three-pole filter at 58 Hz is well within spec. You could lower the rolloff frequency significantly from the example I showed. \$\endgroup\$ – Olin Lathrop Dec 15 '16 at 12:32
  • \$\begingroup\$ Can you explain what roll-off frequency is? \$\endgroup\$ – sixtyTonneAngel Dec 15 '16 at 12:36

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.