I started learning control systems and I have a question about system identification. Let's say I want to identify DC motor. I want to control speed using a PID controller. I can model my system based on physics equations and then compare to my real system. I measure my speed periodically in discrete time (microcontroller). Should I compare my real system with the model in continuous time and then transfer it into discrete model with my sampling frequency and design discrete controller? Or how can I identify a discrete system? Thank you.
The most typical method is to identify the process transfer function in the continuous domain, in your case using the physics equation.
Then, you can design a continuous controller, such a PID controller. Once your controller is designed, discretize the controller to implement it.
You could also discretize the process transfer function and design the controller directly in the z-domain. In my experience it is less intuitive to perform the design this way.
Many options are here available, some are very complex and so the controller could be. The simple and minimal way is to make a PID controller then do Ziegler-Nichols method to tune the PID.
However your control loop may be spitted into many cascaded loops, then you have to tune each separately. High tech identification algorithms would involve an injection of a known signal pattern (PRBS) and then compute parameters offline with a Matlab identification toolbox, or similar approach.
For your DC motor, the first loop would be a current loop, which consists of PI controller whose parameters could be analytically computed from motor inductance and resistance.