N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
Diff: callbacks.cpp
- Revision:
- 38:232c51b6853f
- Parent:
- 37:09373294ff22
- Child:
- 39:6f3d08745cd9
--- a/callbacks.cpp Thu Apr 16 07:12:36 2015 +0000 +++ b/callbacks.cpp Thu Apr 16 21:57:38 2015 +0000 @@ -32,29 +32,41 @@ dbg_loop_q = vq = c->pid_q->Update(ref_q, q_filtered); dbg_loop_d = vd = 0.0f; - dbg_loop_q = vq = c->user->throttle; + dbg_loop_q = vq = c->user->throttle / 2.0f; + /* - if(c->user->throttle <= 0.1f){ float ramp = (c->user->throttle*10.0f)*(c->user->throttle*10.0f); vd = ramp*vd; vq = ramp*vq; - } - - */ + } dbg_loop_d = vd; dbg_loop_q = vq; + */ InverseParke(vd, vq, angle, &valpha, &vbeta); dbg_valpha = valpha; dbg_vbeta = vbeta; - dbg_dtc_b = ((-valpha + sqrt(3.0f) * vbeta) / 2.0f); c->modulator->Update(valpha, vbeta); } +void fast_test(Context *c) { + float angle, angle120, angle240; + angle = c->motor->GetPosition(); + angle120 = angle + 120.0f; + if (angle120 >= 360.0f) angle120 -= 360.0f; + if (angle120 < 0.0f) angle120 += 360.0f; + angle240 = angle -120.0f; + if (angle120 >= 360.0f) angle240 -= 360.0f; + if (angle120 < 0.0f) angle240 += 360.0f; + c->inverter->SetDtcA(0.5f + 0.5f * FastSin(angle)); + c->inverter->SetDtcB(0.5f + 0.5f * FastSin(angle120)); + c->inverter->SetDtcC(0.5f + 0.5f * FastSin(angle240)); +} + void slow(Context *c) { c->user->UpdateThrottle(); //c->user->throttle = c->filter_th->Update(c->user->throttle); @@ -68,6 +80,7 @@ void log(Context *c) { //c->debugger->Write(0, dbg_dtc_b); + //c->debugger->Write(1, dbg_q_filtered); //c->debugger->Write(1, dbg_dtc_b); //c->debugger->Write(2, dbg_dtc_c); } \ No newline at end of file