Average period of input signal

  • How to implement the following functions.

    That applet takes n signals to calculate the average value, and this n can be set by itself. If n is 20, the applet will not output the first signal until it receives 20 signals, and then each output signal is the average value calculated by taking down 20 signals.

  • Hello Pangfengjiang,

    Solid approach for this is:
    pasted-from-clipboard.png

    Full VA Design can be downloaded here:
    SignalDuration Averaging.va

    The signal periods are measured behind a debouncer. the debouncer makes sure to remove noise spikes.
    Then a kernel environment on the last 20 values is taken.
    Division of the resulting sum of all periods by 20.
    Removing first 19 averages to get an average for each period after the first 20.
    Generate a period of average last 20 periods, but tricky:

    - Period is showing up as single tick-pulse, getting half the period of duration by SignalWidth.
    Please have a look into documentation of PeriodToSignal and WidthToSignal to fully understand.
    Pulse duration is half of period.

    Best regards,