Design and implementation of a motor control solution based on STM32 microcontroller

Publisher:真诚的友谊Latest update time:2016-09-19 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The inverter is an electric energy control device that uses the on-off function of power semiconductor devices to convert the industrial frequency power supply into another frequency. It can realize the functions of soft starting, variable frequency speed regulation, improving operation accuracy, changing power factor, overcurrent/overvoltage/overload protection, etc. for AC asynchronous motors. The inverter integrates high-voltage and high-power transistor technology and electronic control technology and is widely used. The function of the inverter is to change the frequency and amplitude of the AC motor power supply, thereby changing the period of its moving magnetic field to achieve the purpose of smoothly controlling the motor speed. The emergence of the inverter simplifies the complex speed control. The combination of inverter + AC squirrel cage induction motor replaces most of the work that could only be done by DC motors, reduces the size, reduces the maintenance rate, and brings the transmission technology to a new stage. This article will explore how the standard microcontroller based on ARM breaks the complex control mode in a market that has long been monopolized by DSP and FPGA. We will use STMicroelectronics' STM32 series microcontroller based on the Cortex-M3 core as an example to illustrate this process.

Small motors with power below 300 W are used in many applications, such as automobiles, printers, copiers, paper processing machines, factory automation, space and military vehicles, test equipment, and robots. In general, the production of motors is roughly inversely proportional to their power, which means that the production of small motors far exceeds that of large motors. The most widely used small motors are DC motors, brushless DC motors, and stepper motors.

The main difference between stepper motors, DC motors, and brushless DC motors is how they are driven. Stepper motors move in steps, while DC motors and brushless DC motors usually use analog control for continuous movement. Because stepper motors move in steps, they are particularly suitable for absolute addressing applications. Common stepper motors on the market today can provide accurate movement capabilities of 1.8° or 0.9° per step. Stepper motors use direct control, and their main command and control variables are step position; in contrast, DC motors use motor voltage as the control variable and position or speed as the command variable. DC motors require a feedback control system, which controls the motor position indirectly, while stepper motor systems are mostly operated in an "open loop" manner.

DC motors are the most common and cheapest small motors and are used in a wide range of applications. Brushless DC motors claim to provide higher reliability and lower noise and cost, but so far they have only replaced traditional DC motors in a few production applications such as disk drives or computer fans. In some applications, brushless DC motors have many advantages over traditional brush motors, such as replacing brushes with electronic components and sensors, which not only prolongs motor life and reduces maintenance costs, but also does not generate noise. The characteristics of DC motors make them the easiest motors to use in speed control systems. The excitation current

is related to the main flux of the DC (the flux of the magnets in a PMSM motor), and the 90° phase-shifted current can control torque, which is equivalent to the armature current of a DC motor. Field-oriented control allows precise speed control with fast response when the load changes, keeping the stator flux and rotor flux in perfect 90-degree phase difference, ensuring optimized energy efficiency even in transient operating environments. This is the basic theoretical framework for more complex control methods based on motor topologies, especially for PMSM motors. This theory is the basis for sensorless motor drives, which can significantly reduce costs (no speed or angle sensors and related wiring are required) and improve motor reliability. In this case, only the motor mathematical model, current and voltage values ​​must be used to estimate the rotor angle position by calculation. This state observer theory (among other control methods) can achieve sensorless speed control at a minimum of only a few hundred revolutions per minute, which in some cases is a stationary state.

However, this is an additional real-time load on the CPU. Finally, the microcontroller must continuously recalculate the vector control algorithm at a rate of 1KHz to 20KHz, depending on the bandwidth of the final application. Processing Parke and Clarke transformations and implementing multiple PID controllers and software phase-locked loops does require intensive digital computing, which is why digital signal processors, microprocessors or FGPA devices have been used as controllers in the past.

Although dedicated dual-mode controllers and low-end fixed-point DSP architectures have become available, STMicroelectronics chose to develop the STM32 microcontroller using the Cortex-M3 core. This solution is well suited to meet the requirements of a large number of brushless motor drives. From a one-time engineering cost perspective, the advantage of this solution is the cost-effectiveness of using an industry-standard ARM? core and a standard microcontroller.

Based on the Harvard architecture, this 32-bit RISC uses the Thumb2 instruction set, providing 16-bit and 32-bit instructions. Compared to pure 32-bit code, this instruction set can significantly improve code density while retaining most of the advantages of the original ARM7 instruction set (additional optimized multiply-add operations and hardware division instructions).

Motor control systems require microcontrollers with excellent real-time responsiveness (short interrupt latency), pure processing functions (such as single-cycle multiplication), and excellent control performance (when handling non-sequential execution flow and conditional branch instructions). The Cortex-M3 can meet all these requirements. For example, when the clock frequency is 72MHz, a sensorless field-oriented control of a permanent magnet motor is completed in 25μs, which is equivalent to 25% CPU load at a 10kHz sampling rate.

STMicroelectronics has expanded the motor vector control function library supported by 32-bit STM32 microcontrollers (MCUs) to add algorithms that support single-shunt sensorless control, internal permanent magnet (IPM) motor control, and permanent magnet synchronous (PMSM) motor field weakening control. There are currently about 40 motor control applications on the market using STMicroelectronics' Cortex-M3-based STM32 microcontrollers. Among the new algorithms currently available to designers, the single-shunt current sensing support function only requires one current sensing resistor, which saves system cost compared to the common sensorless control mechanism that requires three resistors. Single-shunt current sensing is a patented technology developed by STMicroelectronics that offers high DC bus voltage utilization, low current distortion and low audible noise. By adding a "maximum torque-to-current ratio" (MTPA) control algorithm, the expanded library gives designers greater freedom to define the electrical parameters of brushless IPM motors to meet the high power density and high-speed performance requirements of practical applications. Based on these new algorithms, developers can take full advantage of the rich motor control peripherals of STM32, including two three-phase PWM timers integrated in STM32, so that one microcontroller can control two brushless motors simultaneously. By breaking the rule of one microcontroller controlling one motor, designers can save costs, reduce design size and power consumption using STM32 without any performance impact. The three analog-to-digital converters integrated in the microcontroller can support three-way sample-and-hold current capture for high-precision motor drives. Because STM32 uses the advanced ARMCortex-M3CPU industry-standard architecture, users can save more time developing motor control solutions on STM32 than using enterprise proprietary architectures.

Even the most sophisticated algorithms can hardly correct inaccurate analog measurements, but the overall performance of the motor drive system depends to some extent on the quality of the analog-to-digital converters. The STM32F103 chip has three built-in 12-bit analog-to-digital converters with a sampling rate of 1MSps, and a total unadjusted error (TUE) of less than 5 LSB over the entire temperature and voltage range. The digital interface of the analog-to-digital converter has three main functions: first, it frees the CPU from simple control tasks and data processing; second, it connects the rest of the chip (interrupt requests, DMA requests, trigger inputs); and finally, it synchronizes the operation of the STM32's multiplexer.

Among the functions useful for brushless motor control, we first consider the channel read sequencer. Compared with the traditional scanning circuit (converting a certain number of channels in sequence according to the analog input number), the sequencer can convert the channels in any order within a sequence of 16 conversion channels (for example: Ch3, Ch3, Ch0, Ch11). This function gives designers more design flexibility when designing printed circuit boards. For the purpose of averaging conversion, it allows multiple sampling of the same channel (in a sequence). When the entire sequence is converted, the DMA channel sends the conversion results to RAM and the interrupt handler generates an interrupt request.

In the process of detecting the motor phase current, the noise generated by the transient voltage on the power switch (in offline switching applications, the typical noise reaches hundreds of V/μs) is an important cause of reading errors, which may lead to a very low signal-to-noise ratio of the measurement result. The solution is to synchronize the analog-to-digital converter with the timer controlling the power stage: since the commutation moment can be predetermined (defined by the compare register of the 3 PWM timers), an additional compare channel can be used to trigger the analog-to-digital conversion operation slightly before or after the commutation moment. For this reason, the STM32 enables a second sequencer (also called the injection sequencer) that has priority over the normal sequencer and can interrupt the current conversion with a new conversion that cannot be delayed. Normally, the normal sequencer is responsible for "housekeeping" conversions, continuously sensing the temperature or DC bus voltage (as a background task) and then sending it to RAM via the DMA channel, while the injection sequencer will handle the time-critical conversions and store the conversion results in the ADC registers (an interrupt will be generated, but the delay cannot be accepted).

For a general-purpose microcontroller capable of performing advanced motor control functions, it is one thing to have a microcontroller and another to get started with development easily. Both sides of this problem can be addressed with software and hardware tools. The first is to have a motor control development starter kit, which includes test tools (JTAG probe and optical isolator), microcontroller chip, power stage board and demonstration PMSM motor, which is used for product performance evaluation and development purposes. The modular design allows upgrading the demonstration application (such as a dual motor control microcontroller board) to evaluate multiple (or custom) power stages. Finally, STMicroelectronics provides motor control software libraries free of charge to STM32 customers. Version 2.0 of the Motor Control Library supports various configurations using a simple and inexpensive list of #define statements in the header file.

The library contains field-oriented control algorithms for both AC induction and synchronous motors, written in C programming language to simplify code readability and maintainability, again demonstrating the efficiency of modern compilers. The library also provides a robust sensorless control algorithm for PMSM motors (based on a flux observer), as well as a dedicated control algorithm for ultra-fast interior permanent magnet motors (IPM). Of course, the software also supports common speed and position sensors (incremental encoders, Hall sensors or tachometer sensors). The STM32 supports three current sensing methods, using isolated sensors or shunts. The STM32 peripherals can implement an innovative single current sensing method to perform vector control using the lowest cost configuration (a simple unique resistor). This technology is patented because it minimizes the intrinsic current distortion.

ST's main development projects are sensorless PM motor control to control the motor to standstill and dual motor control with built-in power factor correction. Recently, STMicroelectronics successfully demonstrated a single current sensing method, where only one STM32 microcontroller can perform two single current sensing vector control functions, while also managing the PFC stage with a 40 kHz control loop (see Figure 1). Design and implementation of a motor control solution with an STM32 microcontroller Design and implementation of a motor control solution with an STM32 microcontroller From discrete power switch devices to complex system chips, STMicroelectronics is committed to supporting the motor control market for a long time with its unique product portfolio. The STM32 microcontroller product line will continue to be deployed in four new directions, as shown in Figure 3, two of which are suitable for motor control. The first product line will target the low-cost market and develop low-end 16-bit motor control microcontrollers. The other product line is based on high performance and targets applications that require higher processing performance, larger memory capacity and high-bandwidth interfaces. Such a broad product portfolio combined with the Cortex-M3 core is bound to establish the versatility of the STM32 architecture for current and future motor drives.











Keywords:STM32 Reference address:Design and implementation of a motor control solution based on STM32 microcontroller

Previous article:STM32 FSMC interface driver TFT-LCD design
Next article:Design and implementation of CMMB intelligent network monitoring system based on STM32

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号