Main Content

PWM-Controlled DC Motor

This model shows how to use the Controlled PWM Voltage and H-Bridge blocks to control a motor. The DC Motor block uses manufacturer datasheet parameters, which specify the motor as delivering 10W mechanical power at 2500 rpm and no-load speed as 4000 rpm when run from a 12V DC supply. Hence if you set the PWM reference voltage to its maximum value of +5V, then the motor runs at 4000 rpm. If you set it to +2.5V, then it runs at approximately 2000 rpm. The Simulation mode parameter is set to Averaged for both the Controlled PWM Voltage and H-Bridge blocks, resulting in fast simulation. To validate the averaged behavior, change the Simulation mode parameter to PWM in both blocks.

Model

Simulation Results from Simscape Logging

The plot below shows the current passing through the motor and the speed of the motor shaft.

Results from Real-Time Simulation

This example has been tested on a Speedgoat Performance real-time target machine with an Intel® 3.5 GHz i7 multi-core CPU. This model can run in real time with a step size of 30 microseconds.