stock mbed AnalogReads current loop closed and working
Fork of priustroller by
Diff: callbacks.cpp
- Revision:
- 36:11766b5da6ed
- Parent:
- 35:83cf9564bd0c
diff -r 83cf9564bd0c -r 11766b5da6ed callbacks.cpp --- a/callbacks.cpp Mon Mar 16 15:40:07 2015 +0000 +++ b/callbacks.cpp Thu Apr 16 04:08:47 2015 +0000 @@ -23,7 +23,7 @@ //The necessary changes were analytically determined by observing that a postive vd command corresponded to a reading of negative q axis torque //and that a positive vq command produced a reading of positive d axis torque. //This may be the final step in aligning the handedness of the reference and the output. - + c->reference->GetReference(angle, c->user->throttle, &ref_d, &ref_q); dbg_ref_d = ref_d; @@ -31,6 +31,19 @@ dbg_loop_d = vd = c->pid_d->Update(ref_d, d_filtered); dbg_loop_q = vq = c->pid_q->Update(ref_q, q_filtered); + /* + + 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; @@ -41,14 +54,16 @@ void slow(Context *c) { c->user->UpdateThrottle(); + //c->user->throttle = c->filter_th->Update(c->user->throttle); } void debug(Context *c) { - //c->serial->printf("%f %f %f %f %f %f\n\r", dbg_d_filtered, dbg_q_filtered, dbg_ref_d, dbg_ref_q, dbg_loop_d, dbg_loop_q); - //c->serial->printf("%f %f %f %f\n\r", dbg_d_filtered, dbg_q_filtered); + c->serial->printf("%f %f %f %f %f %f\n\r", dbg_d_filtered, dbg_q_filtered, dbg_ref_d, dbg_ref_q, dbg_loop_d, dbg_loop_q); + //c->serial->printf("%f\n\r", dbg_angle); + //c->serial->printf("%f\n\r", c->user->throttle); } void log(Context *c) { - //c->debugger->Write(0, dbg_d_filtered); + //c->debugger->Write(0, dbg_angle); //c->debugger->Write(1, dbg_q_filtered); } \ No newline at end of file