Give away medical masks when you place an order. learn more

Using Kinetis BLDC Motor Control Applications



Brushless DC electric motors are also known as electronically commutated motors, and as the name states, BLDC are also DC powered. The main characteristics is the fact that BLDC motors don’t use brushes, instead, they are electronically commutated.

A BLDC has a rotor with permanent magnets and a stator with windings. It is essentially a DC motor turned inside out. The brushes and commutator have been eliminated and the windings are connected to the control electronics. The control electronics replace the function of the commutator while energizing the proper winding.

By removing the brushes and mechanical commutation, we eliminate sparks which is one of the advantages of BLDC motors. BLDCs are potentially cleaner, faster, less noisy more efficient and reliable, but do require the electronic control.

This article discusses the main features needed by microcontrollers to be able to run an efficient BLDC motor control algorithms and introduces how the Kinetis family of MCU implement those features (as well as how to use them). Ideal applications in which Kinetis technology does motor control are also mentioned.

There is a short introduction to electronic motor control but basic knowledge in BLDC motor control is recommended. If you require further assistance, please visit www.freescale.com/motorcontrol for references on BLDC and other motor control techiniques, as well as tutorials, videos and in-depth explanation of basic and advanced motor control theory.

Electronic motor control benefits

Using advanced motor control techniques and 3-phase brushless motors, as opposed to single-phase motors with simple or no control, offers several benefits to the end application and support structure of the product. Brushless motors are far more efficient than brushed motors, most obvious reason being the fact that brushes exert parasitic torque (wasted energy) on the rotor. Additional problems with brushes are: glitches in torque, audible noise, mechanical wear. Brushless motors, on the other hand, can be controlled to obtain low audible noise and flat torque response. The lack of brushes also means less need of maintenance (brushes wear down and need to be changed). Brushless motor in the same power and size space will also run faster than their brushed counterparts.

Brushless motors also allow for the design of motor form factors that are difficult or impractical for brushed motors, two examples: the “pancake” motor, a flat motor which is starting to gain usage in washing machines and pumps, and the typical computer fan with the “external” rotor (permanent magnets for the rotor are outside of the stator windings instead of inside).

Typical BLDC motor control system

As with any control system, a typical motor control system will include a control or “output” section and a feedback or “input” section. In a typical motor control system, the abstract representation is as follows.


Figure 1: Simplified motor control system

Basic elements are:
  • Power amplifier (which can go from a single power switch up to a 3-phase inverter made with 6 power transistors).
  • Feedback for each sensed variable: In a motor control system the most basic feedback is speed (or position, from which speed can be obtained). Speed/position sensors come in many forms. In BLDC systems, the most typical sensors are hall effect sensors, one for each phase, these are used to determine when the rotor has moved a single step, the period at which this move happens is used to determine the speed of the motor. Current going into the motor is another important variable, in DC and BLDC motors current is directly related to motor torque, in sinusoidal motors it is also related to torque but not in a linear way. In these motors it is also an important feedback method, and in Field-oriented control (FOC) techniques it is an essential variable. Notice that there are methods to estimate the position of the rotor without sensors, these techniques are called sensorless, and will be covered in more detail.
  • Speed and current (torque) reference: This is the user or system input where the expected outputs are defined. These can be a direct setting from a user in an HMI, or can be an automazed control coming from another computer or system via a serial communication link.
Speed and current controllers: In MCU-based motor control these blocks are usually made up of software. Advanced DSP controllers and MCU with DSP coprocessors (such as the ARM® CortexTM- M4 core in Kinetis MCUs) can help with the mathematical calculations needed to perform the control function. The most typical form of control in motor systems is PI (proportional – integrative). PID controllers are not typically used because the D term (derivative) can make the system susceptible to high frequency noise. The advantage of the D term is improving response to fast changes in the input, because motors are slow mechanical processes (as opposed to other controlable variables), and motors are slowly started up to avoid current peaks, the advantage of adapting to fast changes does not help.

BLDC motor control system

A BLDC motor control is a three phase system. The diagram in Figure 1 needs more detail to fully explain a BLDC motor control system.


Figure 2: BLDC control block diagram

Notice that this block-level representation works for both sensored and sensorless BLDC motor controllers. The main difference lies in the speed feedback and input sections. A typical sensored BLDC application will use three hall effect sensors as the speed/position feedback, the controller needs only input pins and a timer to detect the switching pattern and swiching period. A sensorless algorithm, on the other hand, will measure the BEMF (back-electromagnetic force) voltage generated by the phase of the motor that is not being driven in a specific moment, to measure the rate of change of this voltage and deduce the motor speed based on that measurement. This requires either an ADC or analog comparator and a timer, plus some more complex code. In following sections, the way Kinetis MCUs’ peripherals solve this is discussed.

Software components

The software that keeps the motor and controller running works with specific characteristics that, in some cases, are only common in control systems. The diagram below shows the most important components in sensored and sensorless BLDC motor control systems.


Figure 3: Typical software components in a sensored BLDC application

There are several things to point out from the above diagrams:
  • Analog inputs: analog inputs need to sample quick enough that data will be available within sampling periods. This is highly critical in sensorless BLDC applications where data needs to be available at least each PWM pulse to precisely determine when the zero crossing happens. Notice the figures below. The first one is an oscilloscope screenshot of the signal typically used to measure BEMF in BLDC motors. As can be noted, the signal is noisy due to the effect of PWM signals on the other phases. Signal needs to be sampled during a specific moment, synchronized to the PWM signal, so that the zero-crossing detection signal is accurate and repeatable (as shown in diagram below).
 

Figure 4: BEMF signal and synchronized sampling window
  • PWM signal commutation: an important process in BLDC motor control is comutation, switching the correct combination outputs on and off to create the 6-step commutation sequence used in BLDC motor control. Besides needing a 6-output PWM module, a BLDC motor control system needs to be able to switch the PWM signals on and off (for commutation). So that there are no glitches in the switching pattern going into the motor, the switching should not interfere or affect the PWM signals (which are asynchronous to the commutation pattern). Periodical glitches translate into uneven torque and even audible noise.
  • Math operations: there are several math procedures happening periodically. The most intensive of which are the PI controllers. To keep a consistent output, the PWM signals have to be periodically updated, the rate at which they are refreshed increases the accuracy of the control, meaning that if the PI controller is executed more frequently, given a properly calibrated and characterized system, the results will be much better. The operations needed to solve a PI controller are usually CPU intensive and is made up of several point product operations. These operations are traditionally slow in a typical CPU core, so both optimized algorithms and specialized instructions designed for digital signal control and processing, such as exectuing several operations at a time or being to grab data from several sources, will make this part of the process more efficient.
  • Delays: the processes described above cannot happen at the exact time or exactly after the other. They need to be timed. In a normal MCU, this would happen usign a timer, manually turning timers on and off. This process of synchronizing the timers at each control period adds up to a lot of time, and it becomes a particular issue when reaching the top speed and the switching happens in very fast periods. Hardware-aided delays and triggers increase the efficiency of a motor controllers by offloading the CPU from them. The diagrams below highlight an example of this.

Figure 5: BEMF signal and synchronized sampling window


Figure 6: Manual triggering

Even with a simplified example it is obvious that being able to automatically trigger an ADC conversion would offload CPU of a task that might otherwise affect the performance of the full application (the difference between being able to communicate at 9600 or 19200 bps, for example.These types of features add up to improve motor control performance. The following section will outline some of the interactions implemented in motor control-enabled MCU to improve performance.

Detailed software – MCU – hardware interaction

The simplest 8-bit MCU is able to do sensored BLDC motor control as long as it has three PWM outputs, three general purpose outputs, three general purpose inputs and one additional timer, with some clever software, even the additional timer may be avoided. This doesn’t mean that it would be an ideal solution, it would probably be limited in speed and torque control, it would also lack the ability to detect faults and take action to avoid failures. Such a solution would make sense in low-end devices using low power and where’s there’s little risk, such as small computer fans.

Most motor control systems need several more features. Torque control: add at least one ADC channel and amplifier (for the shunt resistor). Over and under voltage monitoring: add another ADC channel. Automatic fault detection: add at least one input pin triggering all PWM signals to be disabled. Sensorless operation: add three more ADC channels, preferably linked to delay units that precisely trigger conversions periodically. More complex control algorithms call for even more support features.

The following is a list of features in motor control MCU that help improve BLDC motor control performance:

Feature How it works Why it helps performance
6-channel PWM Being able to control six channels of PWM allows the use of bipolar complementary PWM switching schemes that allow energy regeneration and electric motor breaking. There is no practical or fast enough way of generating six synchronized PWM signals; this is the only way to get the mentioned advantages.
Fast ADC or high-speed comparators Used to detect zero-cross signals to estimate motor speed without sensors. As speed increases BEMF signals also become faster, if the analog is not able to keep up, the top speed the controller can handle is limited, or alias signals can be captured and lead to erratic behavior.
Automatic fault control Disables PWM signals automatically based on a state change on a trigger pin. Near instantaneous shutting down of PWM signals means faster blocking of the hazardous condition and a better chance of avoiding damage to the controller or motor.
Additional timer with input capture An input capture channel is used to correctly sample the period of sensor signals, if analog used in sensorless algorithm is also able to trigger input capture channels, this feature can also help sensorless algorithms. Input capture is a more precise time measurement than polling a pin and turning a timer on and off, there is no software delay involved.
ADC – PWM synchronization The PWM period triggers ADC conversions so that they happen in the same moment periodically. Sampling periodically and in the same PWM switching state (when the power is not acting) helps obtain noise-free samples, refer to Figure 6 below.
Synchronized loading of PWM counter values Instead of each channel value being written directly, all channel values are written to buffer registers and then are all loaded at the same time via a trigger signal. When channels are updated in different moments the temporary inconsistencies in duty cycle (however small) can cause glitches and audible noise in the motor operation.
Complementary switching with dead-time insertion When using complementary switching dead-time insertion is needed to avoid shorting transistors. If dead-time insertion is not available, it has to be done manually by the software during each PWM cycle, this takes away CPU time and limits the top controllable speed.
DSP, fractional, or floating point instructions Several algorithms need intense math operations: PI or PID filtering for speed and torque control, fractional multiplications and divisions for speed and commutation time estimation. Typical RISC or CISC instructions sets without DSP support take many CPU cycles to perform even a single sum operation, optimized operation will save CPU time for other operations or for faster sampling times.
Mask and swap of PWM output plus software output control Ability to preset which PWM signals will be turned off and which on in the following PWM reload cycle or upon a manual trigger, as well as setting the output with software control (overwritting the timer) in specific moments. Makes motor commutations precise and clean, avoiding glitches due to the manual enabling and disabling of all the signals.



Figure 7: PWM to ADC synchronization

Figure 8: Complementary switching with dead time insertion (shown in grey)

Kinetis MCUs

The Freescale Kinetis MCUs, represent the most scalable portfolio of ARM® CortexTM-M4 MCU in the industry. Kinetis devices come in many different derivatives, from low-pin count/low-speed devices, up to Ethernet and high speed USB enabled devices upwards of 120 MHz of bus clock speed. These devices also feature an innovative, 90 nm Thin Film Storage (TFS) Flash Technology with unique FlexMemory (configurable embedded EEPROM). Kinetis devices include a core set of peripherals, and then builds upon basic features to specific applications. Examples of specific peripheral differentiators: segment LCD, USB, ethernet, analog frontend for medical or for metering, etc. The basic feature set in most of the Kinetis devices includes as well all the motor control features which will be detailed in the next section, most devices in the family are able to handle BLDC motor control and other motor control algorithms that will be explained later.

Kinetis motor control features

In the case of motor control, Kinetis MCU family parts include a basic subsystem capable of executing low to mid-complexity motor control algorithms. The following table details these features, building on previous sections, but detailing how Kinetis technology implements the motor control features.

Feature Kinetis peripheral How it is implemented
6-channel PWM FlexTimer module (FTM) There is no practical or fast enough way of generating six synchronized PWM signals; this is the only way to get the mentioned advantages.
Fast ADC ADC Kinetis ADC module can be configured to convert samples in less than 2 uS.
Automatic fault control FlexTimer module (FTM) FTM module has up to four fault inputs which are synchronized with the PWM outputs. When one of the enabled signals is asserted the PWM outputs are stopped and an interrupt can be optionally triggered.
Input capture FlexTimer module Kinetis MCUs include up to three FTM modules. While at least one will have the six channels available to drive a 3-phase inverter in full complementary-bipolar mode, another FTM channel can be configured as an input capture to measure pulse width from hall effect sensors and have a very precise speed measurement. Additionally, input capture channels from the FTM can be triggered by high speed comparators, simplifying the measurement of zero-crossing periods in sensorless algorithms.
ADC-PWM synchronization ADC, FTM, PDB (programable delay block) and HSCMP (high speed comparator) One of the most complex features for motor control enabled in Kinetis MCUs is the ability to synchronize several sources without software intervention. As explained before, sensorless algorithms in particular are sensitive to PWM timing, sampling needs to happen only in certain periods. Kinetis MCUs’ peripherals have triggering sources and sink to allow this to happen automatically. Analog modules (like ADC or HSCMP) can be triggered at specific times by the PDB. The PDB basically receives a trigger from the PWM module (the FTM) and then times an output trigger after a preconfigured amount of time. This whole process would traditionally be controlled by software, taking away resources from the CPU, Kinetis technology takes care of this given some initial configuration.
Synchronized reloading of PWM values FlexTimer module (FTM) FTM is able to load several critical registers that are buffered by the module. The LDOK (load enable) bit enables the loading of buffered values to the actual registers upon a PWM cycle or external trigger, as long as this bit is off, registers are not updated, allowing software to change these values without affecting the output or causing unexpected glitches.
Complementary switching with deadtime insertion FlexTimer module (FTM) FTM is able to automatically insert dead time when it is configured to modulate channel pairs in combined mode (both channels outputting a synchronous signal which may or may not be inverted). The DTEN register enables and disables this function and DTVAL determines how many timer counts dead time is inserted.
DSP instructions Cortex M4- core Even though the ARM® CortexTM-M4 core is not a formal DSP core, it does include DSP instructions that are capable of drastically offloading the CPU of instructions.
Mask and swap of PWM output plus software output control FlexTimer module (FTM) The Outmask register in the FTM determines which outputs are enabled at a particular time. When doing BLDC commutation, it makes the process simpler by allowing the outputs to simply be masked or enabled by manipulating bits in a single register instead of having to turn channels off and on, which is a more complex process and might also end up causing glitches.


Types of motors and control algorithms adequate for Kinetis Technology

With the features mentioned above plus the appropriate motor control software, Kinetis technology is capable of executing the following control algorithms.
  • DC (forward, reverse, bipolar, unipolar): brushed DC motors need no more than a single PWM channel and single input for a sensor to be controlled. More complex algorithms can include the use of a 4-transistor H-bridge for forward-reverse control, as well as bipolar control for current recirculation.
    • FlexTimer module: four PWM channels. If a quadrature encoder is used as a sensor, a second FTM can be used as a quadrature encoder input.
    • ADC: motor current and DC bus voltage (both optional).
    • GPIO: speed/position sensor.
    • DSP instruction: PI controller.
  • Stepper (unipolar, bipolar, full step, half step, microstepping): stepper motors are another type of motor (with brushed DC) that can be very easy to control (unipolar, full step) but can escalate in complexity to arrive to better performance (bipolar, half-step, microstepping). Though many applications don’t even need feedback (it is enough to precisely count the number of steps taken by the controller), microstepping (an algorithm used to obtain a soft torque/stepping profile) does need at least current feedback.
    • FlexTimer module: eight PWM channels.
    • ADC: motor current and DC bus voltage (both optional).
    • GPIO: speed/position sensor.
  • BLDC sensors: as explained earlier, critical components are six channels of PWM and an input capture channel to measure the Hall effect sensor switching period for speed.
    • FlexTimer module: six PWM channels. If a quadrature encoder is used as a sensor, a second FTM can be used as a quadrature encoder input. Synchronized reloading of PWM values. Masking, swapping, and software output control of PWM signals for effective commutation.
    • ADC: motor current and DC bus voltage (both optional).
    • GPIO + 1 input capture: Hall effect speed/position sensor.
    • DSP instructions: PI controller
  • BLDC sensorless: though it might sound similar in complexity, this is one of the tipping points for motor control. Not any MCU will do sensorless BLDC motor with a high performance.
    • FlexTimer module: six PWM channels. Synchronized reloading of PWM values. Masking of PWM signals for effective commutation.
    • ADC: motor current and DC bus voltage (both optional).
    • ADC or comparator: sampling of three phase signals to detect zero crossing.
    • Input capture: measure zero crossing time.
    • Delay block: correctly time the start of sampling without any CPU intervention.
    • DSP instructions: PI controller.
  • PMSM with sensors (FOC, sinusoidal modulation, three shunt resistors): PMS (permanent magnet synchronous) motors are similar in construction to a BLDC motor: permanent magnet rotor and stator with 3-phase winding. The difference with PMSM motor is in the fact that, because of their construction, they can be more effectively controlled by sinusoidal signals (emulated by PWM outputs). Field oriented control (FOC) is the advanced technique used in conjunction with sinusoidal modulation to control these motors, it consists on mathematically (with matrix operations) converting the sensed current that powers the motor from sinusoidal signals into two linear vectors. These vectors are then controlled with PI controllers and then transformed back into sinusoidal signals. It is beyond the scope of this paper to describe the algorithm any further. More information on this and other techniques can be obtained from www.freescale.com/motorcontrol
  • PMSM sensorless (FOC, sinusoidal modulation, three shunt resistors): PMSM sensorless technique are very complicated to implement and demanding on the CPU. It is possible for Kinetis MCUs to run a PMSM sensorless algorithm, but it might reach a practical limit in terms of available resources to execute other critical tasks.
  • ACIM V/Hz: ACIM (alternate current induction motors) are another important leap in motor control complexity. The most important reason for this is the fact that they are asynchronous. While previously described motors have a permanent magnet rotor that makes the rotor completely synchronous to the stator electric field (when controlled correctly), the ACIM motor does not have permanent magnets, so the core “follows” the stator electric field but with a certain angle of phase difference that is called “slip.” In these motors, the relationship between motor speed, torque, frequency, and voltage is not linear, so the precise control of these motors is very complex. One technique that is used to simplify ACIM control is to use Volts-per-Hertz (V/Hz) profile. Essentially it means to create a table of values of voltage and frequency in which the motor will accelerate appropiately. This technique does not output the most precise results but it is simple, so in many applications that don’t need a very high precision, this can be a good fit.
Freescale has a privileged position in the market to offer a wide range of solutions to satisfy virtually all of customer needs. When it comes to more advanced motor control solutions, Freescale offers an extensive portfolio to cover even the most demanding application.

In some cases, the need of dedicated DSP of DSC controller might be required. Freescale has an extensive library of solutions implemented in Digital Signal Controllers or Power Architecture® technology that can help customers quickly tackle challenges presented by the implementation of advanced motor control algorithms such as complex ranges of Field Oriented Control, single shunt PMSM control or even advanced sensorless start-up processes. For access of Freescale’s library of motor control solutions, please visit www.freescale.com/motorcontrol.

Ideal Kinetis Technology + motor control applications

Kinetis MCUs are ideally suited to be used in many motor control applications. By providing an extensive roadmap of pin-to-pin compatible solutions and key modules designed for optimal motor control.

Examples of motor control applications ideally suited for Kinetis MCUs:
  • Small to medium size appliances: many appliances don’t need advanced motor control but would benefit from a simpler motor control coupled with other features in Kinetis technology, for example, a high end coffee maker could have a motor controller in the water pump or an integrated coffee grinder.
  • Toys: many toys use simple, cost effective motors for everything from vibration to robotic movement.
  • Industrial controls: though many industrial control systems are distributed and rely on networks of processors, a cost effective or multipurpose industrial panel could include an embedded BLDC controller for use in small conveyor belts, fans or pumps, etc.
Conclusion

Freescale has a history of innovation in the Motor Control market, with the addition of the Kinetis Family to the portfolio of motor control solutions; Freescale continues to expand its breath of options to fit various customer requirements.

Driven by the market’s constant needs to reduce power consumption, noise and increase efficiency, the use of BLDC motors continues to increase. Freescale is commited to offer targeted solutions to help customers quickly implement motor control to their application whether it's in the factory automation market, appliances, or medical. We understand the challenges the customer faces and with the continuous addition of products and enablement solutions, we try to get the customer to market quickly and efficiently.

The Kinetis MCU family represents a great option for a large number Motor Control applications in many segments of the industry. Freescale’s introduced 120-150 MHz ARM® CortexTM-M4 core with DSP functionality, and features such as single cycle MAC, single instruction multiple data (SMID) extensions and single precision floationg point unit support the intensive math processing algorithms required for motor control applications. Key modules specifically designed to undertake motor control tasks, such as Freescale’s FlexTimers offer up to a total of 20 channels. Hardware dead-time insertion and quadrature decoding, as well as a precise ADC converstion module, enable the Kinetis family to address many of your motor control needs.

Wherever your motor control needs take you, don’t hesitate to visit Freescale’s website for the most up to date information on motor control solutions at www.freescale.com/motorcontrol.

References
  1. For more motor control information, applications, reference designs, recommended parts, etc. visit:
    www.freescale.com/motorcontrol
  2. For further information on the Kinetis family of microcontrollers as well as training resources visit:
    www.freescale.com/Kinetis
  3. For further information on the DSC family as well as training resources visit:
    www.freescale.com/DSC
  4. And the ARM home page for Cortex M4:
    http://www.arm.com/products/processors/cortex-m/cortex-m4-processor.php
Supplier