100% software filter possible with Uc that replaces the real thing? - Page 1
Forum section: electronics / projects

author: AlanR
author_rank: Regular Contributor
timestamp: June 30, 2014, 07:18:14 am
content: After reading up on someone wanting to turn a SMPS into a battery charger. I got a light bulb moment about filters. Has anyone who deals with programming and digital stuff, ever made a microcontroller that can mimic filters where you simply write in software an algorithm that is the "equivalent" to a passive filter that uses capacitors and resistors or active filters that use op amps and passives? It seems such a setup would greatly cut down on parts count and cost if the Uc can artificially filter a signal simply by programming in some elaborate code.Probably already patented and used, or it is not feasible. I really don't know since I don't screw around with 1's and 0's and all that other fancy digital stuff. I believe in numbers greater than 1.

author: AndyC_772
author_rank: Super Contributor
timestamp: June 30, 2014, 07:30:32 am
content: You mean, has the digital filter been invented?Yes.

author: Odysseus
author_rank: Regular Contributor
timestamp: June 30, 2014, 07:35:43 am
content: Absolutely, and though it's a great idea, you're certainly not the first. See the pseudocode listed here for a simple example:http://en.wikipedia.org/wiki/Low-pass_filter#Discrete-time_realizationHowever, anti-aliasing (band-width limiting) is one analog filtering task that cannot be replaced digitally. Also the inverse problem of reconstruction must also be done in the analog domain.That said, oversampled ADCs/DACs (sigma-delta types) have much more relaxed analog requirements as they essentially perform the majority of the anti-aliasing and reconstruction digitally.

author: AlanR
author_rank: Regular Contributor
timestamp: June 30, 2014, 07:36:57 am
content: Quote from: AndyC_772 on June 30, 2014, 07:30:32 amThat's cool. Wonder why it is not used more often to replace lots of acitve analog filters or passive filters (although I want analog filters to stay forever. Heheh)? Is it cost and programming that is the issue and the power required for the uC?Quote from: Odysseus on June 30, 2014, 07:35:43 amAhhh. I see now.

author: miceuz
author_rank: Frequent Contributor
timestamp: June 30, 2014, 10:32:17 am
content: That's called digital signal processing, you can do *better* filters in software that do not drift with temperature, age and whatnot.http://www.dspguide.com/

author: dannyf
author_rank: Super Contributor
timestamp: June 30, 2014, 09:57:57 pm
content: Possible but difficult.one way would be to use a few bandpass amplifiers whose gains are controlled by a mcu, or band with controlled by a mcu.another approach is to ADC the signal, perform a fft on it and use some of the gains plus oscillators to reconstitute the output.a more realistic approach, beyond a mcu, is to use a dsp controlled by a mcu - the dsp can be reprogrammed by the mcu based on user inputs.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 01, 2014, 03:23:05 am
content: What kind of filter are we talking? The digital scheme is:Input Voltage > ADC > Digital Happens Here > DAC > Output VoltageAn ADC senses voltage, not power; and a DAC requires a power amplifier to deliver any current (most of them have a small amp internally). Whereas an analog LC filter works on impedance and power transfer.To replace an SMPS ripple filter, you need a power amplifier capable of delivering the load current, or if you bypass that around, at least delivering the ripple current and voltage*. Which begets the question...what's the amp powered from? I know, let's power it from another SMPS...which needs a filter... aha, let's use a digital filter there too!....Oh, wait.*This is an interesting approach to get low ripple on a high voltage supply without having to use huge components (piles of capacitance, let alone iron-cored inductors measured in the henries!). Most commonly done with an op-amp, set up to deliver current into the supply, inverse to the ripple voltage. Thus, bucking the ripple. This works because the op-amp only needs to make up a small fraction of an already-mostly-filtered supply.That's a rather silly case, though. Power supply filtering is pretty dumb and obvious, why would you even try DSP there? A more subtle case -- and perhaps this is what you were getting at? -- is using DSP for the error amplifier / feedback controller. Usually a PID in a SISO loop, which replaces the error amp and compensation components. An excellent example would be thus: build an analog constant current source, using a switcher, and feedback on current, so it's inherently current limited and stable. Drive the current setpoint with a DAC, and read the output voltage with an ADC. Do the voltage control digitally. The main advantage to this approach is having full software control over the compensation (it's just a few registers, not plugging in entire resistors and capacitors), and any kind of conditions you might like to add (over voltage/current, enable, temp throttling, modulation, etc.). For simple cases (a dumb bench supply, let's say), it's no advantage over a full analog solution, but may nonetheless be handy since you'll already have the digital values in memory for printing to a display.Personally, I would take the digital one level up, providing an analog min(x,y) function to decide between current setpoint and current limit, and have the voltage error amp analog. So the digital provides two voltages, one representing the current max, the other the voltage setpoint. The analog decides what to do with it. Nice part is it's easy to test -- hook up pots instead of DACs and you've got a perfectly useful bench supply already, with just a few wires needed.You can also implement the digital one level down, perhaps using a much faster ADC, or a comparator, or something, to tell the logic where the current is at, and setting the timer-counter accordingly, or whatever. I don't condone this, because if the software ever freezes -- and it's not a matter of if, but when: no code is perfect, nor is any processor guaranteed to execute perfectly -- the timer-counter just keeps on doing whatever it was doing, which at best means your output voltage freezes in its tracks, but at worst means your load gets a huge spike, or the transistors happily keep on switching into a dead short, etc. In contrast, the high level approach will always have voltage and current under control, if not necessarily the right values you were looking for.Tim