I am using the PID example giving in buck converter current mode control. First, I could not find where it is found in the library so I used the example given in the models.
secondly, whenever I put the calculation delay in the Digital C-Script-based PI to 0 value, my system crashes and shows errors, anyone can clarify what is it about?
The PI controller is not in the library, but you can use the one from the example in your models.
Setting the calculation delay to zero is not a valid input for the C-Script based PI-Contreller. However you may put in a very small value to make it’s effect negligible.
Understanding the C-Script requires deeper knowledge of the PLECS system and using it is not recommended for the beginner. The C-Script chapter in the documentation is a good read and also gives some examples.
I have another question related to PID which is stupid but I have to ask it because I am cunfused all the time about it. in the example given of C-Script based PI-Contreller.
I am not sure what I actually should insert in the Kp and Ki variable, is it
If you open the Controller block, you can have a look at the implementation (Ctrl+U) of the digital as well as the analog controller. The digital version is implemented using a C-Script block and the analog one uses gain blocks and a continuous time integrator. Both versions are implemented in the known parallel controller structure (as opposed to serial).
I would suggest you use the analog version if you don’t have experience in discrete time domain modelling. The PI-element can be expressed as a n inverted zero in the s-domain. R. W. Erickson has some good lecture notes on bode plots, google it.
G(s) = k_r * (1 + w_c / s)
When packing the Analog PI version of the controller into an equation, we get
G(s) = k_p + k_i / s.
Using coefficient comparison you, can determine the values for k_p and k_i:
k_r + k_r * w_c / s = k_p + k_i / s
->> k_p = k_r
->> k_i = k_r * w_c
For the digital version, there is more stuff involved.