Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of priustroller by
Revision 34:bfe180de813a, committed 2015-03-16
- Comitter:
- nki
- Date:
- Mon Mar 16 04:58:35 2015 +0000
- Parent:
- 33:e7b132029bae
- Child:
- 35:83cf9564bd0c
- Commit message:
- [WORKING] current loop closed, signs of (Iq, Id) and (Vq, Vd) aligned.
Changed in this revision
--- a/callbacks.cpp Mon Mar 16 03:09:48 2015 +0000
+++ b/callbacks.cpp Mon Mar 16 04:58:35 2015 +0000
@@ -17,8 +17,12 @@
Clarke(-(I_b + I_c), I_b, &alpha, &beta);
Parke(alpha, beta, angle, &d, &q);
- dbg_d_filtered = d_filtered = c->filter_d->Update(d);
- dbg_q_filtered = q_filtered = c->filter_q->Update(q);
+ dbg_d_filtered = d_filtered = c->filter_q->Update(q); //swapped
+ dbg_q_filtered = q_filtered = -c->filter_d->Update(d); //these and added a negative on this line.
+
+ //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);
@@ -27,15 +31,10 @@
dbg_loop_d = vd = c->pid_d->Update(ref_d, d_filtered);
dbg_loop_q = vq = c->pid_q->Update(ref_q, q_filtered);
- /*
- vd = 0.0f;
- vq = c->user->throttle;
- */
+ InverseParke(vd, vq, angle, &valpha, &vbeta);
- vd = 0.05f;
- vq = 0.95f;
-
- InverseParke(vd, vq, angle, &valpha, &vbeta);
+ dbg_valpha = valpha;
+ dbg_vbeta = vbeta;
c->modulator->Update(valpha, vbeta);
}
@@ -46,9 +45,10 @@
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);
}
void log(Context *c) {
- c->debugger->Write(0, dbg_d_filtered);
- c->debugger->Write(1, dbg_q_filtered);
+ //c->debugger->Write(0, dbg_loop_d);
+ //c->debugger->Write(1, dbg_loop_q);
}
\ No newline at end of file
--- a/includes.h Mon Mar 16 03:09:48 2015 +0000 +++ b/includes.h Mon Mar 16 04:58:35 2015 +0000 @@ -25,5 +25,7 @@ #define dbg_q_filtered debug_registers[11] #define dbg_ref_d debug_registers[12] #define dbg_ref_q debug_registers[13] +#define dbg_valpha debug_registers[14] +#define dbg_vbeta debug_registers[15] #endif \ No newline at end of file
--- a/main.cpp Mon Mar 16 03:09:48 2015 +0000
+++ b/main.cpp Mon Mar 16 04:58:35 2015 +0000
@@ -11,11 +11,11 @@
Context *context = new Context();
context->ConfigureOutputs(D6, D13, D3, D8);
context->ConfigureCurrentSensors(A1, A2, 0.01f, 0.7f);
- context->ConfigureIdPidController(0.01f, 0.8f, 0.0f, 2.0f, -2.0f);
- context->ConfigureIqPidController(0.01f, 0.8f, 0.0f, 2.0f, -2.0f);
+ context->ConfigureIdPidController(0.0f, 0.0f, 0.0f, 1.0f, -1.0f);
+ context->ConfigureIqPidController(0.001f, 0.0f, 0.0f, 1.0f, -1.0f);
context->ConfigureThrottle(A0, 0.8f, 3.0f);
context->ConfigurePositionSensor(A4, A5, 0.249f, 0.497f, 0.231f, 0.499f, 205.0f);
- context->ConfigureReference(5.0f);
+ context->ConfigureReference(5.0f); // max phase current
context->ConfigureDebugger(2, 1000);
context->AttachCallBack(&fast, 5000);
context->AttachCallBack(&slow, 10);
--- a/meta/referencesynthesizers.cpp Mon Mar 16 03:09:48 2015 +0000
+++ b/meta/referencesynthesizers.cpp Mon Mar 16 04:58:35 2015 +0000
@@ -5,7 +5,7 @@
#include "core.h"
void SynchronousReferenceSynthesizer::GetReference(float angle, float throttle, float *ref_d, float *ref_q) {
- *ref_d = 0.0f;
+ *ref_d = 0.00f;
*ref_q = _max_phase_current * throttle;
}
