BeyondBitsIssue 8 MOTOR CONTROL EDITION

Motor Control

Introducing Motor Control Motor control and motor drive solutions

With a rich history of innovation in motor control, Freescale is dedicated to continue our commitment to understand and solve the current roadblocks developers face with a comprehensive portfolio of solutions.

The latest edition of Beyond Bits captures the attention of both novice and advanced motor control developers looking to:

• Reduce development time by jump starting their effort with reference designs, application notes and a global support team

• Increase power efficiency by using the most advanced control techniques available through differentiated hardware platforms and peripherals, motor control libraries, and unique tools to optimize these systems

• Decrease system costs via a best-in-class portfolio of high-performance, low-power MCUs capable of very flexible, innovative control implementations

• Comply with safety and energy mandates via complimentary libraries and advanced algorithms

Beyond Bits provides a brief glimpse into the breadth and scope of the Freescale motor control portfolio, much of it unique and built over decades of research and development. We discuss the advantages of different motor types and the methods of control, followed by a portfolio overview and a helpful selection guide. Next, we provide application examples and techniques we’ve implemented using our solutions, and we close with our software and development tools offerings. Solutions such as reference designs, application notes, software, tools and MCU families are listed at the end of each article to help you get started right away on your next design.

Freescale continues to partner with innovators to make motors quieter, more efficient, smaller and to reduce mechanical vibration, and hopefully we can help you make them even smarter.

To refine your motor skills, visit freescale.com/motorcontrol or contact your local Freescale field applications engineer.

Regards,

Geoff Lees Vice President and General Manager, Industrial and Multi-Market Business

freescale.com/motorcontrol 1 Introduction 4 Motor Types and Their Control 7 An Introduction to Freescale MCUs 8 Control Wizard in the Freescale Solution Advisor Market Trends 10 BLDC Motor Control 13 Permanent Magnet Synchronous Motor Control 15 AC Induction Motor Control 17 Switched Reluctance Motors 19 Encoder Signal Processing 21 Three-Phase Current Measurement Application Examples 25 Select Freescale Solutions for Your Application 27 Motor Applications for Small Appliances 29 Digital Control of Switched Reluctance Motor Drives 31 Industrial/Appliance Consumer Ceiling Fan 34 Household Washing Machines 36 Dual Motor Control for Air Conditioning with 100 MHz/32-bit DSC 38 Industrial/Appliance PMSM Drive 40 Industrial Drives 43 Digital AC Drive Control 45 Servo Robots for Industrial Applications: PMSM with Encoder 47 Continuous Positive Airway Pressure (CPAP) Machine 49 BLDC Motor Control for Respirators 51 Motor Control Using MQX RTOS Enablement 53 Freescale Motor Control Boards 55 Freescale Embedded Software Libraries 56 Motor Control Development Toolbox 59 Motor Application Tuning Wizard 60 FreeMASTER Summary

Table of Contents Table of Contents Introduction Introduction

Motor Types and Their Control Summary of key motor types and control

Overview Motor types that most effectively sensor wiring, sensor power supply Freescale provides comprehensive meet these requirements include AC and increases reliability. Still, there motor control solutions for almost all induction motors (ACIM), permanent are applications where higher cost of electric motor topologies. magnet synchronous motors (PMSM), sensors is not as important as higher brushless DC motors (BLDC) and position resolution. The most common Motor Control Application switched reluctance motors (SR). speed/position sensors are: Requirements The following pages will cover their • Tachogenerators • Minimize energy losses main characteristics, types of control, • Hall sensors • Prevent environment pollution advantages and typical applications. • Encoders • Decrease acoustic noise and Digital Motor Control power harmonics • Resolvers Digital control allows more efficient • Increase system performance- Applications requiring the motor to motor control with variable speed and versus-cost ratio operate with a required speed (pumps, sensorless control. The term sensorless fans, compressors, etc.) are speed • Increase productivity, flexibility control means that there is no position/ controlled. In variable frequency drives, and robustness velocity sensor on the motor shaft, so motor speed is typically proportional • Increase safety and reliability the rotor position/velocity is calculated to frequency. The actual motor speed • Reduce system size and weight from measured current and voltage. is maintained by a speed controller • Growth of digital control and The sensorless control provides a to reference speed command. reducing usage of analog cost-effective and reliable solution that Speed control offers low dynamic components and total system cost eliminates the position/velocity sensor, performance. For high dynamic and

Figure 1: Electric Motor Type Classification

Electric Motors

AC DC

Asynchronous Synchronous Variable Reluctance

Induction Sinusoidal Brushless Reluctance SR Stepper

Permanent Magnet

Surface PM

Interior PM

Wound Field

4 Beyond Bits Motor Control Edition

stability performance, speed control This requires additional connections Permanent Magnet with inner current loop (cascade to the motor, which may not be Synchronous Motor control) is required. The majority of acceptable in some applications. variable speed drives are controlled by Also, the additional cost of the cascade control. Most complex drives position sensors and the wiring (servos, industrial robots, linear motors) may be unacceptable. The physical require additional position control. connection problem could be solved Applications requiring the motor by incorporating the driver in the motor to operate with a specified torque body, however, a significant number regardless of speed (hand tools, electric of applications do require a sensorless power steering, traction, vehicles, etc.) solution due to their low-cost nature. employ torque control. Most BLDC sensorless techniques Brushless DC Motor are based upon extracting position information from the back EMF voltage of the stator windings while the motor is spinning. Those techniques could be Similar to BLDC motors, PMSMs used from 5 percent of nominal speed, have a three-phase stator and a when back EMF is measurable. BLDC rotor with surface/interior-mounted back EMF sensorless techniques permanent magnets. can be used without complex control A PMSM provides rotation at a fixed algorithms, due to back EMF voltage speed in synchronization with the sensing in unexcited motor phase. frequency of the power source. PMSMs Advantages are therefore ideal for high-accuracy • Heat generated in stator is easy fixed-speed drives. Boasting very high- to remove power density, very high efficiency and high response, the motor is suitable for • High torque per frame size BLDC motors have a three-phase most sophisticated applications in the • Reliability due to absence of brushes stator winding and a rotor with industrial segment. It also has a high and commutator surface-mounted permanent magnets. overload capability. A PMSM is largely A BLDC motor does not have a • Highest efficiency maintenance free, which ensures the commutator and is more reliable than • Good high-speed performance most efficient operation. a DC motor. The digital control and • Precise speed monitoring and Synchronous motors operate at power electronics replace the function regulation possible an improved power factor, thereby of the commutator and energize the improving the overall system power proper winding. They are used in home Drawbacks factor and eliminating or reducing utility appliances (such as refrigerators, • Rotor position sensing required for power factor penalties. An improved washing machines and dishwashers), commutation power factor also reduces the system’s pumps, fans and other devices that • Torque ripple voltage drop and the voltage drop at require high reliability and efficiency. • Position sensor or sensorless the motor terminals. In the BLDC motor, the rotor position technique is required for motor Advantages must be known to energize the phase operation • Heat generated in stator is easy pair and control the phase voltage. • Difficult to startup the motor for to remove variable load using sensorless If sensors are used to detect rotor • High torque per frame size position, then sensed information must technique • Reliability due to absence of brushes be transferred to a control unit. and commutator • Highest efficiency • Synchronous operation makes field orientation easy freescale.com/motorcontrol 5 Introduction

• Good high-speed performance Advantages tries to minimize the reluctance (air gap • Precise speed monitoring and • Low cost per horsepower distance) of the magnetic circuit. The regulation possible (no permanent magnets) magnetic field creates a force on the rotor so that its poles line up with the • Smooth torque • Inherent AC operation (direct connection to AC line) poles of stator phase. Drawbacks • Very low maintenance (no brushes) • Rotor position sensing required Advantages and rugged construction • Low cost resulting from simple • Position sensor or sensorless • Available in wide range of construction technique is required for power ratings motor operation • High reliability • Low-cost speed control • Difficult to startup the motor using • High fault tolerance with tachogenerator sensorless technique • Heat generated in stator is easy • Simple control (volt per hertz + PFC to remove AC Induction Motor can handle 8-bit MCU) • High-speed operation possible Drawbacks Drawbacks • Inefficient at light loads • Acoustically noisy • Rotor temperature change • High vibration complicates sensorless control • Magnetic non-linearities make • Speed control requires varying smooth torque control difficult stator frequency • Dependent on electronic control • Position control difficult (field for operation orientation required) For more information about Freescale Switched motor control solutions, visit Reluctance Motor freescale.com/motorcontrol.

ACIM is the most popular motor for industrial and consumer applications. This is due to many factors such as the lack of commutator/brushes (high reliability), high efficiency at high loads and the ability to connect directly to the AC line. ACIMs have a classic three-phase stator and commonly have a “squirrel cage” rotor in which the conductors are shorted together at both ends. The operation principle of ACIM is very similar to a SR motors do not contain magnets transformer. A rotor current is induced and are constructed such that both in the rotor circuit from the stator the stator and rotor have salient poles. windings. This current produces rotor The motor is driven by a sequence of flux, which interacts with the stator current pulses applied at each phase, electromagnets to produce torque. which requires control electronics for operation. The SR motor works on the principle that the magnetic circuit

6 Beyond Bits Motor Control Edition

An Introduction to Freescale MCUs For motor control

Freescale is a leading supplier of DSC solutions can tailor almost any Our Commitment to embedded controllers with a strong motor control application. Long-Term Supply legacy of offering solutions for motor Freescale is committed to ensuring control applications. Our broad Kinetis MCUs our products are available for our portfolio of MCUs spans across 8-, Based on the 32-bit customers through the entire lifetime 16- and 32-bit platforms, featuring ARM® Cortex™-M Core of their systems. To that extent, low-power, analog, control and 32-bit Kinetis MCUs represent the most Freescale commits to a minimum communications hardware. scalable portfolio of ARM Cortex-M product cycle of 10, and in some core-based MCUs in the industry. cases, 15 years for our MCUs Freescale 8-bit HC(R)S08 There are more than 300 MCUs in targeting the industrial, automotive and MCU portfolio the portfolio spanning the entry-level medical markets. For product longevity Kinetis L MCUs based on the ARM Our portfolio of 8-bit MCUs provides terms and conditions, and to obtain a Cortex™-M0+ core and Kinetis K series a wide range of highly functional list of available products, visit MCUs based on the ARM Cortex™-M4 solutions for low- to mid-range freescale.com/productlongevity. industrial and automotive motor core with IP compatibility across the control applications. From tiny RS08 range as well as pin compatibility devices to highly functional S08 across parts offered within the same controllers combining timers and portfolio. Enabled by innovative 90 nm analog integration along with a range thin film storage (TFS) flash technology of connectivity and HMI peripherals, with unique FlexMemory (configurable 8-bit MCUs are an ideal solution for embedded EEPROM), Kinetis MCUs simple, cost-sensitive motor control feature the latest low-power innovations applications. Within the S08 family and high-performance, high-precision there is a wide range of 5-volt options mixed-signal capability. Kinetis MCUs are supported by market-leading that offer more durability and reliability enablement from Freescale and our in harsh industrial environments, ecosystem partners. The Kinetis line is meeting appliance safety standard suitable for a wide range of low- to mid- IEC60730. Our 5-volt S08 families offer range motor control applications. exceptional EFT/ESD performance.

16- and 32-bit DSCs It’s More Than Just Silicon Freescale is dedicated to providing Freescale DSCs combine DSP semiconductor solutions that build value speed with MCU control for the ideal into your products. When you purchase industrial motion control solution. from us, you’re buying more than These flexible 16- and 32-bit devices just an embedded processor. You’re are particularly well suited for electric getting access to a broad ecosystem of motor control with timers and analog technical support services, development peripherals specifically designed to tools and training—all designed to make meet the requirements of the most your job easier and your end products demanding motor control application. better. In this brochure, you will learn With a range of solutions from cost- more about the resources we are effective options in small flash and providing beyond our MCUs that you package combinations to highly can harness through your design effort. integrated and optimized options, our

freescale.com/motorcontrol 7 Introduction

Control Wizard in the Freescale Solution Advisor

Not sure where to start? The Figure 1: Find Best-Fit Motor Control Process Solutions Freescale Solution Advisor is a web- based tool that helps identify best-fit processors and tools for any type of design. The tool can check pin muxing, identify supporting Tower System modules, link related reference platforms, software and application notes, and then save the details in one place to share with your team. The Solution Advisor is so powerful that we like to call it our “virtual FAE” who never sleeps. To recommend best options for your motor control application, the embedded Motor Control Wizard • Which control algorithm? After the Motor Control Wizard works begins by asking six simple, multiple- its magic, you can further refine choice questions: BLDC trapezoidal commutation control, scalar control (V/Hz), or the recommended processors by • What is your application? sinusoidal vector control (field- identifying specific requirements, such as the number and type of analog-to- Large appliance, small appliance, oriented control) digital (ADC) interfaces, timers, pulse power tool, portable electronics, • Which sensor type? width modulators (PWM) and the computing, data storage Open loop, hall sensor, encoder, support for tools such as Freescale equipment, robotics, HVAC, tacho generator, sensorless, etc. FreeMASTER and the Mathworks heavy industrial MATLAB™/Simulink™. The Solution The Motor Control Wizard knows • What is your function? Advisor can then recommend which specialized peripherals and appropriate Tower System modules, Compressor, pump, fan, rotator, performance are needed for hundreds link related reference platforms and actuator or servo, dual motor of requirement combinations, and how application notes, and save sessions control, inverter they map to the available Freescale for later. No matter when you need solutions. For example: • What motor type are you using? assistance, the Freescale Solution AC induction motor (ACIM), • For small motors and appliances, Advisor is ready to help. brushless DC motor (BLDC), use 8-bit S08 or Kinetis L series For more information, visit permanent magnet synchronous controllers freescale.com/solutionadvisor. motor (PMSM), etc. • For cost-optimized high-performance motors requiring 20 microsecond • Select all the features you’d like control loops, use DSCs from the list below. • For high-performance motors with Quiet motor operation, high- high reliability and IEC61508 safety speed motor (> 10K RPM), requirements, use MCUs precise speed, precise torque control, heavy lifting or high torque, etc.

8 Market Trends Market Trends

BLDC Motor Control Trapezoidal back EMF BLDC motor control techniques

Three-Phase BLDC Motor Figure 1: Six-Step Commutation The brushless DC (BLDC) Voltage motor is also referred to as an +UDCB electronically commutated motor. Phase A There are no brushes on the rotor, -U and commutation is performed DCB +UDCB electronically at certain rotor positions. The stator magnetic circuit is usually Phase B

made from magnetic steel sheets. -UDCB +U Magnetization of the permanent DCB magnets and their displacement Phase C on the rotor are chosen in such a -UDCB way that the back EMF (the voltage 30º 60º 90º 120º 150º 180º 210º 240º 270º 300º 330º Electrical induced into the stator winding due to Angle rotor movement) shape is trapezoidal. This allows a rectangular shaped three-phase voltage system (see Figure 2: Power Stage Topology figure 1) to be used to create a Three-Phase Power Stage rotational field with low torque ripples. C

PWM1 PWM3 PWM5 Six-Step BLDC Motor S S S Commutation AT BT CT Power B The rectangular shape of applied Source A voltage ensures the simplicity of DC Voltage control and drive. The BLDC motor PWM2 PWM4 PWM6 rotation is controlled by a six-step S S S Three-Phase BLDC Motor AB BB CB commutation technique (sometimes called 60, 120 degree control).

The six-step technique creates the MOSFET/1 GB Drivers voltage system with six vectors over PWM1 PWM2 PWM3 PWM4 PWM5 PWM6 one electronic rotation as shown in Pulse Width Modulator figure 1. The applied voltage needs (PWM) Module (Flex Timer) MCU to have amplitude and phase aligned with the back EMF. Therefore, the BLDC motor controller must: motor is controlled with minimal torque Voltage Amplitude • Control the applied amplitude ripple and maximal power efficiency. Controlled by PWM • Synchronize the six-step One possibility to control the three- commutation with the rotor position Three-Phase Power Stage phase six-step voltage amplitude is The three-phase six-step voltage The rotor position must be known at to have a variable power source DC system is created by a three-phase certain angles in order to synchronize voltage. This solution requires DC bus power stage with six IGBTs (MOSFET) the applied voltage with the back EMF voltage controlled with quite complex power switches controlled by the MCU (voltage induced due to movement of topology. The benefit of such a solution on-chip PWM module. the PM). Under that condition, the BLDC is the lack of high-frequency current

10 Beyond Bits Motor Control Edition

Figure 3: Six-Step Commutation Specifics ranges. In that case, one PWM pulse per motor commutation is introduced. This also means the PWM frequency A B C varies according to motor speed.

0 Position Feedback % The rotor position must be known in 1. 3. 5. order to drive a BLDC motor. This is provided with: 0 • Position sensors, or % 2. 4. 6. • Sensorless The solution with position sensors usually utilizes hall sensors. The main disadvantages are: BLDC ØA • Necessity for additional connections between position sensors and the ØC ØB control unit USc = UbackEMFc • Cost of the sensors and wiring Therefore, sensorless techniques are much more widespread today. There are two main groups for the ripples in the BLDC motor windings, determined by all six transistors (Sat to sensorless techniques: resulting in lower loss (especially the Scb) switching as shown in Figure 2. • Those based on back EMF sensing motor magnetic circuit loss). The four quadrant control requires For the majority of the motors and complementary PWMs. The • Low-speed techniques applications, this is not critical and a complementary PWM means that the The sensorless techniques based on constant power source DC voltage bottom switch (transistor) is controlled back EMF sensing are dedicated for is used. The three-phase average with a signal inversed to the top medium (>5 percent of nominal speed) voltage amplitude is then controlled switch transistor of the same phase. to high-speed range because they by a PWM technique on the top and The two quadrant control does not require significant value of the induced bottom transistors of two conducting require complementary control of the back EMF voltage. This voltage is motor phases (the third phase is off). inverter switches. The unipolar PWM proportional to rotor speed. The six-step controller uses one of complementary switching is more The low-speed techniques are two PWM techniques: popular due to lower loss. The applied based mainly on motor inductance • Bipolar PWM switching voltage vector at one PWM cycle has alteration on rotor position, so this the same polarity. The vector amplitude • Unipolar PWM switching does not require the back EMF changes from DC bus voltage and and can be used at low-speed, or There are a few derivatives of the two zero. In the case of the bipolar PWM zero-speed control range. Some of PWM switching techniques. According switching, the applied voltage vector these techniques require complex to the operating quadrants of the polarity changes during the PWM hardware which increases system power stage voltage and current: cycle, so the applied amplitude cost. At high speed, the back EMF is • Four quadrant power stage control changes from positive DC bus voltage more significant than the inductance for motoring and generating mode to negative DC bus voltage. alteration, so most of the controllers • Two quadrant power stage control The PWM frequency is usually use a combination of a low-speed with motoring mode only constant at >10 kHz. However, a control technique with the back EMF derivative of the PWM switching based technique. Or, they use the The bipolar/unipolar switching and technique is a technique which can back EMF techniques only. the operating quadrant control is be used for very high motor speed

freescale.com/motorcontrol 11 Market Trends

Sensorless Technique Speed Controller Freescale Enablement Based on Back EMF The motor rotation speed is usually BLDC controllers usually require Zero Crossing controlled using the rotor position MCU or DSC devices with PWM, The rotor position estimation is based feedback provided to the speed ADC, PDB and other modules on the back EMF voltage induced in regulator. The speed regulator controls supporting BLDC motor control. the stator phases due to rotor flux the three-phase power stage PWM Freescale motor control devices (permanent magnet) rotation. The (applied voltage amplitude). support the BLDC motor control. back EMF voltage phase corresponds BLDC Motor Control with Reference designs, application notes with the rotor position relative to and software solutions for BLDC PLL Commutation stator position. motor control applications are available One advantage of BLDC motor The six-step commutation specific at freescale.com/motorcontrol. control compared to standard DC feature is that one of the three phases motors is that the speed can be is off at a time. exactly determined with the six-step After the commutation transient commutation frequency. This allows (current recirculation, the fly-back for very accurate speed control. diodes conduct the decaying phase One of the benefits of accurate current), the current of phase x: BLDC motor speed control is that ISx = 0 and so USx = BEMFC the commutation period is constant and the six-step amplitude feedback The phase back EMF voltage zero is based on the phase difference crossing can be measured. between estimated back EMF zero The back EMF zero crossing sensing crossing and the required zero can be provided using ADC or crossing instant. comparators that usually build inside the controller devices.

12 Beyond Bits Motor Control Edition

Permanent Magnet Synchronous Motor Control High-performance and power-efficient motor control

Introduction Figure 1: Field-Oriented Control Vector Explanation Permanent magnet synchronous motors (PMSM) are typically used for The “d” axis refers Axis of phase B high-performance and high-efficiency to the “direct” axis of the rotor flux motor drives. High-performance motor The “q” axis is the axis of Rotor position control is characterized by smooth motor torque along against phase A rotation over the entire speed range which the stator field (measured by must be developed position sensor) of the motor, full torque control at N zero speed, and fast acceleration and Rotation Axis of phase A deceleration. To achieve such control, S vector control techniques are used for PM synchronous motors. The vector Stator windings control techniques are usually also referred to as field-oriented control (FOC). The basic idea of the vector maximal, when they are perpendicular How to Simplify Control control algorithm is to decompose to each other. It means that we want of Phase Currents to a stator current into a magnetic to control stator current in such a Achieve Maximum Torque field-generating part and a torque- way that creates a stator vector DC motor control is simple because generating part. Both components perpendicular to rotor magnets. As all controlled quantities are DC values can be controlled separately after the rotor spins we must update the in a steady state and current phase/ decomposition. Then, the structure stator currents to keep the stator flux angle is controlled by a mechanical of the motor controller (vector control vector at 90 degrees to rotor magnets commutator. How can we achieve that controller) is almost the same as a at all times. The reactance torque of in PMSM control? separately excited DC motor, which an interior PM type PMSM (IPMSM) simplifies the control of a permanent is as follows, when stator and rotor DC Values/Angle Control magnet synchronous motor. magnetic fields are perpendicular. First, we need to know the rotor Let’s start with some basic Torque= position. The position is typically 32pplPMIqs FOC principles. related to phase A. We can use – Number of pole pairs pp an absolute position sensor (e.g., Torque Generation – Magnetic flux of the permanent lPM resolver) or a relative position sensor A reactance torque of PMSM is magnets (e.g., encoder) and process called generated by an interaction of two – Amplitude of the current in alignment. During the alignment, the Iqs magnetic fields (one on the stator and quadrature axis rotor is aligned with phase A and we one on the rotor). The stator magnetic know that phase A is aligned with As shown in the previous equation, field is represented by the magnetic the direct (flux producing) axis. In reactance torque is proportional to the flux/stator current. The magnetic field this state, the rotor position is set to amplitude of the q-axis current, when of the rotor is represented by the zero (required voltage in d-axis and magnetic fields are perpendicular. magnetic flux of permanent magnets rotor position is set to zero, static that is constant, except for the field MCUs must regulate the phase stator voltage vector, which causes that rotor weakening operation. We can imagine current magnitude and at the same attracted by stator magnetic field and those two magnetic fields as two bar time in phase/angle, which is not such to align with them [with direct axis]). magnets, as we know a force, which an easy task as DC motor control. tries to attract/repel those magnets, is freescale.com/motorcontrol 13 Market Trends

1. Three-phase quantities can Figure 2: Basic Principle of Field-Oriented Control transform into equivalent two-phase quantities (stationary reference Measured Current Generated Voltage frame) by Clarke transformation. 2. Then, we transform two-phase

quantities into DC quantities by rotor Phase A α d d α Phase A Three-Phase Stationary Rotating electrical position into DC values Phase B ol Phase B to β to q q to β SVM Phase C Two-Phase Rotating ocess Stationary Phase C

(rotating reference frame) by Cont r P r Park transformation. The electrical rotor position is a Electrical rotor Electrical rotor position position mechanical rotor position divided by numbers of magnetic pole pairs pp. 7. Using the space vector modulation, voltage. The calculation of the BEMF After a control process we should the output three-phase voltage observer requires math computation generate three-phase AC voltages is generated as multiply accumulation, division, on motor terminals, so DC values sin/cos, sqrt which is suited for DSCs, of the required/generated voltage A complete FOC speed PMSM control Kinetis ARM core-based MCUs or the should be transformed by inverse structure with Freescale motor control Power Architecture family. Park/Clarke transformations. library functions is shown in the article titled, “Industrial/Appliance PMSM Amplitude Control Drive,” page 39, figure 2. Field/Flux Weakening All quantities are now DC values, Control which are easy to control, but how do Sensorless Control The operation beyond the machine we control them in magnitude? The rotor position information is base speed requires the PWM inverter For magnitude control we use PI needed to efficiently perform the to provide output voltages higher than controllers in the cascade structure. control of the PMS motor, but a rotor its output capability limited by its DC We can control many state variables position sensor on the shaft decreases link voltage. To overcome the base as phase current (torque loop), speed the robustness and reliability of the speed limitation, a field-weakening or position as with DC motors. overall system in some applications. algorithm can be implemented. A Therefore, the aim is not to use this negative d-axis required current will FOC in Steps mechanical sensor to measure the increase the speed range, but the To perform vector control: position directly but instead to employ applicable torque is reduced because some indirect techniques to estimate of a stator current limit. Manipulating 1. Measure the motor phase currents the rotor position. These estimation the d-axis current into the machine 2. Transform them into the two- techniques differ greatly in approach has the desired effect of weakening phase system (a, b) using Clarke for estimating the position or the type the rotor field, which decreases the transformation of motor to which they can be applied. BEMF voltage, allowing the higher 3. Calculate the rotor position angle stator current to flow into the motor At low speed, special techniques like with the same voltage limit given by 4. Transform stator currents into the high frequency injection or open-loop the DC link voltage. d,q-coordinate system using start-up (not very efficient) are needed Park transformation to spin the motor over the speed Freescale Enablement 5. The stator current torque (isq) and where BEMF is sufficiently high for the Reference designs, application notes flux (isd) producing components BEMF observer. Usually, 5 percent of and software solutions for PMSM are controlled separately by the base speed is enough for proper control applications are available at the controllers operation in sensorless mode. freescale.com/motorcontrol. 6. The output stator voltage space- At medium/high speed, a BEMF vector is transformed back from the observer in d/q reference frame is d,q-coordinate system into the two- used. The PWM frequency and phase system fixed with the stator control loop must be sufficiently by inverse Park transformation high to get a reasonable number of samples of phase current and DC bus

14 Beyond Bits Motor Control Edition

AC Induction Motor Control Operation principles

Introduction was used for speed regulation and Figure 2: ACIM Incision This article describes the basic startup. The more common type operation principles and control of AC consists of a rotor in a squirrel induction motors (ACIMs). cage form. AC induction machines are popular Operation Principle due to their simplicity, reliability and The principle of operation for an ACIM direct operation from an AC line is based on the voltage induction voltage. ACIMs are asynchronous from the stator to the rotor. When machines and always have a lower the stator winding is fed by a three- mechanical rotor speed than the phase supply voltage, the current power line frequency. flows in the winding and the stator Historically, variations to speed rotating magnetic field is generated. requests was a limitation for AC Induced voltage in the rotor windings machines, but the development of will create the rotor current and the frequency converters has simplified rotor magnetic field. The interaction For example, a 50 Hz, six-pole motor speed changes, and are now between two magnetic fields creates ACIM with 7 percent slip results in widely used. the mechanical torque needed to turn the following: the rotor. ACIM Fabrication The operational rotor speed is lower ACIM fabrication begins with a three- than the stator magnetic field speed in phase winding placed in the winding order to achieve rotational torque. slot of the stator. There are two basic types of rotor winding concepts. The There are three defined operational first type places the rotor winding variables of ACIM: synchronous placed in the winding slot with a slip speed, slip speed and slip. From these results, it is apparent ring on the shaft, which historically The synchronous speed is proportional that the motor runs at a lower speed to supply frequency and inversely than the supplied voltage frequency Figure 1: Example of ACIM proportional to the number of and requires regulation for precise paired poles. speed operation. Speed Torque Characteristic The slip speed is represented in the The speed torque characteristic shows difference between the synchronous the ACIM reaction on the load. speed and the rated speed. The slip The convenient operating point is the ratio between slip speed and selection is in the middle of the speed synchronous speed and shows how torque characteristic of the stable part much the rotor speed falls with of the motor region. In this area, the the load. speed falls slightly with the load.

freescale.com/motorcontrol 15 Market Trends

Figure 3: ACIM Speed Torque Characteristic control of motor torque and magnetic flux. The control is based

Torque on the transformation of current/ voltage coordinates from stationary Operating Point to rotation that makes the control

Motor similar to DC machine control. The Stable control incorporates fast torque/ Unstable Part Part Braking Motor Generator flux current control loops and slower Region Region Region speed/position control loops. The FOC requires the knowledge of the actual rotor position, which is

Generator typically measured by the encoder or resolver. In some cases, the sensor cannot be used and the rotor position -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 Speed in percent of synchronous speed is calculated using the sensorless observer from measured machine 2.0 1.8 1.6 1.4 1.2 1.0 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1.0 -1.2 Slip as a fraction of synchronous speed currents and voltages. Advanced control techniques provide an excellent dynamic performance, ACIM can operate as a generator There are two groups of control wide speed range from zero speed but it is necessary to supply machine methods. First, the simple method is and excellent efficiency. They can be reactive energy because there is named voltage/frequency control (or used for industrial and servo drives no source of magnetic field. The scalar control) and refers to applied but also for advanced appliance generator speed torque characteristic voltage that is proportional to applied applications such as washers. region is central symmetry to torque frequency. This method is simple, is On the other hand, they require zero crossing point. On the left there not dependent on motor parameters a high-performance MCU with is a braking region. In the case of and can use the entire speed range. dedicated motor control peripherals. ACIM in generator mode the slip is a On the other hand, it does not Freescale offers a family of DSCs, the negative value. include current controllers and does MC56F8xxx based on 56F800E/X not control the machine optimally in It is evident from the characteristic, cores and ARM Cortex-M4 core- transient states. This technique is that the motor start torque is based Kinetis MCUs that provide the appropriate for fans, pumps restricted. The full motor start torque ideal solution for advance control of and compressors. can be achieved using an advanced AC induction motors. control method. Freescale offers 8-bit MCUs such as Reference designs, application notes the MC9S08P/MP with dedicated and software solutions for ACIMs, ACIM Control peripherals that can easily handle are available at freescale.com/ ACIM changes speed according the task. motorcontrol. to supply frequency and voltage Second, there are advanced control provided by the frequency converter. methods such as field-oriented This is efficient and allows the entire control (FOC) or direct torque control machine speed range to be used. (DTC). FOC enables independent

16 Beyond Bits Motor Control Edition

Switched Reluctance Motors Control techniques using Freescale solutions

Switched Reluctance Figure 1: Two-Phase 4/2 Switched Reluctance (SR) Motor Motor Features Stator A switched reluctance (SR) motor is a (4 Poles) Phase B rotating electric machine where both stator and rotor have salient poles. Phase A The stator winding comprises a set of coils, each of which is wound on one pole. The rotor is created from lamination in order to minimize the Rotor (2 Poles) eddy current losses. SR motors differ in the number of phases wound on the stator. Each has a certain number of suitable Aligned Rotor Position Unaligned Rotor Position combinations of stator and rotor poles. Figure 1 illustrates a typical two-phase defined by the turn-on Qon and the the SR power stage defines SR motor with a 4/2 (stator/rotor) pole turn-off Qoff angles. the freedom of control for an configuration and a stepped gap. The When the voltage is applied to the individual phase. stepped gap is used to eliminate dead stator phase, the motor creates There are a number of control zones, where motor torque is zero at a torque in the direction of increasing techniques for SR motors. They symmetrical SR motor and it ensures inductance. When the phase is differ in the structure of the control motor startup in the proper direction. energized in its minimum inductance algorithm and in position evaluation. The motor is excited by a sequence position, the rotor moves to the Three basic techniques for controlling of current pulses applied at each forthcoming position of maximal SR motors can be distinguished, phase. The individual phases are inductance. The movement is defined according to the motor variables consequently excited, forcing the by the magnetization characteristics that are being controlled: motor to rotate. The current pulses of the motor. A typical current profile • Angle control need to be applied to the respective for a constant phase voltage is shown • Voltage control phase at the exact rotor position in figure 2. • Current control relative to the excited phase. Control of SR Motor In angle control techniques, the The inductance profile of SR motors The SR motor is driven by voltage constant full voltage is applied in the is triangular shaped, with maximum strokes coupled with the given SR motor. The speed of the motor is inductance when it is in an aligned rotor position. The profile of the controlled by changing on/off angles. position and minimum inductance phase current together with the The speed controller processes the when unaligned. Figure 2 illustrates magnetization characteristics defines speed error (the difference between the idealized triangular-like inductance the generated torque and thus the the desired speed and the actual profile of both phases of an SR speed of the motor. Due to this fact, speed) and calculates the desired motor with phase A highlighted. The the motor requires electronic control on/off angles. This technique is not individual phases A and B are shifted for operation. Several power stage suitable for full speed range operation electrically by 180 degrees relative topologies are being implemented, since during low-speed operation the to each other. When the respective according to the number of motor maximal voltage amplitude generates phase is powered, the interval is phases and the desired control high current peaks in the motor called the dwell angle: Qdwell. It is algorithm. The particular structure of phases. This technique is used to run

freescale.com/motorcontrol 17 Market Trends

Figure 2: Ideal Phase Inductance and Current Profile switching of individual phases. Also, the motor structure causes noise and torque ripple. The greater Stator Phase A the number of poles, the smoother Aligned Just in Touch Aligned the torque ripple, but motor construction and control electronics become more expensive. Torque Rotor ripple can also be reduced by iphA advanced control techniques such LA LB as phase current profiling. Freescale Enablement The selection of suitable MCUs for control of SR motors depends on

OFF selected algorithms and required ON Dwell Position/Time speed range. In the case of sensor application and low-speed range, the SR motor over nominal speed. At current reaches desired amplitude, the 8-bit MCU with a PWM module the nominal speed, the full voltage is the current controller keeps the phase is a sufficient option. The Freescale applied on the motor phases and by current at the desired level. MC9S08MP16 MCU includes properly adjusting on/off angles the a 6-channel PWM module with As is apparent from the description, motor can achieve operation over the commutation support, which is the SR motor requires position nominal speed. very important for applications with feedback for motor phase high-speed range where precise In voltage control techniques, the commutation. In many cases, this commutation is required. The speed of the motor is defined by requirement is addressed by using sensorless algorithms are too complex the voltage applied to the motor position sensors, such as encoders for 8-bit devices without additional phases. The voltage applied to the and Hall sensors. The result is that the external components. The Freescale phase is directly controlled by a implementation of mechanical sensors DSC family provides an optimal speed controller. The speed controller increases costs and decreases system solution. This family offers advanced processes the speed error (the reliability. Traditionally, developers PWM modules, very fast ADC with difference between the desired speed of motion control products have PWM to ADC synchronization and and the actual speed) and generates attempted to lower system costs by a powerful DSP core, such as an the desired phase voltage. The reducing the number of sensors. A MC56F8006 or MC56F8013. Both desired voltage is generated by the variety of algorithms for sensorless are the smallest representatives of SR inverter using PWM modulation. control have been developed, the DSC family and offer the best During PWM modulation, the on/off most of which involve evaluation performance/price ratio. Several other times are constant. Once the applied of the variation of magnetic circuit members of the Freescale DSC family voltage has achieved its maximal parameters that are dependent on are suitable for these applications. value, the motor speed can be the rotor position. increased over the nominal speed by Reference designs, application changing on/off times. SR Motor Applications notes and software solutions for SR motor control are available at In the case of current control, there is The SR motor itself is a cost-effective freescale.com/motorcontrol. one more control loop: inner current machine of simple construction. Since control loop employed in the control of high-speed operation is possible, the SR motor. In this type of control, the motor is suitable for high-speed the output of the speed controller applications, such as vacuum defines the required current amplitude cleaners, fans and white goods. As in the motor phase. Based on the discussed above, the disadvantage required current amplitude, the new of the SR motor is the need for shaft- on/off times are calculated. Once the position information for the proper

18 Beyond Bits Motor Control Edition

Encoder Signal Processing Devices for industrial applications

Introduction Quadrature Incremental processed by the on-chip hardware Quadrature encoders are widely used Encoder of the controlling MCU. in industrial motor control applications The quadrature incremental encoder The quadrature encoder typyically as precise rotor position sensors is a position feedback device that has three output signals. The “phase mounted directly on the motor shaft. provides incremental counts. The A” and “phase B” signals consist This article will provide information on incremental encoder provides relative of a series of pulses, the phase the principle of the encoder operation information, where the feedback shifted by 90° (therefore the term and the quadrature decoder MCU signal is always referenced to a start “quadrature” is used). The third signal, module used for decoding of the position. The signals are directly called “index,” provides the absolute position information. position information, in motion

Figure 1: Quadrature Encoder Output Signals and Position Encoding Modes

Phase A

Phase B

Counter Increment/ +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1 -1 -1 +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1 -1 -1 +1 +1 +1 +1 +1 +1 +1 Decrement

Counter Value

Time

Phase A

Phase B Counter Increment/ +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1 Decrement

Counter Value

Time

freescale.com/motorcontrol 19 Market Trends

control used to check the pulse Implementation of the More information on the initialization counting consistency. That means, Quadrature Decoder and configuration of the quadrature after each revolution, the value of on DSCs decoders can be found in the the counted pulses is captured and following application notes, design The special purpose enhanced compared against the defined value. reference manuals and device quadrature encoder/decoder module If a difference is detected, the control reference manuals: is part of the newly introduced algorithm then must perform the MC56F84xx family of DSCs. It • AN4381 (Configuring the position offset compensation. provides interfacing capability to FlexTimer for Position and Speed Quadrature Decoder position/speed sensors used in Measurement with an Encoder) industrial motor control applications • DRM128 (PMSM Vector Control The quadrature decoder is the MCU and has four input signals: phase with Quadrature Encoder on Kinetis) peripheral module used for hardware A, phase B, index and home. This decoding of the encoder signals • DRM102 (PMSM Vector Control module is used to decode shaft and is a standard component of with Single-Shunt Current-Sensing position, revolution count and speed. Freescale motor control dedicated Using MC56F8013/23) It also supports different sources of chips. Though there are differences in • MC56F844XXRM, interrupt events. the implementation of the quadrature K40P100M72SF1RM decoders in particular MCU families, the Implementation of the These documents are available at principle is the same: it counts rising Quadrature Decoder freescale.com/motorcontrol. and falling edges of both phase signals. on Kinetis MCUs The internal logic of the quadrature The quadrature decoder is one of decoder evaluates the direction of the several features of the FlexTimer rotation by increasing or decreasing module that is part of the Kinetis family the counter value. There are also other of MCUs. It is not as rich in features arrangements of the output encoder as the previously mentioned module signals. For example, the phase A and only has two input signals, phase signal is a chain of the pulses while A and phase B, so only the position the polarity of phase B determines the can be evaluated directly. If required, counting direction, as shown in the processing of the index signal has to lower time diagram in figure 1. be made by another on-chip timer.

20 Beyond Bits Motor Control Edition

Three-Phase Current Measurement Freescale dedicated MCUs make it easy

Overview Figure 1: Three-Phase Inverter Topology Advanced motor control algorithms such as field-oriented control (FOC) and direct torque control (DTC) require T1 T3 T5 sensing of motor phase currents. To reduce the number of sensors and Vdc T2 T4 T6 overall cost of the solution, the phase currents can be measured by means of low-cost shunt resistors with a simple R1 R2 R3 interface between the shunt resistors Rdc and MCU inputs. The phase current is measurable only at a certain instant and thus the current sensing based on the Ph. B shunt resistors requires support from Ph. A Ph. C the MCU. Freescale dedicated motor control devices provide exceptional hardware support, allowing the user to solve specific application needs.

Figure 2: Current Sensing

PWM1-T1

PWM2-T2

PWM3-T3 PWM1-T1 PWM4-T4

PWM5-T5

PWM6-T6 PWM2-T2 I SA Dead Time

ISB

ISC

Isense_A

Isense_A Time to Current Stabilization I sense_B ADC Current Sensing Conversion Duration

Isense_C time Critical PWM Pulse Width

PWM PWM PWM Current Reload Reload Reload Current Current Sampling Sampling Sampling

freescale.com/motorcontrol 21 Market Trends

synchronization via hardware without Figure 3: Hardware Interconnection of Internal Modules software intervention. The PWM module generating the output voltage PWM out 0 PWM out 1 as the variable duty cycle signal also 6-ch. from PWM out 2 generates the synchronization signal. 8-ch. PWM out 3 Crossbar eFlex PWM PWM out 4 This synchronization signal is internally PWM out 5 processed by a timer that defines Triggers delay between the synchronization signal and a signal triggering the ADC module. Once the timer value is set, the synchronization and ADC Min. Three Min. Three conversion work automatically. If Event Triggers Event Triggers needed, it is simple to manage the

Simultaneous value in the timer register in runtime Acquisitions and thus the instant of ADC sampling. Another great feature of Freescale Current: Phase A Current: Phase B Current: Phase C Current: Phase C motor control MCUs is that the ADC 12-bit, 12-bit, VDC bus module contains two independent 8-ch. ADC0 8-ch. ADC1 AD converters with two independent sample and hold circuits. This feature Rslt3 Rslt3 Rslt1 Rslt2 Rslt1 Rslt2 allows the user to sample, hold and convert two analog signals, in this case currents, at the same time. This ADC operation is called the Current Sensing transistors and thus with the voltage simultaneous operating mode. Since Fundamentals generation peripheral module, which is we always measure just two currents the PWM module. and the third is calculated from the Electric motors are powered by following equation, i +i +i = 0, we can inverters. Figure 1 depicts the typical Detailed switching conditions of all a b c calculate the third current as precisely topology of the three-phase inverter. inverter phases in the case of the as possible. The inverter consists of three half- complementary PWM mode are bridge units with top and bottom shown in figure 2. Current Sensing Using the transistors. The shunt resistors (R1, R2 MC56F84xxx DSC Family and R3) used for current sensing are Freescale MCU Support This very powerful DSC family provides placed below the bottom transistors of for Current Sensing flexible support for hardware triggering. the corresponding phase. Freescale dedicated motor control ADC conversions can be synchronized MCUs provide wide flexibility for all In some cases, it is possible to by any module connected to the possible current sensing configurations reconstruct the three-phase current internal crossbar modules, such with shunt resistors. The Freescale just from a DC link shunt resistor as PWM, timer modules, GPIO MCU portfolio that supports the R . A voltage drop on the shunt and comparators. Apart from the dc smart current sensing comprises resistor is amplified by the operational simple synchronization support, the MCUs based on DSCs, Qorivva amplifier and sampled and converted MC56F84xxx DSC family also provides MCUs (based on Power Architecture by the ADC peripheral module. Since support for multitriggering modes technology) and Kinetis solutions the current flows through the shunt with a programmable number of (based on the ARM core). resistors when the bottom transistor conversions on each trigger. is switched on (T2, T4, T6), an instant The current sensing mechanism of ADC sampling must be precisely requires synchronization between defined and synchronized with the PWM and ADC peripheral modules. switching conditions of inverter It is necessary to control the

22 Beyond Bits Motor Control Edition

The typical configuration of internal Figure 4: Principle of Synchronization peripheral modules allowing the hardware synchronization is shown in figure 3. Compare Value 1 The eFlex PWM module is used for both the PWM output generation eFlexPWM Counter (PMW out 0, PWM out 1,…, PWM Init out 6) and ADC sampling instant eFlex PWM SYNC generation. The trigger events are connected through the crossbar eFlex PWM switch module to the ADC module Generator Outputs 0, 1 (internally two ADCs: ADC0 and Dead Time/2 Dead Time/2

ADC1). ADC0 and ADC1 run eFlex PWM Pins 0, 1 simultaneously and can convert not only the currents but also other Power analog signals such as VDC bus Stage Dead Time Dead Time Voltage and temperature. eFlex PWM The principle of synchronization Compare Value t1 between the eFlex PWM module and eFlex PWM Compare Event ADC modules is shown in figure 4. t2 ADC S&H and Conversion The PWM period is defined by two ADC registers: init and compare value. The ISR t3 synchronization signal is generated at the beginning of the PWM period (SYNC signal). Since the ADC module has 16 result Comprehensive information about Each eFlex PWM submodule has one registers, it is possible to convert up the hardware synchronization for the counter and six compare registers. to 16 analog signals without reading corresponding device can be found The compare registers that are not the results. All 16 conversions can at freescale.com. Here, you can find used for the PWM signal generation be triggered by one trigger or several application notes and design reference can be used for a synchronization triggers. The results can be read after manuals describing how to configure purpose. When the eFlex PWM the ADC conversion is complete using the current sensing, process ADC submodule counter reaches the an interrupt service routine or DMA. results, manage the synchronization in compare value defining the trigger runtime and calculate or reconstruct Conclusion event, the trigger output from the motor phase currents. Freescale current sensing and analog eFlex PWM module is generated and Design reference manuals: DRM092, signal measurement solutions allow starts the ADC conversion process. If DRM102 the ADCs are set up for simultaneous the user to simplify the overall solution Application notes: AN1930, AN3234, operation then both ADCs are and reduce the system cost. The smart AN3731, AN1933, AN4410 triggered at the same instant. In hardware synchronization provides the case of the ADC module on the extremely precise definition of the MC56F84xxx devices, the conversion instant of sampling the analog signals times are as follows: (current, voltage, temperature, etc.). Moreover, the hardware synchronization • Single conversion time: 425 ns increases MCU throughput. • Additional conversion time: 300 ns • Eight conversions using parallel mode: 1.325 us, 16 results

freescale.com/motorcontrol 23 Application Examples Application Examples

Select Freescale Solutions for Your Application Find the right device based on your requirements

Overview Figure 1: Freescale MCU for Motor Control Selection of an embedded MCU for motor control applications requires a developer to consider multiple parameters. Nowadays, motor control applications are not dedicated drives for rotating machines but have become complex systems including several interfaces, real-time operating systems, high-performance peripherals and other elements. Freescale offers MCUs designed for motor control applications that range from low-end to high-end devices covering most performance and peripheral requirements. Sensorless the application dependent code is For consumer, industrial and appliance Open loop without actual speed designed individually for a dedicated drives, Freescale offers MCUs based feedback application and includes user on S08, DSC, Power Architecture interfaces, communication protocols, technology, and Kinetis MCUs based on • Control algorithm: BLDC safety features and additional state ARM Cortex-M0+ and Cortex-M4 cores. commutation control, sinusoidal machine functionality. scalar control, sinusoidal Requirements vector control Complexity of the motor control The definition stage of a new motor • Memory requirements: RAM/ algorithms can be divided into control project is one of the most flash space required for specific several segments based on important parts of the application applications initial requirements. The following segmentation of a typical motor development process. These • Real-time operating system (RTOS) parameters should be considered control application defines the • Preferred core: 8-, 16- or 32-bit when selecting an MCU: main groups which contain a list of • Safety standards (i.e., appliance peripherals, memory sizes and typical • Target applications: fan, pump, safety IEC60730 standard) applications as well as MCU cores washer, dryer, servo, general control, which are recommended to run certain industrial control, etc. Application Complexity control algorithms. • Motor type: PMSM, ACIM, BLDC, The typical motor control application SRM, stepper motor can be divided into two parts: the 1. Very Low-End Segment • Required speed or torque accuracy motor control algorithms and the Motor types related to this segment application dependent code. The are single-phase AC, DC and • Speed/position sensor motor control algorithms are almost universal motors. The motor is Mechanical sensor (Hall sensors, identical for a certain type of motor controlled with low dynamics, such as quadrature encoder, tacho and a selected control technique. slow changes in the control loop. The generator, SinCos) They do not depend on the closed loop, if implemented, is usually application type. On the other hand, only one speed loop or the motor is driven in an open loop. freescale.com/motorcontrol 25 Application Examples

MCU requirements Figure 2: Motor Control Applications • CPU speed <= 32 MHz Very Low End Low End Middle End High End • Timer with three-phase output PWM On/Off motors Pumps Washers and dryers Complex industrial capability drives • Single ADC Single-phase motors Residential Commercial Dual motor control compressors compressors • Comparator Hand and power Fans Industrial drives Servo drives • Package <= 32 pins tools • Flash memory 8–32 KB Food processor Respiratory HVAC Military drives Freescale S08 MCUs and Kinetis MCUs based on the ARM Cortex-M0+ • Timer with three-phase output Freescale MCUs, DSCs, Cortex-M4 core are suitable for such applications. PWM capability and Power e200 cores with FPU are • Dual ADC capable parallel sampling suitable for such applications. 2. Low-End Segment • Comparator with DAC This segment covers PM synchronous, Design Considerations • Quadrature decoder AC induction and BLDC motors that These additional factors should be are used in low dynamic, sensor or • Package 32–64 pins considered when selecting an MCU: sensorless applications. • 32–100 KB • Future system extension: reserved The MCU core is capable to run Freescale MCUs, DSCs and memory space for firmware update the FOC algorithm and the timer is Cortex-M4 cores are suitable for • Device package: pin-to-pin compatible capable of generating three-phase such applications. devices enable simple upgrade to sinusoidal or trapezoidal PWM signals. 4. High-End Segment a higher performance device when MCU requirements High-end motor control applications system requirements increase • CPU speed <= 50 MHz predominantly comprise of PMSM • Power consumption: MCU for • Timer with three-phase output or ACIM high dynamic field-oriented battery supplied applications should PWM capability sensorless control and servo drives. have lower power consumption to increase battery life • Single ADC (with two sample and The control algorithms are very hold modules for FOC) complex and computed in high • On-chip peripherals: analog and precision arithmetic. Control loops can digital peripherals can reduce the • Comparator with DAC contain an outer position loop that is use of external components like • Package <= 32 pins implemented apart from conventional comparators, program gain amplifiers • Flash memory 12–32 KB speed and current controllers. and independent clock source Freescale MCUs, DSCs and Kinetis The PFC is required. The MCU • Application support: available MCUs based on the ARM Cortex-M0+ performance is capable to control two example applications can speed core are suitable for such applications. motors independently. code development 3. Middle Segment MCU requirements • Available hardware and software The type of application related to • CPU speed: 150+ MHz tools using Tower System kits this segment is sensorless control of • Floating point unit (FPU) enable the preparation of application code while the final hardware PM synchronous and AC induction • Timer with three-phase output s designed motors. The MCU core is sufficient PWM capability for performing high dynamic, FOC • 4x fast ADC capable parallel Conclusion algorithms with optional power sampling for dual motor control factor correction (PFC) routines. The Choosing the right device for • Comparator with DAC core supports fast mathematical the application is the key factor operations (one cycle multiplication) • Quadrature decoder for a successful design concept. The selection guide, reference and DSP instructions. • Ethernet designs, hardware and software • Advanced UART MCU requirements tools help to simplify the process. • CPU speed 50–100 MHz • Package 64–144 pins For more information, visit • Flash memory 512 KB–2 MB freescale.com/motorcontrol.

26 Beyond Bits Motor Control Edition

Motor Applications for Small Appliances Using BLDC motors in small home appliances

Introduction Figure 2: Freescale Kinetis BLDC Sensorless Reference Brushless motors are more efficient at Design Block Diagram converting electricity into mechanical power than brushed motors. Lack BLDC Sensorless Three-Phase Inverter Input Voltage of a commutator allows for reduced Motor Control for K60 Three-Phase Overcurrent MC33927 Flag Low-Voltage Three- complexity and maintenance, as well MOS-FET Power Phase driver Stage BLDC as lower electromagnetic interference. Browser Motor DC Bus U,I BEMF Brushless motors can develop high Input Voltage Kinetis K60 torque with a good speed response App. PWM PBD ADC State FlexTimer0 Ethernet BE/MF Sense and can be easily controlled by an Machine Commutation MCU. They can also operate in a Buttons API PI Controller Speed Fault very wide speed range to enable Computing FlexTimer1 SCI Speed Ramp Protection fine motion control and hold torque and Scaling when stationary. Input FreeMASTER Brushless motors have come to dominate many applications, namely Kinetis Peripheral Input Software Motor Parts Device on Three-Phase Inverter hard drives, CD/DVD players, pumps, fans, robotic vacuum cleaners, coffee application reference designs and/or cleaner is a typical example of when machines, mixers, hairdryers, bread demo software which can be easily MCU speed control is needed. It cutters and spindle drives in adjustable reconfigured according to application- enables bi-directional operation with or variable speed applications. They specific needs. fast torque response and low noise. are also a popular motor choice for RC toys and vacuum cleaners also High Efficiency helping to increase battery life for utilize very high-speed operation. Brushless motors are used in place model aircraft, remote control (RC) of various types of AC motors. The Low Price, High Quality cars and portable power tools. most significant reason to switch to Small appliances are usually produced Application Requirements a brushless motor is the dramatic in very large volumes, therefore one reduction in power required to operate of the most important requirements Each application has very specific them versus a typical AC motor. Some is cost effectiveness. Cost-effective requirements. Though it’s not easy to devices use brushless motors in order control topology with BLDC motors cover all solutions through a single to increase overall system efficiency allows for lower device prices while example, Freescale offers many and achieve a higher efficiency class maintaining the quality of the product. according to the European Union Additional price reduction can be Figure 1: BLDC Motor energy label. In small, battery-powered achieved by removing the position Cross Section devices, improving drive efficiency also sensor. For more information on this helps to lengthen battery life. option, see the related small appliance Speed Variability and articles in this edition of Beyond Bits. Speed Control High Reliability In addition to the brushless motor’s Reliability is an important aspect of higher efficiency, certain home brushless motors, as they contain appliance devices use brushless a minimal number of mechanical motors because the built-in MCU parts: no commutator, no slip rings, allows for programmability, variable- and no winding on rotary parts. The speed and/or load modulation with most important parts of the drive are enough precision. A robotic vacuum freescale.com/motorcontrol 27 Application Examples

the inverter and controller design. Figure 3: MCU Selection for Specific Applications Therefore, it is necessary to pay attention to good hardware design Application Application Example Requirements Devices Tools with reliable software. Robot vacuum Kinetis K series MCUs Hardware and cleaner based on the ARM core, software tools, High Communication DSC family 56F82xx, motor control drivers As the MCU is part of the whole 56F83xx, 56F84xx and algorithms, FreeMASTER, design, it is possible to use it to Coffee machines, S12X, DSC family Mid Processor Expert increase system intelligence and RC planes 56F80xx, 56F81xx Toys, mixers, fans RS08, HCS08, HC08, value. Adding a modern user Low interface, special features or Kinetis L connectivity will improve system value The back EMF sensing technique fit most requirements, making it simple with minimal expense. Hardware can is based on the fact that only two to fine tune custom applications. be dramatically reduced by using the phases of a brushless DC motor are The combination of market-proven right MCU. energized at one time. The third phase Freescale MQX software solutions Dimensions and Weight is a non-fed phase that can be used and the silicon portfolio provides a High output power, low weight and to sense the back EMF voltage. streamlined and powerful platform as small form factors are desirable for RC The whole system according to the a comprehensive source for hardware, planes, helicopters and electric hand user interface input and feedback software, tools and service needs. tools. This is one reason that BLDC signals, generates three-phase PWM Freescale Enablement motors have displaced other types of output signals for the motor inverter. motors and combustion engines. More information about Freescale For the sensorless BLDC application Kinetis MCUs based on the ARM example, it is necessary to sense Application Concept core, DSCs and S08 MCUs can the following parameters during the The system consists of hardware and be found at freescale.com/Kinetis, application run: software tools for controlling this type freescale.com/DSC and of motor. • DC bus voltage freescale.com/S08. Hardware consists of: • DC bus current More information about Freescale • Three-phase inverter • Phase A, B, C back EMF voltages modular hardware development • MCU board The commutation time and period platform and motor control solutions can be found at • User interface are calculated from these measured freescale.com/Tower parameters. To manage these tasks, and freescale.com/motorcontrol. Software consists of: the Freescale processor must have The FreeMASTER runtime debugging • PWM generation control rich features of timers, ADC converters tool and CodeWarrior integrated • Rotor position measurement and PWM to ADC synchronization development environment (IDE) studio • User interface modules. The processor must also are integral parts of motor control contain special control registers with • Fault control application development. To learn more, hardware and software triggers which • Current limitation visit freescale.com/FreeMASTER and can make six-step control very easy. freescale.com/CodeWarrior. • Speed controller The controller must control the rotor Implementation of Several design reference manuals on rotation, therefore, the controller Freescale MCUs the topic of sensorless BLDC control, requires some information to determine Freescale offers several 8-, 16- and including DRM135, DRM078, DRM086, the rotor’s orientation/position (relative 32-bit MCU families that are perfectly DRM128 and DRM117, as well as to the stator). Some designs may use adapted to the requirements of application notes such as AN4142, Hall effect sensors or an encoder to modern industrial and household AN4376, AN4254 and AN1914, are directly measure the rotor’s position. applications, combining high available at freescale.com. Others measure the back EMF in the performance and low cost. unpowered coils to infer the rotor Freescale MQX™ software solutions position, eliminating the need for Hall offer a straightforward API with a effect sensors. This technique is known modular architecture that is scalable to as sensorless BEMF control.

28 Beyond Bits Motor Control Edition

Digital Control of Switched Reluctance Motor Drives High-speed sensorless solution for vacuum cleaners

Recent progressive variable speed Figure 1: Ideal Phase Inductance and Current Profile drives are designed to increase product performance and system Stator Phase A efficiency. One such motor type which Aligned Just in Touch Aligned can benefit from digital control is the switched reluctance (SR) motor. The SR motor brings advantages in Rotor both cost and reliability over other types of adjustable speed drives. iphA LA These include its simple mechanical LB construction, high efficiency and high power density. On the other hand, large torque ripple, due to double saliency construction, limits usage of the SR motor in many applications. OFF ON Dwell Position/Time Another advantage of an SR motor is its high-speed operation (> 50,000 RPM). This results in a smaller motor Application Concept Another method for sensorless for a given output power and reduces As noted in the “Switched Reluctance position estimation presented in this the size and weight of the target Motors” article on page 17, the SR article is based on phase current peak application. A typical application motor requires position feedback for detection. This control method allows that can benefit from this feature motor phase commutation. However, SR motor operation at a very high is the vacuum cleaner. The high- implementing mechanical sensors speed, making this method useful for speed SR motor makes the vacuum increases costs and decreases system the vacuum cleaner application. cleaner smaller and lighter, and the reliability. Therefore, manufacturers The principle of this method can noise generated by torque ripple is of vacuum cleaners have attempted be seen in figure 1. The phase comparable to other types of motors. to eliminate position sensors for starts to be excited at the moment control of the SR motor. A variety of corresponding to the desired current Application Requirements algorithms for sensorless control have amplitude. The current begins to rise • Very high speed (>50,000 RPM) been developed, most of which involve until the position where the stator • Open loop speed control flux linkage estimation. These methods and rotor poles begin to overlap. • Maximal speed limitation calculate the actual phase flux linkage At this moment, the phase current and use its relation to the reference reaches its maximum. In other words, • One direction of rotation flux linkage for position estimation. The the current peak determines the • Fast start up time (500–1000 ms) main disadvantage for these methods exact position of the rotor. Knowing • Full power in 2–3 seconds is that the estimation of the flux linkage the time of two consecutive current • Small DC bus capacitor (<10 μF) is based on a precise knowledge peaks, the commutation period and of the phase resistance. The phase corresponding on/off times can be resistance varies significantly with calculated. The current peak can temperature, which yields unwanted be detected by external circuitry or integration errors, especially at low by using a powerful DSC for direct speed. These integration errors create software evaluation. a significant position estimation error. freescale.com/motorcontrol 29 Application Examples

and feedback signals, the system Figure 2: System Concept generates PWM signals for the two- phase SR high voltage power stage. Two-Phase SR Power Stage Two-Phase Inverter High voltage waveforms generated by the DC-to-AC inverter are applied to DC Bus Voltage and Phase Two-Phase Power Line Current Sensing SR Motor the motor.

VDCB IPh A IPh B The state of the user interface is scanned periodically, while the DC bus voltage and the excited phase current are sampled. The SR motor

ADC Module PWM Module starts on command from the start/

Phase DC Bus Duty cycle Comm. stop switch. At first, the rotor is Currents Voltage Sequence Current Peak DC Bus Voltage aligned to a known position. As soon Detection Correction as the rotor is stabilized, the startup Commutation Period Commutation algorithm begins to excite the phases Angle Control to get the SR motor running. During Phase Current Start Up Algorithm Onboard startup, the rotor position is evaluated JTAG Start/Stop Programming/ GPIO by an algorithm. Once the SR motor SpeedUp/Down Ramp Required voltage FreeMASTER OtherPurposes Module Generation achieves a stable speed, the rotor MC56F8013 Controller Board position is evaluated from the peak current. After the startup sequence, the SR motor speed is increased to The advantage of this method is Implementation maximum by a speed ramp. that it is independent of the motor The MC56F8013 DSC is a good The phase current is sampled every parameters. All we need to know is choice for this application. This device 4.4 μs. The number of ADC samples the rotor position at the current peak. is a member of the MC56F80xx taken during a PWM period is Another advantage is that the current family, which is well suited for digital calculated at the beginning of every peak detection algorithm is very motor control, combining the DSP’s PWM cycle, according to the actual simple compared to the estimation calculation capability with the MCU’s duty cycle. The current samples are of the flux linkage method. Thus, this controller features on a single chip. evaluated by the peak detection method can be used at very high These hybrid controllers offer many algorithm. Once the peak has been speeds, whereas the low number of dedicated peripherals, such as pulse detected, the actual commutation current samples for flux calculation width modulation (PWM) modules, fast period and on/off times are calculated limits the precision of the flux linkage analog-to-digital converters (ADC), from the latest and previous estimation method. timers, communication peripherals peak times. Though the control technique is (SCI, SPI, I2C) and on-chip flash The application software is written simple, it requires a powerful MCU and RAM. The example of digital in C language except for the current if fully implemented digitally without implementation of a current peak sensing, current peak evaluation and any external components. This MCU algorithm using the MC56F8013 commutation event interrupt routines, has to be capable of very fast phase DSC can be seen in figure 2. The since they are time critical. These current sampling and current peak example meets all requirements for routines are written in assembler. evaluation. For example, in a two- vacuum cleaner application discussed phase SR motor running at 60,000 above. Figure 2 illustrates the system Freescale Enablement RPM, the commutation period is only concept, which incorporates a A full description of this application, 250 μs. To gain sufficient precision two-phase SR high voltage power including software and hardware in current peak detection, the phase stage, a two-phase SR motor and resources, can be found in reference current has to be evaluated at least an MC56F8013 controller board, design DRM100 at freescale.com. every 5 μs. which executes the control algorithm. In response to the user interface

30 Beyond Bits Motor Control Edition

Industrial/Appliance Consumer Ceiling Fan Sensorless field-oriented control for ceiling fan sinusoidal BLDC motor with PFC

Introduction Figure 1: Sensorless Sinusoidal BLDC/PMSM FOC + PFC Brushless direct current (BLDC) motors are readily gaining popularity DC Bus Voltage (VDC) where energy savings are required. BLDC fans offer several advantages Rectified AC Voltage (Vac) over traditional brushed DC motor and induction motors, including more Rectifier PFC Ceiling torque per weight, more torque per FAN AC watt (increase efficiency), high dynamic Input response, increased reliability, reduced noise, longer lifetime, more power and overall reduction in electromagnetic interference (EMI). This article covers PFC Vdc a typical ceiling fan application with PWM cost-effective smart electronics along PWM FOC and Feedback with the advantages of BLDC motors PFC Generation Processing Feedback BEMF as mentioned above. The reduced Control Observer energy consumption in this application Speed Command makes it an excellent choice for the energy efficiency initiative. 8 kHz current control loop frequency Application Concept This article is dedicated to the is used to gain excellent performance, FOC sensorless sinusoidal BLDC/PMSM low noise and high efficiency. In order to run the motor properly, FOC for the ceiling fan application. Features of Ceiling Fans five stages are taken to start the fan, including sector detection, start, open System Overview • Speed range 140–320 RPM loop, merge and closed loop. Front-end power factor circuit (PFC) • Input power factor > 0.95 from followed by three-phase inverter with minimum speed of 90 RPM Sector detection stage: The motor Freescale DSCs is used to drive a must start with a relatively large initial • Direction can be reversed when three-phase sinusoidal back EMF torque rotor position, otherwise there fan is running BLDC/PMSM motor. The three shunt will be oscillation or failure when • Start-up even if the vanes are still resistors cascaded in the lower leg starting the fan. Consider dividing rotating (due to inertia) of the inverter are required to obtain the rotor position of 0–360 electrical three-phase current. The power • 45 seconds to deceleration/ degrees into six sectors, and the configuration is shown in figure 1. A acceleration from 90 to 320 RPM sectors can be identified using stator firmware observer is applied to obtain • 25 watt total power consumption magnet’s B-H characteristics. the rotor’s magnetic axis position • Speed control in five steps through Start stage: Because there are current which is crucial for the vector field- IR remote pulses in the windings when detecting oriented control (FOC) algorithm. The the rotor’s initial position, these current sensorless vector control algorithm pulses may cause a bit of mechanical with 16 kHz PWM frequency and vibration. This stage is designed freescale.com/motorcontrol 31 Application Examples

Figure 2: Sensorless Sinusoidal BLDC/PMSM FOC, Software Blocks

d-current PI Control Required Inverse Park Compensated d-current Transformation Voltage SVM PWM u u α α d, q DC Bus u Ripple u β Elimination β

α, β Inverter

Required Three-Phase Speed Sector DC Bus From Speed PI Control q-current Voltage Remote PI Control Control

Extended BEMF Estimation and Tracking Observer

i i i d-current d α α, β a d, q i i b q-current iq β ic Current

α, β a, b, c Sensing Sensors Processing Feedback Park Clarke Two Transformation Transformation Currents

to add some delay before actually smoothly in the merge stage, now the cascaded in the lower legs of the starting the fan. output of the speed control loop is inverter. When calibration is complete, used as IQ reference instead of using the stop task then positions the Open loop stage: When the rotor’s magnetic axis has been detected, a given reference value. detection task to be executed. The position detection task is intended to the open loop control for speed is PFC Control used. During open loop operation, realize the function mentioned in the Boost circuitry in a discontinuous the observer for position and speed sector detection stage. The start stage conduction mode is used to estimation is enabled and the speed realizes the function mentioned in the implement the PFC inner current mode loop is also enabled to obtain start stage and the run state realizes control. Outer voltage loop controls reference IQ which will be used in the the functions mentioned in the open the DC bus and provides constant close loop. loop stage, merge stage and close voltage with input and speed of fan loop stage. Merge stage: Once a desired speed changes. Inner current loop controls is achieved, the control transfer from the input current and corrects the Sensorless Driving with PFC speed open loop runs to speed close input power factor > 0.95 and input To read the speed and position in loop. In close loop, the estimated current THD. rotor position is used to perform park sensorless control, it is necessary and inverse park transformation and Software Design to know the motor parameters well to calculate its model observer. The use the speed loop’s output as the The software is designed using a parameters are programmed into quadrature current reference. There state machine so that the software the BEMF observer algorithm. This could be a shift between the estimated is easy to understand and control. observer’s function is to calculate the position and simulated position during The fault task deals with overcurrent, position of the BEMF, which is needed open loop running. overvoltage and undervoltage. The to drive the motor. The position is then Closed loop stage: Since the rotor’s initial task initializes all variables used passed through the tracking observer position used in the algorithm has in the algorithm. The calibration task to be filtered, and as a side product, been transferred from simulated rotor gets the DC offset of currents passing determines the actual speed. The PFC position to estimated rotor position through the three shunt resistors

32 Beyond Bits Motor Control Edition

current loop algorithm is three times Performance PFC: Has two main control loops: faster than FOC and the voltage loop The application uses two system current and voltage. The slow moving is at much lower speed. control loops. voltage loop keeps the DC bus voltage constant. The current loop is critical as At this point, we see that this solution FOC: Has two main control loops: it controls the input current waveform. requires a powerful controller from the current and speed loops. The current Freescale 56800E/Ex family of DSCs. loop is critical and is calculated on the Freescale Enablement PWM frequency at 16 kHz. The loop Implementation • Application based on FSLESL has several tasks: Freescale offers a selection of DSCs freescale.com/motorcontrol for this important task. The following is • Reading of measured currents and • Embedded software and motor a list of what is mandatory for such voltage, and reconstruction of the control libraries an application: current from two values into three freescale.com/fslesl • BEMF + tracking observer • PWM: Two PWM configurations • FreeMASTER visualization tool • Clarke and Park transformation freescale.com/FreeMASTER One for FOC should offer a center-aligned mode, • D and Q current controllers and • Application support from Freescale complementary switching their limitation depending on the motor control experts capability with the deadtime DC bus voltage insertion, and three-phase • DC bus ripple compensation orientation • Space vector modulation One for PFC and PWM • PWM update of three-phase inverter synchronization with the ADC • ADC configuration for the next step • ADC: Simultaneously measures two FOC currents and PFC current, with two channels working in parallel • SCI: Necessary for the communication with FreeMASTER to allow application debugging • Interrupt controller: Must be priority controlled to avoid disintegrity of the control technique. The interrupt latency should be short. • Core: Must have great computation potential in terms of mathematical operation

freescale.com/motorcontrol 33 Application Examples

Household Washing Machines Freescale MCUs provide smart solutions for home appliances

Overview Figure 1: Pancake PM Synchronous Motor One of the most useful home appliances used in households across the world is a washing machine. Washing machine features are still being improved thanks to incorporating MCUs that allow manufactures to implement many useful features. Typical features available in the most modern consumer washers include: • Plenty of pre-defined programs for different laundry types • Variable temperature settings • Variable spin speed • Quick wash programs Motor Types Driving the Washer: focus on sensorless control techniques 1) Vintage motor construction eliminating the position sensor. The • Variable load support a. Single-phase ACI motors sensorless control techniques require • Water level control powerful MCUs. b. Single-phase universal motors • Delayed execution 2) Modern motor construction Typical Horizontal Belt- Washing Machine Varieties a. Three-phase ACI motors Driven Washing Machines There are many types of washing b. Three-phase PMS motors Motor type machines varying in mechanical • Three-phase ACIM (two poles) construction, motor types driving Control System for Motor Control Modern control systems focus on a drum, a control system of the • Three-phase PMSM (eight poles) more sophisticated control topology motor control part, human interface, Load capacity of standard washer supporting sinusoidal control. One of level of energy efficiency, washing size 60 cm x 60 cm x 85 cm the most popular control topologies performance, drying performance • From 5 kg up to 12 kg is field-oriented control (FOC), and water consumption. • Typically—7 kg or 8 kg allowing for maximum efficiency, Mechanical Construction maximum motor power, minimum Drum spin speed 1) Drum position torque ripple, reduction of audible • From 1000 RPM to 1600 RPM a. Horizontal washers noise and utilization of the maximum Transmission ratio—drum to motor (dominate in EU markets) motor torque that is required at motor • From 1:6 to 1:16 acceleration during the motor/drum b. Vertical washers • Typically around 1:10 (popular in US and AP markets) startup. The drive solution with ACI motor requires information about rotor Motor power 2) Drum loading speed. In the case of the PMS motor • About 750 W a. Front load washers drive, information about the rotor Motor torque b. Top load washers position and speed is required. The • About 2 nm control algorithm of the PMS motor 3) Drive construction • In some cases 3.5 nm a. Belt driven processes the rotor position and calculates the speed based on the Key features of washer b. Direct drive difference of the rotor position in time. applications Since the position sensor is relatively • Motor control part expensive, the washer manufacturers FOC

34 Beyond Bits Motor Control Edition

Speed closed loop DSC family is an ideal solution for Up to 32 KB of FlexNVM— Torque control loop such a complex application requiring additional program or data flash Flux control loop a powerful core and smart and Up to 2 KB of FlexRAM— flexible peripherals like eFlex PWM, Position and speed estimation in additional RAM memory ADCs, timers, crossbar and hardware case of sensorless control • eFlex PWM module—Eight channels interconnectivity. Typical DSC-based • 12-bit ADC with 300 ns conversion • Fault control logic MCUs include: time—2 x 8 channels • Washer safety • MC56F825X/4x family • Safety class B • 16-bit SAR ADC with temperature • MC56F844x/5x/7x family sensor—1 x 24 channels • Application state machine The MC56F825X/4X is a member of • DMA—Four channels • Communication with main the Freescale family of DSCs based • Two quad timer modules control system on the 56800E core. Family key • One quadrature decoder module features include: Belt-Driven vs. • Two periodic interval timers • Core operation frequency—60 MHz Direct Drive Washers • Analog comparator with integrated • High-speed peripheral clock— The most common washing machines 6-bit DAC—four modules 120 MHz contain belts. This mechanical • 12-bit DAC—one module construction consists of two pulleys with • Flash memory—from 48 KB to 64 KB • Crossbar module the belt transmitting the power, torque • RAM memory—from 6 KB to 8 KB and the speed from the motor to the • Three queued SCIs, three queued • eFlex PWM module—Six channels 2 drum. The smaller pulley is mounted on SPIs, two I Cs, one FlexCAN • 12-bit ADC with programmable the motor shaft while the larger pulley is gain—from 2 x 4 channels to 2 x 8 Conclusion mounted on the drum shaft. Assuming channels The washing machine is one of the the typical motor to drum transmission • Analog comparator with integrated most sophisticated white goods in ratio is 1:10, the drum speed at 5-bit DAC—three modules terms of motor control due to a wide spinning operation of 1600 RPM and speed range, load variation and cost startup motor torque 2 nm, we can • 12-bit DAC—one module optimization. Freescale provides simply calculate the speed of the motor • Crossbar module dedicated MCUs that are capable to corresponding to the spinning operation • Queued SCI, queued SPI, I2C, effectively solve the needs of these as 16000 RPM and torque on the drum MSCAN complex applications. during the startup as 20 nm. The MC56F844x/5x/7x is the initial Comprehensive information about Direct drive washing machine family of 32-bit 56800EX core-based MCUs, programming and debugging construction does not include pulleys DSCs. The 56800EX includes all tools and universal high voltage and belts, therefore the motor shaft features of the 56800E core as well as inverters for simplifying application is directly mounted to the drum the following enhancements: development can be found at shaft. The motor supporting this • 32-bit x 32-bit MULT/MAC freescale.com. Here you can also find mechanical construction is optimized operations application notes and design reference for high torque and relatively low- • Address generation unit (AGU) manuals describing details of the speed operation. This type of motor, includes shadow registers specific washing machine application called “Pancake Motor,” has specific • Bit-reverse address mode and providing design hints utilizing the construction as shown in figure 1. supporting FFT great features of Freescale MCUs. Typical construction of the pancake • New bit manipulation instruction— Reference Designs—DRM110, motor includes: BFSC DRM075, DRM070, DRM099 • Rotor construction—permanent Family key features: magnet Application Notes—AN3476, AN3234 • Core operation frequency— Videos—PMSM sensorless motor drive • Stator winding—three-phase up to 100 MHz High voltage power stage— • 24 to 48 poles • High-speed peripheral clock— 3PHACBLDCHVPSUG Freescale Support 120 MHz Additional information related to the • Program/data flash memory—up to for Washing Machine washer application, such as touch 256 KB Applications control, connectivity (ZigBee) and water • Program/data RAM—up to 32 KB The Freescale MCU portfolio provides level measurement (pressure sensors), solutions for a wide variety of washing • FlexMemory can be found at freescale.com. machine applications. The Freescale freescale.com/motorcontrol 35 Application Examples

Dual Motor Control for Air Conditioning with 100 MHz/32-bit DSC Single DSC controls two motors plus PFC

Introduction Figure 1: MC56F84xx Block Diagram Motor drives are an integral part MC56F84xx of various home appliances. Their Core System Communication development is dictated by safety and 56800EX 4-ch. DMA 3x UART environment-friendly requirements, 100 MHz Memory Resource 3x SPI Protection Unit by performance requirements, and CAN Memory Quadrature Decoder of course by the manufacturing 2x I2C/SMBus 256 KB Flash cost. Often, the vector control (also CRC FlexMemory EOnCE (Debug Module) Voltage Regulator called field-oriented control (FOC)) is 32 KB Flash or JTAG requested. Vector control provides 2 KB EEPROM Internal Watchdog excellent dynamic performance, 32 KB SRAM External Watchdog Clocks and Timer utilizes the full motor torque capability Inter-Module Cross Bar and controls the motor with high efficiency and dynamics. Additionally, High-Res MC 4x Analog 2x HS ADC DAC PWM SAR ADC PWM CMP 8-ch./12-bit Timers 1-ch./12-bit 16-ch./16-bit the need for a unity input power factor 8-ch. + 12-ch. + 6-bit DAC with PGA leads to the implementation of power PWM 4-ch. factor correction (PFC) circuitry. control applications. Two pulse-width- conditioning unit, where it controls Some appliances accommodate modulation (eFlex PWM) modules both the fan and compressor. more than one motor. One example enable implementation of dual motor is a washer with a water pump and The application requirements for such control. Two 12-bit high-speed analog- main drive, or an air conditioning unit a system are as follows: to-digital converters (ADCs), with up to accommodating both a compressor • Dual control of permanent magnet 300 ns/3.33 Ms/s sampling frequency and fan. Traditionally, these motors synchronous motors were driven by separate electronic are used for analog value sensing. Four • Sinusoidal vector control of circuits. However, the push for minimal analog comparators, with integrated both motors cost has resulted in drives that control 6-bit digital-to-analog converters • Sensorless motor position two motors in parallel using a single (DACs) enable emergency shutdown estimation MCU, thus minimizing duplication of of the PWM outputs. Programmable expensive electronic components. delay block (PDB) synchronizes ADC • High startup torque, wide triggering with the PWM pulses needed speed range Freescale DSC Dedicated for motor current reconstruction. The • PWM frequency of 8–16 kHz for Dual Motor Control direct memory access (DMA) controller • Three-phase current sensing using Freescale offers a number of DSCs reduces core interruption and increases shunt resistors (in some cases, a that satisfy the requirements of performance. The inter-module crossbar single shunt current sensing on the advanced motor control applications. is a versatile peripheral that provides DC bus may be preferred), DC bus The recently announced 100 MHz generalized connections between voltage sensing on-chip peripherals. MC56F84xx DSCs based on • Power factor correction at the the 32-bit MC56800EX core are Application Requirements input (depending on the region and dedicated to digital power conversion total power) and sensorless dual motor control. The dual sensorless sinusoidal vector control with power factor correction • Hardware and software fault The MC56F84xx includes advanced is typical for washers where a single protection high-speed and high-accuracy MCU controls both the pump and • Connectivity with a master/ peripherals dedicated to motor main drive—or, for an outdoor air slave system

36 Beyond Bits Motor Control Edition

Figure 2: Dual Motor Control Topology algorithms in parallel. Typically, a single DC bus circuitry of the inverter is shared between the motors. In order Three-Phase DC Bus Inverter PMSM to decrease the current stress of a Interleave Motor 2 AC Line PFC Fan single DC bus capacitor and to achieve

Three-Phase a minimal DC bus voltage ripple, the Control Feedback Inverter PMSM Motor 1 PWM pulses of these two motors are Control Feedback Compressor Control Feedback shifted from each other by 50 percent of the PWM period. This PWM shift allows Sensorless FOC Sensorless FOC Interleave PFC the alternation of ADC sampling so that Control Control Control Motor 1 Motor 2 two ADC converters are sufficient. Then, Application Control the calculation of the fast loops of the Application S/W sensorless vector control algorithm for MC56F84xx each motor alternates as well. As an option, the PFC might be • Meeting the IEC60730 appliance flux. According to the results of these required. Several types of PFC safety standards controllers, the output voltage vector is topologies may be implemented, calculated and proper complementary depending on the performance Application Concept PWM signals for the inverter are requirements, output power and load This solution concept demonstrates generated. In the case of above nominal conditions. For the higher power, the that a single DSC MC56F84xx controls high motor speeds, a special algorithm interleaved PFC running in continuous the whole application—both motors, must be included that allows operation conduction mode is often used. The PFC, provides the connectivity and in the field weakening region. Moreover, interleaved PFC accommodates two the application controls. The power some motors have a strong reluctance MOSFET power switches and two hardware includes two power inverters torque. In order to use this reluctance PFC inductors. The MCU senses the sharing the DC bus circuitry, PFC torque and thus allow the construction input current and controls the power power electronics, current and voltage of the smallest (and cost-effective) motor switches in order to maintain the input sensing and an auxiliary power supply. possible, developers are implementing a current as sinusoidal and synchronized The advanced motor control algorithm special algorithm called maximal torque with the grid. A typical PWM frequency is based on the vector control per amp (MTPA) that allows full utilization for PFC is in the range of 50–100 kHz. of the reluctance torque. The separation technique. In a special reference The advanced motor control algorithm and independent control of the torque- frame, the stator currents can be requires the dedicated peripheral generated and flux-generated currents separated into a torque-producing features and CPU performance of allows a highly dynamic operation, from component and a magnetic field- the MCU in order to manage both very low speeds and excellent control producing component. These motors plus the PFC. The Freescale characteristics. components are represented by DC MC56F84xx satisfies the application values and can be controlled both For proper functionality, the vector requirements, and is the ideal candidate separately and independently. control algorithm requires position for such advanced applications. The vector control algorithm requires and speed information. The most measurement of the three-phase useful algorithm for a sensorless Freescale Enablement currents using a fast ADC. The current position calculation of permanent Freescale offers a comprehensive measurement must be synchronized magnet synchronous motors is based set of reference designs, with the center of the PWM pulses in on the calculation of the back EMF application notes and tools targeting order to avoid a switching noise and mathematical model of the motor. motor control available at obtain a meaningful mean-time current In runtime, the DSC solves a set freescale.com/motorcontrol. of equations, runs digital filters and value. Typically, two-phase currents Reference designs describing dual motor estimators, and calculates the motor are measured simultaneously, and the control with PFC using MC56F84xxx will position and speed. third is calculated. The control system be available in Q1 2013. includes two current control loops, one Dual motor control requires the for torque and one for magnetic field calculation of two whole vector control freescale.com/motorcontrol 37 Application Examples

Industrial/Appliance PMSM Drive Sensorless PMSM field-oriented control for compressors, fans, pumps and similar drives

Introduction Figure 1: Sensorless PMSM Field-Oriented Control Sensorless permanent magnet synchronous motor (PMSM) field- oriented control (FOC) for industrial or appliance drives is gaining popularity as a cost-effective, energy-efficient controller solution. This article provides PMSM information on the sensorless PMSM FOC for compressors, fans, pumps and similar drives.

Current Typical Requirements Feedback Industrial or applicance drives such as compressors, fans and pumps are usually variable power with a mid- speed operation range. PWM FOC and Feedback Generation BEMF Processing Control requirements include: Speed Observer Command • Sensorless FOC of a PMS motor. To achieve this, a powerful DSC to create torque. The torque is the DC bus voltage has a reserve must be chosen. proportional to the supplied current. to be applied on the motor and the • Speed 200 to 10,000 RPM It is time consuming to control three current can then be increased in the mechanical. The sensorless sinusoidal wave forms. Therefore it motor. A higher speed is then reached. algorithm must estimate position and is essential to decompose the three Freescale has developed this method speed within this speed range. components into two components of field weakening. • Startup and alignment torque aligned to the rotor position. Then, the depends on the drive. The two components are used to control Sensorless Driving This application requires position compressors have high start-up the system: one that controls the field and speed information. The use of a torque while the fans have low. and the other, the torque. position sensor is costly, so it cannot • PWM frequency of 5 to 10 kHz.This Finally, there are PI controllers to be used. Therefore, it is necessary is a compromise among switching control these two currents. The to get the position and speed without losses, audible noise and enough desired torque current value is the need of additional physical samples for the sensorless control, provided by the output of the speed PI position sensors. where the ADC is synchronized to controller. The magnetization current To reach the speed and position, the PWM. is kept at zero until the strength of it is necessary to know the motor the field is reduced. This moment Application Concept parameters well to calculate its occurs when the speed is high and model observer. The parameters are FOC the induced BEMF is at the level of programmed into the algorithm called The PMS motor rotates when its three the DC bus voltage; it is not possible the BEMF observer. This observer’s phases are supplied by sinusoidal to reach higher speeds. By reducing function is to calculate the position of current. The phase of each sine the strength of the field, the lower the BEMF, which is needed to drive must be aligned to the rotor position level of BEMF is induced. In this case, the motor. The position is then passed

38 Beyond Bits Motor Control Edition

Figure 2: Sensorless PMSM FOC, Software Blocks

Field Control D Current Control

Inverse Park FW Error ud Transformation SVM PWM Calculator u α d, q u β Phase α, β Three- req uq Inverter

Ramp Speed Control Q Current Control

i i i d α α, β a d, q i i b iq β i α, β a, b, c c Current Park Clarke Sensors Transformation Transformation

θ Tracking BEMF Observer Observer

through the tracking observer to be the control technique. The interrupt on a 100 MHz DSC). The speed loop filtered, and as a side product the latency should be short. runs at the period of 1 to 5 ms. actual speed is filtered. Its inputs for • Core: Must have great computation Tasks include: current, applied voltages and speed potential in terms of mathematical • Speed ramp calculation are then measured. operation. • Speed PI controller calculation This solution requires a powerful Performance controller from the Freescale 56800E/ • Field weakening algorithm Ex family of DSCs. The application uses two main loops: The speed loop duration has been current and speed. The current loop is measured as 1.8 μs. The code Implementation critical and is calculated on the PWM occupies 3165 words of ROM and Freescale offers a selection of DSCs frequency of 10 kHz. The loop has 279 words of RAM. for this important task. The following several tasks: is a list of what is mandatory for such • Reading of measured currents and Freescale Enablement an application: voltage, and reconstruction of the • Application based on FSLESL freescale.com/motorcontrol • PWM: Should offer center-aligned current from two values into three mode, complementary switching • BEMF + tracking observer • Embedded software and motor capability with the deadtime • Clarke and Park transformation control libraries freescale.com/fslesl insertion, three-phase oriented and • D and Q current controllers and synchronization with the ADC. their limitation depending on the • FreeMASTER visualization tool • ADC: Simultaneously measures two DC bus voltage freescale.com/freeMASTER currents, with two channels working • DC bus ripple compensation • Application support from Freescale in parallel. motor control experts • Space vector modulation • SCI: Necessary for the • PWM update communication with FreeMASTER to allow application debugging. • ADC configuration for the next step • Interrupt controller: Must be priority The duration of the current loop has controlled to avoid disintegrity of been measured as 14 μs (measured

freescale.com/motorcontrol 39 Application Examples

Industrial Drives Simple ACIM V/Hz Drives

Introduction Figure 1: Voltage/Frequency Relation This article describes the basic control method for an AC induction Phase motor (ACIM). The method principle, Voltage hardware and software implementation Base Point 100% will be explained, and solutions will be recommended and described.

ACIM V/Hz Control Open loop voltage/frequency (V/F) control (scalar control) is one of the Boost most frequently used, simplest control Voltage methods. This method doesn’t require Boost Base Frequency high computing power and there is no Freq. Freq. feedback, which means that the rotor speed accuracy remains low and an expensive speed sensor is not required. Scalar control is typically used for The stator supply voltage must also Below the base point, the motor drives where changing of speeds vary according to frequency, as the operates at optimum excitation, called is required and low accuracy result would be an overcurrent in the constant torque operation, due to the speed regulation and low dynamic motor winding. The control algorithm constant V/F ratio. Above this point, performance are acceptable. This maintains a constant magnetizing the motor operates under-excited, makes ACIMs with V/Hz control current (flux) in the motor by varying called constant power operation, due convenient for low-cost drives like the stator voltage with frequency. to the limit of the rated voltage. fans, ventilators, pumps, compressors Figure 1 shows the relation between and as a driver of other appliances. stator voltage and frequency. Block Control Scheme These drives also enjoy the benefit of Figure 2 shows the V/Hz control The most common high efficiency requiring little maintenance. structure, which can be divided into technique for maintaining an average hardware and software. The hardware voltage level is via pulse width V/Hz Principle consists of a frequency converter, modulation (PWM). In this method, The volt per hertz (V/Hz) control sensors and driver, while the software voltage pulses are not an issue, as method is one of the most popular is comprised of a control algorithm. motor winding includes inductance scalar methods, and controls the which ensures a smooth current in magnitude and frequency of variables Hardware the stator. such as frequency, voltage or current. The motor is supplied by the This method principle is based on For sine stator current generation, the adjustable frequency generated from motor speed being proportional to duty cycle of the stator voltage pulses the frequency converter with voltage supply voltage frequency, enabling fluctuate in relation to the sinusoidal DC bus. The frequency converter motor speeds to be easily changed. reference signal. consists of an input diode rectifier, The applied stator voltage is calculated DC bus capacitor and output voltage directly from the applied frequency in three-phase inverter. order to maintain a constant air gap flux within the machine.

40 Beyond Bits Motor Control Edition

Figure 2: Control Structure The inverter is built from three half- bridge units (see figure 3) where the

Rectifier Three-Phase Inverter top and bottom switch are controlled ~ DC Bus complementarily. This means that once Line Three- the first switch is turned on, the second Voltage Phase 230 V/50 Hz ACM must be turned off, or vice versa. = During state change, both switches are

Temperature, turned off, resulting in dead time. Current and Voltage Sensing The most popular devices for motor

Overcurrent control applications are power Temperature and PWM DC Bus Voltage and Overvoltage MOSFETs and IGBTs. Software Modulation Techniques Temperature Faults and Voltage There are two pulse generation ADC Processing Processing methods for each complementary pair. DC Bus Voltage An easier method uses a comparison

Speed of an isosceles triangle carrier wave V1 V2 Setup Speed DC Bus PWM Command V/Hz Ripple Generator with a sine-modulating wave, as Processing Elim. with shown in figure 4. Dead Time F The more complicated, but more effective method of space vector modulation uses six active vectors Figure 3: Three-Phase Inverter with DC Bus and two zero vectors. Each active vector corresponds to three transistors + DC Bus from the top and bottom area. The zero vectors activate either all top or T T T 1 3 5 all bottom-switching elements. The space between active vectors relates C + to a combination of the nearest active vector and arbitrary zero vector. T T T 2 4 6 Software - DC Bus The application measures the DC bus voltage, current and temperature. The overcurrent and overvoltage faults are checked to avoid drive failure. Ph. B The DC bus voltage is also used for the ripple elimination. Ph. A Ph. C The speed command is processed using the ramp. The corresponding voltage is calculated using the Three-Phase AC Motor V/ Hz ramp and the DC bus ripple elimination block then eliminates the influence of the DC bus voltage ripple according to the generated phase voltage amplitude. The PWM generation process calculates a three-phase voltage system from the required amplitude and frequency.

freescale.com/motorcontrol 41 Application Examples

Finally, the three-phase PWM inverter Figure 4: Pulse Width Modulation Technique pulses are generated. Generated PMW Carrier Recommended Devices Sine Wave Wave 1 For the solution described, Freescale S08MP16 or Kinetis series MCUs are recommended depending on the 0 core required. ωτ The S08MP16 is an 8-bit device with frequencies up to 50 MHz and an -1 HCS08 core. The Kinetis K series offers a more powerful 32-bit ARM Cortex-M4 core with frequencies up to 1 PWM Output T1 150 MHz. The K series also integrates (Upper Switch) 0 up to 1 MB of flash and 128 KB 1 ωτ SRAM versus the 16 KB flash and PWM Output T 2 0 1 KB RAM memory of the S08MP16. (Lower Switch) Kinetis K40 MCUs also offer a 144 LQFP or MAPBGA package in comparison with the maximum 48-pin LQFP package of the S08MP16. Both devices include the FlexTimer module for PWM generation and PDB module for triggering. The S08MP16 has only one 12-bit ADC against two ADCs with up to 16-bit resolution offered with Kinetis K40 MCUs. Selecting the right device depends upon the requirements of your application. If your application is performing multiple processes on a single device, the more powerful, higher performance Kinetis MCUs offer a simple solution. For a more cost- effective solution, the S08MP16 is ideal. For more information about ACIM V/Hz control, visit freescale.com.

42 Beyond Bits Motor Control Edition

Digital AC Drive Control Freescale solutions for industrial AC drives

Industrial AC drives are used to drive Figure 1: Dual MCU Industrial AC Drive Topology a wide variety of asynchronous or synchronous AC motors. The AC I/O Signals Communication induction motor is a popular choice for industrial automation and OEM machinery applications. Industrial UI and Communication automation covers a wide range MCU of applications including pumps, fans, HVAC, centrifuges, elevators, Isolation Barrier escalators, test stands, packaging, smart material working and smart Motor Control MCU baggage handling.

AC drives use different control PWM Signals Analog Signals techniques depending upon the final application. The most common is Three-Phase Power Stage AC open loop V/Hz, which is used for MOTOR low dynamic applications like fans or pumps. High dynamic applications use field oriented control (FOC), which Industrial drives use many types of communication peripherals (SCI, SPI, allows for precise motor control under communication interfaces, including I2C), and on-board flash and RAM. a variety of conditions. Many AC drives PROFI bus, MODBUS, CANopen, are equipped with auto detection of Selection of a secondary controller DeviceNet and EtherNet IP. the motor parameters, allowing for depends on the complexity of the sensorless drive operation. Application Requirements user interface and the amount of I/O signals. A general-purpose MCU AC drives are available in a wide range MCU requirements for AC drives is often suitable for simple user of output power, from 250 W (DIN rail differ with complexity of the AC drive interfaces, while an MCU with LCD or mounted) up to several megawatts. and position of the isolation barrier. VGA controller is often preferred for Very high-power AC drives usually Low-power drives often use dual more advanced applications. Kinetis L connect multiple lower power AC MCU topology where the MCU on the and K series MCUs are ideal for these drives in parallel. non-isolated side is responsible for advanced user interface applications. Beyond AC motor control, industrial motor control and the isolated MCU drives are equipped with many handles user interface and I/O signals. Kinetis K Series additional features. Typical features This topology is shown in figure 1. When AC drives use a single MCU of AC drives include implementation A DSC is often used as a primary topology, the MCU is located on the of a programmable logic controller controller. The Freescale MC56F80xx, non-isolated side, while all I/Os and (PLC) as well as on-board or MC56F82xxx, MCF56F84xxx family communication and user interfaces is well suited for digital motor control, expansion I/O ports. These I/O ports employ galvanic isolation. The can be used to apply switches, combining the DSP’s calculation Kinetis K series is ideal for AC drives relays and other sensors to the capability with the MCU’s controller implementing a programmable logic application. The PLC can speed features on a single chip. These hybrid controller, operating system and a wide target application development and controllers offer many dedicated range of communication interfaces. eliminate complicated wired schemas. peripherals such as pulse width Kinetis MCUs are the most scalable Another important feature of AC modulation (PWM) modules, analog- low power, mixed-signal ARM drives is communication support. to-digital converters (ADC), timers, freescale.com/motorcontrol 43 Application Examples

Cortex-M4 core-based solutions in Figure 2: Kinetis MCU Portfolio the industry. The portfolio consists of seven MCU families with over Family Program Flash Packages Features 200 pin-, peripheral- and software- Low power, mixed signal, USB, Ethernet, K70 Family 512 KB–1 MB 196–256-pin encryption and tamper detect, DDR, compatible devices (see figure 2). graphic LCD Each family offers excellent Low power, mixed signal, USB, Ethernet, K6x Family 256 KB–1 MB 100–256-pin performance, memory and feature encryption and tamper detect, DDR scalability with common peripherals, Low power, mixed signal, USB, segment K50 Family 128–512 KB 64–144-pin LCD, Ethernet, encryption and tamper detect, memory maps and packages, operational transimpedance amplifiers providing easy migration both within K40 Family 64–512 KB 64–144-pin Low power, mixed signal, USB, segment LCD and between families. K30 Family 64–512 KB 64–144-pin Low power, mixed signal, segment LCD The most suitable family for advanced AC drives is the Kinetis K70 series, K20 Family 32 KB–1 MB 32–144-pin Low power, mixed signal, USB with a powerful ARM Cortex-M4 core K10 Family 32 KB–1 MB 32–144-pin Low power, mixed signal running at 120/150 MHz. Peripherals include an integrated graphics LCD controller, IEEE® 1588 Ethernet Vybrid Controller Series These devices allow an application MAC, Full- and High-Speed USB 2.0 For more advanced AC drives, to be split into two parts. The ARM On-The-Go with device charger detect which run operating systems such Cortex-M4 core is responsible for real- capability, hardware encryption and as Linux, there are devices from time control of motor drives, including tamper detection capabilities. The the Vybrid series suitable for such PLC, while the ARM Cortex-A5 core K70 is available with 512 KB or 1 MB high demands, particularly those in can run operating systems responsible of flash in 256-pin MBGA packages. the VF6xx family. The VF6xx family for rich multimedia. Each MCU includes a rich suite of features a heterogeneous dual- For more information, visit analog, communication, timing and core solution that combines ARM freescale.com/Kinetis or freescale. control peripherals, as well as a single Cortex™-A5 and Cortex-M4 cores. com/dsc. precision floating point unit and NAND The family also features dual USB 2.0 flash controller. 256-pin versions OTG controllers with integrated PHY, include an on-chip DRAM controller dual 10/100 Ethernet controllers with for system expansion. The K70 also L2 switch, 1.5 MB of on-chip SRAM includes peripherals for motor control and a rich suite of communication, such as up to four FlexTimers with two connectivity and human-machine or eight PWM outputs, up to four ADC interfaces, multiple serial interfaces and programmable delay blocks for including UARTs with support for FTM to ADC synchronization. This set ISO7816 SIM/smart cards, SPI and of peripherals allows for the design of I2C and dual CAN modules. VF6xx powerful and complex AC drives. devices can interface to a variety of external peripherals and memories for system expansion and data storage.

44 Beyond Bits Motor Control Edition

Servo Robots for Industrial Applications: PMSM with Encoder Kinetis MCUs and DSCs

Introduction Figure 1: CNC Machine Block Diagram Robots have begun to play a large part in the factory automation System HMI Axis Control process, substituting for humans in Supervisor operations such as welding, painting, assembling, cutting, palletizing and Safety Safety Safety general operations where the machine MCU MCU MCU can perform the work cheaper, faster and more accurately. This article Motor Motor Motor Control MCU Control MCU Control MCU focuses on the system description and requirements from a motor control perspective. Power Power Power Module Module Module Requirements 400 V 400 V 400 V Whether the configuration of the robot architecture is linear or articulated, most applications demand high accuracy of the robotic arm motion. Therefore, the motor control strategy employs the position control loop Concept positional instruction by interpolating where actual position is captured it to various coordinate systems and The high-level block diagram shown in by the position sensor, usually the sending the information to particular figure 1 illustrates the components of incremental or absolute encoder with motor controllers. a simple robotic system, in this case, a very high resolution. The degrees of milling CNC machine. The top layer of From the peripheral requirements point freedom (DOF) (number of moving the machine control architecture is the of view, the MCU should be capable joints) of the robotic system are main CNC controller, which typically of handling different kinds of industrial equal to the number of motors used. requires utilization of multiple MCU communication protocols and contain a Consequently, the higher the value cores. The tasks and services it must large internal on-chip memory. On the of DOF, the higher the requirements perform include: other hand, there is no need for specific on precision of movement of each motor control peripheral modules. motor, as position errors introduced • Human-machine interface/display by each motor are multiplied. It is not should enable entering, visualization The demands on the motor control rare to find encoders with millions of and editing of the complete CNC layer are different from the upper pulses in these sorts of applications. program. layer. Applying a single MCU may not satisfy the application needs in each The demands on the position control • System supervisor monitors and case. An additional monitoring safety of the tool holder of the punching or directs other MCUs, handles system MCU might be required. Beyond drilling CNC machine are lower when exceptions and interrupt signals. It communication, the main MCU compared to the welding or miller stores the CNC control program, executes the motor control algorithm CNC machine, where the movement tool calibration and tool offset and handles the fault states of the of the joints has to be precisely parameters, as well as different user particular drive. The motor control synchronized in order to maintain the compensations and other settings. algorithm includes calculation of required trajectory. • Axis control processor interprets position, speed and current (torque) the CNC program and calculates control loops. The optimal size of freescale.com/motorcontrol 45 Application Examples

on-chip non-volatile memory is in the Robotic systems often include Dedicated motor control MCUs range of tens of kilobytes. The MCU additional components that have are available in the following must have dedicated motor control to be controlled by an MCU, such Freescale families: peripheral modules, including a timer as an automatic tool changer and • MC56F84xx, 32-bit/100 MHz DSC for 6-channel PWM generation, tool coolant control, or in the case based on 56800EX Core a fast and accurate AD converter of the CNC lathe machine, a spindle • Kinetis K40, K60 MCUs based on and an interface for processing the drive control. the ARM Cortex-M4 core encoder signals. Implementation of These solutions have dedicated motor Communication between the main Freescale MCUs control peripheral modules, including CNC controller and the motor control PWM generation with synchronized MCUs is sometimes realized with Each layer of the control chain can be ADC. Floating point unit is not optical bus in order to protect the equipped by a Freescale MCU. required, as the performance of the position information in harsh, As mentioned, the top layer requires core is sufficient for execution of the noisy environments. significant computation power to vector control algorithm. The bottom layer represents power perform multiple tasks, though it does modules, each driving a single not require specific motor control Freescale Enablement motor. These do not contain specific peripherals. The Freescale portfolio of Additional information, including MCU logic, but can be equipped 32-bit solutions offers several options reference designs, application notes with an intelligent driver of IGBTs or to meet this need: and embedded software libraries for power MOSFETs that can perform • Vybrid controller solutions built on motor control is available at failsafe and diagnostic features. The single- or dual-core ARM Cortex-A5/ freescale.com/motorcontrol. information is passed over the fast Cortex-M4 solutions communication interface to the motor • Kinetis K70 MCU based on the control MCU. The power module ARM Cortex-M4 core measures the feedback signals These MCUs contain safety features (phase currents, voltage) used in the that are equipped with floating control algorithm. point unit, possess high-performance cores and are suitable for trajectory calculation.

46 Beyond Bits Motor Control Edition

Continuous Positive Airway Pressure (CPAP) Machine Components, characteristics and device implementation

Introduction Figure 1: CPAP Implementation According to the National Sleep Foundation, more than 18 million American adults have obstructive sleep apnea (OSA). OSA occurs when the back muscles of the throat relax while sleeping, causing the airway to narrow, resulting in snoring. These muscles could also completely block the flow of air to the lungs. When the brain detects a lack of oxygenation, it sends an impulse to the muscles forcing them to restart the breathing process. While this is a normal process that often happens to healthy people, patients with OSA may repeat this process hundreds of times during the night without being aware of this problem. Some symptoms of OSA are daytime drowsiness, headaches and irritability. People with sleep apnea also tend to Application Requirements in the mask. The most common be overweight. This syndrome is more Constant airflow pressure can humidifier for this application is the common among men than women. be obtained by the continuous heater-humidifier. The humidity level can be adjusted by the patient. The most common treatment for sleep monitoring of the system pressure in apnea is a method of pushing air conjunction with the ventilator motor The user interface needs to be as through the airway called continuous control speed regulation. The main simple as possible, yet provide the positive airway pressure (CPAP), as goal is to control the output pressure physician with accurate feedback. The shown in figure 1. The main goal of and not the airflow. device must be robust and able to be this device is to provide constant Due to the nature of this syndrome, used for extended periods of time. positive pressure to the respiratory the CPAP must be placed near the As shown in figure 1, the patient is system in order to prevent muscles patient during sleep. Therefore, it required to wear a mask through the from obstructing the airway. needs to be noise free and avoid night. As this method is not ideal, the This article shows the main CPAP toggling that might disturb the CPAP includes features that allow a components, its characteristics and patient’s sleep. patient to get used to this impediment. what Freescale offers for a CPAP The CPAP counts with a humidifier For example, some CPAP devices device implementation. chamber that increases the amount of include algorithms that decrease vapor in the air to avoid drying out the the air pressure during exhale and airways or skin in the case of leakage increase during inhale.

freescale.com/motorcontrol 47 Application Examples

Algorithms can also be applied Figure 2: CPAPC Block Diagram to allow the device to adjust functionality during different levels Power Supply of sleep. Ramp pressure algorithms Air Pump Blower can also be programmed to help the To the Mask patient fall asleep. P Water Container The ventilator can also be switched off if the mask slips off during sleep, causing a loss in air pressure.

Application concept FTM/6PWM ADC PGA Segment LCD Figure 2 shows a block diagram for a CPAP based on a Kinetis K40 MCU. SLCD 10:00

The K40 MCU includes Full-Speed Kinetis K40 MCU Keyboard USB 2.0 On-The-Go with device Touch charge detect capability and a flexible USB- Sensing OTG low-power segment LCD controller GPIO with support for up to 320 segments. Devices start from 64 KB of flash in 64-pin QFN packages extending The K40 offers a segment LCD monitor breathing behavior or to up to 512 KB in a 144-pin MAPBGA controller and touch sensing detect mask displacement. interface peripherals. package with a rich suite of analog, The humidifier chamber heater can communication, timing and The Kinetis K40 MCU is based on be controlled through a GPIO with control peripherals. the ARM Cortex-M4 core with DSP a 16-bit ADC channel measuring The K40 USB and segment LCD capabilities that facilitate pressure the temperature. MCUs are Freescale Energy-Efficient control algorithms and a digital filter Freescale Enablement Solutions. The K40 includes a flex for pressure sensing. Freescale offers a variety of timer designed to generate PWM The system uses the MPXV7002 software and tools that help reduce signals for BLDC motor control in pressure sensor. This device is development time. These include addition to other peripherals such as inside the 2 kPA range, which is an modular platforms such as Tower timers, ADC and PDC used for the appropriate pressure for a respiratory System development boards, phase and voltage readings for system. In addition to the MPXV7002, CodeWarrior IDE, a real-time debug a sensorless motor. a differential pressure sensor can be monitor and data visualization tools added to the system to detect airflow, such as FreeMASTER.

48 Beyond Bits Motor Control Edition

BLDC Motor Control for Respirators Using high-speed sensorless BLDC motor control in medical devices

Introduction Figure 1: Kinetis K60 MCU Block Diagram Brushless DC (BLDC) motors are widely used in medical devices due Air Input High- High-Speed Pressure to their high reliability, high efficiency, Voltage Three-Phase Speed Respiratory Power Stage BLDC Fan low maintenance and many other Ventilation Control advantages. One of the most popular DC Bus, UI BEMF applications is a sleep apnea machine. Voltage Kinetis Peripherals For people who suffer from sleep Freescale MCU PBD apnea, the most common treatment ADC Block PWM RTOS (BEMF Sense, U Power is the use of a continuous positive Generator DCB, IDCB) Electronic Communication airway pressure (CPAP) device, which Temperature Commutation Control “splints” the patient’s airway open Data Storage Humidity Software during sleep by means of a flow Control User Interface Current Controller of pressurized air into the throat. Pressure Fault Sensing Display Protection The patient usually wears a plastic Pressure Controller Motor facial mask, which is connected Parts by a flexible tube to a small CPAP machine. Advanced models may warm or humidify the air and monitor the • Safety algorithms other hand, when the high-speed patient’s breathing to ensure proper If we look more closely at this operation is used it is easier to treatment. For pressuring the air, a application, we can see that the motor achieve the required air pressure. small and usually very-high-speed control requirements are also very strict. The maximal speed typically ranges BLDC or PMSM motor is used. from 30,000 to 60,000 RPM. In • Reliability: As sleep apnea minimal speed mode, the motor machines are medical devices, Application Requirements should operate from 1500 RPM. reliability is first placed on the The motor controls in the sleep That equals roughly 2.5 to 5 motor to start and operate with 100 apnea machine have very complex percent of maximum speed. This percent reliability in any condition. requirements. A first important is very complicated from the PI That means the motor is already requirement is MCU power. The controller setting point of view due spinning in a forward or backward dedicated MCU performs many other to the very wide range of speed. In direction just before startup. algorithms, so the motor control part the high-speed region, it is also very should not consume more than • Pressure control: The difference difficult to determine commutation 20 percent of total controller power. with standard BLDC applications instance, as only a few samples In addition to motor control, the is that a fan is typically controlled of BEMF are measured between controller should perform: according to required pressure not commutations. For high-speed by required speed. The machine • Display control operation, a very fast and precise must generate the pressure • Communication ADC converter is required. according to pre-defined ramps and • Air humidity control • Low noise: A quiet motor makes patient requirements. • Air temperature control sleep more comfortable for patients • High-speed operation and wide and their sleeping partners. Noise • Recording data to allow doctors speed range: For small dimensions can be generated by the mechanical to verify adequacy of treatment or to allow enough airflow, the part of the fan, but it can also be adjust required pressure speed must be increased. On the caused by motor torque ripple. freescale.com/motorcontrol 49 Application Examples

• High accelerations and braking: This increases precision of the that ensure safe PWM signal The motor usually has small measured back EMF voltage. For generation with minimal MCU diameter lightweight impellers which this sensorless BLDC application, it intervention. There are three provide lower inertia. This allows the is necessary to sense the following FlexTimers modules (FTM) on the system to operate with very high parameters during the application run: K60 device. FTM0 is an eight-channel dynamics, such as acceleration • DC bus voltage timer, while FTM1 and FTM2 are two- and braking near 200,000 RPM per channel timers. Each FTM module is • DC bus current second. This dynamic is required to a timer that supports input capture, achieve the requested pressure in a • Phase A, B and C back EMF output compare and PWM signal very short time. voltages generation that control electric motor • Current control as an inner loop: The commutation time and period and power management applications. are calculated from these measured To achieve such a high dynamic, Performance Data the application must be equipped parameters. Precise computation of • Supply voltage: 24 V with a current controller. Otherwise, a commutation instance is one of the motor can be overloaded by the most important aspects of the • Supply current: 3.5 A exceeding maximal motor current. application. In the very high speed • Max speed: 30,000 RPM The current control also has region, only a few samples of BEMF • Dynamics: 200,000 RPM per additional noise reduction. Small, voltages are measured, and one of the second following methods should be used to high-speed BLDC motors usually • ROM: 6, 2 KB have very low inductance compared achieve sufficient accuracy. • RAM: 390 bytes to a conventional BLDC motor. • Multisampling of BEMF voltage • Processor load 16% (96 MHz) In this case, the bipolar PWM during one PWM period cannot be used. A solution can be • Increase of PWM frequency to Freescale Enablement achieved with higher frequency, achieve more samples For more information about Kinetis unipolar PWM strategy, or a power • Software zero cross approximation MCUs, visit freescale.com/Kinetis. stage with input DC-DC converter to change motor supply voltage • Usage of analog comparators For more information about the according to the motor speed. Implementation of Freescale Tower System, visit freescale.com/Tower. • Memory footprint and MCU Freescale MCUs performance: All previous For more information about The hardware abilities of the requirements must be met the Freescale FreeMASTER peripheral modules on the Kinetis K60 to achieve 20 percent power runtime debugging tool, visit MCU significantly reduce the CPU consumption. freescale.com/FreeMASTER. load on the user software and enable Application Concept precise high-speed sensorless BLDC See also design reference manuals: motor control. The Kinetis K60 MCU DRM135, DRM078, DRM086, The application concept is a pressure is based on the ARM Cortex-M4 core DRM128, DRM117 and application closed-loop BLDC drive using a with pulse width modulation (PWM), notes: AN4142, AN4376, AN4254 sensorless back EMF integration 2 x 16-bit ADCs with ADC to PWM and AN1914, which are available at technique with current control synchronization, programmable delay freescale.com. inert loop. FlexTimer, PDB and block, analog comparators, up to four ADC modules in sensorless BLDC fault inputs for global fault control, motor drives offer typical usage Ethernet controller, PGA, DAC, USB, examples. The FlexTimer simplifies up to 1 MB of internal flash and up calculation of PWM signals using to 128 KB of SRAM. It also contains the automatic complementary signal the mask and invert control registers generation and dead time insertion. with hardware and software triggers It significantly increases the safety of for simplified 6-step control. These PWM generation and the complete modules reflect specific requirements application. The PDB offers precise of the motor control application timing of the ADC sampling event.

50 Beyond Bits Motor Control Edition

Motor Control Using MQXTM RTOS Runtime library application control

Motor Control and MQX Figure 1: Motor Control Process Under the MQX RTOS Operating System TM Embedded applications are becoming Application Software Under MQX more complex and putting more MQX Initializations pressure on the Motor Control Process with Dedicated Driver software programmers. In a complex MQX Task 2 MQX Task 1 Motor Control Task: system, a number of tasks must run Application Control Shell Task • MC Driver Initialization in parallel and in real time under the • Motor Control Upper Software Layer operating system, including Ethernet, Internet CGI Interface ADC Done Timer Timeout USB and SDHC. One such task is (~50 micros) (~1 min) RTCS Ethernet the control of an electrical motor like Communication Processes DC, brushless DC, stepper or even Kernel/(MQX) Interrupt Kernel/(MQX) Interrupt Short Period ISR 1 Long Period ISR 2 three-phase sinusoidal motors such as USB Interface PMSM or AC induction motors. Vector Control Loop Driver Speed Control Driver USB • ADC Current Sensing • Speed Regulator API • Rotor Position Detection (Field Weakening) • Clark Park Transformations MQX RTOS • Current Regulators Other MQX Processes The MQX RTOS is a runtime library of functions that programs use for real-time multitasking applications. on constant sampling (for example, independent on MQX task processing. The MQX RTOS supports MPU ACIM and PMSM sinusoidal motor The motor control process is provided applications and can be used with control) or asynchronous events (for by one or more kernel interrupts or flexible embedded I/O products for example, BLDC motor commutation MQX highest priority interrupt tasks. networking, data communications, file control) with a fast system response The motor control process software management and control. requirement. The required response of is then similar to a standard non- the most critical events is usually one to operating system approach. The The main MQX application area is for tens of microseconds. The MQX RTOS MQX RTOS is used for initialization large controller devices such as Kinetis is a complex system with dynamic of motor control and also non-motor MCUs based on the ARM Cortex-M4 allocations and POSIX scheduling and control related tasks such as Ethernet processor with peripherals for has a system default tick duration of 5 communication in such a way to ensure Ethernet, USB, SDHC and additional ms. It is evident that the motor control that the time-critical motor control support. Some of these devices are process needs to be serviced with task is always executed on time and equipped with a PWM module and interrupts of high priority. the MQX-based tasks are done in the other peripherals designed or suitable remaining time slots. for motor control. Motor Control Under When to Use Motor Control the MQX RTOS Freescale Enablement Under the MQX RTOS The actual implementation of motor For MQX control applications, control under the MQX RTOS depends Freescale provides hardware Typical MQX-based motor control on the motor type, control algorithms platforms, MQX software installation, applications control one or more and application requirements. Each application notes and reference motors with dedicated sensors plus motor control technique consists of designs. Motor control under the other application functionalities such as periodic and asynchronous tasks. MQX operating system is described Ethernet or USB connectivity, display in AN4254. Three-phase BLDC control and user interfaces. In terms of Writing motor control applications under sensorless control with the MQX the time scheduling, advanced motor the MQX RTOS is usually provided RTOS using the K60N512 is control applications are naturally based as a dedicated motor control driver, described in DRM135. freescale.com/motorcontrol 51 Enablement Enablement

Freescale Motor Control Boards Hardware development kits provide rapid prototyping of motor control applications

Overview Figure 1: Motor Control Boards Freescale motor control development boards are intended to support the rapid evaluation and prototyping of a variety of motor control applications using Freescale MCUs.To cover both low- and high-voltage applications Freescale built two motor control development boards: • Low-voltage Tower System- compatible platform • High-voltage platform Tower System Three-Phase Low-Voltage Power Stage The TWR-MC-LV3PH low-voltage three-phase motor control module was designed to provide a Tower System-compatible module for motor control applications. This peripheral module is interchangeable across the development platform and can be used with a variety of existing controller modules.

Three-Phase High-Voltage Power Board available MCU Tower System modules, • Three-phase MOSFET gate driver High-voltage applications (supplied accommodating a selected MCU, it with overcurrent and undervoltage from mains) require a different provides a ready-made, software- protection approach of inverter board design development platform for one-third • Three-phase and DC bus current due to safety requirements and horsepower offline motors. Feedback sensing shunts isolation distances. The Freescale signals are provided that allow a variety high-voltage power board combines • DC bus-voltage sensing of algorithms to control three-phase a three-phase inverter and power • Three-phase back EMF voltage PMSM and BLDC motors. factor correction stage. The board sensing circuitry The TWR-MC-LV3PH module features: allows development and prototyping • Low-voltage on-board power of applications for white goods, • Power supply voltage input 12 to 24 supplies industrial and general-purpose drives. VDC, extended up to 50 V • Encoder/Hall sensor sensing Enablement Three-Phase Low-Voltage • Output current up to 8 A circuitry Tower System Board • Power supply reverse polarity • Motor power and signal connectors protection circuitry The three-phase low-voltage control • User LED, power-on LED, six PWM board (TWR-MC-LV3PH) is a peripheral • Three-phase bridge inverter LED diodes Tower System module. With one of the (six MOSFETs) • Braking resistor MOSFET

freescale.com/motorcontrol 53 Enablement

Sets of jumpers located on the board Three-Phase High-Voltage • Hardware overcurrent fault enable configuration setting of analog Power Board protection signals. SPI communication channel The three-phase high-voltage power • Active PFC and MC33937 driver signal selectors are board is a power stage and part of the • Overvoltage comparator with available through zero-ohm resistors. Freescale embedded motion control DC-brake resistor interface The MC33937 provides overcurrent series of development platforms. The • SCI-to-USB optically isolated and undervoltage functions, in kit consists of the main board and communication interface addition to other functions. a selected MCU daughter card. The The main component of three-phase interface between the card and the A filtered DC bus current signal is fed inverters is the smart power module main power board provides a 96-pin into the pre-driver current comparator (SPM). The high-speed built-in HVIC PCI connector which accommodates input. If the current exceeds the provides optocoupler-less single all required signals for the three-phase adjustable reference value, all six supply IGBT gate driving capability inverter and active power factor transistors are switched off while a that reduces the overall size of correction stage. fault bit setting in the status register. the inverter system design. Each The TWR-MC-LV3PH kit contains The power board is capable to phase current of the inverter can a three-phase BLDC motor with control sensored or sensorless PM be monitored separately due to the Hall sensors LINIX 45ZWN24-40 synchronous motors, AC induction divided negative DC terminal. motors and BLDC motors with the with parameters: The platform currently supports key power up to 1 kW. The DC bus MCUs dedicated for motor control • Rated voltage of 24 VDC voltage is regulated using PFC to applications: • Rated speed 4000 RPM the value of 400 VDC which enables • Rated power 40 W generation of three-phase output • MC9S08MP16 • Continuous current 2.34 A signals with amplitude up to 230 VAC. • MC56F80xx The board supports Tower System The algorithms for motor control • MC56F82xx standards and interface pin-out. applications required apart from • MC56F84xx However, not all Freescale MCUs powerful MCUs are also motor analog • MPC564xL signals (current, voltage) and a rotor are dedicated for motor control • K40X256 applications. The list of recommended position feedback. The motor position Tower System MCU modules that are in case of sensorless applications Availability fully compatible from TWR-MC-LV3PH is calculated using a motor model. The TWR-MC-LV3PH Tower System regarding number of PWMs, ADCs However, the real position of the rotor modules are currently available at and timer channels is as follows: is essential at least for initial application freescale.com for direct ordering tuning. The power board contains • 8-bit or through distributors. The kit interfaces for quadrature decoder, Hall contains three-phase BLDC motor, TWR-S08PT60 sensors, tacho generator and optional 24 VDC power supply and the Tower • ColdFire resolver position and speed feedbacks. System module. The BLDC example TWR-MCF5441X The HV power board features: applications are available for Kinetis • DSC MCU and DSC platforms. • Input voltage of 85–250 VAC TWR-56F8257 • Output current up to 15 A The kit and application software are TWR-56F8400 available at freescale.com/Tower. • Auxiliary power supplies 15 V and 5 • ARM core-based Kinetis MCUs V DC from rectified voltage The high-voltage power board will TWR-K40X256 • Three-phase IGBT power module be available for ordering in 2013. Currently, the board redesign is in TWR-K60N512 • Analog sensing (DCB voltage, DCB progress as well as mass production TWR-K70F120M current, phase currents, back preparations. The MCU daughter EMF voltage) cards will be available for both Kinetis • Motor speed/position sensors MCU and DSC platforms. interface (encoder, Hall, tacho generator, resolver)

54 Beyond Bits Motor Control Edition

Freescale Embedded Software Libraries A rapid product development tool designed to ease software development

Overview The libraries are broken into four main variable speed, AC motor drive Freescale embedded software function groups: system that implements field libraries are a complementary group • General function library: Contains oriented control techniques without of algorithms ranging from basic the basic building blocks of a real- position or speed sensors to provide mathematics operations to advanced time control application. Functions the lowest cost solution. transformations and observers, for basic mathematical calculations, Individual libraries are delivered as which can be easily incorporated into trigonometric functions, simple look- standalone modules, the interfaces complex real-time control applications. up tables and control functions such have been combined into a single The complementary algorithms help to as PI and PID controllers. public interface to reduce the speed development and ease of use • Motor control library: The number of files required for inclusion in applications that require intensive fundamental blocks of a motor by application programs and to math computation and control such as control application. The libraries ease development. advanced high-efficiency motor control include vector modulation, Park and Freescale Enablement and power conversion. Clarke transformations and specific The libraries are currently available motor related functions to build Features for Freescale DSCs running on the digitally controlled motor drives. The libraries are highly optimized, 56800E/56800EX cores, ColdFire V1 • General digital filter library: Includes tested on Freescale hardware and are and Kinetis platforms based on the filter functions for signal conditioning easy to use as they are implemented ARM Cortex-M4 core. (IIR of various order). with a C-callable function interface. The The libraries are available for download • Advanced control library: Functions functions have been tested against the at freescale.com/fslesl. reference model in MATLAB. that enable the construction of a

Figure 1: Field-Oriented Control Using Algorithm Blocks

GFLIB_ControllerPlp GFLIB_ControllerPlr MCLIB_Decoupling MCLIB_SVMStd MCLIB_ParkInv PWM * a d, q PWM PMSM b Decoupling PWMc α, β id*= 0

GFLIB_ControllerPlr MCLIB_Clark ia d, q α, β ib

ic α, β a, b, c MCLIB_Park MCLIB_AnglObsrv res α GDFLIB_FilterIIR1 θ res β

freescale.com/motorcontrol 55 Enablement

Motor Control Development Toolbox A model-based tool to support rapid application development for Freescale MCUs

Model-based design (MBD) is is less costly. Additionally, since the these steps can be iterative and can becoming the standard methodology model is an executable specification, be revisited from a later step. The four for developing embedded systems there is no ambiguity about its steps are: that implement the desired behavior behavior which aids requirements • MIL: Uses a model to develop of a control system. MBD is a validation. With automatic code requirements for the overall graphical method using mathematics generation, the same model is reused application control strategy and start and states to define and design throughout the development process testing at the very earliest stage control applications such as motor for rapid prototyping, production code using idealized simulation in the PC control systems in the automotive, generation and various forms environment. Idealized simulation of aerospace and industrial application of integration testing. the controller and the motor (plant) space. Many companies model their With the additional support of an model is done on a host PC without motor controller algorithms with embedded target, model-in-the-loop regard for the embedded controller the target motor, or plant, using a (MIL), software-in-the-loop (SIL) and or target hardware characteristics. graphical simulation environment to processor-in-the-loop (PIL) verification Since testing can start at the accelerate development. is performed on the same model requirements phase, specification MBD reduces development time by to evaluate the application design and modeling errors are found enabling engineers to do more work more quickly and thoroughly than immediately, versus in the later on their desktop vs. solely relying on with a traditional design and steps of the design effort, allowing the target hardware. Using a model- verification approach. corrections to be made to the based vs. a traditional approach, algorithm model with little impact on quality is improved because testing MBD Development Steps cost and timing. starts at earlier stages without MBD supports a design process that • SIL: Uses the model to generate hardware. The financial cost is reduced is represented in four steps (see figure ANSI C code. This tests the C code since errors are found and corrected 1) which correlates to the left side of using a compiler on the host PC earlier in the development when it the development “V” diagram. All of with the same test vectors as in step

Figure 1: Model-Based Development Steps

56 Beyond Bits Motor Control Edition

1. Verification of the functionality using hand code or a mix of hand includes the TÜV SÜD certificates, a of C code is done by comparing code and model generated code. certification report and other artifacts the MIL outputs to the SIL outputs. With an available embedded target, needed for certification. In order to Component or unit testing can also automatic generation of model follow the certified workflow, the be performed on the generated C code with the software for MCU capability to run PIL or a similar code. Since this step is done on initialization and peripheral interface on-target testing approach, must be the host PC, the unit testing time is is also possible. At this stage, you available. The MCD Toolbox, with reduced versus running the unit tests may perform verification, log data, its embedded target, provides PIL on the target MCU. This step verifies calibrate and analyze execution capability to allow the full TÜV SÜD the accuracy of the generated C on the target MCU in the target certified workflow so that it is possible code’s numerical results. application environment. Most likely, to produce the artifacts of a complete • PIL: Uses the model to generate the ECM with the target MCU will ISO 26262 tool qualification package target MCU code, compiled and not work on the real system as well for embedded system certification. tested on evaluation hardware. as it did in simulation, so an iterative Since MCD Toolbox supports the PIL allows numerical equivalence process takes place by analyzing Freescale MPC564xL MCU, it is also testing and verifies data coherency results on the ECM/MCU and possible to use this workflow on the of the software running on the modifying the model or first MCU in the industry to achieve target MCU by comparing its output its interfaces. a formal ISO 26262 certificate for ASIL D functional safety capability with the results in step 2. During Enabling MBD for this step it is possible to verify that by an independent third party. This Motor Control ® the execution semantics of the combination of Mathworks IEC , MCD model are being preserved during The Motor Control Development (MCD) Toolbox for the required target support code generation, compilation and Toolbox is a comprehensive collection for PIL, and an ASIL D certified MCU ® linking with the target MCU and of tools that plug into the MATLAB / allows automotive and industrial ® compiler. This enables the collection Simulink tool rapid application control engineers to design motor of execution metrics on the target development targeting Freescale control systems in an IEC 61508 (SIL3) MCU allowing for the evaluation of MCUs. The MCD Toolbox includes and ISO 26262 (ASIL-D) compliant the MCU’s performance. This type of support for motor control applications system using MBD. development and enables control testing is also useful for test vectors For step three of the MBD process, engineers and embedded developers that are too dangerous or expensive not only does the MCD Toolbox enable to meet the demands of shorter to run the target hardware. This PIL support but it also generates code project life cycles. The MCD Toolbox is also the only way to unit test required to start up the MCU and includes an integrated embedded target-specific optimized code. PIL run from either flash or RAM memory target with Simulink and its production can only be performed if there is an configurations. The CodeWarrior IDE, code generation, Embedded Coder®. embedded target available in the Green Hills Software MULTI and Wind This enables Freescale MCUs to modeling environment. River Diab compilers are supported. support the MBD processes MIL, SIP, • Target: Embedded control The MCD Toolbox includes profile PIL and generation of software for the module (ECM) hardware and utilities to enable measurement of MCU’s initialization and peripherals. MCU implementation with direct execution time on the MCU when interfaces to the peripherals is MATLAB and Simulink family of performing PIL operations. done using code generated from products provide a verification and the model in the previous steps. validation workflow for use with In this final step, the integration of Embedded Coder, which has been the control algorithm software with certified by the TÜV SÜD. Mathworks target MCU hardware is often done provides an IEC certification kit that

freescale.com/motorcontrol 57 Enablement

To support step 4 of the MBD Summary References process, the MCD Toolbox contains The MCD Toolbox with MBD using mathworks.com/model-based-design peripheral device interface blocks MATLAB, Simulink and embedded mathworks.com/products/iec-61508 and drivers supporting motor control coder provides the software tools development including ADC and PWM needed for all four steps of the MBD en.wikipedia.org/wiki/Model-based_ with cross triggering, as well as SPI process. By using these tools with design for gate pre-driver communication an MBD approach, companies can businesswire.com/portal/site/home/ and CAN communication. The MCD reduce development time and cost, permalink/?ndmViewId=multimedia_ Toolbox has built-in support for direct with an increase in quality for their detail&eid=50398223&newsLang=en code download to the target MCU motor control applications. For motor through the RAppID boot loader control applications, such as electric utility, leveraging the Qorivva MCU- power steering where functional safety based built-in boot assist module. is of concern, there is the added The Freescale FreeMASTER real-time benefit of having a software tool set debug monitor and data visualization that can provide the SIL 3/ASIL D tool interface is also built in to enable artifacts needed for certification of monitoring of signals in real time on the control application. the MCU as well as to support data The MCD Toolbox supports the logging, profiling, signal capture and Freescale MPC564xL and MPC567xK parameter tuning. FreeMASTER MCUs. The MPC564xL is the first provides visibility into the target MCU MCU in the industry to achieve a for algorithm calibration and tuning formal ISO-26262 certificate for ASIL that is often required in advanced D functional safety capability. control systems and those required by motor control development. With MCD Toolbox, the MATLAB and Simulink MBD environment The MCD Toolbox features an and Freescale MCUs provide a Automotive Math and Motor Control comprehensive embedded software Library developed by the Freescale development environment from Motor Control Center of Excellence. initial system requirement to final This library provides math functions target implementation. such as trigonometric functions, PI controllers, FIR and IIR filters and motor control operations including Park and Clarke transforms. With this library, engineers can develop their algorithms during steps 1 and 2 of the MBD process using blocks optimized for execution on Freescale MCUs and run bit-accurate simulations for those algorithms.

58 Beyond Bits Motor Control Edition

Motor Application Tuning Wizard Customize motor control applications to your PMSM

Overview Figure 1: Tuning Wizard Control Structure Page Current trends in motor control application development are increasing motor drive efficiency, decreasing cost and speeding up time to market. The way to accomplish demanding requirements is an implementation of state-of-the-art motor control algorithms and use of motors capable to be driven with high efficiency. Freescale offers such solutions with sensorless control of permanent magnet synchronous motors (PMSM). The sensorless algorithm implementation decreases total cost eliminating a rotor position sensor. • Up to three PMSMs support 5. Position and speed: Sensor Instead of the position sensor, the selector (quadrature encoder, Hall sensorless algorithm estimates rotor • Fractional 16-, 32-bit and floating sensors, SinCos, resolver) position by calculating a state observer number format selector in real time. Such complex routines • Online update of selected 6. Sensorless: BEMF DQ observer, require precise settings of motor application control variables tracking observer model parameters. To run new PMSM using Freescale 7. Output file: List of constants generated to output header file in To simplify process of control algorithm application code, the input parameters required target format parameter calculations, setting are required to be added into the and tuning, the Tuning Wizard tool Tuning Wizard. The parameters 8. Cascade: Application tuning based was developed. are used for calculations of state on cascade control structure (scalar, observer, control loop PI controller voltage FOC, current FOC, speed Features and application dependent constants. FOC, field weakening) The Tuning Wizard is an HMTL-based Required parameters can be taken 9. App control: FreeMASTER user- user-friendly graphical plug-in tool for from the motor data sheet or using defined control page FreeMASTER. The tool can be used for a Freescale procedure for PMSM PMSM field-oriented control application parameter measurement. Freescale Enablement The Tuning Wizard tool will be delivered development and real-time parameter The Tuning Wizard plug-in tool as part of the PMSM reference designs tuning and helps motor control users consists of several dedicated control to enable users an adaptation of to adapt Freescale motor control tabs. The tab configuration depends Freescale motor control applications. applications to their motors without on an application type (sensor or detailed knowledge of source code sensorless). Available control tabs are: Prepared application notes will explain and control constant calculations. 1. Introduction: Basic application the Tuning Wizard concept from the description structure and feature point of view and Tuning Wizard Key Features also how to integrate the plug-in tool 2. Parameters: Obligatory input motor • Static calculation of control to existing motor control applications. parameters and application parameters Application notes and other • Real-time tuning of selected 3. Current loop: Inner control loop, PI information about the Tuning Wizard control structures controller (parallel or recurrent form) of d,q currents tool are available at • Storing output constants in freescale.com/motorcontrol. header file 4. Speed loop: Outer loop, PI controller (parallel or recurrent form), • Configurable IDE speed ramp and filter freescale.com/motorcontrol 59 Enablement

FreeMASTER Real-time data visualization tool simplifies motor control application development

The motor control drive represents a Figure 1: FreeMASTER Visualization Screen real-time embedded application with a number of system variables and control parameters. These parameters and variables need to be observed and evaluated in real time in order to optimally develop, set up and tune the control algorithm. Traditionally, developers use code debuggers and oscilloscopes for the development of motor control applications. Unfortunately, such traditional development is quite arduous. The limiting factor of oscilloscope usage is that the current and voltage signals of the drive often differ from the values processed by the processor. The measured signals are affected by the instrumentation components inserted A small routine, which resides in user sensing circuitry, by measurement noise into the HTML code as embedded code, stores the selected variables and also by the offset and gain error of ActiveX objects. This allows for creation in the on-board memory buffer that the analog-to-digital converter. Since of a user-friendly display of complex is then loaded onto the PC and the developer needs to evaluate the real-time data dashboards. displayed as a course. The recorder measured signals on the processor side, is very useful for tracking variables the oscilloscope does not allow effective Real-Time Data Visualization which change so fast that they cannot development of the complex application. Variable window displays the selected be tracked by the scope. A typical variables or the memory location of example is the motor current. the target processor. The important FreeMASTER The stimulator enables stimulation of part of the setting is the real type In order to help the users in the the selected variables in time. A typical transformation of the variables. It development of real-time embedded example is the speed profile of the enables transformation of the variable applications, Freescale offers washing machine application. FreeMASTER, a real-time debug, available on the target processor into a monitor and data visualization tool. It format that is more understandable for Availability users (volts, amps, RPM). supports a completely non-intrusive Freescale supports automotive, monitoring, visualization and control of Real-Time Data Scope industrial and appliance MCUs and embedded system variables that is key The tool enables visualization of the DSCs including 56F8xxx, S08, Kinetis, for real-time application development variables of the target processor S12/S12X, Qorivva and ColdFire V1/ and tuning. in a way similar to that of classical V2/V4. A variety of communication oscilloscopes. It enables the display of interfaces are supported. The selection Key Features up to eight courses in a single scope includes BDM, SCI, CAN, USB, MQX Real-Time Control window. The oscilloscope is useful for I/O, Control page enables effective control tracking variables that change relatively and JTAG. FreeMASTER is available of the application. HTML form is slowly. A typical example is the speed for use with Freescale products supported so the user can easily design of the motor. and can be downloaded at freescale.com/FreeMASTER. a custom project. The visualization The recorder window enables the area enables use of third-party visualization of fast changing variables. 60 Summary

We hope this edition of Beyond Bits has provided you a better understanding of our motor control solutions and how they can help you in future designs. We aim to provide solutions that address the major challenges you face in developing motor control applications as well as collateral to help you quickly and easily find the right solution to address your specific needs. For additional information on the solutions covered in Beyond Bits, visit freescale.com/motorcontrol, freescale.com/solutionadvisor and freescale.com/support.

For further support, contact any of our regional sales offices. Our authorized distributors are available to offer local support through all of your design stages. For more information, visit freescale.com/motorcontrol

Freescale, the Freescale logo, CodeWarrior, ColdFire, Kinetis, Processor Expert and Qorivva are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Vybrid is a trademark of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. ARM is the registered trademark of ARM Limited. ARM Cortex-A5, Cortex-M4 and Cortex-M0+ are trademarks of ARM Limited. The Power Architecture and Power.org word marks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org. © 2012, 2013 Freescale Semiconductor, Inc. Document Number: BBMTRCTRL REV 1