The System Identification Toolbox app is indeed the solution, but I can understand the amount of choices and options make it rather confusing at first. Especially if you have no prior knowledge to model identification. If you are going to use a PID controller, I simply suggest you perform a frequency identification on the system (as this estimates a transfer function of your model). In the essential, this is done using the following steps:
- Create a suitable input. a suitable input is an input signal that persistently excites the systems dynamics. A good example: Pure white noise. This excites every frequency equally and thus excites every dynamic in the system. Poor example: a sinusoid, this only excites one specific frequency, and therefore just one specific dynamic behaviour. In general, if you take the FFT of the input signal, the estimation's accuracy at a certain frequency is highly influenced by the magnitude of the input signal at this frequency.
One can create a suitable input signal in MATLAB using
idinput.mat function, with preferably the PRBS or RBS options.
- Use this input signal to measure the system in open loop (assuming the system is open loop stable) closed-loop identification is also possible, but requires a bit more insight, and really only required if it is unsure the open loop system will run into physical limits or is unstable.
- Use the measured data and the input signal (remember to store both) to create an estimate of the system. From these vectors, create an
iddata object using the function baring the same name. With this object, you can identify the model using the
etfe.m function. I'd suggest looking up their references to find out what kind of optional tuning parameters are possible.
And... well thats it! But I must note there are plenty of optional parameters that can be tuned to improve the identification, but I leave those for now to prevent unwanted confusion. I do have one note about identification: The highest frequency you can identify is equal to the nyquist frequency of the controller. This is half the sampling frequency of your system. The lowest frequency you can identify is roughly 1/Measurement length. Additionally, longer measurement result in more frequency points, thus higher estimation accuracy (this is specifically important for resonance peaks). Most algorithms work such that if the measurement length is increased to infinity, the true model can be extracted. Lastly some pages worth looking into:
I thought about setting the gains to 0 initially and evaluate the system just with Feed-forward control and then examine the new gains from the Feed-forward data
Uhm, usually one tweaks the Feedforward parameters using the residual of the error for a certain reference. if you set your PID gains to 0, the loop is not closed and therefore the error you create is practically worthless. Additionally, the goal of feedforward is to polish the error to optimize reference tracking, but most of the work (such as approaching the reference initially) must be done by a feedback controller. As such, I advice to first tune a nice feedback controller (PID for instance) and use that to tune Feedforward.
If you have any further questions, or struggle with obtaining the results, feel free to ask further and if possible share some data (like bode plots) to improve my answers.