Go Down

### Topic: Question about magnitude (Read 3355 times)previous topic - next topic

#### Noisecontrol

#90
##### Jun 20, 2018, 10:02 pm
Why in the sin wave example code if amplitude multiplay 2 it become equal peak amplitude .
Do in this code if amplitude *2 it become peak amp?

#91

#### Noisecontrol

#92
##### Jun 22, 2018, 02:24 pmLast Edit: Jun 22, 2018, 02:27 pm by Noisecontrol
Hello pieter
I change code to this and use 3.3 V of ardino pin

Code: [Select]
`#define LIN_OUT 1 // use the log output function#define FHT_N 256 // set to 256 point fht#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))#include <FHT.h> // include the libraryconst double a12200 = pow(12200,2);const double a206 = pow(20.6,2);const double a1077 = pow(107.7,2);const double a7379 = pow(737.9,2);const double CORR = 0;const int GAIN = 1;int f;double RA,CF,f2,f4,C,ADCNUM;void setup() {  Serial.begin(115200); // use the serial port  ADCSRB = 0; // Free running mode  ADMUX = (DEFAULT << 6) | 0; // A0  sbi(ADCSRA, ADEN); // Enable ADC  sbi(ADCSRA, ADATE); // Auto trigger  sbi(ADCSRA, ADSC); // Start conversion  // 19.231 kHz  sbi(ADCSRA, ADPS2);  sbi(ADCSRA, ADPS1);  cbi(ADCSRA, ADPS0);}void loop() { do {    cli();  // UDRE interrupt slows this way down on arduino1.0    for (int i = 0 ; i < FHT_N ; i++) { // save 256 samples      while (!(ADCSRA & _BV(ADIF))); // wait for adc to be ready      sbi(ADCSRA, ADIF); // Clear interrupt flag      byte m = ADCL; // fetch adc data      byte j = ADCH;      int k = (j << 8) | m; // form into an int      k -= 0x0200; // form into a signed int      k <<= 6; // form into a 16b signed int      fht_input[i] = k; // put re3l data into bins    }    fht_window(); // window the data for better frequency response    fht_reorder(); // reorder the data before doing the fht    fht_run(); // process the data in the fht    fht_mag_lin(); // take the output of the fht    sei();    for (uint8_t i = 0 ; i < FHT_N / 2 ; i++) {      f=i * 19231UL / FHT_N;      Serial.print(f);      Serial.print(" HZ:");      Serial.println(fht_lin_out[i]); // send out the data    }  } while(0);  while(1);}`

Result is for frequency 1051 Hz is 2928

Code: [Select]
`0 HZ:1600075 HZ:7936150 HZ:23225 HZ:36300 HZ:6375 HZ:11450 HZ:9525 HZ:30600 HZ:20676 HZ:30751 HZ:4826 HZ:19901 HZ:59976 HZ:16641051 HZ:29281126 HZ:12961201 HZ:291277 HZ:201352 HZ:171427 HZ:311502 HZ:101577 HZ:211652 HZ:201727 HZ:241802 HZ:111878 HZ:141953 HZ:462028 HZ:7802103 HZ:12242178 HZ:4682253 HZ:232328 HZ:172403 HZ:72478 HZ:52554 HZ:122629 HZ:132704 HZ:192779 HZ:172854 HZ:122929 HZ:153004 HZ:133079 HZ:813155 HZ:1303230 HZ:543305 HZ:123380 HZ:263455 HZ:203530 HZ:383605 HZ:173680 HZ:363756 HZ:323831 HZ:203906 HZ:133981 HZ:44056 HZ:554131 HZ:3704206 HZ:4684281 HZ:1354357 HZ:264432 HZ:164507 HZ:164582 HZ:74657 HZ:264732 HZ:274807 HZ:134882 HZ:34957 HZ:125033 HZ:85108 HZ:285183 HZ:1785258 HZ:1975333 HZ:465408 HZ:85483 HZ:95558 HZ:265634 HZ:465709 HZ:175784 HZ:95859 HZ:265934 HZ:66009 HZ:96084 HZ:16159 HZ:206235 HZ:726310 HZ:746385 HZ:106460 HZ:136535 HZ:116610 HZ:366685 HZ:256760 HZ:356836 HZ:206911 HZ:296986 HZ:67061 HZ:177136 HZ:137211 HZ:197286 HZ:597361 HZ:527436 HZ:27512 HZ:177587 HZ:77662 HZ:127737 HZ:447812 HZ:427887 HZ:67962 HZ:68037 HZ:58113 HZ:88188 HZ:88263 HZ:208338 HZ:448413 HZ:298488 HZ:18563 HZ:38638 HZ:98714 HZ:448789 HZ:518864 HZ:188939 HZ:109014 HZ:149089 HZ:129164 HZ:89239 HZ:109315 HZ:319390 HZ:369465 HZ:179540 HZ:9`

I dont know how this number change to voltage

#### PieterP

#93
##### Jun 22, 2018, 03:23 pm
I dont know how this number change to voltage
No. I cannot keep on holding your hand like this. I already gave you the formulas you need, and the documentation of the FHT library tells you what the different functions do to the output, how to interpret it, and the mathematical formulas used to calculate these results.

#### Noisecontrol

#94
##### Jun 22, 2018, 06:58 pm
Why k value in above code is biger than 1024?
Code: [Select]
`fht_input[i] = k; // put real data into bins`

#### PieterP

#95
##### Jun 22, 2018, 07:05 pm
Write down mathematically what happens with k, then you know why.

#### Noisecontrol

#96
##### Jun 22, 2018, 08:44 pmLast Edit: Jun 22, 2018, 08:48 pm by Noisecontrol
Write down mathematically what happens with k, then you know why.
I wish to have good math
I have to leave this project after one month effort .it doesnt have any thrive

#### PieterP

#97
##### Jun 22, 2018, 08:47 pm
Whining about it won't help. Trying will.

#### Noisecontrol

#98
##### Jun 23, 2018, 04:22 amLast Edit: Jun 23, 2018, 01:30 pm by Noisecontrol
I think k is 16 bit thus range of it is 0 to 65536
Thus per 1 ADC  is equal voltage/65536
For example for 5 volt is equal 0.000076 volt
Is it true?

#### Noisecontrol

#99
##### Aug 05, 2018, 08:27 pmLast Edit: Aug 05, 2018, 08:29 pm by Noisecontrol
Hello
Finally make sound level meter after 4 month
It show dBA
Leq
Sone
Phone
Ta
NRR
O

Go Up