I am currently modeling a complex system with numerous joints and motors (from sim mechanics) and I ran into an issue while trying to discretize the system. To start, I modeled my PID controllers as continuos (I have 12 of them). I now wish to turn them into discrete-time PIDs.
However, when I switch the PID's to discrete, the simulation that used to take a couple of minutes to run now takes hours. Furthermore, as the simulation goes on, it only gets slower. When I switched the PID's back to continous, the simulation ran in minutes as it did before. I even tried to switch only one of the 12 PID controllers into discrete to see what effect it would have and the same thing ended up happening - the simulation would take hours. I tried this with two different solver types (ode15s and ode23t) and tried to reduce the solver's relative tolerance from 1e-3 to 1e-2 but it did not help.
Initially I used a PID sample time of 0.001 but this ran way too slow so i switched it to 0.01 and it started running faster but the simulation would still take hours.
Is there a reason why this is happening? And is there a way to get around this?