Why does differentiating PID feedback break the system?
8 views (last 30 days)
I have designed the following motor speed controller, which takes feedback of the motor's position from a rotary encoder, and differentes it to get the speed.
However, I realized that this not only makes the controller really inaccurate, it also makes the quality of the output dependant on the fundamental sample time of the model. Here are different speed outputs I get at various sample times when giving the controller a reference of 15000rpm (250rps) :
- 1/50000s (50KHz) :
- 1/500000s (500KHz) :
- 1/1000000s (1MHz) :
So the higher the sampling frequency, the closer to the reference the controller output settles. I have found that increasing the frequency to about 5MHz results in a pretty much a perfect output, but now the simulation takes forever to run.
Also for comparison, when I take the speed feedback directly as shown follows, it also results in a good output:
As far as I can tell, differentiating the position signal gives an accurate replica of the speed signal, so I am very confused as to why this is happening. Is there a solution to this that doesn't involve running this system at 5MHz? Any help on understanding or solving this problem would be appreciated!
Pemendra Kumar Pardhi on 1 May 2022
Hello Janith Wijekoon With increasing sampling time signal gose to nearly continues time mode which requires large memory. Moreover in discret time domain with less sampling frequency less no of samples point which has required less memory size. With large sampling frequency (i.e large memory size signals) shape will near fine signal with slow speed However less sampling frequency gives less sample data that's why reconstruction of signals will not be good. But run time of simulation model willl be fast due to less memory required.
Only one doubt why it gives different output speed. It is dibatable.
Dr Narayanaswamy P R Iyer on 1 May 2022
Hi: Instead of integrator at the output of convert to RPS module, use a multiplier block along with time block or time module and see how it goes.
Peter O on 2 May 2022
Numerical differentiation is a very tricky thing to get right for a lot of controls cases. The reason is because unless you have a constant derivative, there is no guarantee that . When they differ enough, the control action may not be acting on the correct change in the error signal. In practical systems, noise will further exacerbate the problem, so it is common to also incorporate an averaging step to the derivative to improve the error derivative at the cost of lag time. When implemented correctly, a good differential controller can reduce the time it takes to bring a signal back to the desired setpoint after a large excursion of the signal. But the relative timing of the loop and the signal dynamics are important.
As your example here shows, when the timestep is small, the change in signal is more likely to reflect the true system derivative (5 MHz -> 200 ns timestep on a signal with much slower dynamics is practically the instantaneous value), but as the timestep grows this is no longer the case. The derivative gain then acts on an "echo" or altered representation of the system state, which can push the control signal in the wrong direction, leading to oscillation, increased settling time, and/or instability.
More Answers in the Power Electronics Control