last working

Dependencies:   FastPWM3 mbed

Fork of foc-ed_in_the_bot_compact by Bayley Wang

Files at this revision

API Documentation at this revision

Comitter:
nki
Date:
Tue May 17 09:58:58 2016 +0000
Parent:
9:074575151e4b
Commit message:
Bayley tweaked- that night we took the altermoter apart;

Changed in this revision

config.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 074575151e4b -r 6829abb438fc config.h
--- a/config.h	Tue May 17 06:44:09 2016 +0000
+++ b/config.h	Tue May 17 09:58:58 2016 +0000
@@ -2,7 +2,7 @@
 #define __CONFIG_H
 
 #define CPR 4096
-#define POS_OFFSET 5.3f
+#define POS_OFFSET 1.73f
 #define POLE_PAIRS 3.0f
 #define RESOLVER_LOBES 3.0f
 
diff -r 074575151e4b -r 6829abb438fc main.cpp
--- a/main.cpp	Tue May 17 06:44:09 2016 +0000
+++ b/main.cpp	Tue May 17 09:58:58 2016 +0000
@@ -150,15 +150,15 @@
     float sin_p = sinf(p);
     float cos_p = cosf(p);
     
-    //float pos_dac = 0.85f * p / (2 * PI) + 0.05f;
-    //DAC->DHR12R2 = (unsigned int) (pos_dac * 4096);
+    float pos_dac = 0.85f * p / (2 * PI) + 0.05f;
+    DAC->DHR12R2 = (unsigned int) (pos_dac * 4096);
     
     ia = ((float) adval1 / 4096.0f * AVDD - I_OFFSET - ia_supp_offset) / I_SCALE;
     ib = ((float) adval2 / 4096.0f * AVDD - I_OFFSET - ib_supp_offset) / I_SCALE;
     ic = -ia - ib;
     
-    float u = ib;
-    float v = ic;
+    float u = ia;
+    float v = ib;
     
     alpha = u;
     beta = 1 / sqrtf(3.0f) * u + 2 / sqrtf(3.0f) * v;
@@ -185,7 +185,7 @@
     if (vq < -1.0f) vq = -1.0f;
     if (vq > 1.0f) vq = 1.0f;
     
-    DAC->DHR12R2 = (unsigned int) (-q * 20 + 2048);
+    //DAC->DHR12R2 = (unsigned int) (-q * 20 + 2048);
     //DAC->DHR12R2 = (unsigned int) (-vd * 2000 + 2048);
     
     //vd = 0.0f;
@@ -208,5 +208,7 @@
     startup_msg();
     
     for (;;) {
+        //pc.printf("%f\r\n", p);
+        //wait_ms(100);
     }
 }