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.
Dependencies: mbed
Diff: GPA.cpp
- Revision:
- 8:d68e177e2571
- Parent:
- 7:87b823282bf0
- Child:
- 10:a28f393c6716
--- a/GPA.cpp Sat Mar 17 08:43:07 2018 +0000 +++ b/GPA.cpp Thu Mar 22 17:32:37 2018 +0000 @@ -1,3 +1,73 @@ +/* + GPA: frequency point wise gain and phase analyser to measure the frequency + respone of dynamical system + + hint: the measurements should only be perfomed in closed loop + assumption: the system is at the desired steady state of interest when + the measurment starts + + exc(2) C: controller + | P: plant + v + exc(1) --> o ->| C |--->o------->| P |----------> out + ^ | | + | --> inp | exc: excitation signal (E) + | | inp: input plant (U) + -------------------------------- out: output plant (Y) + + instantiate option 1: + GPA(float fMin, float fMax, int NfexcDes, int NperMin, int NmeasMin, float Ts, float Aexc0, float Aexc1) + + fMin: minimal desired frequency that should be measured in Hz + 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 + 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 + 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"; + + excitation input at (1): + inp = Kp*(exc + off - out); + + excitation input at (2): + inp = Kp*(off - out) + exc; + + 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: + ----------------------------------------------------------------------------------------- + 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 + + in matlab you can use: + dataNucleo = [... insert measurement data here ...]; + g = frd(dataNucleo(:,2).*exp(1i*dataNucleo(:,3)), dataNucleo(:,1), Ts, 'Units', 'Hz'); + gcl = frd(dataNucleo(:,4).*exp(1i*dataNucleo(:,5)), dataNucleo(:,1), Ts, 'Units', 'Hz'); + + if you're evaluating more than one measurement which contain equal frequency points try: + dataNucleo = [dataNucleo1; dataNucleo2]; + [~, ind] = unique(dataNucleo(:,1),'stable'); + dataNucleo = dataNucleo(ind,:); + + autor: M.E. Peter +*/ + #include "GPA.h" #include "mbed.h" #include "math.h"