Motor control method based on STM32 microcontroller

Publisher:好的哎Latest update time:2014-10-20 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  The advent of frequency converters and advanced motor control methods have made three-phase brushless motors (AC induction motors or permanent magnet synchronous motors) once a huge success in speed control applications. These high-performance motor drivers were mainly used in factory automation systems and robots. In the past decade, the sharp price reduction of electronic components has enabled these motor drivers to enter cost-sensitive markets such as home appliances, air conditioners or personal medical devices. This article will explore how standard ARM-based microcontrollers can break through complex control modes in a market that has long been dominated by DSPs and FPGAs. We will use STMicroelectronics' STM32 series microcontrollers based on the Cortex-M3 core as an example to illustrate this process.

  Figure 1: STM32: A solid foundation for growth

  First, let's review the basic principles of motor control. Why is the processor so important in motor control systems? Why do we need very good computing performance? After all, Nicolas Tesla didn't need a compiler when he invented the AC motor a century ago. As long as speed regulation is required, people cannot avoid using an inverter to drive a good 3-phase motor. Controlling the operation of a permanent magnet synchronous motor (PMSM) is even more inseparable from the inverter. The core of this complex power electronic system is a 3-phase DC-to-AC inverter, in which the microcontroller plays a management role and performs the common trinity control functions in a fully digital way: detection (current, speed, angle...), processing (algorithms, housekeeping...), and control of power switches (the lowest configuration has at least 6 switches).

  The simplest way to achieve variable speed operation of a three-phase AC motor is to use scalar control. The principle of scalar control is to maintain a constant ratio between the frequency and voltage applied to the motor. This is a very popular control method for entry-level motor drives, suitable for applications with very common load characteristics and low control bandwidth requirements (such as very small power pumps and fans). Unfortunately, not all applications can tolerate such a simple control process and its application limitations. In particular, scalar control cannot guarantee the best motor performance (torque, energy efficiency) in transient environments. To overcome these limitations, other motor control methods have been developed, among which field-oriented control (also known as vector control) is one of the most widely used methods. This control method uses two decoupled DC controllers to drive any AC motor (induction motor or permanent magnet motor) in the same way as a separately excited motor, regardless of the operating frequency (i.e. speed). The excitation current is related to the DC main flux (magnet flux in a PMSM motor), while the 90° phase-shifted current can control the torque and function as 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 stationary. 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 are available, STMicroelectronics chose to develop STM32 microcontrollers using the Cortex-M3 core. This solution is well suited to meet the requirements of a large number of brushless motor drives, and 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 with pure 32-bit code, this instruction set can greatly improve code density while retaining most of the advantages of the original ARM7 instruction set (additional optimized multiplication and addition operations and hardware division instructions).

  Motor control systems require microcontrollers to have 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 10 kHz sampling rate.

  In the STM32 microcontroller, this core works closely with the STMicroelectronics optimized flash interface, and only a few external components are needed to handle external events (Figure 2 shows the block diagram of the STM32F103 medium-capacity microcontroller). Needless to say, the PWM timer and the analog-to-digital converter are the most important components. The PWM timer includes state-of-the-art features such as center-aligned mode PWM signal generation and dead-time insertion logic, with a special emphasis on safety: the module directly controls the commutation of the power switch, which can control the power of several kilowatts. For example, the register code used to configure certain important parameters can be protected by a lock to prevent software failure. As long as the "Emergency Stop" pin is pulled low, all I/O pins are placed in a user-configurable safe state. This function is designed using a combinational logic module, which ensures that the protection circuits can still work properly before switching internally to the backup oscillator when the main clock (crystal) fails. Finally, the microcontroller also includes a fourth comparison channel dedicated to triggering the analog-to-digital converter to achieve the best current measurement accuracy.

STM32F103 medium capacity microcontroller block diagram

  Figure 2: STM32F103 medium-capacity microcontroller block diagram

  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 multiplexers. Among these functions that are useful for brushless motor control, we first consider the channel read sequencer. Compared with the traditional scanning circuit (according to the analog input number, a certain number of channels are converted in sequence), in a sequence of 16 conversion channels (for example: Ch3, Ch3, Ch0, Ch11), the sequencer can convert channels in any order. When designers are designing printed circuit boards, this function brings designers greater design flexibility. In order to achieve the purpose of averaging conversion, multiple sampling of the same channel is allowed (in a sequence). When the entire sequence is converted, the DMA channel sends the conversion result to RAM, and the interrupt handler generates an interrupt request.

  During the detection of the motor phase current, the noise generated by the transient voltage on the power switch (typically several hundred V/µs in offline switching applications) is an important source of reading errors, which can 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 registers 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 injection sequencer), which has a higher priority than the normal sequencer and can interrupt the current conversion operation with a new conversion operation that cannot be delayed. Normally, the normal sequencer is responsible for "housekeeping" the conversion, continuously detecting the temperature or the DC bus voltage (as a background task) and then sending it to the RAM through the DMA channel, while the injection sequencer will handle the time-critical conversion operation and store the conversion result in the analog-to-digital converter register (an interrupt will be generated, but the delay cannot be accepted).

  Having a general-purpose microcontroller capable of performing advanced motor control functions is one thing, but getting started with development is another. Both sides of the puzzle can be addressed with hardware and software tools. The first is a motor control development starter kit that includes test tools (JTAG probe and optoisolator), microcontroller chip, and power stage board and demonstration PMSM motor for product performance evaluation and development purposes. The modular design allows upgrading the demonstration application (e.g. dual motor control microcontroller board) to evaluate multiple (or custom) power stages. Finally, STMicroelectronics provides a motor control software library free of charge to STM32 customers. Version 2.0 of the motor control software library supports a variety of configurations using a simple and inexpensive list of #define statements in the header file. The software library contains field-oriented control algorithms for AC induction and synchronous motors, which are written in C programming language to simplify code readability and maintainability, again demonstrating the efficiency of modern compilers. The software library also provides a robust sensorless control algorithm for PMSM motors (based on flux observers) and a dedicated control algorithm for ultra-high-speed interior permanent magnet motors (IPM). Of course, the software also supports common speed and position sensors (incremental encoders, Hall sensors or tachometers). The STM32 supports three current sensing methods by using isolated sensors or shunts. The STM32 peripheral can implement an innovative single current sensing method to perform vector control using the lowest cost configuration (a simple unique resistor). This technology has been patented because it can minimize the intrinsic current distortion rate.

  STMicroelectronics’ current main development projects are sensorless permanent magnet 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 3).

STM32F103HD can handle dual motor control and digital PF at the same time

  Figure 3: The STM32F103HD can handle dual motor control and digital PF simultaneously

  From power switch discrete devices to complex system chips, STMicroelectronics is committed to supporting the motor control market with its unique product portfolio for a long time. 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 is aimed at 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.

Reference address:Motor control method based on STM32 microcontroller

Previous article:Design of the lower computer of the environmental monitoring system based on multithreading
Next article:Design of CAN bus node based on Cortex-M3 core chip LM3S2965

Recommended ReadingLatest update time:2024-11-16 14:39

Cortex-M3 Learning Log (V) -- -- DAC Experiment
Finally I got a chance to learn about the peripheral functions of LPC1768. Gradual progress is the basic rule of learning. Maybe the DAC of LPC1768 is similar to the DAC integrated in 8-bit MCU and 16-bit MCU, but since this is a lazy cat's learning log, I will review the DAC again, maybe I can get a taste of it^_^DAC
[Microcontroller]
Cortex-M3 Learning Log (V) -- -- DAC Experiment
Research and implementation of testing methods for Cortex-M3 microprocessor based on ARM technology
0 Introduction With the development of semiconductor technology, the integrated circuit manufacturing process has developed from deep submicron to nanometer level. The significant improvement of transistor integration has increased the complexity of chips and the functions of single chips have become stronger and s
[Microcontroller]
Research and implementation of testing methods for Cortex-M3 microprocessor based on ARM technology
Cortex-M3 and Cortex-M4 Fault exception application 2----- Implementation of Fault handling function
       When the project is being debugged, the Fault handler may be just a breakpoint instruction, and the debugger stops the program after encountering this instruction. By default, since non-hard Faults are disabled, all non-Faults that occur will be reported as hard Faults. Therefore, as long as a breakpoint is set
[Microcontroller]
Cortex-M3 and Cortex-M4 Fault exception application 2----- Implementation of Fault handling function
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号