derp

Dependencies:   FastPWM3 mbed

Revision:
18:1215f085b60f
Parent:
16:46703e957b30
Child:
19:d537c79cc48f
diff -r 46703e957b30 -r 1215f085b60f main.cpp
--- a/main.cpp	Tue Apr 19 05:46:29 2016 +0000
+++ b/main.cpp	Tue Apr 19 08:36:16 2016 +0000
@@ -13,7 +13,7 @@
 
 #define PI 3.141593f
 #define CPR 4096
-#define POS_OFFSET 4.5f
+#define POS_OFFSET 5.5f//4.5f
 
 #define I_SCALE_RAW 25.0f //mv/A
 #define R_UP 12000.0f //ohms
@@ -33,7 +33,7 @@
 
 #define INTEGRAL_MAX 1.0f
 
-#define Q_REF_MAX (-100.0)
+#define Q_REF_MAX (100.0)
 
 FastPWM *a;
 FastPWM *b;
@@ -45,7 +45,7 @@
 Serial pc(USBTX, USBRX);
 
 int adval1, adval2;
-float ia, ib, ic, alpha, beta, q;
+float ia, ib, ic, alpha, beta, q, p;
 double vq = 0.0, q_integral = 0.0, last_q = 0.0;
 
 float throttle_scaler = 0.0f;
@@ -54,7 +54,7 @@
  
 extern "C" void TIM1_UP_TIM10_IRQHandler(void) {
     if (TIM1->SR & TIM_SR_UIF) {
-        float p = pos.GetElecPosition() - POS_OFFSET;
+        p = pos.GetElecPosition() - POS_OFFSET;
         if (p < 0) p += 2 * PI;
         
         //float pos_dac = 0.85f * p / (2 * PI) + 0.05f;
@@ -104,7 +104,7 @@
         if (vq > 1.0f) vq = 1.0f;
         
         //DAC->DHR12R2 = (unsigned int) (vq * 2000 + 2048);
-                    
+                
         *a = 0.5f + 0.5f * vq * sinf(p);
         *b = 0.5f + 0.5f * vq * sinf(p + 2 * PI / 3);
         *c = 0.5f + 0.5f * vq * sinf(p - 2 * PI / 3);
@@ -191,7 +191,7 @@
     pc.printf("%s\n\r", "THE DENTIST controller Rev. A");
     
     for (;;) {
-        pc.printf("%d %f\n\r", state, throttle_scaler);
-        wait_ms(100);
+        //pc.printf("%f\n\r", p);
+        //wait_ms(100);
     }
 }