# Brushless DC Motor

This example shows how a system-level model of a brushless DC motor (i.e. a servomotor) can be constructed and parameterized based on datasheet information. The motor and driver are modeled as a single masked subsystem. If viewing the model in Simulink®, select the Motor and driver block, and type Ctrl+U to look under the mask and see the model structure.

This model of a brushless DC motor uses a standard configuration. An inner feedback loop controls current and an outer feedback loop controls motor speed. Speed demand is set by the voltage presented at the Vref pin, and motor direction by the voltage presented at the Vdir pin. If the voltage at the Vbrk pin goes high, then Vref is overridden and speed demand set to zero to implement a braking action.

In this model, the speed demand is set to 2V which corresponds to 40,000rpm. After one second, the Vdir pin is set high, and the motor reverses to -40,000rpm. At 2 seconds, the braking pin Vbrk is set high, and the motor slows to zero rpm. The efficiency of the brushless DC motor is calculated as the ratio of mechanical power out to electrical power in. Hence it can be transiently outside of the 0 to 100 percent range due to rotor inertia.

The manufacturer datasheet for the brushless dc motor gives the stall torque as 0.44mNm, the maximum permissible speed as 100,000rpm, mechanical time constant as 5ms, rotor inertia as 0.005gcm^2, efficiency as 41 percent at 0.23mNm and 40,000rpm, no-load current as 22mA and nominal voltage as 12V. The time constant is based on using the manufacturer motor driver which uses block commutation. The motor driver can be configured so that when the speed reference voltage is as at its maximum of +5V, the commanded speed is 100,000rpm.

The Servomotor block in the Motor and driver subsystem is used to model the inner current feedback loop, plus balance mechanical and electrical powers. For system design, it is not usually necessary to model the current switching controlled by the motor driver, whereas ensuring the correct torque-speed characteristics and current drawn from the DC supply is. The vector of maximum torque values is in practice determined by the maximum driver current. Motor drivers normally have a maximum current setting which should be matched to the maximum rated motor torque, or the maximum torque that is to be applied to the load if the motor is over-specified. Here the vector of maximum torque values is set to be the motor stall torque up to and beyond the maximum speed of 100,000rpm. The assumption is that system in which the motor and driver are used will take care of ensuring that the motor does not overheat by operating too long at high torque and speed combinations.

Motor electrical losses are assumed to consist of two terms. The first is a fixed loss that is independent of load, and this is calculated as Vcc*I0 where Vcc is the nominal supply voltage and I0 is the no-load DC current drawn from the driver power supply. Note that if block commutation is used, as for the driver this example is based on, I0 will be twice the current in an energized phase winding. The second loss term is proportional to the square of instantaneous motor winding current. This can be approximated as a term that is proportional to the square of the average torque. The two loss terms are implemented by the Servomotor block.

There are three Motor and driver mask parameters which have to be tuned to match datasheet values. These are the proportional and integral gains for the speed feedback controller, and the time constant for the inner-loop current controller. Here, the datasheet gives the no-load time constant as 5ms. A typical rule of thumb is that an inner control loop should be at least ten times faster than the outer loop. This means a time constant of 0.5ms for the current controller. With this value set, the proportional term is then increased until the speed time constant is approximately 5ms. The integral gain should then be set when performing a speed step under load, and increased until steady-state error is removed in the order of 5ms. Some fine tuning of the two gains is then needed to recover the 5ms rise time under no load.

### Model

### Motor and Driver Subsystem

### Simulation Results from Simscape Logging

The plot below shows the speed of the brushless DC motor under varying conditions. The load torque is a constant value always opposed to the rotation of the shaft. Commands to reverse direction and brake are applied.