Jared Baxter / Mbed 2 deprecated Impedance_Fast_Circuitry_print_V_I

Dependencies:   mbed-dsp mbed

Fork of Impedance_Fast_Circuitry by Jared Baxter

Revision:
43:c593a8b9688f
Parent:
42:52a92a8d2cc7
Child:
44:41c262caf898
--- a/main.cpp	Fri Jan 30 07:22:00 2015 +0000
+++ b/main.cpp	Fri Jan 30 08:14:36 2015 +0000
@@ -11,7 +11,7 @@
 #include "AngleEncoder.h"
 #include "adc.h"
 #include "dma.h"
-#include "pdb.h"
+#include "pit.h"
 
 // Analog sampling
 #define MAX_FADC 6000000
@@ -23,6 +23,8 @@
 DigitalOut led_red(LED_RED);
 DigitalOut led_green(LED_GREEN);
 DigitalOut led_blue(LED_BLUE);
+DigitalOut test1(PTB19);
+DigitalOut test2(PTB18);
 
 AngleEncoder angle_encoder(PTD2, PTD3, PTD1, PTD0, 8, 0, 1000000); // mosi, miso, sclk, cs, bit_width, mode, hz
 DigitalIn AMT20_A(PTC0); // input for quadrature encoding from angle encoder
@@ -63,11 +65,18 @@
     dma.reset();
     adc_init(A1);
     adc_init(A2);
+    pit_init(pc);
     
     pc.printf("\r\n\r\n\r\n");
     
     while(1) {
+        
         rotary_count++;
+        if(rotary_count & 0x01) AMT20_A.mode(PullUp);
+        else AMT20_A.mode(PullDown);
+        if((rotary_count>>1) & 0x01) AMT20_B.mode(PullUp);
+        else AMT20_B.mode(PullDown);
+        
         if(pc.readable() > 0) {
             char temp = pc.getc();
             
@@ -78,13 +87,15 @@
                     adc_stop();
                     // then proceed to 's' to display the array
                 case 's':
-                    for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("% 1i: %f\t% 1i: %f\r\n",i,sample_array1[i]*3.3/65535,i,sample_array2[i]*3.3/65535);
+                    for(int i = 0; i < TOTAL_SAMPLES; i++) pc.printf("%i: %f\t %f\t %i%i\r\n",i,sample_array1[i]*3.3/65535,sample_array2[i]*3.3/65535, (angle_array[i]>>1)&0x01, angle_array[i]&0x01);
                     pc.printf("\r\n");
                     break;
                 case 'f':
-                    for(int i = 0; i < TOTAL_SAMPLES; i++) {sample_array1[i] = 0; sample_array2[i] = 0;}
+                    for(int i = 0; i < TOTAL_SAMPLES; i++) {sample_array1[i] = 0; sample_array2[i] = 0; angle_array[i] = 0;}
                     pc.printf("Arrays cleared\r\n");
                     break;
+                case 'r':
+                    pc.printf("Quadrature: %i%i \r\n", (HW_GPIO_PDIR_RD(HW_PORTC)>>1)&0x01, HW_GPIO_PDIR_RD(HW_PORTC)&0x01);
             }
         }
     }