element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs TI Hercules LaunchPad RM57: Digital filtering Heart
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: martinvalencia
  • Date Created: 28 Jul 2015 12:04 PM Date Created
  • Views 2254 views
  • Likes 3 likes
  • Comments 11 comments
  • heart
  • texas-instruments
  • librerie
  • matlab
  • dsp
  • filter_digital
  • rm57
  • hercules
  • launchpad
Related
Recommended

TI Hercules LaunchPad RM57: Digital filtering Heart

martinvalencia
martinvalencia
28 Jul 2015

Digital filter design:

 

The cardiac signal has a bandwidth of 200Hz, we want to design a filter to remove band reject of 60Hz power line induced around us:

 

1. Calculation:

 

BW = bandwidth of the input signal.

Fs: Sampling frequency.

FNyquist: Nyquist frequency.

Fn = frequency standard for Matlab.

 

Fs=2*BW=2*200Hz=400Hz

Fnyquist=BW=200Hz


2. Selection of frequency:

 

N = Order of the digital filter.

AB = Bandwidth.

 

fir1 - Window-based FIR filter design

This MATLAB function uses a Hamming window to design an nth-order lowpass , bandpass, or multiband FIR filter with linear phase.

 

    b = fir1(N, AB)

    b = fir1(N, AB, ftype)

 

ftype= ‘LOW’,’HIGH’.

 

Note: For the correct choice of filter order must use values close to 90, for behold where an FIR filter has the same response as an IIR filter optimally.

          The bandwidth must be separated over 20 Hz or integral multiples of this so that the filter has a high attenuation (dB).



Demonstration:

 

First case- poor selection of bandwidth:

 

Select a width of less than 10 Hz band.

 

Finferior = 55Hz

Fsuperior = 65Hz

 

h = fir1(90,[55/200 65/200],'stop')

freqz(h,1,512)

image

 

coefficients generated
image

 

Conclusion: The maximum drop is 20dB, attenuation is very low for such a high order filter.

 

Second case-bandwidth Excellent Selection:

 

Finferior = 55Hz

Fsuperior = 75Hz

Selected width greater than 20Hz band and the result was good, with a 72dB care.

h = fir1(90,[50/200 75/200],'stop');

freqz(h,1,512)

image
coefficients generated
image
General code in Matlab:

h = fir1(90,[50/200 75/200],'stop')

freqz(h,1,512)

h=fliplr(h);

fid=fopen('archivo.txt','w');

fprintf(fid,'const float32_t firCoeffs32[NUM_TAPS] = {\n');

fprintf(fid,'%0.10ff, \n',h);

  fprintf(fid,'};');

 

image

 

This code creates a text file with the output coefficients RMx to add to Hercules.

 

https://www.keil.com/pack/doc/CMSIS/DSP/html/arm_fir_example_f32_8c-example.html

 

 

Main code file (Hercules RM57x):

#include "HL_sys_common.h"

/* USER CODE BEGIN (1) */

#include "HL_adc.h"

#include "arm_math.h"

#include "type_defs.h"

/* USER CODE END */

#define TEST_LENGTH_SAMPLES 512

#define BLOCK_SIZE                                        16

#define NUM_TAPS                                          91

/* -------------------------------------------------------------------

* The input signal and reference output (computed with MATLAB)

* are defined externally in arm_fir_lpf_data.c.

* ------------------------------------------------------------------- */

float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES];

//extern float32_t refOutput[TEST_LENGTH_SAMPLES];

/* -------------------------------------------------------------------

* Declare Test output buffer

* ------------------------------------------------------------------- */

static float32_t testOutput[TEST_LENGTH_SAMPLES];

/* -------------------------------------------------------------------

* Declare State buffer of size (numTaps + blockSize - 1)

* ------------------------------------------------------------------- */

static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1];

/* ----------------------------------------------------------------------

** FIR Coefficients buffer generated using fir1() MATLAB function.

** ------------------------------------------------------------------- */

/*Filtro para una frecuencia de 1kHz*/

const float32_t firCoeffs32[NUM_TAPS] = ADD HERE COEFF OF MATLAB

 

 

Schematic diagram of the cardiac signal amplifier circuit
image


 

Hercules RM57 Launchpad Texas Instruments
image


Application:


Input signal:

 

Signal sampled by the ADC (Hercules RM57x)
image

 

The resolution of the digital analog converter of Hercules is 12 bits, so this can sample much more faithfully the analog signal of the heart.

 

Filtered signal

 

The heart signal was properly filtered, you can clearly notice the PQRST wave
image

image

 

Video
You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

 

Tips and Conclusions:

 

• The application of digital filters Microcontroller is a great option at the time of reducing the elements within a circuit.

• Consideration should be given the capacity version of Hercules you are using, the Rm57 version has an excellent RAM,

     allowing you to work without problems in the implementation of digital filters, the RM46 version is also an excellent choice for its large capacity FLASH and RAM.

• The RM42x version is not recommended for the implementation of digital filters for not having large RAM memory.

• The digital filters were designed in MATLAB, for his great accuracy in delivering the coefficients for digital filters.

• We recommend using a high order filters to obtain the desired results.

 

 

My best reference Jan Cumps

https://e2e.ti.com/group/launchyourdesign/m/boosterpackcontest/666127

  • Sign in to reply

Top Comments

  • anujaapte
    anujaapte over 9 years ago +2
    Well written post martinvalencia and interesting workflow with MATLAB for filter design followed by TI hardware for implementation. I wonder if you have looked into the automatic code generation capabilities…
  • DAB
    DAB over 9 years ago +1
    Excellent detailed post. Well done. DAB
  • balearicdynamics
    balearicdynamics over 9 years ago +1
    Great and inspiring. There are a lost of good references. Enrico
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to martinvalencia

    Martin, please can you be more specific on the kind of source data you need to work on for the discrete convolution process ?

     

    Taking in account the context you are working with, and accordingly with the Discrete Convolution definition of Wikipedia, it seems to be an almost complex data set processing in most of the cases involving integrals. But analysing in depth the problem if I am not wrong your application is related on a time-based function, based on the data acquired during a certain time sample. In this case most of the problems we can meet in the general definition, covering almost all the possible cases in a single mathematical group of definitions, can be dramatically simplified reducing the number of trigonometry we should use to approach the problem.

     

    I have not investigated too much but for example in cases where time evolving events (our case fits in) the digital convolution of a function the will be used to filter the real data source with a function model is simplified a lot also reducing the calculation. Take a look to this mathematical description of an application in geophysical data analysis. Maybe our case is a bit more complex but the principle remain valid.

     

    Respect to where and how to convert the bare mathematical approach to a software at the actual data I have started exploring the mathlab (that's open source) but I have no idea if it can fit in your application and if this tool can be usable.

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • martinvalencia
    martinvalencia over 9 years ago in reply to balearicdynamics

    thank you very much, well now I have great doubt with which I struggle everyday, you know to use the discrete convolution or where I can find some application example?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • martinvalencia
    martinvalencia over 9 years ago in reply to jw0752

    thank you very much for your words, for me it is very important to read your comments because you always bring positive and good things.

    good start to the week!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to martinvalencia

    The way you are discussing the theme is very well. Take your time, you are doing a great work. If I have some doubt on the math details I will ask you, don't worry image

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 9 years ago

    Hi Martin,

    I enjoyed reading your post. Keep up the good work.

    John

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube