aversive_10-03-12/modules/devices/control_system/filters/biquad/biquad.c File Reference

#include <biquad.h>
#include <string.h>

Go to the source code of this file.

Functions

void biquad_init (struct biquad_filter *p)
void biquad_flush_memories (struct biquad_filter *p)
void biquad_set_numerator_coeffs (struct biquad_filter *p, int16_t b0, int16_t b1, int16_t b2)
void biquad_set_deniminator_coeffs (struct biquad_filter *p, int16_t a1, int16_t a2)
void biquad_set_divisor_shifts (struct biquad_filter *p, uint8_t recursive_shift, uint8_t out_shift)
void biquad_set_series_son (struct biquad_filter *p, struct biquad_filter *son)
int32_t biquad_do_filter (void *data, int32_t in)


Function Documentation

int32_t biquad_do_filter ( void *  data,
int32_t  in 
)

filter processing, 1 iteration. This function is not protected against writing in the structure while execution is ongoing!

Definition at line 107 of file biquad.c.

References biquad_filter::a1, biquad_filter::a2, biquad_filter::b0, biquad_filter::b1, biquad_filter::b2, biquad_do_filter(), biquad_filter::mem_in_1, biquad_filter::mem_in_2, biquad_filter::mem_out_1, biquad_filter::mem_out_2, biquad_filter::out_shift, gen_regs::p, biquad_filter::recursive_shift, and biquad_filter::son.

Referenced by biquad_do_filter().

void biquad_flush_memories ( struct biquad_filter p  ) 

this is useful for cleaning the filter memories before a new data set. With this you avoid having old data in the filter memories when beginning to filter a new stream. Can also be used after changing the coefficients, to avoid jumps of the output value.

Definition at line 46 of file biquad.c.

References IRQ_LOCK, IRQ_UNLOCK, biquad_filter::mem_in_1, biquad_filter::mem_in_2, biquad_filter::mem_out_1, and biquad_filter::mem_out_2.

void biquad_init ( struct biquad_filter p  ) 

init sets an unity filter, as usual

Definition at line 27 of file biquad.c.

References IRQ_LOCK, and IRQ_UNLOCK.

void biquad_set_deniminator_coeffs ( struct biquad_filter p,
int16_t  a1,
int16_t  a2 
)

Definition at line 73 of file biquad.c.

References biquad_filter::a1, biquad_filter::a2, IRQ_LOCK, and IRQ_UNLOCK.

void biquad_set_divisor_shifts ( struct biquad_filter p,
uint8_t  recursive_shift,
uint8_t  out_shift 
)

Definition at line 84 of file biquad.c.

References IRQ_LOCK, and IRQ_UNLOCK.

void biquad_set_numerator_coeffs ( struct biquad_filter p,
int16_t  b0,
int16_t  b1,
int16_t  b2 
)

accessors to coefficients

Definition at line 61 of file biquad.c.

References biquad_filter::b0, biquad_filter::b1, biquad_filter::b2, IRQ_LOCK, and IRQ_UNLOCK.

void biquad_set_series_son ( struct biquad_filter p,
struct biquad_filter son 
)

this sets a filter to put in series. use as following :

biquad_set_series_son(& filter1, &filter2)

then please use ONLY the filter1. The filter 2 will recursively be called into the filter 1 function : output = biquad_do_filter(& filter1, input);

You can put in series as much biquad filters as you want.

Definition at line 95 of file biquad.c.

References IRQ_LOCK, IRQ_UNLOCK, and biquad_filter::son.


Generated on Fri Mar 12 06:32:06 2010 for AVR by  doxygen 1.5.6