# PWM speed control

I would like to create simulation of speed control of BLDC motor (something based on following scheme):

But I have a problem with understanding how to compute duty cycle in Controller block (that is PI controller based on many sources). From what I already know is that PI controller get on input difference between desired speed and actual speed and its output is treated as duty cycle but...how? Difference between desired and actual speed can be very large but based on following image:

reference signal should take values from 0 to 1, but if I take desired speed for example 600 rad/s and have actual value for example 300 rad/s then PI controller output will be much higher than 1. On following image is showed exemplary output from PI controller in closed-loop control system:

I would like then to know how to convert PI controller output into duty cycle of PWM signal.
I would also like to make sure that I correctly understand PWM control system. Commutation Logic block decide which switches in Three-Phase Inverter block are closed (current is flowing) or opened (current is not flowing). But if specified switches are actually closed or opened depends of PWM signal value (if PWM signal value is 1 then switches are closed and when PWM signal value is 0 then switches are opened).

Here, we have two PI controllers, where first is the one that takes as input difference between desired and actual speed, and second that takes as input difference between output from first PI divided by mechanical constant and Imax and thus I have several more quesions:

• is Imax maximal value from ia, ib, ic or sum of them or something else?
• several sources shows scheme where output of first PI controller (whose input is difference between desired and actual speed) isn't divided by mechanical constant. Should I divide output from first PI controller by mechanical constant or not?
• should pwm signal with duty cycle lower than 50% reverse direction of current in phases similarly to this movie (link to specified fragment) https://youtu.be/b5J5qkR7msc?t=482 ?
• "I would like then to know how to convert PI controller output into duty cycle of PWM signal.". Your Simulink screenshot already shows a block namedcontroller whose output is named duty cycle. Does it not output PWM ?
– AJN
Commented Sep 26, 2020 at 16:23

reference signal should take values from 0 to 1, but if I take desired speed for example 600 rad/s and have actual value for example 300 rad/s then PI controller output will be much higher than 1.

In a control system, the gains chosen has to be based on required dynamic response characteristics as well as the capability of the control-effector system. Here, your control-effector has a limitation of being able to accept input in range $$\[0,1]\$$. So for the largest error that you want the system to behave linearly (without saturation), your proportional (and integral) gains need to be small enough to naturally keep the PI output inside $$\[0,1]\$$. For error outside this range, you system will have non linear behaviour which will have to tolerated.

e.g. If the value of Proportional gain, P = 0.003 , then the output is (600-300)*0.003 = 0.9. It will be within the limits. Moreover, you can add logic at the output of the PI controller to limit the value to $$\[0,1]\$$ range. Simulink has a saturation block which can be used.

I would like then to know how to convert PI controller output into duty cycle of PWM signal.

Your Simulink screenshot already shows a block named controller whose output is named duty cycle. Does it not output PWM ? More info is need to answer this.

Commutation Logic block decide which switches in Three-Phase Inverter block are closed (current is flowing) or opened (current is not flowing). But if specified switches are actually closed or opened depends of PWM signal value (if PWM signal value is 1 then switches are closed and when PWM signal value is 0 then switches are opened).

Yes, both processes will interfere with each other if the switching frequency of the PWM and commutation are close. Keep one of the frequencies much higher than the other. The lower frequency signal will act an an enable or gating signal for the other process.

• Thank you for quick response. Idea to use ideal version of PI controller instead of parallel version is something I needed. Thanks for confirmation of information about PWM way of working. Image with scheme is taken from following movie: youtube.com/watch?v=b5J5qkR7msc Commented Sep 26, 2020 at 19:48
• @Zekhire Since you have added additional questions (and more details), consider opening a new question (with all the details). It will improve the chances of people seeing it and you getting an answer.
– AJN
Commented Sep 27, 2020 at 2:10
• Ok. Thanks for advice. Commented Sep 27, 2020 at 8:15