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 the PWM reference voltage is set to its maximum value of +5V, then the motor should run at 4000 rpm. If it is set to +2.5V, then it should run at approximately 2000 rpm. The Simulation model 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.
The plot below shows the current passing through the motor and the speed of the motor shaft.