Get Your Motor Running With the NXP Kinetis Motor Suite

Brushless DC (BLDC) and permanent magnet synchronous motors (PMSMs) are now favored in many applications, but the control software to run them can be daunting to implement. Kinetis Motor Suite from NXP bridges that gap with embedded control software and an intuitive GUI to minimize the software complexity and speed up the development process.

This article will provide a short introduction to BLDC and PMSM motor construction and key operational parameters, before getting into how to drive them. It will then discuss why the software is complex, how to manage that, and some hardware options. It will then look at how to get a project up and running with NXP’s Kinetis Motor Suite.

Three-phase brushless DC motors (BLDC) and their close cousins, permanent magnet synchronous motors (PMSMs), have become industry workhorses in the last decade as the cost of their control electronics has decreased dramatically and new control algorithms have proliferated. BLDC motors offer high reliability, high efficiency and high power-to-volume ratio. They can run at high speed (greater than 10,000 rpm), have low rotor inertia allowing for quick acceleration, deceleration and quick reverse, and have high power density, packing a lot of torque into compact sizes. Today, they are used in any number of applications, including fans, pumps, vacuums, quadcopters and medical devices, to name just a few.

PMSMs have similar construction to the BLDC with a wound stator and permanent magnet rotor, but the stator construction and winding is more similar to an AC induction motor, producing a sinusoidal flux density in the air gap. PMSMs run synchronously with the applied 3-phase AC voltage and have higher power density than AC induction motors because no stator power is going towards inducing the magnetic field in the rotor. Today’s designs are also more powerful while having a lower mass and moment of inertia, making them attractive for industrial drives, traction applications and appliances.

Creating the drive

Given these advantages it’s no wonder that these motors have become so popular. However, nothing comes without a price, and in this case it is the complexity of drive and control circuitry. The elimination of commutating brushes (and their accompanying reliability issues) imposes the need for electrical commutation to create the stator rotating field. This requires a power stage (Figure 1).

Simplified block diagram of a 3-phase motor drive

Figure 1: Simplified block diagram of a 3-phase motor drive. The three half bridges switch the motor phase currents under the direction of the controller, the output of which is amplified and level shifted by the pre-driver. (Diagram drawn using Digi-Key Scheme-it)

The star-connected motor phases are attached to three half-bridge driver circuits. These use power FETs to switch the bus power to energize the windings, although other types of power devices, such as IGBTs, can also be used. The FETs are driven by a pre-driver stage that level shifts and amplifies the phase inputs from the motor controller, which can be a MCU, DSP, FPGA state-machine, or some other programmable controller. Using feedback from the motor (not shown in Figure 1), the controller sequences the bridge FETs to create a rotating magnetic field that pulls the rotor around.

There are two common waveforms used to do this. The first is a six-step trapezoidal drive, where 360 degrees of electrical rotation are broken up into 60-degree steps. The second is a sinusoidal drive, where PWM sine voltage waveforms offset by 120 degrees are driven in the motor phases. Trapezoidal control is often used with BLDC motors, as it is easier to implement. Sinusoidal control offers higher motor efficiency and less ripple, and can be used with both BLDC motors and PMSMs.

The circuit shown in Figure 1 can be realized in many ways. For low-power, single-function applications like fan control, all the blocks can be integrated into one chip. For more complex applications like medical devices, the pre-driver and power FETs might be integrated into one IC. The controller is implemented separately so it can handle other functions in the application. For high-power industrial or electric-vehicle drives, the controller, pre-driver and power stage are all separate. The galvanic isolation is added between the high bus voltage of the motor and driver and the low-voltage signals of the controller.

Controlling the current

Since the currents need to be adjusted to control speed under varying load, a feedback-control mechanism must be employed. This is where it gets complicated. To get good speed control with good dynamic torque response, a technique known as vector control (also known as field oriented control, or FOC) is employed in a sinusoidal drive.

The details of FOC are beyond the scope of this article. In essence, the stator phase currents are measured and then converted from three dimensions to a two-dimensional coordinate space, using matrix operations. The resulting 2D vector represents the motor flux linkage and the motor torque. Typically, a proportional-integral (PI) controller is then used to adjust these 2D current components to match the needs of an outer speed-control loop (determined by another PI controller) before being converted back to 3D phasor currents to be applied to the 6-step drive.

In order for the control equations to work, the position of the motor rotor needs to be determined. Aside from embedding a true shaft encoder in the motor, there are two main options: use Hall-effect sensors, called sensored control; or sense the back EMF (electromotive force) of the motor, called sensorless control. Sensorless is becoming the most common due to lower cost, but both require the motor to be turning in order to sense the true position. Motor startup can be tricky under this condition, as it needs to start up in open-loop mode until the motor position is determined.

Once the control software is developed, the control system needs to be tuned. The PI controller’s parameters must be adjusted to match the motor type, load variation and other potential disturbance factors. These parameters control the step response and bandwidth of the controller. If they are set too low, the motor response will lag. If they are set too high, the controller can oscillate and become unstable. Once the control software is written and debugged, months of testing and adjusting are often required to get the required response across all conditions.

Managing the software complexity

The complexity of the math involved with these control equations necessitates a compute platform with enhanced math or DSP instructions. It also needs to have fast analog-to-digital (A/D) conversion capability to measure the motor currents, as well as specialized timer modules to produce precisely aligned PWM signals. Off-loading these functions to a DSP, or other dedicated processor, frees the CPU to perform other application tasks.

Fortunately, low-cost MCUs specifically targeting FOC motor control are now on the market. NXP, for example, offers a family of ARM® Cortex®-M-based motor-control devices called the Kinetis V series (Figure 2).

Diagram of NXP Kinetis V series of ARM Cortex-M-based MCUs (click for full-size)

Figure 2: The NXP Kinetis V series of ARM Cortex-M-based MCUs has high-performance cores, motor-control timers, fast A/D converters and various memory and package sizes. (Image source: NXP)

The Kinetis V series scales in core capability, memory sizes, timers and A/D-converter channels, digital-to-analog (D/A) converters, and comparators. This allows optimized implementation of simple BLDC speed control on the low end, all the way up to multiple PMSMs with the high-end devices. The Cortex-M0+ core found in the KV1x MCU family is augmented with hardware square root and divide functions. This makes the Kinetis KV1x devices suitable for BLDC and PMSM motors with relatively constant load and control-loop frequencies less than 12 KHz.

The Kinetis KV3x and KV4x MCU families use the Cortex-M4 core, which supports DSP functions and floating-point math. These devices can support higher dynamic load applications with control loops up to 20 KHz, and very high-performance solutions. The Kinetis KV5x MCU family features the Cortex-M7 core along with Ethernet connectivity and security IP.

The FlexTimer and eFlexPWM timers support dead-time insertion to eliminate current shoot through as phase legs turn off, as well as other motor-specific features. The FlexTimer has a single time base per timer block, while the eFlexPWM can support up to four time bases per PWM block, giving great flexibility over PWM generation and synchronization for advanced motor-control algorithms.

The A/D blocks enable capturing and processing of two signals simultaneously, which is important for sensorless control. The sampling frequency increases on the higher-end devices. All parts also have one or more 12-bit D/As and a corresponding number of comparators, relative to the number of PWM channels, with 6-bit reference D/A converters.

Motor-control-optimized processors are one part of the equation, but that still leaves the problem of developing the FOC software, which in the past required deep expertise in motor management and control theory. However, that barrier has now been reduced thanks to a new free tool available from NXP – the Kinetis Motor Suite (KMS).

KMS is a hardware and software solution that includes proprietary FOC motor-control IP contained in protected flash memory on select Kinetis V series MCUs and a simple-to-use GUI to setup and tune the motor system. KMS eliminates the need for in-depth knowledge of motor control, allowing those with limited expertise to develop an application and then embed it with the rest of the application software. KMS can get a motor running and tuned in as little as 30 minutes.

Getting started with KMS

Here is how to get started developing your own motor-control solution. The easiest approach is to purchase an FRDM-V31F Freedom development platform and corresponding high- or low-voltage platform driver board. In this case we will use the FRDM-MC-LVPMSM Freedom evaluation board. If you are a Tower System development board user, there are also suitable processor and driver boards available for that platform.

To this you will need to add your motor and an appropriate DC source for the motor voltage. If you don’t have a motor, a good option is the FRDM-MC-LVMTR-ND, a 24 V, 3-phase BLDC motor from NXP for the Freedom Development Kit.

The FRDM-V31F board has the MKV31F128VLH10P microcontroller on board. This contains the embedded KMS IP. Please note that only Kinetis microcontrollers with the “P” suffix contain the KMS IP.

Once you have the boards, it’s time to get the software tools from the Kinetis Motor Suite getting started page, where there are links to download the three tools you need, including:

  • Kinetis Software Development Kit (KSDK)
  • Kinetis Design Studio (KDS) Integrated Development Environment (IDE)
  • Kinetis Motor Suite.

Now it’s time to assemble the hardware. Connect the two Freedom boards together by plugging the 3-phase FRDM-MC-LVPMSM board into the FRDM-KV31F board with the FRDM-MC-LVPMSM board on top. Connect the three phase terminals of the motor to the FRDM-MC-LVPMSM board and connect the motor voltage via the power input jack. Connect the USB-to-mini-USB cable between your computer and the FRDM-KV31F. The green power LED on the microcontroller board should light up and the RGB LED on the same board should flash. You are now ready to make motor measurements and spin your motor.

Launch Kinetis Motor Suite and select a new project. It will ask you to identify your hardware platform (Freedom, High Voltage or Tower system), the control type (Sensored Position, Sensorless Velocity, or Sensored Velocity), and development environment (IAR or Kinetis Design Studio IDE.)

After giving your project a name and selecting a COM port you will be asked to enter your motor’s basic information. You will need to know your motor’s rated speed, rated RMS current, rated voltage and the number of pole pairs (Figure 3).

Image of KMS screen to enter motor information

Figure 3: KMS screen to enter motor information. The values shown are for the FRDM-MC-LVMTR board. These values are used by the embedded control algorithm to control the motor. (Image source: NXP)

Once these are entered, KMS will energize and rotate your motor to measure its electrical characteristics – stator resistance, stator inductance and stator flux (Figure 4). It needs these to adjust the motor control parameters later on. Make sure the motor is disconnected from the load during this step.

Image of KMS screen to enable measurement of motor electrical characteristics

Figure 4: KMS screen to enable measurement of motor electrical characteristics. The values are updated by KMS as it measures and spins the motor. (Image source: NXP)

Next, KMS will measure the mechanical inertia of the system by quickly spinning the motor up and down. This should be done either bare shaft or connected to other system mechanical components, such as gears or belts, but not to the dynamic load.

KMS now has all the information it needs to run the motor at rated speed. A simple mouse click starts the test and KMS brings up a software oscilloscope to show you the motor startup, the transition from open loop to closed loop control and then ramp up to rated speed (Figure 5).

Graph of KMS starts the motor and ramps up 

Figure 5: KMS starts the motor and ramps up to rated speed while displaying the RPM on a speed/time graph. (Image source: NXP)

By performing just these four steps, KMS has determined the necessary parameters and programmed the control loops to get your motor running without requiring one line of control code to be written.

Tune it up

However, we have not yet tuned the motor. KMS also assists in this often-difficult task by using Active Disturbance Rejection Control (ADRC). This is a part of the SpinTAC™ Control system from Linestream Technologies and is embedded within KMS. ADRC replaces proportional- integral-differential (PID) control within KMS and uses the motor characteristics and system inertia from the set-up steps to tune the controller. The user only needs to set one parameter: bandwidth. This requires two steps to tune the motor.

The first step is to run the motor at minimum speed and set the maximum bandwidth that generates a stable speed using the KMS Speed Controller (Figure 6).

Image of KMS Speed Controller input

Figure 6: KMS Speed Controller input. Clicking on the bandwidth arc will set a new value. (Image source: NXP)

Then run the motor at maximum speed and adjust the bandwidth down, if necessary, to obtain stable operation. The motor is now tuned.

Tuning using ADRC not only adjusts for motor and inertia parameters, but also addresses other disturbances from the non-ideal case, such as load change, bearing wear, and friction change. It does so because it actively estimates these disturbances and compensates for them in real time, and ADRC performs better than PI controllers. This is shown in Figures 7 and 8.

Image of performance comparison of PI controller vs. SpinTAC controller

Figure 7: Performance comparison of PI controller vs. SpinTAC controller for applied torque disturbance. The SpinTAC controller has less error and faster settling time than the PI controller.

Graph of performance comparison of PI controller vs. SpinTAC controller

Figure 8: Performance comparison of PI controller vs. SpinTAC controller for removed torque disturbance. The SpinTAC controller has the same error and faster settling time than the PI controller.

These figures show the PI and SpinTAC controllers response to a 50% torque increase and removal on a motor running at 75% rated speed. The initial controller error is better or the same for the SpinTAC controller, and the settling time is faster than the PI controller. The adaptive nature of ADRC improves on standard PI controllers across the range of controller disturbances, without the need for further tuning or run-time adjustments.

Next steps

There you have it. Your motor is running and tuned without writing one line of code. However, we have just scratched the surface of the capability of KMS. It can be used to program motion sequences, adjust startup parameters, perform torque control, provide braking and protection features, and fine tune many parameters to your application.

Of course to build your final product you will need to adjust and convert the KMS firmware to your final hardware configuration and embed it within your application firmware. NXP provides a comprehensive app note for converting to your custom hardware along with a complete API reference manual. You can continue to use the tools within KMS to adjust and fine-tune your application, right up to product release and commissioning.

Conclusion

BLDC and PMSMs are workhorse motors with many applications, but they typically require careful attention position sensing, driving circuitry and control software. NXP has simplified the task of developing motor drive applications through the introduction of KMS. Using this hardware and software solution you don’t necessarily need to know all the details of motor drives and control, so even with limited expertise, you can get a motor running and tuned in as little as 30 minutes. 

  • Get Your Motor Running With the NXP Kinetis Motor Suite已关闭评论
    A+
发布日期:2019年07月14日  所属分类:参考设计