This is the latest (main) BeagleBoard documentation. If you are looking for stable releases, use the drop-down menu on the bottom-left and select the desired version.

Function rc_filter_moving_average

Function Documentation

int rc_filter_moving_average(rc_filter_t *f, int samples, double dt)

Makes a FIR moving average filter that averages over specified number of samples.

Any existing memory allocated for f is freed safely to avoid memory leaks and new memory is allocated for the new filter.

Note that the timestep dt does not effect the dynamics of the produced filter. It is simply copied into the ‘dt’ field of the rc_filter_t struct. However, it is necessary for creation of this filter for compatability with the soft-start feature and any other user codepaths that may be dependent on a filter’s timestep.

Parameters
  • f[out] Pointer to user’s rc_filter_t struct

  • samples[in] The samples to average over (>=2)

  • dt[in] desired timestep of discrete filter in seconds

Returns

Returns 0 on success or -1 on failure.