DC motor speed control


Introduction

In this experiment, a mathematical model of a permanent-magnet DC motor will be simulated using the parameters estimated in the previous experiment. It will be shown that the motor speed cannot be held constant under varying load and voltage conditions. To overcome this, a closed-loop system will be developed using a PI controller so that the output speed closely matches the desired speed under various load conditions. Finally, the designed system will be run in real time to control the actual DC motor at a constant speed.

Theoretical background

Motor model

The DC motor model characterized in the previous experiment is summarized in transfer-function form in Eqns. 1 through 4:

\[I_{a} = \frac{V_{a} - E_{a}}{sL_{a} + R_{a}}\tag{1}\]
\[T_{\mathrm{em}} = k_{t}I_{a}\tag{2}\]
\[\omega _{m} = \frac{T_{\mathrm{em}} - T_{l} - T_{c}}{sJ + B}\tag{3}\]
\[E_{a} = k_{e}\omega _{m}\tag{4}\]

where

  1. Va : terminal voltage

  2. Ea : back-emf

  3. Ia : armature current

  4. Ra : armature resistance

  5. La : armature inductance

  6. ke : back-emf constant

  7. kt : torque constant

  8. J : rotor inertia

  9. B : coefficient of viscous friction

  10. Tc : torque due to Coulomb friction

  11. Tem : output/electromagnetic torque

  12. Tl : load torque

  13. ωm : rotor speed

Depending on the application, the motor's output torque, speed, or position may need to be controlled. In the following section, a PI controller is designed to control the motor's output torque by controlling the applied terminal voltage.

Controller design

Consider a scenario in which the motor's output, or electromagnetic, torque must be controlled. Eqn. 2 shows that this can be achieved directly by controlling the motor armature current. This is accomplished using a proportional-integral (PI) controller whose transfer function is given in Eqn. 5, where ki,p and ki,i are the proportional and integral gains, respectively. The input to this controller, Ei, is the current error: the difference between the desired armature current Iref and the actual armature current Ia, as shown in Eqn. 6. The output of this controller is the armature voltage that must be applied to obtain the desired armature current and, in turn, the desired motor output torque.

\[PI(s) = \frac{V_{a}(s)}{E_{i}(s)} = k_{i,p} + \frac{k_{i,i}}{s}\tag{5}\]
\[E_{i}(s) = I_{\mathrm{ref}}(s) - I_{a}(s)\tag{6}\]

The current-control system is summarized below, where M(s) is the actual motor model:

Current controlled DC motor model

For a small change in the PI controller's error signal, the corresponding change in current, obtained from Eqns. 1, 5, and 6, is given below:

\[\Delta V_{a}(s) = \left(k_{i,p} + \frac{k_{i,i}}{s}\right) \times \Delta E_{i}(s)\tag{7}\]
\[\Delta I_{a}(s) = \frac{\Delta V_{a}(s)}{sL_{a} + R_{a}}\tag{8}\]

The back-emf term has been ignored in the small-signal model above because, when Va changes, Ia changes much faster than Ea. This is because the mechanical time constant of the motor, given by J/B, is much larger than the electrical time constant, given by La/Ra. Since the back-emf is proportional to the rotor speed, it responds more slowly than the armature current to a step change in the applied voltage and can therefore be ignored in the equation above. The overall small-signal model is obtained by combining the two equations above.

\[\frac{\Delta I_{a}(s)}{\Delta E_{i}(s)} = \frac{k_{i,p}s + k_{i,i}}{s} \times \frac{1}{L_{a}s + R_{a}}\tag{9}\]

The ki,p and ki,i gain values are adjusted to obtain the desired transient response. There are multiple ways to quantify the desired response. In the time domain, the desired rise time and overshoot for a step input are usually specified, and the gains are adjusted to satisfy these requirements. Alternatively, in the frequency domain, the desired phase margin and crossover frequency are specified. We will use the latter approach because it provides a better picture of system stability. The steady-state response of the system is obtained by substituting s = jω into Eqn. 9.

\[\frac{\Delta I_{a}(j\omega )}{\Delta E_{i}(j\omega )} = G(j\omega ) = \frac{j\omega k_{i,p} + k_{i,i}}{j\omega } \times \frac{1}{j\omega L_{a} + R_{a}}\tag{10}\]

The system above is tuned for a desired phase margin of Φi at the crossover frequency ωi,c as follows. At the crossover frequency, the system gain equals 1, and the system phase shift equals -π + Φi. Substituting this into Eqn. 10:

\[\angle G(j\omega _{i,c}) = -\pi + \Phi _{i} = -\frac{\pi }{2} + \tan^{-1}\left(\frac{\omega _{i,c}k_{i,p}}{k_{i,i}}\right) - \tan^{-1}\left(\frac{\omega _{i,c}L_{a}}{R_{a}}\right)\]
\[\Rightarrow \frac{\omega _{i,c}k_{i,p}}{k_{i,i}} = \tan\left(\Phi _{i} - \frac{\pi }{2} + \tan^{-1}\left(\frac{\omega _{i,c}L_{a}}{R_{a}}\right)\right)\]
\[\Rightarrow k_{i,p} = \frac{k_{i,i}}{\omega _{i,c}} \times \tan\left(\Phi _{i} - \frac{\pi }{2} + \tan^{-1}\left(\frac{\omega _{i,c}L_{a}}{R_{a}}\right)\right) = C1 \times k_{i,i}\tag{11}\]

where

\[C1 = \frac{1}{\omega _{i,c}} \times \tan\left(\Phi _{i} - \frac{\pi }{2} + \tan^{-1}\left(\frac{\omega _{i,c}L_{a}}{R_{a}}\right)\right)\tag{12}\]

and

\[|G(j\omega _{i,c})| = 1 = |\frac{j\omega _{i,c}k_{i,p} + k_{i,i}}{j\omega _{i,c}} \times \frac{1}{j\omega _{i,c}L_{a} + R_{a}}|\]
\[\Rightarrow (\omega _{i,c}k_{i,p})^{2} + k^{2}_{i,i} = \omega ^{2}_{i,c}((\omega _{i,c}L_{a})^{2} + R^{2}_{a})\]
\[\Rightarrow k_{i,i}= \omega _{i,c}\sqrt{\frac{(\omega _{i,c}L_{a})^{2} + R^{2}_{a}}{(\omega _{i,c} \times C1)^{2} + 1}}\tag{13}\]

Given the desired Φi and ωi,c and the motor parameters, the PI gains can be solved using Eqns. 11 through 13.

The controller above maintains the motor at the desired current and, in turn, the desired motor torque while other system inputs vary. To achieve speed control rather than torque control, the system is modified by adding an outer speed PI controller to the existing inner current PI controller, as shown below:

Speed controlled DC motor model

Here, M(s) is the actual motor model, and I(s) is the current-controlled system model, which includes the current PI controller and the motor's armature-current model.

To control the motor's speed rather than its torque, the same procedure can be followed with the following simplifying assumption: the response time of the motor current is an order of magnitude shorter than that of the motor speed for a step change in the applied voltage. This is achieved by setting the crossover frequency—which is also the system bandwidth in this case—of the current-loop PI controller an order of magnitude higher than that of the speed-loop PI controller. Thus, for a step change in the applied voltage, the current reaches its final steady state much earlier than the motor speed. Therefore, when tuning the speed controller, I(s) in the figure above can be assumed to be 1. The simplified speed controller model is shown below:

Simplified speed-control model in which the inner current-loop transfer function equals 1.

Let Es = ωref - ωm be the speed error. With the inner current loop approximated as unity, the open-loop transfer function from a small change in speed error to the resulting change in motor speed is:

\[\frac{\Delta \omega _{m}(s)}{\Delta E_{s}(s)} = \frac{k_{s,p}s + k_{s,i}}{s} \times \frac{k_{t}}{Js + B}\tag{14}\]

The system above is similar to the current controller designed earlier. Following the same procedure gives the speed controller's gains:

\[k_{s,p} = C2 \times k_{s,i}\tag{15}\]

where

\[C2 = \frac{1}{\omega _{s,c}} \times \tan\left(\Phi _{s} - \frac{\pi }{2} + \tan^{-1}\left(\frac{\omega _{s,c}J}{B}\right)\right)\tag{16}\]

and

\[k_{s,i}= \frac{\omega _{s,c}}{k_{t}}\sqrt{\frac{(\omega _{s,c}J)^{2} + B^{2}}{(\omega _{s,c} \times C2)^{2} + 1}}\tag{17}\]

where ks,p and ks,i are the speed PI controller's proportional and integral gains.

Simulation of DC motor speed control

The above speed control model is simulated using Workbench in this section.

please noteNote

Save the model at frequent steps.

Open-loop motor model

  1. Create a new project and add a new model file to the project.

  2. Set this model file as Start model/Function in the project properties.

  3. Open the model properties and set Step time to 1E-4.

  4. Drag and drop a subsystem tool from the Signal Routing tool class in the Toolbox.

  5. A subsystem is an enclosure within which more tools can be added. Double-click the subsystem to open it.

  6. Drag and drop the following tools from the Toolbox to the subsystem model and connect them as shown.

    # Tool type Tool class Tool name
    1 In-port Signal Routing I
    2 Adder Subtractor Math Block Add
    3 Transfer Function Continuous TransferFnc
    4 Out-port Signal Routing O
    5 Gain Math Block Gain
    6 In-port Signal Routing I1
    7 Adder Subtractor Math Block Add1
    8 Transfer Function Continuous TransferFnc1
    9 Gain Math Block Gain1
    10 Out-port Signal Routing O1

    DC motor model in Workbench

  7. Change the properties of each tool to the values listed in the table below. The reason for each value is given in the rightmost column.

    Tool name Property field Property value Comments
    I Name Va Motor applied terminal voltage Va
    Add Arithmetic operation +- Computes Va - Ea in Eqn. 1
    TransferFnc Numerator {1} Numerator of transfer function in Eqn. 1 which is equal to 1.
    TransferFnc Denominator {La, Ra} Denominator of the transfer function in Eqn. 1. Substitute the values for La and Ra obtained from the previous experiment. The output of this tool is the motor current.
    O Name Ia This is the motor current.
    Gain Gain kt Substitute the value of kt = ke obtained from the previous experiment. The output of this tool is Tem, as given by Eqn. 2.
    I1 Name Tl Load torque
    Add1 Arithmetic operation -+ The differential torque in Eqn. 3 is the output of this tool, which computes Tem - Tl. For this model, Tc is ignored, but it may also be subtracted if desired.
    TransferFnc1 Numerator {1} Numerator of transfer function in Eqn. 3 which is equal to 1.
    TransferFnc Denominator {J, B} Denominator of the transfer function in Eqn. 3. Substitute the values for J and B obtained from the previous experiment. The output of this tool is the motor speed.
    Gain1 Gain ke The motor speed is scaled by ke to obtain back-emf Ea. This is looped back to Add to get the voltage difference.
    O1 Name wm This is the motor speed ωm.

  8. Return to the main motor model by clicking its tab at the top.

  9. Resize the subsystem so that all the ports can be seen. A tool can be resized by clicking and dragging any of the four squares in the tool's corner.

  10. To observe the motor speed and current when a voltage and load are applied to the motor, add the following tools to the main model and connect them as shown.

    # Tool type Tool class Tool name
    1 Step Signal Sources Step
    2 Step Signal Sources Step1
    3 Mag-time Scope Display Scope
    4 Mag-time Scope Display Scope1

    DC motor model in Workbench

  11. Change the properties of each tool to the values listed in the table below.

    Tool name Property field Property value Comments
    Step Final value 10 Start at 0 V and step the applied voltage to 10 V
    Step Step time 1 Step the voltage at time t = 1 s
    Step1 Final value 0.05 Start at 0 Nm and step the load torque to 0.05 Nm
    Step1 Step time 7 Step the load at time t = 7 s

  12. Run the simulation model and observe the current and speed results in the scopes. As shown, the current and speed both change when either the applied voltage or the load torque is varied. In the following steps, the PI controller designed earlier is added to control the motor current and speed profiles.

Motor current control

In this section, the current through the motor is controlled using a PI controller.

  1. Compute ki,p and ki,i using Eqns. 11 through 13 (first compute C1 using Eqn. 12, then ki,i using Eqn. 13, and finally ki,p using Eqn. 11) so that the system has a phase margin of Φi = π/3 at the crossover frequency ωi,c = 2π x 200. The crossover frequency is chosen as 200 Hz, which is sufficiently below the switching frequency of 6 kHz. This prevents the current controller from trying to compensate for the switching-current harmonics.

  2. Delete the Step tool connected to the Va port of the motor model.

  3. Add another subsystem to the model, in which the PI controller will be modeled. Double-click the subsystem to open it.

  4. Drag and drop the following tools from the Toolbox to the subsystem model and connect them as shown.

    # Tool type Tool class Tool name
    1 In-port Signal Routing I
    2 In-port Signal Routing I1
    3 Adder Subtractor Math Block Add
    4 Gain Math Block Gain
    5 Gain Math Block Gain1
    6 Integrator Math Block Integrator
    7 Adder Subtractor Math Block Add1
    8 Saturation Non-linear Saturation
    9 Out-port Signal Routing O

    DC motor PI current controller

  5. Change the properties of each tool to the values listed in the table below.

    Tool name Property field Property value Comments
    I Name Ref Desired reference motor current.
    I1 Name Fbk Actual motor current.
    Add Arithmetic operation +- Difference between the desired and actual motor current.
    Gain Gain ki,p Substitute the value of ki,p computed in step 1.
    Gain1 Gain ki,i Substitute the value of ki,i computed in step 1.
    Integrator Integrator Type Anti-windup Reason explained later.
    Integrator Upper Limit 38 Set to the maximum positive output voltage. This is equal to the DC bus voltage minus the device drop (≈ 1.5 V).
    Integrator Lower Limit -38 Set to the minimum negative output voltage. This is the negative of the DC bus voltage minus the device drop (≈ 1.5 V).
    Saturation Upper Limit 38 Set to the maximum positive output voltage. This is equal to the DC bus voltage minus the device drop (≈ 1.5 V).
    Saturation Lower Limit -38 Set to the minimum negative output voltage. This is the negative of the DC bus voltage minus the device drop (≈ 1.5 V).
    O Name Out Applied terminal voltage to generate the desired current profile.

    When there is a large difference between the desired and actual currents, the PI controller produces a large output voltage to correct the error quickly. In a real-world system, the magnitude of this voltage is limited by either the available DC bus voltage or the voltage ratings of the motor and power electronics. Hence, in a practical implementation of a PI controller, the controller output is limited to the maximum possible voltage. During transient conditions, when the actual current differs from the desired current, the integrator in the PI controller rapidly builds its output to a large value because of the persistent input error. When the error returns to zero, this large integrator output does not decrease immediately and causes the actual current to overshoot the desired value. The resulting negative error causes the integrator output to fall, but it can fall by a much larger amount than desired, causing the current to undershoot. This process repeats, and the resulting oscillation dies down slowly. To avoid this, the range over which the integrator is active is clamped by setting it to Anti-windup. If the integrator output reaches this limit, the integrator is disabled until the polarity of the error reverses. This significantly improves the system response.

  6. Return to the main motor model by clicking its tab at the top.

  7. Resize the PI controller subsystem so that all the ports are visible.

  8. Add a Step tool and connect the model as shown. Step the current to 1 A at t = 1 s by setting Final value to 1 and Step time to 1.

    DC motor closed loop current control

  9. Run the simulation and observe the motor-current and speed results. In the current scope, zoom in at t = 1 s to view the step response. As shown, the current settles to the final value within a few milliseconds, whereas the speed takes a few seconds to settle to its final value. This justifies the earlier assumption in Eqn. 8, where the back-emf was ignored in the small-signal model because it changes much more slowly than the current. In most practical motors, the mechanical time constant is orders of magnitude higher than the electrical time constant.

  10. Recompute ki,p and ki,i for Φi = π/6 and Φi = π/2, and obtain the current and speed responses for the computed gain values.

Motor speed control

In this section, the speed of the motor is controlled using a PI controller.

  1. Compute ks,p and ks,i using Eqns. 14 through 17 so that the system has a phase margin of Φs = π/3 at the crossover frequency ωs,c = ωi,c/10 = 2π x 20. The crossover frequency is chosen as 20 Hz, which is one tenth of the crossover frequency of the inner current loop.

  2. Remove the connection between the Step tool and the current PI controller subsystem.

  3. Copy and paste (Ctrl + C, Ctrl + V) the current PI controller subsystem, as shown, to add a speed PI controller. Connect the tools as shown.

    DC motor closed loop speed control

    The reference input to this pasted PI controller is the desired motor speed and the feedback is the actual motor speed.

  4. The reference speed is stepped to 100 rad/s at t = 1 s. To do this, change the Final value of the Step tool connected to the speed PI controller to 100 and Step time to 1.

  5. Change the PI controller gain values in the pasted subsystem to the values computed in step #1.

  6. Run the simulation and observe the speed. As shown, the speed settles rapidly to the desired speed compared with the open-loop system. The speed is also maintained when the load torque is applied. Contrast this with the open-loop case, in which the speed drops when a load torque is applied.

  7. Observe the current result. The current profile will vary depending on the motor parameters and controller gain values used. In most cases, when used with the intended motor, the motor current would rise above 5 A, which is the maximum current limit of the three-inverter module. To prevent this overcurrent, the outputs of the integrator and PI controller must be limited, as was done for the current PI controller. In the speed PI controller, set Upper Limit to 5 and Lower Limit to -5 for both the Integrator and Saturation tools.

  8. Rerun the simulation and observe the result.

    please noteNote

    The steady-state motor current and speed cannot both be controlled independently at the same time. The only quantity within the motor that the user can directly control is the applied terminal voltage. Thus, only one motor variable can be controlled at steady state: the motor current, rotor speed, or rotor position. In speed-control mode, the inner current loop merely dictates the path that the motor current takes to reach its final steady state. Its final value cannot be controlled independently.

Real-time DC motor speed control

In the previous section, the motor speed-control model was simulated. In this section, the same system is run in real time to control the speed of an actual motor.

  1. Open a new Workbench session.

  2. Create a new project and add a model file to it. Set this model file as the Start model/Function in project properties.

  3. Open model properties and set the Step time to 0.0001 and Run time to 2.

  4. Within the project properties, select the drop-down menu at the top, and then select Device Configuration. Change the following properties:

    1. Change Device within Main sub-division to 3 Inverter

    2. Change Run Mode within Main sub-division to Till Runtime.

    3. Change Frequency (Hz) within PWM Configuration sub-division to 12000.

    4. Change Waveform within PWM Configuration sub-division to Triangle.

    5. Change Encoder Lines within AQB Configuration sub-division to 2048.

    Workbench device configuration.

  5. From the simulation model, copy and paste only the speed and current PI controllers, as shown:

    Copy pasted speed and current PI controller.

  6. Drag and drop the following tools from the Toolbox to the model and connect them as shown.

    # Tool type Tool class Tool name
    1 Step Signal Sources Step
    2 AQB Speed Hardware Integration AQB
    3 Mag-Time Scope Display Scope
    4 Analog Input Hardware Integration ADC
    5 Gain Math Block Gain
    6 Mag-Time Scope Display Scope1
    7 Gain Math Block Gain1
    8 Constant Signal Sources Constant
    9 Adder Subtractor Math Block Add
    10 Adder Subtractor Math Block Add1
    11 PWM Output Hardware Integration PWM
    12 PWM Output Hardware Integration PWM1
    13 True/False Signal Sources Boolean
    14 Digital Output Hardware Integration GPO

    DC motor real-time speed control model

  7. Change the properties of each tool to the values listed in the table below.

    Tool name Property field Property value Comments
    Step Final value 100 Desired reference motor speed.
    Step Step Time 1 Step motor speed from rest to desired speed at time t = 1 s.
    AQB Channel 1 Actual motor speed feedback.
    ADC Channel 3 Actual motor current feedback.
    Scope Realtime log Enabled Enable to log real-time motor speed feedback.
    Scope1 Realtime log Enabled Enable to log real-time motor current feedback.
    Gain Gain -5 Scaling to convert ADC signal to actual current. The scaling value is given within the ADC property.
    Gain1 Gain 1/80 1/(2 x Vdc), which converts the voltage to a value between ±0.5.
    Constant Magnitude 0.5 The signal above is centered at 0.5 to obtain the duty cycle.
    Add1 Arithmetic operation -+ The duty cycle of one inverter leg is obtained by adding the scaled duty to 0.5, and that of the other is obtained by subtracting it from 0.5.
    PWM Channel 2 Each PWM channel controls the voltage at one of the output terminals.
    PWM1 Channel 1 Each PWM channel controls the voltage at one of the output terminals.
    Boolean Value True This pulls the inverter out of reset so that it can be used to generate the desired output voltage.
    GPO Channel 1 The inverter being used is Inverter 1.

  8. Connect the motor (the one without the encoder) to Inverter 1 (the color of each motor terminal must match that of the corresponding inverter terminal). Even though the generator (the one with the encoder) is not used in this case, connect it to Inverter 2 instead of leaving the terminals open.

    Connect the three-inverter module to the DC power supply. Connect the three-inverter to the computer via USB. Connect the generator speed feedback to the three-inverter's Encoder 1 DSUB connector in the back panel.

  9. Turn ON the DC power supply and set the voltage to 40 V.

  10. Ensure that the Numerical simulation to Real-time mode transition button button on the top dock is pressed to enable real-time mode. Click the run button.

  11. Observe the speed and current results in the scopes. Click Model display scope autofocus time axis alone to focus the results. After about 2 s, stop data logging by clicking Numerical simulation and real-time prototyping Stop button.

  12. Turn OFF the DC power supply.

  13. In some cases, the current may be extremely choppy. This occurs because the speed controller tries to correct noise in the speed feedback in real-time mode. To avoid this, redesign the PI controller for a crossover frequency of 2 Hz, i.e., ωs,c = ωi,c/100 = 2π x 2.

    Use the redesigned PI values and rerun the motor.

  14. Replace the Step reference with a Sine reference whose Magnitude is 100 and whose Frequency is 1.

  15. Turn ON the DC power supply and rerun the model.

  16. Observe whether the motor tracks the reference speed.

  17. Turn OFF the DC power supply and disconnect all the connections including the USB.

This concludes the experiment on DC motor speed control. In this experiment, the DC motor was actively loaded only in simulation, not in real time. This will be done in the following experiment, where the controller designed in this experiment will be used.

Lab report and reading assignment
  1. Attach plots of Ia and ωm from the simulation when the motor was operated in an open loop.

  2. State the PI controller gain values obtained. Attach plots of Ia and ωm from the simulation when the motor was operated in current-control mode with different gain values.

  3. State the PI controller gain values obtained. Attach plots of Ia and ωm from the simulation when the motor was operated in speed-control mode.

  4. Attach a plot of ωm from real-time speed control.

  5. In current-control mode, what would the speed profile look like if the friction coefficient B were zero and there were no voltage limitation?

  6. How would you extend the speed-control model to perform position control? What system transfer function would be used to tune the PI controller?