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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Function GDFLIB_FilterFIR_FLT<br />

FLT);<br />

GDFLIB_FILTERFIR_PARAM_T_FLT Param;<br />

GDFLIB_FILTERFIR_STATE_T_FLT State;<br />

tFloat fltInBuf[FIR_NUMTAPS_MAX];<br />

tFloat fltCoefBuf[FIR_NUMTAPS_MAX];<br />

#define OUT_LEN 16<br />

void main(void)<br />

{<br />

int ii;<br />

tFloat fltOutBuf[OUT_LEN];<br />

// Define a simple low-pass filter<br />

// The filter coefficients were calculated by the following<br />

// Matlab function (coefficients are contained in Hd.Numerator):<br />

//<br />

//function Hd = fir_example<br />

//FIR_EXAMPLE Returns a discrete-time filter object.<br />

//N = 15;<br />

//F6dB = 0.5;<br />

//<br />

//h = fdesign.lowpass('n,fc', N, F6dB);<br />

//<br />

//Hd = design(h, 'window');<br />

//return;<br />

ii = 0;<br />

fltCoefBuf[ii++] = -0.997590551617365;<br />

fltCoefBuf[ii++] = -0.995837825348525;<br />

fltCoefBuf[ii++] = 0.0095364856578114;<br />

fltCoefBuf[ii++] = 0.0199709259997918;<br />

fltCoefBuf[ii++] = -0.962045819946586;<br />

fltCoefBuf[ii++] = -0.930427167532233;<br />

fltCoefBuf[ii++] = 0.137360839237161;<br />

fltCoefBuf[ii++] = 0.447230387221663;<br />

fltCoefBuf[ii++] = 0.447230387221663;<br />

fltCoefBuf[ii++] = 0.137360839237161;<br />

fltCoefBuf[ii++] = -0.30427167532233;<br />

fltCoefBuf[ii++] = -0.962045819946586;<br />

fltCoefBuf[ii++] = 0.199709259997918;<br />

fltCoefBuf[ii++] = 0.0095364856578114;<br />

fltCoefBuf[ii++] = -0.995837825348525;<br />

fltCoefBuf[ii++] = -0.997590551617365;<br />

Param.u32Order = 15;<br />

Param.pfltCoefBuf = &fltCoefBuf[0];<br />

// Initialize FIR filter<br />

GDFLIB_FilterFIRInit_FLT (&Param, &State, &fltInBuf[0]);<br />

// Initialize FIR filter<br />

GDFLIB_FilterFIRInit (&Param, &State, &fltInBuf[0], Define FLT);<br />

// ##############################################################<br />

// Available only if single precision floating point<br />

// implementation selected as default<br />

// ##############################################################<br />

// Initialize FIR filter<br />

GDFLIB_FilterFIRInit (&Param, &State, &fltInBuf[0]);<br />

// Compute step response of the filter<br />

<strong>for</strong>(ii=0; ii < OUT_LEN; ii++)<br />

{<br />

// fltOut contains step response of the filter<br />

fltOutBuf[ii] = GDFLIB_FilterFIR_FLT ((tFloat)(1), &Param, &State);<br />

// fltOut contains step response of the filter<br />

fltOutBuf[ii] = GDFLIB_FilterFIR ((tFloat)(1), &Param, &State, Define<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 />

166 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!