Ura

Dependencies:   CMSIS_DSP_401 mbed

Revision:
8:027ed43684af
Parent:
7:a4cff60f035b
Child:
9:748d94f021f6
--- a/main.cpp	Tue Nov 25 17:04:32 2014 +0000
+++ b/main.cpp	Thu Nov 27 16:24:23 2014 +0000
@@ -24,7 +24,7 @@
 
 int flag = 0;
  
-int SAMPLE_RATE_HZ = 40000;             // Sample rate of the audio in hertz.
+const int SAMPLE_RATE_HZ = 40000;             // Sample rate of the audio in hertz.
 const int FFT_SIZE = 16;                // Size of the FFT.
  
 const static arm_cfft_instance_f32 *S1;
@@ -41,7 +41,12 @@
 float magnitudes3[FFT_SIZE];
 int sampleCounter = 0;
 
- 
+const int SAMPLE_QUANTITY = 1000000/(16*(1000000/SAMPLE_RATE_HZ));
+
+float magnitudes_per_second[SAMPLE_QUANTITY];
+int index_of_magnitudes[SAMPLE_QUANTITY];
+int index_of_samples;
+             
 void samplingCallback()
 {    
     // Read from the ADC and store the sample data
@@ -140,9 +145,6 @@
     samplingBegin();
  
     while(1)
-
-
-        
         // Calculate FFT if a full sample is available.
         if (samplingIsDone())
         {            
@@ -162,6 +164,8 @@
             arm_max_f32(magnitudes2, FFT_SIZE, &maxValue2, &testIndex2);
             arm_max_f32(magnitudes3, FFT_SIZE, &maxValue3, &testIndex3);
             
+
+            
                 {
        if (HAL_GetTick() > (cnt1 + 1000))
         {
@@ -198,6 +202,9 @@
                 delta_t = (testIndex - testIndex2)*0.000025;
             double fi = asin(330*delta_t/0.33);
 
+
+magnitudes_per_second[index_of_samples]=maxValue;
+index_of_magnitudes[testIndex]=testIndex;
             
        if (HAL_GetTick() > (cnt1 + 1000))
         {
@@ -207,6 +214,7 @@
                 pc.printf("     MAX value at magnitudes 2[%d] : %+8.2f\r\n", testIndex2, maxValue2);
                 pc.printf("     MAX value at magnitudes 3[%d] : %+8.2f\r\n", testIndex2, maxValue3);
                 pc.printf("     Angle is  : %+8.2f\r\n", fi);
+                index_of_samples = 0;
                 flag++;
                 }
             else if (flag==1){
@@ -218,6 +226,8 @@
                 flag=0;
                 }
         }
+        else
+        index_of_samples++;
 
 
             samplingBegin();