Jared Baxter / Mbed 2 deprecated Impedance_Fast_Circuitry_print_V_I

Dependencies:   mbed-dsp mbed

Fork of Impedance_Fast_Circuitry by Jared Baxter

Files at this revision

API Documentation at this revision

Comitter:
baxterja
Date:
Fri Jun 22 17:57:22 2018 +0000
Parent:
85:f1be018aacac
Commit message:
Added time stamping, Also added capabilities to print complex voltage and current instead of Magnitude and phase if desired.

Changed in this revision

Jareds_DSP/filters_jared.cpp Show annotated file Show diff for this revision Revisions of this file
Jareds_DSP/print_data.cpp Show annotated file Show diff for this revision Revisions of this file
Jareds_DSP/print_data.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f1be018aacac -r 850351993d88 Jareds_DSP/filters_jared.cpp
--- a/Jareds_DSP/filters_jared.cpp	Wed Apr 25 16:21:11 2018 +0000
+++ b/Jareds_DSP/filters_jared.cpp	Fri Jun 22 17:57:22 2018 +0000
@@ -87,7 +87,8 @@
                         
                           double mag = 51000*sqrt((real_ip * real_ip + imag_ip * imag_ip)) / ((float) y_0_squared);
                           double phase = -atan2(_output_samples[1][j], _output_samples[0][j])+atan2(_output_samples[3][j], _output_samples[2][j]);
-                        set_print_buffer(mag,phase, print_identifier);
+                          set_print_buffer(mag,phase, print_identifier);
+                            //set_print_buffer_V_I(_output_samples[2][j],_output_samples[3][j],_output_samples[0][j],_output_samples[1][j], print_identifier);
                     }
                 }
                 else//if this isn't the last set of filters
diff -r f1be018aacac -r 850351993d88 Jareds_DSP/print_data.cpp
--- a/Jareds_DSP/print_data.cpp	Wed Apr 25 16:21:11 2018 +0000
+++ b/Jareds_DSP/print_data.cpp	Fri Jun 22 17:57:22 2018 +0000
@@ -33,15 +33,24 @@
     status_2 = 0;
 }
 void set_print_buffer(double mag,double phase, int print_identifier)
-{
-    
-    
+{ 
     if (printing_counter<printing_length)
     {
         printf("PRINT OVERLOAD\n\r");
     }
     
-    printing_length[print_identifier]=sprintf (print_buffer[print_identifier], "%d %E %f\n\r",print_identifier, mag, phase);
+    printing_length[print_identifier]=sprintf (print_buffer[print_identifier], "%d %.3E %.3f %.4f\n\r",print_identifier, mag, phase, timer.read());
+    //printing_counter[print_identifier] = 0;  
+}
+
+void set_print_buffer_V_I(double Vr,double Vi, double Ir, double Ii, int print_identifier)
+{ 
+    if (printing_counter<printing_length)
+    {
+        printf("PRINT OVERLOAD\n\r");
+    }
+    
+    printing_length[print_identifier]=sprintf (print_buffer[print_identifier], "%d %.3f %.3f %.3f %.3f %.4f\n\r",print_identifier, Vr, Vi, Ir, Ii, timer.read());
     //printing_counter[print_identifier] = 0;
     
 }
\ No newline at end of file
diff -r f1be018aacac -r 850351993d88 Jareds_DSP/print_data.h
--- a/Jareds_DSP/print_data.h	Wed Apr 25 16:21:11 2018 +0000
+++ b/Jareds_DSP/print_data.h	Fri Jun 22 17:57:22 2018 +0000
@@ -4,7 +4,10 @@
 #include "mbed.h"
 #include "stdio.h"
 
+extern Timer timer;
+
 void print_filter_data(Serial *pc,bool is_actively_printing);
 void set_print_buffer(double mag,double phase, int print_identifier);
+void set_print_buffer_V_I(double Vr,double Vi, double Ir, double Ii, int print_identifier);
 
 #endif
\ No newline at end of file
diff -r f1be018aacac -r 850351993d88 main.cpp
--- a/main.cpp	Wed Apr 25 16:21:11 2018 +0000
+++ b/main.cpp	Fri Jun 22 17:57:22 2018 +0000
@@ -49,6 +49,8 @@
 DigitalIn sw2(SW2);//Button 2 Currently not being used
 DigitalIn sw3(SW3);//Button 3 Currently not being used
 
+Timer timer;
+
 // defined in dma.cpp
 extern int len;
 extern uint16_t static_input_array0[];//ADC 0(swaps between a0 and a1.  Used to measure current)
@@ -183,7 +185,8 @@
     pdb_start();
     bool is_actively_printing = false;
     char read_in_character = 'a';
-    //while(print_buffer_count<PRINT_BUFFER_LENGTH) 
+    //while(print_buffer_count<PRINT_BUFFER_LENGTH)
+    timer.start();
     while(!GATHER_STATISTICS||print_buffer_count<PRINT_BUFFER_LENGTH)
     {
         if(pc.readable())//if the python code has sent any characters recently
@@ -192,11 +195,21 @@
             {
                 read_in_character = pc.getc();// read the keyboard input
                 if (read_in_character == 'R')//start printing
+                {
+                    timer.reset();
+                    //timer.start();
                     is_actively_printing = true;
+                }
                 else if (read_in_character == 'S')//Stop printing
+                {
+                    //timer.stop();
                     is_actively_printing = false;
+                }
                 else if (read_in_character == 'P')//return probe number
                     pc.printf("p%d",probe_number);
+                else if (read_in_character == 'I')//return probe number
+                    pc.printf("IMPEDANCE");
+                
             }
             
         }