[chbot] Software filter. Fast attack, slow decay

Trevor Wignall zl3adz at gmail.com
Sun Jun 19 06:39:21 BST 2022


The hardware circuit is missing a discharge resistor, so it would take
infinite time to discharge. There are two places you could add this
resistor, giving two different behaviours. One is across the capacitor. The
other is across the diode (or with a slight change in value across the
series diode plus resistor combination).
The software can simply model the hardware behaviour if we can ignore the
forward voltage drop of the diode, which allows us to use a simple if
(Input > Output) test. Rather than using multibyte multiplications, we can
calculate the change in output voltage and add that to the previous output
voltage to get the new output voltage, with most or all of the
multiplications necessary to calculate the change replaced by shift right
operations performed on the difference between input and output (or
performed on the output voltage if you are modelling a resistor across the
output). You will probably need a multibyte addition routine and possibly a
multibyte subtraction routine (or use the addition routine with negative
numbers).

On Sun, Jun 19, 2022 at 4:47 PM Stephen Irons <stephen at irons.nz> wrote:

> My solution was to implement the (low-pass) filter in any standard way,
> and implement the ideal diode as the max() function: the input to the
> filter is the larger of the input value and the current filtered value.
>
> For interest, my preferred implementation for a single-pole low-pass
> filter is 'exponential smoothing'
> https://en.wikipedia.org/wiki/Exponential_smoothing
>
> Stephen Irons
>
> On Sun, Jun 19, 2022 at 16:34, Robin Gilks <gb7ipd at gmail.com> wrote:
>
> Here's another question for you all!!
>
> I'm trying to implement "something like" a VU Meter in software (in an
> embedded system so it has to be small & fast).
> The hardware equivalent to a diode running into an RC filter
>
>           |\ |             R
>    in ----|  |----------vvvvvv--------- out
>           |/ |                    |
>                                  ___
>                                  ___  C
>                                   |
>                                   |
>  common ----------------------------------------
>
> My first port of call for filters is an IIR but that does not have the
> fast attack I'm after, especially if I want the long tail.
>
> Does anyone have any magic that doesn't disappear into a morass of DFTs
> and FFTs and 3 page equations summing integrals from 0 to infinity ;)
>
> Cheers - hopefully see you tomorrow.
>
> --
> Robin Gilks
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20220619/42528261/attachment.html>


More information about the Chchrobotics mailing list