element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
Experimenting with Vibration Sensors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Vibration Sensors
  • More
  • Cancel
Experimenting with Vibration Sensors
Blog Vibration Sensor and Exercising - Calculating FFT on Nucleo Board - Blog #3
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: yosoufe
  • Date Created: 26 Dec 2020 10:37 PM Date Created
  • Views 3746 views
  • Likes 3 likes
  • Comments 3 comments
Related
Recommended

Vibration Sensor and Exercising - Calculating FFT on Nucleo Board - Blog #3

yosoufe
yosoufe
26 Dec 2020

  • CMSIS 5
  • Code
  • Results
  • Related Links

 

I tried to calculate the FFT on the Nucleo board for this blog. I think it is somehow working but not very clean. I am not sure what is wrong or if something is wrong. Please let me know if you know what I am doing wrong.

 

CMSIS 5

I am using the CMSIS library to calculate the FFT. I had some difficulties to get the pre-compiled libraries and include them in my project.

They have not documented it very well on how to get the library. So these are the steps I needed to do to get the pre-compiled library for the Nucleo board on Ubuntu 18.04 and STM32CubeIDE:

  1. Download the latest release ".pack" file from github. The latest version, at the time of writing this blog, is called "ARM.CMSIS.5.7.0.pack".
  2. Rename the file to "ARM.CMSIS.5.7.0.zip" and then un-compress it by right clicking on it and clicking on "Exctract here".
  3. Now you need the following two files inside the uncompressed directory.
    • "ARM.CMSIS.5.7.0/CMSIS/DSP/Include/arm_math.h"
    • "ARM.CMSIS.5.7.0/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a"
  4. The rest is the same as the following YouTube video on how to use these files. Just note that in the previous version of CMSIS, the library files were in the git repo (according to video) but now they only exist in the released ".pack" file

(This is not my video)

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

 

 

Code

The code can be found in my github here. The code does this:

  • I am using Timer 3 to trigger the ADC at frequency of 10kHz
  • At the end of each ADC conversion, DMA is triggered to write the result in adc_buf[4096] array in circular manner.
  • The following YouTube video was very helpful to setup the TIMER, DMA and ADC in STM32CubeIDE.
  • At the end of 4096th DMA operation, a callback is called to set a triggert of FFT calculation.
  • At the trigger, first, I copy the adc_buf to a fft_in buffer array and also convert from 16-bit unsigned int to a float with unit of voltage.
  • Then the FFT function from CMSIS is being called.
  • Then the FFT complex numbers are converted to absolute values into freqs[2048] array.
  • Finally I am using the STM32CubeMonitor to visualize some of the frequencies. The FFT would create values for 2048 frequencies. Unfortunately STM32CubeMonitor cannot show all of them, so I just plot few of them.

 

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

 

In order to map the FFT results to frequencies I am using the following logic (in Python)

 

def get_freq(freqs_idx):
     sampling_frequency = 10000
     signal_length = 4096
     frequency = freqs_idx * sampling_frequency / signal_length 
     return frequency

 

So for example the 10th element of freqs array would represents the frequency of  get_freq(10) which is 24.41 Hz.

 

Results

I recorded a video to show the results and also possible problems. Sorry for my bad English.

  • I am first showing the code and how I setup Timer, ADC, DMA and FFT
  • Then I compare the FFT calculation of signal on Oscilloscope with the Nucleo board results.
    • The top left is showing the FFT, calculated by Oscilloscope
    • The bottom bar chart shows the FFT calculation on Nucleo Borad. The chart is created with STM32CubeMonitor. I could guess that there could be some problems with the STM32CubeMonitor as well because they frequently stated that the application is not created for monitoring arrays.

I see the video is only playing on 720p resolution, So I uploaded it on Youtube for 1080p resolution as well: https://youtu.be/WFoQAf8ER3o

 

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

 

Related Links

Previous Blogs:

  • Vibration Sensor and Exercising - Introduction - Blog #1
  • Vibration Sensor and Exercising - Basic Experiments - Blog #2
  • My Progress: Experimenting with Vibration Sensors

External Resources:

  • STM32CubeMonitor tool suite overview
  • CMSIS Libraries
  • FFT documentation of the CMSIS
  • Sign in to reply

Top Comments

  • DAB
    DAB over 4 years ago +1
    Nice update. DAB
  • yosoufe
    yosoufe over 4 years ago in reply to jiajie

    Hi,

    I am not sure. I only used STM32CubeIDE. You might search "how to include header files in keil".

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jiajie
    jiajie over 4 years ago

    May I know how to add these is keil?

    • "ARM.CMSIS.5.7.0/CMSIS/DSP/Include/arm_math.h"
    • "ARM.CMSIS.5.7.0/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a"
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 4 years ago

    Nice update.

     

    DAB

    • 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