Capstone project files

Dependencies:   mbed-dsp mbed capstone_display_2

Revision:
5:bc45ed158abf
Parent:
4:9ee3ae61db7f
Child:
6:8441a6864784
--- a/main.cpp	Tue Apr 15 20:27:43 2014 +0000
+++ b/main.cpp	Tue Apr 15 20:46:22 2014 +0000
@@ -208,8 +208,8 @@
 int main() {
     //arm_iir_lattice_instance_f32* filter1 = new arm_iir_lattice_instance_f32();
     arm_fir_instance_f32* filter = new arm_fir_instance_f32();
-    float* history;    
-    
+    float* history; //history of RMS voltages.
+    int index_h = 0;
     int state = 0; //which state of the state machine to be in, change to enum if desired
     
     uint16_t numTaps = NumTaps;
@@ -224,6 +224,12 @@
         {
         case 0: //initialization
             calibrate();
+            
+            for (int i = 0; i < NumTaps; i++)
+            {
+                pCoeffs[i] *= 1.3;
+            }
+            
             arm_fir_init_f32(filter, numTaps, pCoeffs, pState, blockSize);
             //arm_iir_lattice_init_f32(filter1, numTaps, pkCoeffs, pvCoeffs, pState, blockSize);
             //pc.printf("Pre-attachment");
@@ -235,7 +241,7 @@
             break;
             
         case 1: //read data, take samples
-            pc.printf("Reading data.\n\r");
+            //pc.printf("Reading data.\n\r");
             readSamples();
             state = 3;
             break;
@@ -268,26 +274,14 @@
             pc.printf("post filter RMS = %f\n\n\r", estimate);
             state = 1;
             adjustGains(estimate);
+            /*
+            array[index_h] = estimate;
+            index_h++;
+            */
+            
             break;
         case 7: //estimate amplitude using simple peak detection (consider discarding)
-            pc.printf("Into estimation\n\r");
-            int peaks = 0;
-            float sum = 0.0;
-            float prev, current, next;
-            for (int i = 0+1; i < BlockSize-1; i++)
-            {
-                prev = postFilterData[i-1];
-                current = postFilterData[i];
-                next = postFilterData[i+1];
-                if (prev < current && next < current) //local max
-                {
-                    sum += current;
-                    peaks++;
-                }
-            }
-            float average = sum/peaks;
-            pc.printf("Average of peaks (scalar) = %f\n\r", average);
-            state = 1;
+            
             break;
             
         case 8: //digital pot interfacing and calibration
@@ -342,3 +336,27 @@
                 pc.printf("Waveform contents:%f\n\r", waveform[i]);
             }
             */
+            
+            
+            
+            /*
+---------------peak detection
+            pc.printf("Into estimation\n\r");
+            int peaks = 0;
+            float sum = 0.0;
+            float prev, current, next;
+            for (int i = 0+1; i < BlockSize-1; i++)
+            {
+                prev = postFilterData[i-1];
+                current = postFilterData[i];
+                next = postFilterData[i+1];
+                if (prev < current && next < current) //local max
+                {
+                    sum += current;
+                    peaks++;
+                }
+            }
+            float average = sum/peaks;
+            pc.printf("Average of peaks (scalar) = %f\n\r", average);
+            state = 1;
+            //*/