working-est copy with class-based code. still open loop

Dependencies:   mbed

Fork of analoghalls6 by N K

Revision:
3:0a2396597e0d
Child:
5:ee1e6c84c302
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/referencesynthesizers.cpp	Mon Mar 02 01:24:37 2015 +0000
@@ -0,0 +1,18 @@
+#include "includes.h"
+#include "meta.h"
+#include "lut.h"
+
+void SynchronousReferenceSynthesizer::GetReference(float angle, float *ref_d, float *ref_q) {
+    *ref_d = _max_phase_current * LutSin(angle);
+    *ref_q = 0.0f;
+}
+
+float ReferenceSynthesizer::LutSin(float theta) {
+    if (theta < 0.0f) theta += 360.0f;
+    if (theta >= 360.0f) theta -= 360.0f;
+    return sinetab[(int) theta];
+}
+
+float ReferenceSynthesizer::LutCos(float theta) {
+    return LutSin(90.0f - theta);
+}
\ No newline at end of file