devices.xylo.syns63300.imuif.BandPassFilter
- class devices.xylo.syns63300.imuif.BandPassFilter(B_b: int = 6, B_wf: int = 8, B_af: int = 9, a1: int = -36565, a2: int = 31754, scale_out: float | None = None)[source]
Bases:
object
Class that instantiates a single quantised band-pass filter, as implemented on Xylo IMU hardware
This class will design the best filter that meets a pass-band specification, using the class method
from_specification()
. Alternatively, you can specify thea1
anda2
taps directly as a signed integer representation, as well as specifying the number of bits needed for specifying the filter.Attributes overview
Bits needed for encoding the fractional parts of taps
Bits needed for scaling b0
Bits needed for fractional part of the filter output
Integer representation of a1 tap
Integer representation of a2 tap
A virtual scaling factor that is applied to the output of the filter, NOT IMPLEMENTED ON HARDWARE! That shows the surplus scaling needed in the output (accepted range is [0.5, 1.0])
Methods overview
__init__
([B_b, B_wf, B_af, a1, a2, scale_out])compute_AR
(signal)Compute the AR part of the filter in the block-diagram with the given parameters.
compute_MA
(signal)Compute the MA part of the filter in the block-diagram representation.
from_specification
(low_cut_off, high_cut_off)Create a filter with the given upper and lower cut-off frequencies.
- B_af: int = 9
Bits needed for encoding the fractional parts of taps
- B_b: int = 6
Bits needed for scaling b0
- B_wf: int = 8
Bits needed for fractional part of the filter output
- __init__(B_b: int = 6, B_wf: int = 8, B_af: int = 9, a1: int = -36565, a2: int = 31754, scale_out: float | None = None) None
- a1: int = -36565
Integer representation of a1 tap
- a2: int = 31754
Integer representation of a2 tap
- compute_AR(signal: ndarray) ndarray [source]
Compute the AR part of the filter in the block-diagram with the given parameters.
- Parameters:
signal (np.ndarray) – the quantized input signal in python-object integer format.
- Raises:
OverflowError – if any overflow happens during the filter computation.
- Returns:
the output signal of the AR filter.
- Return type:
np.ndarray
- compute_MA(signal: ndarray) ndarray [source]
Compute the MA part of the filter in the block-diagram representation.
- Parameters:
signal (np.ndarray) – input signal (in this case output of AR part) of datatype
pyton.object
.- Raises:
OverflowError – if any overflow happens during the filter computation.
- Returns:
quantized filtered output signal.
- Return type:
np.ndarray
- classmethod from_specification(low_cut_off: float, high_cut_off: float, fs: float = 200) BandPassFilter [source]
Create a filter with the given upper and lower cut-off frequencies. Note that the hardware filter WOULD NOT BE EXACTLY THE SAME as the one specified here. This script finds the closest one possible
- Parameters:
low_cut_off (float) – The low cut-off frequency of the band-pass filter.
high_cut_off (float) – The high cut-off frequency of the band-pass filter.
fs (float) – The clock rate of the chip running the filters (in Hz). Defaults to 200.
- Returns:
the filter with the given cut-off frequencies.
- Return type:
- scale_out: float | None = None
A virtual scaling factor that is applied to the output of the filter, NOT IMPLEMENTED ON HARDWARE! That shows the surplus scaling needed in the output (accepted range is [0.5, 1.0])