In this project article, we’re going to be taking a different approach to my typical project. Driving a brushless motor is relatively simple from a schematic perspective; however, there is a large amount of theory about brushless direct current motors that you need to understand to be successful. If you only have experience with brushed motors or no experience with driving motors at all, we will be covering everything you need to know.
You can find the Altium Project with schematic and board design on GitHub as always, released as open source under the highly permissive MIT license.
Brushless motors cover a wide variety of motor constructions, but the term has become synonymous with PM BLDC (Permanent Magnet BrushLess Direct Current) motors in recent years. For this article, we’ll focus on these and brush over the rest. Suppose you’re looking for a low-cost PMBLDC motor to experiment with. In that case, radio-controlled model electric motors are typically very high-quality brushless motors that can deliver astounding amounts of torque and power when driven correctly. What’s even better is that they are very cheap from companies such as HobbyKing.
In general terms, an electric motor requires a rotating magnetic field to generate movement. In a classical DC motor, this was achieved using a commutator. A commutator is essentially a ring with multiple conducting bands. Each of these bands is one of the motor’s contacts, and graphite contacts called brushes then press against these conducting bands and are, in turn, connected to a DC power source. The motor’s rotation changes the point where the brushes make contact, creating an alternating current going into the brushed motor windings. The obvious drawback is that we have a soft point of contact that wears away and brings with it all the disadvantages of mechanical contacts (EMI, sparks, degrading conductance...).
Several factors have conspired in modern times to make these types of brushed motors a thing of the past:
After all, why use a mechanical device to switch the current when we can do it ourselves using electronics?
BLDC motors have a whole range of advantages over their brushed (and some of their brushless) competition:
As a bonus, a BLDC motor controller can be electronically controlled without the need for direct motion feedback (i.e., an encoder) in what is known as a sensorless configuration. However, there are some limitations to using that approach that we’ll talk about later. For now, let’s review the basics of BLDC motor controllers.
The most common configuration for BLDC motors is a three-phase star setup (also known as a wye configuration).
Each of the resistors in the image above represents each of the windings of the DC motor. We’ll use a similar diagram to explore the inner workings of the motor.
While it’s not an accurate description of modern brushless motors’ real-world construction and electrical properties, it’s a good enough mental model to think about what is happening.
Each axis on the image above represents the current flowing through each winding. The vector sum of the three gives us a representation of the motor’s magnetic field. The magnetic field and current can be considered as being always synchronized for the purpose of this explanation. Keep in mind that IX is not a real current flowing in the system, or the total current provided by our driver, but rather a representation of the equivalent current in terms of the magnetic field.
An additional vector of constant length, not represented in the above figure for clarity, will represent our rotor’s angular position. Our rotor will try to align itself with the IX vector the same way that a compass needle tries to point north. To make the rotor continuously spin, we just need to ensure that the magnetic field we create with the motor windings is rotating around at the correct speed.
A lot of interesting physical parameters of our system can be determined through this representation.
When talking about a BLDC motor controller, a lot of different terms are used for very similar control schemes. This guide is not an attempt at a thorough explanation but rather a simplification to help you start learning how to drive motors as quickly as possible while keeping you aware of what’s happening (i.e., no black boxes or hidden magic).
To that end, I have separated two topics that generally go hand in hand, DC motor control and motor driving. Generally, you will tackle both simultaneously, but the theory can be thought about independently of each other. Since this will be easier to understand, we will adopt this approach.
In most cases, the driving circuit will look something like that shown in the above figure. All of the MOSFETs will need a gate driver, as the current draw to switch the gates on and off rapidly is likely beyond what a microcontroller can provide, and the resistance of the drain-source junction of the FET decreases with higher gate voltages. An optimal design will use N-Channel MOSFETs for all six positions, as they have significantly lower drain-source resistance than their P-Channel counterparts; however, this necessitates the use of a high-side gate driver to drive the gate at a higher voltage than the supply. It is a good idea to choose a half-bridge driver; this will prevent the accidental simultaneous turn-on of both the High and Low sides of any single bridge, a dangerous condition known as a shoot-through.
There are two basic ways of driving your BLDC motor:
Sinusoidal driving is often called Field Oriented Control (FOC). These two principles are generally used together, but sinusoidally driving your DC motor does not automatically make your controller an FOC drive.
While these two methods refer to the basic driving strategy, it’s assumed that this is done through Pulse Width Modulation (PWM); keeping your transistors turned on fully for too long a time is never a good idea!
In trapezoidal driving, only one phase pair is active at any one time, as shown in the diagram below.
As you can see, the whole cycle has just six different states. Each phase has two possible conditions, pulled HIGH or pulled LOW. However, all phases pulled HIGH or all phases pulled LOW are inactive states since no current would be flowing through the windings.
While the ideal option is to modulate both active phases, a typical approach to reduce the number of PWM outputs required is to modulate the high-side transistors (labeled M1, M3, and M5 in the previous figure) to drive the low side with simple GPIOs fully ON. This setup is preferred to provide a complementary PWM output to the low side due to the bootstrap circuit’s need for additional gate drivers.
In the above diagram, you can see the current ripple represented; we’ll discuss this later.
In Sinusoidal driving, PWM is used to modulate the winding current gradually. It’s a more complicated driving mechanism, but it achieves much better performance in most circumstances.
A necessary distinction to note in this topic is BLDC vs. Permanent Magnet Synchronous Motor (PMSM). Many manufacturers will use both terms to refer to either type since the difference lies in the construction of the windings.
This can cause some confusion, so be sure to contact your manufacturer and ask before committing to a driving strategy. The infallible test to identify the motor type is to measure the “Back EMF” (BEMF); this is the voltage that the motor will create while rotating. You want to match your driving scheme to the shape of that BEMF.
Keep in mind that there is no difference in the power stage (although sinusoidal does require better current and positional sensing) and that you could always drive both motor types using both strategies. Still, only a sinusoidal BEMF motor with sinusoidal driving can give you a constant torque (which might be a requirement in your motion control application).
A typical source of confusion at this point is the difference between the driving frequency and the control frequency. In general terms, the driving frequency is the frequency of our PWM pulses, while the control frequency is the frequency of our control system (the time taken for one “control cycle”).
For most systems, the driving frequency will be between 20 kHz and 80 kHz, while the control frequency will typically be around 1 kHz to 5 kHz. Let’s discuss the effects and requirements of each of these to get a clearer picture.
Adopting a higher driving frequency will mostly place hardware restrictions on us. It will require faster gate drivers, faster PWM modules on our controller, faster transistors, and tighter control of the turn-on and turn-off characteristics.
While managing all of this is no trivial task, there are significant benefits to using higher driving frequencies in some scenarios. A faster PWM allows you to control your currents with better granularity, allowing your sinusoidal control to be composed of a greater number of smaller steps. This reduces the mismatch between your driving current and the impedance of your motor, improving overall performance.
Remember the current present in the trapezoidal control waveform diagram? This ripple is caused by this mismatch, which is quite large in trapezoidal control since we have only three possible values for each current (the two directions at 100% and zero). This type of ripple current will also be present on the sinusoidal control waveform but at a lower level.
This ripple current is the leading cause of EMC problems in these drives. It appears at harmonics of the driving frequency, which means that using higher frequencies can also help regulate EMC in some situations, making it more manageable.
The frequency of your ADCs typically determines control frequency. Since the controller operates predominantly as a state machine (with some memory), your controller has nothing to do without any new inputs. Depending on your chosen control algorithms, the computation speed might also become a factor.
The general way to increase control frequency is to either increase controller capability (operating frequency, computing power) or improve the firmware implementation by taking advantage of fractional representation on DSPs, for instance. The main improvements for increasing control frequency come from an increased ability to respond to load transitions, but this is highly dependent on your particular implementation.
For most applications, the control frequency is not nowadays a challenging problem. However, be careful when sharing your computing time with other functions such as communications processing. Using a dual-core MCU or dual MCU configuration for independently handling time-sensitive communications and motor driving is a solution rising in popularity in the industrial sector. It will likely become the trend more generally as more demanding protocols like EtherCat are more widely adopted.
Motor control is a very extensive topic beyond this article’s scope, and there are a lot of useful resources available online and in print. The intention here is to help you understand the options that will affect the required hardware for good control.
In general, control involves measuring a value, comparing it to a reference, and acting on the difference in accordance with a set of rules. Knowing which values require measurement is enough for good hardware design, so we will discuss it here.
The most critical variables for us are rotor position and winding current.
Rotor position can be measured with Hall-effect sensors or by measuring BEMF.
Hall-Effect Sensors: A lot of BLDCs will incorporate Hall-Effect sensors for measuring the rotor position. These Hall-effect sensors might be analog or digital, so check which ones you have available.
Most Hall-effect sensors will require pull-up resistors, and filtering is always advisable.
BEMF: Back EMF can be used to estimate the rotor position (especially in sinusoidal BEMF motors). This configuration is customarily called sensorless control, but you need to know that this configuration has an important caveat; the position can only be measured while the rotor is moving since a static rotor generates no BEMF. This means that the initial position is generally unknown, so starting the motor will require special handling.
Aside from detecting fault conditions, knowing the winding current allows us to measure torque indirectly.
Having good current control is essential for knowing the magnetic field strength that our stator generates (the IX vector). By keeping a constant angular distance between this field and the rotor, we can measure the motor’s torque.
For trapezoidal control, some savings can be achieved by measuring the total current instead of the current for each winding since only one winding is active at any given time.
The two previously discussed variables are all that are required for most control schemes.
Measuring the position using high sampling rates allows us to add some simple processing to the control. This will enable the computation of speed, acceleration, and jerk (although some careful analysis might be required if excellent control is essential for your application).
For some applications, measuring the total current might be a good option since it helps detect some common failure types.
Finally, you might consider including external feedback loops if required for your application. For instance, if a gear reduction is used, you might want to measure the output position utilizing an encoder.
After all the introductory text, it’s finally time to design our drive circuit. This is intended to be a practical guide, after all!
Let’s establish our specification first:
Our power source will be a Lithium polymer battery with at least 3 cells (3S LiPo). The generally acceptable voltages for these batteries range from 10 V to about 13 V. We can easily cover both and give us some extra room with a minimum input voltage of 9 V and a maximum input voltage of 20 V.
Our maximum total current will be 30 A. Since we want a robust drive (and we don’t want to damage our battery!), we will control the total current and design our drive for a peak current of up to 45 A.
Pro tip: it’s a good idea to “bump” your specifications a little. In most cases, your client might need to increase your board’s power after testing. Adding a factor of x1.5 to the rated values is a common rule of thumb.
We won’t target a specific motor, so we want to be able to use both Hall-effect-based and sensorless configurations and support both trapezoidal and sinusoidal driving. That way, we can target both motor types with the same hardware and then choose when working with the firmware.
We will provide additional inputs for an external encoder from CUI’s AMT series. These are incremental quadrature encoders.
While a PWM-based interface might be enough for our purposes, we will use a UART interface for our controller. This allows us to use the ST Motor profiler to define our own set of commands once we build our custom firmware. A basic TTL UART (3.3V) will be enough to keep things simple and can be accessed through a standard USB-to-UART converter.
The controller will be one of the defining features of your drive. Three things should influence your choices:
In our case, we will take advantage of all these time-saving opportunities by using a STSPIN32F0 device. This MPU is essentially an STM32F0 microcontroller with a lot of extra blocks specifically for motor control. This ST product will also provide us with lots of software tools to auto-generate our controller’s firmware. This means we will spend less time coding the basics and more time working on tuning our devices for maximum performance. Firmware is usually a huge part of a product development budget, so making use of the STSPIN-generated firmware can greatly reduce the engineering cost of developing the product for the market.
Since this single chip can be supplied from a VBUS and provides us with gate drivers, ADCs, and comparators; we only need to add a couple of additional blocks:
If you want to use this part but change some of the features, make sure you first check the “Motor Control Workbench” software from ST. This software will help you generate your firmware, and using it first may limit your choices. You don’t want to suddenly find out your controller has a limitation when you reach the design process’s last step!
We will need to build our three nMOS half-bridges for switching the winding current. Since we are operating below the 48 V threshold, there’s no need to consider more ‘exotic’ transistors like GaN-based technologies; standard silicon-carbide-based components will give us the best performance.
Important characteristics to check:
In general terms, Rds(on) will determine the power dissipated by your drive. Remember that you need to account for switching losses too, so this will only give you a minimum dissipated power. The better your heat management, the larger your Rds(on) budget will be.
If our voltage was higher than 80 V, the parasitic gate capacitors would be another factor to consider since you will start to see an effect called “self-turn on.” This effect can have catastrophic consequences if not checked, so be careful!
In terms of current sensing, STs software expects 1 mΩ resistance to the ground. Using two parallel resistors eases our power requirements and gives us more flexibility when choosing the resistor value.
We will use a standard configuration for our gate driving, allowing for different resistance during the turn-on and turn-off operations. This helps us balance our nMOS to have symmetrical timings. Since the limiting factor on our rising and falling times will likely be the EMF generated, we want to ensure that we only penalize our performance just enough to pass our tests.
This section is vital for the drive, so if you are working on very critical applications, you might want to add a couple of things:
Our selected microcontroller has integrated gate drivers, but this may not be the case in most situations. So, let’s discuss these a little more if you need to add your own external gate drivers. We need our gate drivers to source and sink as much charge as fast as possible, to and from our transistors gate. This means that generally, the bigger the driving current, the better.
It’s essential to know how transistors (especially power transistors) behave during switching to understand the selection criteria (Vishay’s AN608 is often a recommended reading). We will focus on the parameters that will make or break our driver:
The offset voltage is the maximum voltage that our gate driver can provide as an offset to our high-driving transistor. Remember that in our totem pole configuration, the top FET requires a positive voltage with respect to its power source connected to the phase. The rule is simple, always ensure that the offset voltage is higher than your bus voltage.
Your gate driver will need to have the capability to drive the transistor gate with a voltage ranging typically from 10 to 20 V. A voltage of 12 V is regularly used, but when using “logic level gate” power MOSFETs, it’s easy to exceed their maximum gate voltage (typically 15 V). Be sure to always comply with this maximum limit. A common way to protect against exceeding this limit is to add Zener diodes to the bootstrap circuit, limiting the maximum gate voltage.
Half-bridge gate drivers are recommended for our application because they will prevent simultaneous activation of any pair of transistors’ high and low sides, but merely blocking this situation isn’t enough on its own. Turn-off times are generally longer than turn-on times, which means that if our controller tries to transition from one state to the other state too quickly, our transistor might turn on before its counterpart has had time to completely turn off, causing a shot-through condition.
To limit this problem, most half-bridge drivers provide an internal “deadtime,” meaning that they have a temporal gap between shutting down a transistor and letting its counterpart turn on. While this protection is desirable in critical environments, this feature will limit the maximum power that can be delivered to the load and has some minor effects on the control as it restricts the maximum driving frequency.
To illustrate this point, if your bridge drivers have 100 ns deadtime and drive them at 20 kHz, you will lose around 0.2% of your theoretical total power delivery. This value rises with higher deadtimes and with higher driving frequencies. It might not seem a significant amount, but this power loss can cause issues in extreme cases.
The primary strategy here is to use the half-bridge deadtime as a minimum (and increase it with driving resistors), and then if margins allow, add an additional software-based deadtime.
Our encoder requires a clean 5 V supply to operate correctly, and since our controller down-converts directly to 3.3 V, we will have to provide our own. The encoder output signals will also be in this range, so we will need to use some resistor dividers to lower these.
The interface specifics will depend on your application and design, but the most common pitfalls can be avoided by remembering the basics. Our environment will be very noisy (electrically and otherwise!), so be sure to use reliable connections that can withstand vibrations and shake and employ proper grounding techniques. Provide good onboard filtering if required and ESD protection as needed.
Depending on your application, some protection mechanisms will be more necessary than others:
If working with currents higher than 50 A, inrush current limiting will become a necessity.
It’s easy enough for lower currents to provide inverse voltage protection with FETs to avoid wiring mishaps. However, on high-current drives, you might be forced to use other mechanisms (like polarized connectors).
When working with applications where the motor is connected to a high inertia load, your motor will need to manage the load’s energy when slowing down. Unless your supply or the rest of your system can offload the required amount of energy (for instance, regeneratively by charging a battery), you should provide a safe path for the return braking current. This is typically achieved by connecting a high-power resistor to the bus that can dissipate the load. Providing this kind of protection is easy and can also help you manage overvoltage conditions.
While the transistors in these situations can take a lot of current, the resistors can’t, so providing a way to limit the current through them with protection in specific scenarios is a good idea.
We’ve implemented such a circuit by shutting the gate off with a simple NPN transistor. This allows our firmware to just leave the pin HIGH, and the transistor will take care of limiting our average current during braking.
We will not be using temperature sensing on this simple drive other than our controller’s integrated features. Still, if your application is safety-critical, you will want to add temperature sensing to your power stage. If you believe your application requires it, the best setup involves placing multiple temperature sensors near your transistors, with the power grounds traced in such a way that they allow you to reliably measure transistor temperatures.
Most of the routing tips for motor drives are derived from two primary considerations:
In terms of Heat management, power planes, and vias are your best friends. Don’t be afraid to place lots of vias in your power planes, especially those carrying high current. Ideally, you should be using more than one layer per phase, so having them well interconnected is crucial to take advantage of the board’s real estate that you are using. Simulating your current density with a tool such as PDN Analyser is a critical sanity check for high current drives to ensure your copper thickness and area are sufficient.
Most of your heat will come from the power stage, especially the MOSFETs and the copper traces themselves, but also from the bus capacitors. Realistically, these traces will have to handle higher temperature increases than seen in most boards, so be sure that they are electrically and thermally well connected. When placing vias for thermal management purposes:
As for EMC, aside from the standard rules, here are some special caveats that might not be obvious when starting out working with motors:
Tips for the trade:
To create the firmware for our drive, we will use the ST Motor Control Workbench. Once the application is installed and running, we just need to click “New Project.” A window will open with several options and applications. If your specific application matches one of the items on the list, you’re free to select it. However, we will proceed here by choosing “Custom” on all parameters (and Generic Low Voltage < 50 V on the type of motor).
Click “OK” and let the software load, and you will be presented with a system view, as shown below.
By clicking on the “Control Unit” part number, you can choose your specific controller. In our case, this is the STSPIN32F0. By clicking each of the boxes, you can set up the corresponding device according to your requirements.
For this example, we will make the following changes:
Once you are finished configuring your device, the “Pin assignment” button can help you validate that everything is correctly mapped.
Once the pin assignment checks are OK, you are ready to generate your code. Simply click the button to the right of the assignment button to create your application code.
This will open CubeMX and start the code generation according to the toolchain settings. From here, you can open the project in your preferred IDE and continue development with any application that’s not on the workbench.
I invite you to explore all the available options in the workbench. Some we’ve discussed here, others like feed-forward, are a topic of their own. You should have enough information to make a start and have your motor up and running so you can start experimenting.
Lastly, I want to provide a list of interesting search terms that might be of interest when designing a motor drive. The world of motor control can be very opaque to the uninitiated; some of these are terms I wish I’d known before I started working on these since they would have made my life a lot easier:
Some of these terms have a different meaning in other fields, so be careful when searching for them.
Have more questions? Call an expert at Altium and discover how we can help you with your next PCB design.