Skip to Main Content Skip to Search
Product Documentation

Model a DC Motor

Overview of DC Motor Example

In this example, you model a DC motor driven by a constant input signal that approximates a pulse-width modulated signal and look at the current and rotational motion at the motor output.

To see the completed model, open the Controlled DC Motor demo.

Selecting Blocks to Represent System Components

Select the blocks to represent the input signal, the DC motor, and the motor output displays.

The following table describes the role of the blocks that represent the system components.

Block

Description

Solver Configuration

Defines solver settings that apply to all physical modeling blocks.

DC Voltage Source

Generates a DC signal.

Controlled PWM Voltage

Generates the signal that approximates a pulse-width modulated motor input signal.

H-Bridge

Drives the DC motor.

Current Sensor

Converts the electrical current that drives the motor into a physical signal proportional to the current.

Ideal Rotational Motion Sensor

Converts the rotational motion of the motor into a physical signal proportional to the motion.

DC Motor

Converts input electrical signal into mechanical motion.

PS-Simulink Converter

Converts the input physical signal to a Simulink signal.

Scope

Displays motor current and rotational motion.

Electrical Reference

Provides the electrical ground.

Mechanical Rotational Reference

Provides the mechanical ground.

Building the Model

Create a Simulink model, add blocks to the model, and connect the blocks.

  1. Create a model.

    If you are new to Simulink, see the Creating a Simulink Model example for information on how to create a model.

  2. Add to the model the blocks listed in the following table. The Library column of the table specifies the hierarchical path to each block.

    Block

    Library Path

    Quantity

    Solver ConfigurationSimscape > Utilities

    1

    DC Voltage SourceSimscape > Foundation Library > Electrical > Electrical Sources

    1

    Controlled PWM VoltageSimscape > SimElectronics > Actuators & Drivers > Drivers

    1

    H-BridgeSimscape > SimElectronics > Actuators & Drivers > Drivers

    1

    Current SensorSimscape > Foundation Library > Electrical > Electrical Sensors

    1

    Ideal Rotational Motion SensorSimscape > Foundation Library > Mechanical > Mechanical Sensors

    1

    DC MotorSimscape > SimElectronics > Actuators & Drivers > Rotational Actuators

    1

    PS-Simulink ConverterSimscape > Utilities

    2

    ScopeSimulink > Commonly Used Blocks

    2

    Electrical ReferenceSimscape > Foundation Library > Electrical > Electrical Elements

    1

    Mechanical Rotational ReferenceSimscape > Foundation Library > Mechanical > Rotational Elements

    1

      Note   You can use the Simscape function ssc_new with a domain type of electrical to create a Simscape model that contains the following blocks:

      • Simulink-PS Converter

      • PS-Simulink Converter

      • Scope

      • Solver Configuration

      • Electrical Reference

      This function also selects the Simulink ode15s solver.

  3. Connect the blocks as shown in the following figure.

Now you are ready to specify block parameters.

Specifying Model Parameters

Specify the following parameters to represent the behavior of the system components:

Model Setup Parameters

The following blocks specify model information that is not specific to a particular block:

As with Simscape models, you must include a Solver Configuration block in each topologically distinct physical network. This example has a single physical network, so use one Solver Configuration block with the default parameter values.

You must include an Electrical Reference block in each SimElectronics network. You must include a Mechanical Rotational Reference block in each network that includes electromechanical blocks. These blocks do not have any parameters.

For more information about using reference blocks, see Grounding Rules in the Simscape documentation.

Motor Input Signal Parameters

You generate the motor input signal using three blocks:

In this example, all input ports of the H-Bridge block except the PWM port are connected to ground. As a result, the H-Bridge block behaves as follows:

In this example, you simulate the motor with a constant current whose value is the average value of the PWM signal. By using this type of signal, you set up a fast simulation that estimates the motor behavior.

  1. Set the DC Voltage Source block parameters as follows:

    • Constant voltage = 2.5

  2. Set the Controlled PWM Voltage block parameters as follows:

    • PWM frequency = 4000

    • Simulation mode = Averaged

      This value tells the block to generate an output signal whose value is the average value of the PWM signal. Simulating the motor with an averaged signal estimates the motor behavior in the presence of a PWM signal. To validate this approximation, use value of PWM for this parameter.

  3. Set the H-Bridge block parameters as follows:

    • Simulation mode = Averaged

      This value tells the block to generate an output signal whose value is the average value of the PWM signal. Simulating the motor with an averaged signal estimates the motor behavior in the presence of a PWM signal. To validate this approximation, use value of PWM for this parameter.

Motor Parameters

Configure the block that models the motor.

Set the Motor block parameters as follows, leaving the unit settings at their default values where applicable:

Current Display Parameters

Specify the parameters of the blocks that create the motor current display:

Of the three blocks, only the PS-Simulink Converter1 block has parameters. Set the PS-Simulink Converter1 block Output signal unit parameter to A to indicate that the block input signal has units of amperes.

Torque Display Parameters

Specify the parameters of the blocks that create the motor torque display:

Of the three blocks, only the PS-Simulink Converter block has parameters you need to configure for this example. Set the PS-Simulink Converter block Output signal unit parameter to rpm to indicate that the block input signal has units of revolutions per minute.

Configuring the Solver Parameters

Configure the solver parameters to use a continuous-time solver because SimElectronics models only run with a continuous-time solver. Increase the maximum step size the solver can take so the simulation runs faster.

  1. In the model window, select Simulation > Configuration Parameters to open the Configuration Parameters dialog box.

  2. Select ode15s (Stiff/NDF) from the Solver list.

  3. Enter 1 for the Max step size parameter value.

  4. Click OK.

For more information about configuring solver parameters, see Simulating an Electronic System.

Running the Simulation and Analyzing the Results

In this part of the example, you run the simulation and plot the results.

In the model window, select Simulation > Start to run the simulation.

To view the motor current and torque in the Scope windows, double-click the Scope blocks. You can do this before or after you run the simulation.

The following plot shows the motor current.

Motor Current

The next plot shows the motor rpm.

Motor RPM

As expected, the motor runs at about 2000 rpm when the applied DC voltage is 2.5 V.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS