Cov txheej txheem:

1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284: 9 Cov Kauj Ruam
1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284: 9 Cov Kauj Ruam

Video: 1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284: 9 Cov Kauj Ruam

Video: 1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284: 9 Cov Kauj Ruam
Video: Ep: 05 แบบบ้าน/ ແບບເຮືອນຊັ້ນດຽວ 10×14m, 4 ຫ້ອງນອນ, 1ຫ້ອງຄົວ./ Tawm qauv tsev yooj yim, Tau sai 2024, Kaum ib hlis
Anonim
1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284
1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284
1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284
1024 Cov Qauv FFT Spectrum Analyzer Siv Atmega1284

Qhov kev qhia yooj yim no (txiav txim siab qhov nyuaj ntawm cov ncauj lus no) yuav qhia koj li cas koj tuaj yeem ua tau yooj yim heev 1024 piv txwv tsom xam ntsuas siv Arduino hom board (1284 nqaim) thiab cov phiaj xwm phiaj xwm. Txhua yam ntawm Arduino lub rooj sib tham ua tau zoo yuav ua, tab sis ntau RAM nws muaj, qhov kev daws teeb meem zoo tshaj plaws uas koj yuav tau txais. Nws yuav xav tau ntau dua 8 KB ntawm RAM los suav FFT nrog 1024 cov qauv.

Spectrum tsom xam yog siv los txiav txim siab qhov tseem ceeb ntawm cov teeb liab. Ntau lub suab (zoo li cov uas tsim los ntawm cov cuab yeej siv suab paj nruag) tau tsim los ntawm cov hauv paus zaus thiab qee qhov kev sib haum xeeb uas muaj ntau zaus uas yog cov zauv ntau ntawm cov hauv paus zaus. Lub tshuab ntsuas hluav taws xob yuav qhia koj txhua yam khoom siv hluav taws xob no.

Koj yuav xav siv qhov teeb tsa no ua lub ntsuas hluav taws xob lossis txheeb xyuas txhua yam cim qhia tias koj xav tias ua rau muaj suab nrov hauv koj lub tshuab hluav taws xob.

Peb yuav tsom mus rau ntawm qhov software ib feem. Yog tias koj xav ua qhov txuas mus tas li rau ib daim ntawv thov tshwj xeeb koj yuav tsum tau ua kom nrov nrov thiab lim lub teeb liab. Qhov kev npaj ua ntej no yog nyob ntawm qhov teeb meem koj xav kawm, nyob ntawm nws qhov dav, qhov cuam tshuam, qhov ntau kawg thiab lwm yam … Koj tuaj yeem tshawb xyuas

Kauj Ruam 1: Txhim Kho Lub Tsev Qiv Ntawv

Peb yuav siv ArduinoFFT lub tsev qiv ntawv sau los ntawm Enrique Condes. Txij li thaum peb xav khaws RAM ntau li ntau tau peb yuav siv cov ceg txhim kho ntawm cov chaw cia khoom no uas tso cai siv cov ntaub ntawv ntab hom (tsis txhob siv ob npaug) los khaws cov ntaub ntawv piv txwv thiab suav. Yog li peb yuav tsum nruab nws manually. Tsis txhob txhawj xeeb, tsuas yog rub tawm cov ntawv khaws cia thiab nthuav nws hauv koj lub tsev qiv ntawv Arduino (piv txwv li Windows 10 kev teeb tsa ua ntej: C: / Cov neeg siv _ _ your_user_name_ / Documents / Arduino / libraries)

Koj tuaj yeem tshawb xyuas tias lub tsev qiv ntawv raug teeb tsa raug los ntawm kev suav ua ib qho piv txwv muab, zoo li "FFT_01.ino."

Kauj Ruam 2: Fourier Transform thiab FFT Cov Tswv Yim

Lus ceeb toom: yog tias koj tsis tuaj yeem sawv ntsug pom ib qho kev ua lej koj yuav xav hla mus rau Kauj Ruam 3. Xijpeem, yog tias koj tsis tau txais txhua yam, tsuas yog xav txog qhov xaus ntawm qhov kawg ntawm ntu.

Cov zaus siv tau los ntawm Fast Fourier Transform algorithm. FFT yog kev siv digital uas kwv yees lub tswv yim kev ua lej ntawm Fourier Transform. Raws li lub tswv yim no ib zaug koj tau txais kev hloov pauv ntawm lub teeb liab tom qab lub sijhawm ua haujlwm, koj tuaj yeem paub nws cov sawv cev hauv qhov ntau zaus, suav nrog qhov nyuaj (tiag + xav txog) qhov tseem ceeb. Lub tswv yim yog qhov sib thooj, yog li thaum koj paub tus lej sawv cev sawv cev koj tuaj yeem hloov nws rov qab mus rau lub sijhawm sau npe thiab tau txais lub teeb liab rov qab zoo ib yam li ua ntej kev hloov pauv.

Tab sis peb yuav ua dab tsi nrog cov txheej no suav ua qhov tseem ceeb hauv lub sijhawm sau? Zoo, feem ntau ntawm nws yuav raug tso tseg rau engineers. Rau peb peb yuav hu lwm lub algorithm uas yuav hloov pauv qhov tseem ceeb no mus rau hauv cov ntaub ntawv ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom ntom zauv (zuag qhia tag nrho): Tus naj npawb ntawm cov zaus yuav zoo ib yam li cov naj npawb ntawm cov qauv.

Koj yeej paub nrog lub tswv yim sib npaug, zoo li qhov no Rov qab mus rau 1980s Nrog Cov Duab EQ. Zoo, peb yuav tau txais cov txiaj ntsig zoo ib yam tab sis nrog 1024 pawg siv tsis tau 16 thiab ntau qhov kev daws teeb meem ntau dua. Thaum qhov sib npaug muab kev pom thoob ntiaj teb ntawm cov nkauj, kev tshuaj xyuas zoo pom zoo tso cai kom suav xam qhov tseeb ntawm txhua ntawm 1024 pawg.

Lub tswvyim zoo, tab sis:

  1. Txij li FFT yog digitalized version ntawm Fourier hloov pauv, nws kwv yees kwv yees cov teeb liab digital, thiab poob qee cov ntaub ntawv. Yog li, hais lus nruj me ntsis, qhov tshwm sim ntawm FFT yog hloov pauv rov qab nrog FFT algorithm inverted yuav tsis muab raws nraim qhov qub teeb liab.
  2. Tsis tas li qhov kev xav xav txog lub teeb liab uas tsis yog qhov kawg, tab sis qhov ntawd yog lub teeb liab tas mus li. Txij li thaum peb yuav digitalize nws tsuas yog rau qee lub sijhawm (piv txwv li cov qauv), qee qhov yuam kev ntxiv yuav raug qhia.
  3. Thaum kawg qhov kev daws teeb meem ntawm analog rau digital hloov pauv yuav cuam tshuam qhov zoo ntawm qhov suav qhov tseem ceeb.

Hauv kev xyaum

1) Qhov piv txwv piv txwv (sau fs)

Peb yuav ua piv txwv lub teeb liab, piv txwv li ntsuas nws qhov dav, txhua 1/fs vib nas this. fs yog qhov piv txwv piv txwv. Piv txwv li yog tias peb ua piv txwv ntawm 8 KHz, ADC (analog to digital converter) uas nyob hauv lub nti yuav muab ntsuas txhua 1/8000 ntawm vib nas this.

2) Tus naj npawb ntawm cov qauv (sau tseg N lossis cov qauv hauv txoj cai)

Txij li thaum peb yuav tsum tau txais txhua qhov txiaj ntsig ua ntej ua haujlwm FFT peb yuav tsum khaws lawv thiab yog li peb yuav txwv cov lej. FFT algorithm xav tau tus lej piv txwv uas yog lub zog 2. Cov qauv ntau dua peb muaj qhov zoo dua tab sis nws yuav siv ntau lub cim xeeb, txhua qhov ntau uas peb tseem yuav xav khaws cov ntaub ntawv hloov pauv, uas yog cov txiaj ntsig nyuaj. Lub tsev qiv ntawv Arduino FFT txuag qee qhov chaw los ntawm kev siv

  • Ib qho npe hu ua "vReal" khaws cov ntaub ntawv piv txwv thiab tom qab ntawd qhov tseeb ntawm cov ntaub ntawv hloov pauv
  • Ib qho npe hu ua "vImag" txhawm rau khaws ib qho kev xav ntawm cov ntaub ntawv hloov pauv

Qhov xav tau ntawm RAM sib npaug rau 2 (arrays) * 32 (khoom) * N (piv txwv).

Yog li hauv peb Atmega1284 uas muaj qhov zoo 16 KB ntawm RAM peb yuav khaws ntau tshaj N = 16000*8 /64 = 2000 qhov tseem ceeb. Txij li tus naj npawb ntawm qhov tseem ceeb yuav tsum yog lub zog ntawm 2, peb yuav khaws ntau tshaj 1024 qhov tseem ceeb.

3) Kev daws teeb meem zaus

FFT yuav suav qhov muaj nuj nqis rau ntau zaus ntau npaum li cov piv txwv. Cov qhab no yuav nthuav tawm los ntawm 0 HZ mus rau qhov piv txwv piv txwv (fs). Yog li, qhov kev daws teeb meem zaus yog:

Kev daws teeb meem = fs / N

Kev daws teeb meem zoo dua thaum qis dua. Yog li rau kev daws teeb meem zoo dua (qis dua) peb xav tau:

  • ntau cov qauv, thiab/lossis
  • qis fs

Tab sis …

4) Tsawg kawg fs

Txij li thaum peb xav pom ntau zaus, qee qhov ntawm lawv tau siab dua li "cov hauv paus zaus" peb tsis tuaj yeem teeb tsa fs qis dhau. Qhov tseeb muaj Nyquist – Shannon sampling theorem uas yuam kom peb kom muaj qhov piv txwv ua tau zoo tshaj ob zaug ntau zaus uas peb xav sim.

Piv txwv li, yog tias peb xav txheeb xyuas txhua qhov spectrum los ntawm 0 Hz kom hais 15 KHz, uas yog kwv yees li qhov ntau zaus uas tib neeg feem ntau tuaj yeem hnov txawv, peb yuav tsum teeb tsa qhov piv txwv ntawm 30 KHz. Qhov tseeb cov tshuab hluav taws xob feem ntau teeb tsa nws ntawm 2.5 (lossis txawm tias 2.52) * qhov siab tshaj plaws. Hauv qhov piv txwv no uas yuav yog 2.5 * 15 KHz = 37.5 KHz. Kev coj ua piv txwv zaus hauv cov suab tshaj lij yog 44.1 KHz (kaw suab CD), 48 KHz thiab ntau dua.

Xaus:

Cov Ntsiab Lus 1 txog 4 coj mus rau: peb xav siv ntau qhov piv txwv ntau li ntau tau. Hauv peb qhov xwm txheej nrog 16 KB ntawm RAM ntaus ntawv peb yuav txiav txim siab 1024 cov qauv. Peb xav ua piv txwv ntawm qhov ntsuas qis tshaj li qhov ua tau, tsuav nws siab txaus los tshuaj xyuas qhov ntau zaus peb xav tau hauv peb lub cim (2.5 * qhov zaus no, tsawg kawg).

Kauj Ruam 3: Simulating Lub Teeb

Simulating teeb liab
Simulating teeb liab

Rau peb thawj zaug sim, peb yuav hloov kho me ntsis TFT_01.ino piv txwv muab hauv lub tsev qiv ntawv, txhawm rau tshuaj xyuas lub teeb liab uas muaj

  • Lub hauv paus zaus, teeb tsa rau 440 Hz (suab paj nruag A)
  • Qhov sib haum xeeb thib 3 ntawm ib nrab ntawm lub zog ntawm qhov tseem ceeb ("-3 dB")
  • 5th harmonic ntawm 1/4 ntawm lub zog ntawm qhov tseem ceeb ("-6 dB)

Koj tuaj yeem pom hauv daim duab saum toj no cov txiaj ntsig tshwm sim. Nws zoo nkaus li zoo li lub teeb liab tiag tiag qee zaum qee zaum tuaj yeem pom ntawm oscilloscope (Kuv xav hu nws "Batman") hauv qhov xwm txheej thaum muaj clipping ntawm lub teeb liab sinusoidal.

Kauj Ruam 4: Txheeb Xyuas Qhov Simulated Signal - Coding

0) Suav nrog lub tsev qiv ntawv

#suav nrog "arduinoFFT.h"

1) Txhais

Hauv kab lus tshaj tawm, peb muaj

const byte adcPin = 0; // UA 0

const uint16_t kuaj = 1024; // Tus nqi no YUAV TSUM yog lub zog ntawm 2 const uint16_t samplingFrequency = 8000; // Yuav cuam tshuam rau timer tus nqi max hauv timer_setup () SYSCLOCK/8/samplingFrequency yuav tsum yog tus lej

Txij li thaum lub teeb liab muaj qhov sib haum xeeb thib 5 (zaus ntawm qhov sib haum xeeb no = 5 * 440 = 2200 Hz) peb yuav tsum teeb tsa cov qauv piv txwv siab dua 2.5 * 2200 = 5500 Hz. Ntawm no kuv xaiv 8000 Hz.

Peb kuj tshaj tawm cov arrays qhov twg peb yuav khaws cov ntaub ntawv raw thiab suav

ntab vReal [kuaj];

ntab vImag [kuaj];

2) Instantiation

Peb tsim cov khoom ArduinoFFT. Cov dev ntawm ArduinoFFT siv tus qauv yog li peb tuaj yeem siv ob qho ntab lossis ob hom ntaub ntawv. Ntab (32 khoom) txaus hauv qhov hais txog qhov tseeb ntawm peb qhov haujlwm.

ArduinoFFT FFT = ArduinoFFT (vReal, vImag, kuaj, samplingFrequency);

3) Simulating lub teeb liab los ntawm populating vReal array, tsis txhob muaj nws nyob nrog ADC qhov tseem ceeb.

Thaum pib ntawm Loop peb nthuav dav vReal array nrog:

ntab mus = (((piv txwv) * signalFrequency) / samplingFrequency); // Tus naj npawb ntawm cov teeb liab mus uas qhov piv txwv yuav nyeem

rau (uint16_t i = 0; i <qauv; i ++) {vReal = ntab ((amplitude * (sin ((i * (TWO_PI * cycles)) / qauv)))) / / Tsim cov ntaub ntawv nrog qhov zoo thiab qhov tsis zoo */ vReal += ntab ((amplitude * (sin ((3 * i * (TWO_PI * cycles))/ qauv)))/ 2.0);/ * Tsim cov ntaub ntawv nrog qhov zoo thiab qhov tsis zoo */ vReal += ntab ((amplitude * (sin ((5 * i * (TWO_PI * cycles)) / qauv))) / 4.0); / * Tsim cov ntaub ntawv nrog qhov zoo thiab qhov tsis zoo * / vImag = 0.0; // Ib feem ntawm kev xav yuav tsum tau xoom rau hauv rooj plaub ntawm looping kom tsis txhob suav yuam kev thiab dhau los}

Peb ntxiv digitalisation ntawm cov yoj yooj yim thiab ob qhov kev sib haum xeeb nrog tsawg dua qhov dav. Tshaj li peb pib qhov kev xav ntawm kev xav nrog xoom. Txij li cov kab no muaj neeg nyob los ntawm FFT algorithm peb yuav tsum tau tshem nws dua ua ntej txhua qhov kev suav tshiab.

4) Kev suav FFT

Tom qab ntawd peb suav FFT thiab qhov ntom ntom ntom ntom ntom ntom

FFT.windowing (FFTWindow:: Hamming, FFTDirection:: Forward);

FFT.compute (FFTDirection:: Forward); / * Suav FFT */ FFT.complexToMagnitude (); / * Suav xam qhov ntau */

FFT.windowing (…) kev ua haujlwm hloov kho cov ntaub ntawv nyoos vim tias peb khiav FFT ntawm qhov txwv tsawg ntawm cov qauv. Thawj zaug thiab zaum kawg nthuav qhia qhov tsis sib xws (tsis muaj "tsis muaj dab tsi" ntawm ib sab ntawm lawv). Qhov no yog qhov ua yuam kev. Kev ua haujlwm "windowing" zoo li txo qhov ua yuam kev no.

FFT.compute (…) nrog cov lus qhia "Forward" suav qhov kev hloov pauv los ntawm lub sijhawm sau mus rau tus lej zaus.

Tom qab ntawd peb suav qhov loj (piv txwv li siv zog) qhov txiaj ntsig rau txhua qhov ntawm cov zaus. Tam sim no vReal array tau ntim nrog qhov ntau qhov tseem ceeb.

5) Serial plotter drawing

Cia peb luam qhov tseem ceeb ntawm cov phiaj xwm phiaj xwm los ntawm kev hu lub luag haujlwm printVector (…)

PrintVector (vReal, (kuaj >> 1), SCL_FREQUENCY);

Nov yog cov haujlwm muaj txiaj ntsig uas tso cai luam tawm cov ntaub ntawv nrog lub sijhawm ua haujlwm lossis cov zaus sib luag.

Peb kuj luam tawm qhov zaus ntawm cov qhab uas muaj tus nqi siab tshaj plaws

ntab x = FFT.majorPeak ();

Serial.print ("f0 ="); Serial.print (x, 6); Serial.println ("Hz");

Kauj Ruam 5: Txheeb Xyuas Qhov Teeb Meem Simulated - Cov txiaj ntsig

Kev Ntsuam Xyuas Ntawm Qhov Teeb Meem Simulated - Cov txiaj ntsig
Kev Ntsuam Xyuas Ntawm Qhov Teeb Meem Simulated - Cov txiaj ntsig

Peb pom 3 qhov sib txuam sib luag rau qhov siv zaus (f0), qhov sib thooj thib 3 thiab 5, nrog ib nrab thiab 1/4 ntawm qhov f0 qhov ntau, raws li xav tau. Peb tuaj yeem nyeem saum lub qhov rais f0 = 440.430114 Hz. Tus nqi no tsis yog 440 Hz, vim yog txhua qhov laj thawj tau piav qhia saum toj no, tab sis nws ze heev rau tus nqi tiag. Nws tsis yog qhov yuav tsum tau los ua kom pom ntau qhov tsis tseem ceeb.

Kauj Ruam 6: Txheeb Xyuas Qhov Teeb Meem Tiag - Txuas ADC

Txheeb Xyuas Qhov Teeb Meem Tiag - Txuas ADC
Txheeb Xyuas Qhov Teeb Meem Tiag - Txuas ADC

Txij li thaum peb paub yuav ua li cas hauv kev xav, peb xav tshuaj xyuas lub teeb liab tiag.

Txoj hlua yog yooj yim heev. Txuas cov av ua ke thiab kab teeb liab mus rau A0 tus lej ntawm koj lub rooj tsavxwm dhau los ntawm cov kab tawm tsam nrog tus nqi ntawm 1 KOhm txog 10 KOhm.

Cov koob tshuaj tiv thaiv kab mob no yuav tiv thaiv cov lus sib piv thiab zam kom tsis txhob nrov nrov. Nws yuav tsum siab kom ntau li ntau tau kom tsis txhob muaj lub suab nrov, thiab qis li sai tau kom muab sijhawm txaus los them rau ADC sai. Xa mus rau MCU cov ntawv kom paub txog qhov kev cia siab ntawm lub teeb liab txuas nrog ntawm ADC cov tswv yim.

Txog qhov ua piv txwv no kuv siv lub tshuab hluav taws xob ua haujlwm kom pub lub teeb liab sinusoidal ntawm zaus 440 Hz thiab qhov dav nyob ib puag ncig 5 volts (nws zoo tshaj yog tias qhov dav dav yog nruab nrab ntawm 3 thiab 5 volts yog li ADC tau siv ze rau qhov ntsuas tag nrho), los ntawm 1.2 KOhm resistor.

Kauj Ruam 7: Txheeb Xyuas Qhov Teeb Meem Tiag - Coding

0) Suav nrog lub tsev qiv ntawv

#suav nrog "arduinoFFT.h"

1) Cov lus tshaj tawm thiab kev txhim kho

Hauv kab lus tshaj tawm peb txheeb xyuas ADC cov tswv yim (A0), tus lej ntawm cov qauv thiab cov qauv piv txwv, zoo li hauv qhov piv txwv yav dhau los.

const byte adcPin = 0; // UA 0

const uint16_t kuaj = 1024; // Tus nqi no yuav tsum yog lub zog ntawm 2 const uint16_t samplingFrequency = 8000; // Yuav cuam tshuam rau timer tus nqi max hauv timer_setup () SYSCLOCK/8/samplingFrequency yuav tsum yog tus lej

Peb tsim cov khoom ArduinoFFT

ArduinoFFT FFT = ArduinoFFT (vReal, vImag, kuaj, samplingFrequency);

2) Timer thiab teeb tsa ADC

Peb teeb tsa timer 1 yog li nws mus los ntawm qhov piv txwv piv txwv (8 KHz) thiab nce kev cuam tshuam ntawm cov khoom sib piv.

void timer_setup () {

// reset Timer 1 TCCR1A = 0; TXC1B = 0; TCNT1 = 0; TCCR1B = ntsis (CS11) | ntsis (WGM12); // CTC, prescaler ntawm 8 TIMSK1 = ntsis (OCIE1B); OCR1A = ((16000000 /8) / samplingFrequency) -1; }

Thiab teeb ADC yog li nws

  • Siv A0 raws li kev tawm tswv yim
  • Ua kom tau txais txiaj ntsig ntawm txhua lub sijhawm 1 tso tawm sib piv sib tw B
  • Ua kom muaj kev cuam tshuam thaum hloov dua siab tshiab tiav

ADC moos tau teeb tsa ntawm 1 MHz, los ntawm prescaling lub moos system (16 MHz) los ntawm 16. Txij li txhua qhov kev hloov pauv yuav siv sijhawm kwv yees li 13 teev ntawm kev ntsuas puv, kev hloov pauv tuaj yeem ua tiav ntawm zaus ntawm 1/13 = 0.076 MHz = 76 KHz. Kev ntsuas qhov ntsuas yuav tsum qis dua 76 KHz kom cia ADC muaj sijhawm los ua piv txwv cov ntaub ntawv. (peb xaiv fs = 8 KHz).

tsis muaj dab tsi adc_setup () {

ADCSRA = ntsis (ADEN) | ntsis (ADIE) | ntsis (ADIF); // qhib ADC rau, xav cuam tshuam thaum ua tiav ADCSRA | = me ntsis (ADPS2); // Prescaler ntawm 16 ADMUX = ntsis (REFS0) | (adcPin & 7); // teeb tsa ADC cov tswv yim ADCSRB = ntsis (ADTS0) | ntsis (ADTS2); // Timer/Counter1 Sib Piv Match B qhov ua rau ADCSRA | = ntsis (ADATE); // qhib qhov pib tsis siv neeg}

Peb tshaj tawm tus cuam tshuam cuam tshuam uas yuav raug hu tom qab txhua qhov kev hloov pauv ADC los khaws cov ntaub ntawv hloov pauv hauv vReal array, thiab tshem tawm qhov cuam tshuam

// ADC ua tiav ISR

ISR (ADC_vect) {vReal [resultNumber ++] = ADC; yog (resultNumber == kuaj) {ADCSRA = 0; // tua ADC}} EMPTY_INTERRUPT (TIMER1_COMPB_vect);

Koj tuaj yeem muaj cov lus piav qhia ntxaws txog ADC hloov pauv ntawm Arduino (analogRead).

3) Teeb

Hauv kev teeb tsa muaj nuj nqi peb tshem tawm cov lus xav tau ntawm lub rooj thiab hu rau lub sijhawm thiab ADC teeb tsa kev ua haujlwm

zero kuv (); // muaj nuj nqi uas teev rau 0 txhua cov ntaub ntawv xav txog - piav qhia hauv ntu dhau los

timer_setup (); adc_setup ();

3) Lub voj

FFT.dcRemoval (); // Tshem tawm DC tivthaiv ntawm lub teeb liab no txij li ADC tau hais txog hauv av

FFT.windowing (FFTWindow:: Hamming, FFTDirection:: Forward); // Ntsuas cov ntaub ntawv FFT.compute (FFTDirection:: Forward); // Suav FFT FFT.complexToMagnitude (); // Suav xam qhov ntau // luam tawm cov spectrum thiab qhov siv zaus f0 PrintVector (vReal, (kuaj >> 1), SCL_FREQUENCY); ntab x = FFT.majorPeak (); Serial.print ("f0 ="); Serial.print (x, 6); Serial.println ("Hz");

Peb tshem tawm DC tivthaiv vim tias ADC tau hais txog hauv av thiab lub teeb liab yog nyob ib puag ncig 2.5 volts kwv yees.

Tom qab ntawd peb suav cov ntaub ntawv raws li tau piav qhia hauv qhov piv txwv dhau los.

Kauj Ruam 8: Txheeb Xyuas Qhov Teeb Meem Tiag - Cov txiaj ntsig

Txheeb Xyuas Qhov Teeb Meem Tiag - Cov txiaj ntsig
Txheeb Xyuas Qhov Teeb Meem Tiag - Cov txiaj ntsig

Tseeb peb pom tsuas yog ib zaus hauv qhov teeb meem yooj yim no. Qhov suav qhov tseem ceeb yog 440.118194 Hz. Ntawm no dua tus nqi yog ze ze ntawm qhov zaus ntau.

Kauj Ruam 9: Yuav Ua Li Cas Txog Qhov Clipped Sinusoidal Signal?

Yuav Ua Li Cas Txog Qhov Clipped Sinusoidal Signal?
Yuav Ua Li Cas Txog Qhov Clipped Sinusoidal Signal?

Tam sim no cia hla dhau me ntsis ADC los ntawm kev nce qhov dav ntawm lub teeb liab saum 5 volts, yog li nws raug kaw. Tsis txhob thawb dhau heev kom tsis txhob rhuav tshem ADC cov tswv yim!

Peb tuaj yeem pom qee qhov sib haum xeeb tshwm sim. Clipping lub teeb liab tsim cov khoom siv ntau zaus.

Koj tau pom cov hauv paus ntawm kev tshuaj xyuas FFT ntawm Arduino pawg thawj coj. Tam sim no koj tuaj yeem sim hloov pauv qhov piv txwv, tus lej ntawm cov qauv thiab qhov ntsuas qhov ntsuas qhov ntsuas. Lub tsev qiv ntawv tseem ntxiv qee qhov ntsuas los laij FFT nrawm dua nrog qhov tsis raug. Koj yuav pom tias yog tias koj teeb tsa qhov piv txwv qis dhau, qhov suav qhov sib piv yuav tshwm sim tsis raug vim yog qhov quav quav.

Pom zoo: