Test of pmic GPA with filter
Dependencies: mbed
Fork of nucf446-cuboid-balance1_strong by
Diff: GPA.cpp
- Revision:
- 23:26a1ccd0a856
- Parent:
- 22:715d351d0be7
- Child:
- 24:33ded7d7bcbd
--- a/GPA.cpp Mon Apr 09 14:48:55 2018 +0000 +++ b/GPA.cpp Mon Apr 09 15:09:54 2018 +0000 @@ -1,6 +1,6 @@ /* GPA: frequency point wise gain and phase analyser to measure the frequency - respone of dynamical system + respone of a dynamical system hint: the measurements should only be perfomed in closed loop assumption: the system is at the desired steady state of interest when @@ -22,38 +22,49 @@ fMax: maximal desired frequency that should be measured in Hz NfexcDes: number of logarithmic equaly spaced frequency points NperMin: minimal number of periods that are used for each frequency point - NmeasMin: maximal number of samples that are used for each frequency point + NmeasMin: minimal number of samples that are used for each frequency point Ts: sampling time Aexc0: excitation amplitude at fMin Aexc1: excitation amplitude at fMax hints: the amplitude drops with 1/fexc, if you're using - Axc1 = Aexc0/fMax the d/dt exc = const., this is recommended + Axc1 = Aexc0/fMax then d/dt exc = const., this is recommended if your controller does not have a rolloff. if a desired frequency point is not measured try to increase Nmeas. - pseudo code for a closed loop measurement with a proportional controller Kp: - - float inp = "measurement of inputsignal"; - float out = "mesurement of outputsignal"; - float exc = myGPA(inp, out); - float off = "desired steady state off the system"; + pseudo code for a closed loop measurement with a controller C: excitation input at (1): - inp = Kp*(exc + off - out); + + - measuring the plant P and the closed loop tf T = PC/(1 + PC): + desTorque = pi_w(omega_desired - omega + excWobble); + inpWobble = desTorque; + outWobble = omega; + excWobble = Wobble(excWobble, outWobble); + + - measuring the controller C and the closed loop tf SC = C/(1 + PC) + desTorque = pi_w(omega_desired - omega + excWobble); + inpWobble = n_soll + excWobble - omega; + outWobble = desTorque; + excWobble = Wobble(inpWobble, outWobble); excitation input at (2): - inp = Kp*(off - out) + exc; + + - measuring the plant P and the closed loop tf SP = P/(1 + PC): + desTorque = pi_w(omega_desired - omega) + excWobble; + inpWobble = desTorque; + outWobble = omega; + excWobble = Wobble(excWobble, outWobble); usage: - exc = myGPA(inp, out) does update the internal states of the gpa at the - timestep k and returns the excitation signal for the timestep k+1. the - results are plotted to a terminal (putty) over serial cennection and look - as follows: + exc(k+1) = myGPA(inp(k), out(k)) does update the internal states of the + gpa at the timestep k and returns the excitation signal for the timestep + k+1. the results are plotted to a terminal (putty) over a serial + connection and look as follows: ----------------------------------------------------------------------------------------- fexc[Hz] |Gyu| ang(Gyu) |Gye| ang(Gye) |E| |U| |Y| ----------------------------------------------------------------------------------------- - 7.01e-01 1.08e+01 -7.45e-02 1.08e+01 -7.38e-02 9.99e-01 9.99e-01 1.08e+01 + 1.000e+00 2.924e+01 -1.572e+00 1.017e+00 -4.983e-02 5.000e+00 1.739e-01 5.084e+00 in matlab you can use: dataNucleo = [... insert measurement data here ...]; @@ -190,7 +201,7 @@ printf(" fexc[Hz] |Gyu| ang(Gyu) |Gye| ang(Gye) |E| |U| |Y|\r\n"); printLine(); } - printf("%11.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e\r\n", fexc, absGyu, angGyu, absGye, angGye, Aexc, Umag, Ymag); + printf("%11.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e %10.3e\r\n", (float)fexc, absGyu, angGyu, absGye, angGye, (float)Aexc, Umag, Ymag); } else { jj += 1; }