working-est copy with class-based code. still open loop
Fork of analoghalls6 by
Diff: loopdriver.cpp
- Revision:
- 10:b4abecccec7a
- Parent:
- 9:d3b70c15baa9
diff -r d3b70c15baa9 -r b4abecccec7a loopdriver.cpp --- a/loopdriver.cpp Fri Mar 06 19:12:53 2015 +0000 +++ b/loopdriver.cpp Sun Mar 08 00:45:28 2015 +0000 @@ -89,28 +89,28 @@ d_mean = 0.01f*d + 0.99f*d_mean; q_mean = 0.01f*q + 0.99f*q_mean; - _reference->GetReference(_motor->angle, &ref_d, &ref_q); //this just returns d = 0 and q = 1 right now. doesn't care about angle + _reference->GetReference(_motor->angle, _user->throttle, &ref_d, &ref_q); //this just returns d = 0 and q = 1 right now. doesn't care about angle float vd = _pid_d->Update(ref_d, d_mean); float vq = _pid_q->Update(ref_q, q_mean); - test_alpha = vd; - test_beta = vq; + vd = 0.0f; + vq = _user->throttle; - /* - //overriding PI controller here because we're not actually doing current control yet - //These values are approximately what I saw coming out of the park transform. just feeding them back in here to test the loop - vd = 0.0f; - vq = -1.0f; - */ InverseParke(vd, vq, _motor->angle, &valpha, &vbeta); - + + if(acquire==1){ + if(bufidx < bufsize){ + fbuffer[bufidx] = _motor->angle; + } + else{ + acquire = 0; + } + } _modulator->Update(valpha, vbeta); /* - _inverter->SetDtcA((LutSin(_motor->angle)/2.0f)+0.5f); - _inverter->SetDtcB((LutSin(_motor->angle - 120.0f)/2.0f)+0.5f); - _inverter->SetDtcC((LutSin(_motor->angle + 120.0f)/2.0f)+0.5f); - */ - + test_alpha = valpha; + test_beta = vbeta; + */ }