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
Design for a Cause - Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Design for a Cause - Design Challenge
  • More
  • Cancel
Design for a Cause - Design Challenge
Blog Blowing-Whistle as Controller(BWaC) ----- Analyse the Spectrum with ArduinoFFT #4
  • 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: fyaocn
  • Date Created: 17 Aug 2018 6:03 AM Date Created
  • Views 1590 views
  • Likes 6 likes
  • Comments 4 comments
Related
Recommended

Blowing-Whistle as Controller(BWaC) ----- Analyse the Spectrum with ArduinoFFT #4

fyaocn
fyaocn
17 Aug 2018

Analyse the Spectrum with ArduinoFFT

1. The ISD1820 is microphone module, the analogue value shall be turned into digital value for processing purpose. 

Pin A0 is set as INPUT, fetching data form ISD1802.

int inputPin = A0;

The following codes do the job with adcTune function, the analogueRead(A0) pins is set for sound wave catching.

void adcTune(double *vReal,double *vImag ,int *readings)
{
  // read from the sensor AND advance to the next position in the array:
  //for (int  readIndex= 0; readIndex < numReadings; readIndex++) {    readings[readIndex] = analogRead(inputPin);  }
  for (int  readIndex= 0; readIndex < numReadings; readIndex++){
    delay(CYCLETIME); // delay fpr cycle
    readings[readIndex] = analogRead(inputPin); 
    }
   
      for (int i = 0; i < numReadings; i++) {
      vReal[i] = readings[i] ;/* Build data with positive and negative values*/
      vImag[i] = 0.0; 
        }
}

imageimage

 

2. The easiest solution to process the digital data is by FFT algorithm. There would be considerable amount of calculation for fast process, especially for low performance Cortex-M0 core. The arduinoFFT library can handle the calculation in short time. There have been many technique in fast calculation on Complex data, and the result is good.

image

In this test, only peak frequency is printed. In fact , the spectrum is available for further encryption. 

In function fftTune(), there are three sub-steps like FFT.windowing(), FFT.Compute(), FFT.ComplexToMagnitude(). After that, FFT.MajorPeak() can pick the peak frequency within the spectrum.

void fftTune(double *vReal,double *vImag, uint16_t samples)
{
         FFT.Windowing(vReal, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD);  /* Weigh data */
        FFT.Compute(vReal, vImag, samples, FFT_FORWARD); /* Compute FFT */
        FFT.ComplexToMagnitude(vReal, vImag, samples); /* Compute magnitudes */
        Serial.println("Computed magnitudes:");
        PrintVector(vReal, (samples >> 1), SCL_FREQUENCY);
        double x = FFT.MajorPeak(vReal, samples, SAMPLINGFREQUENCY);
}

  • Sign in to reply

Top Comments

  • prashanth.nagendrappa
    prashanth.nagendrappa over 7 years ago +1
    Nice Update
  • aspork42
    aspork42 over 7 years ago +1
    Nice update - I was wondering about the reading you got. Your previous post noted a frequency of ~2735 Hz. This shows around 241 Hz. I wonder what value you have for delay(CYCLETIME); Since that could…
  • fyaocn
    fyaocn over 7 years ago in reply to aspork42 +1
    Code in the sketch #define CYCLETIME 1 means only 1 ms is set. The 241Hz is test results when I tap the table. It varies around 200Hz~350Hz if you can try. As to frequency over 2kHz, that is a challenge…
Parents
  • prashanth.nagendrappa
    prashanth.nagendrappa over 7 years ago

    Nice Update

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • prashanth.nagendrappa
    prashanth.nagendrappa over 7 years ago

    Nice Update

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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