03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

signal entering the state delay-line typically requires a larger dynamic range than the<br />

output signal y(k). There<strong>for</strong>e, overflow can occur at the delay-line input of the DF-II<br />

implementation, unlike in the DF-I implementation.<br />

Because there are two delay buffers necessary <strong>for</strong> both DF-I <strong>and</strong> DF-II implementation of<br />

the first order IIR filter, the DF-I implementation was chosen to be used in the<br />

GDFLIB_FilterIIR1_F16 function.<br />

Figure 4-2. Direct Form 1 first order IIR filter<br />

The coefficients of the filter depicted in Figure 4-2 can be designed to meet the<br />

requirements <strong>for</strong> the first order Low (LPF) or High Pass (HPF) filters. Filter coefficients<br />

can be calculated using various tools, <strong>for</strong> example, the Matlab butter function. The<br />

coefficient quantization error due to finite precision arithmetic can be neglected in the<br />

case of a first order filter. There<strong>for</strong>e, the calculation of coefficients can be done using<br />

Matlab as follows:<br />

freq_cut = 100;<br />

T_sampling = 100e-6;<br />

[b,a]=butter(1,[freq_cut*T_sampling*2],'low');<br />

sys=tf(b,a,T_sampling);<br />

bode(sys)<br />

f16B0 = b(1);<br />

f16B1 = b(2);<br />

f16A1 = a(2);<br />

disp('Coefficients <strong>for</strong> GDFLIB_FilterIIR1 function:');<br />

disp(['f16B0 = FRAC16 (' num2str(f16B0) ')']);<br />

disp(['f16B1 = FRAC16 (' num2str(f16B1) ')']);<br />

disp(['f16A1 = FRAC16 (' num2str(f16A1) ')']);<br />

Note<br />

The filter delay line includes two delay buffers which should be<br />

reset after filter initialization. This can be done by assigning to<br />

the filter instance a GDFLIB_FILTER_IIR1_DEFAULT_F16<br />

macro during instance declaration or by calling the<br />

GDFLIB_FilterIIR1Init_F16 function.<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

Chapter 4 API References<br />

Freescale Semiconductor, Inc. 175

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!