Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Revision:
11:dccbaa9274c5
Child:
12:c35ad58f6620
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/callbacks.cpp	Sun Mar 08 08:37:38 2015 +0000
@@ -0,0 +1,40 @@
+#include "includes.h"
+#include "transforms.h"
+#include "filters.h"
+#include "context.h"
+#include "core.h"
+#include "meta.h"
+#include "sensors.h"
+
+void fast(Context *c) {
+    float alpha, beta, d, q, ref_d, ref_q, valpha, vbeta;
+    float I_b, I_c, angle;
+    I_b = c->motor->GetCurrentB();
+    I_c = c->motor->GetCurrentC();
+    angle = c->motor->GetPosition();
+    
+    Clarke(-(I_b + I_c), I_b, &alpha, &beta);
+    Parke(alpha, beta, angle, &d, &q);
+    
+    float d_filtered = c->filter_d->Update(d);
+    float q_filtered = c->filter_q->Update(d);
+
+    c->reference->GetReference(angle, c->user->throttle, &ref_d, &ref_q);
+    
+    float vd = c->pid_d->Update(ref_d, d_filtered);
+    float vq = c->pid_q->Update(ref_q, q_filtered);
+    
+    vd = 0.0f;
+    vq = c->user->throttle;
+    
+    InverseParke(vd, vq, angle, &valpha, &vbeta);
+    
+    c->modulator->Update(valpha, vbeta); 
+}
+
+void slow(Context *c) {
+    c->user->UpdateThrottle();
+}
+
+void debug(Context *c) {
+}
\ No newline at end of file