Design and realization of a kind of STM32 microcontroller to handle motor control

Inverter is a power control device that uses the on-off action of power semiconductor devices to transform a power frequency power supply into another frequency. It can realize soft starting of AC asynchronous motors, frequency conversion speed regulation, improvement of operation accuracy, change of power factor, overcurrent/ Overvoltage/overload protection and other functions. The frequency converter integrates high-voltage and high-power transistor technology and Electronic control technology, and is widely used. The function of the frequency converter is to change the frequency and amplitude of the AC motor power supply, thus changing the period of its moving magnetic field, so as to achieve the purpose of smoothly controlling the motor speed.

Inverter is a power control device that uses the on-off action of power semiconductor devices to transform a power frequency power supply into another frequency. It can realize soft starting of AC asynchronous motors, frequency conversion speed regulation, improvement of operation accuracy, change of power factor, overcurrent/ Overvoltage/overload protection and other functions. The frequency converter integrates high-voltage and high-power transistor technology and electronic control technology, and is widely used. The function of the frequency converter is to change the frequency and amplitude of the AC motor power supply, thus changing the period of its moving magnetic field, so as to achieve the purpose of smoothly controlling the motor speed. The appearance of the frequency converter simplifies the complicated speed control. The combination of frequency converter + AC squirrel cage induction motor replaces most of the work that can only be done with DC motors, reduces the volume, reduces the maintenance rate, and makes the transmission The technology has developed to a new stage. This article will discuss how standard ARM-based microcontrollers can break the complex control mode in a long-term monopolized market by DSP and FPGA. We will take ST’s STM32 series microcontrollers based on the Cortex-M3 core as an example to discuss this process.

Many applications will use small motors with a power of less than 300 W, such as automobiles, printers, copiers, paper processors, factory automation, space and military vehicles, test equipment, and robots. Overall, the output of a motor is approximately inversely proportional to its power, which means that the output of small motors far exceeds that of large motors. The most widely used small motors include DC motors, brushless DC motors and stepper motors.

The main difference between stepper motors, DC motors and brushless DC motors is their driving methods. Stepper motors move step by step, while DC motors and brushless DC motors usually use continuous-moving analog control. Since the stepper motor adopts step-by-step movement, it is especially suitable for all addressing applications. At present, the common stepper motor on the market can provide precise movement capability of 1.8° or 0.9° per step. The stepper motor adopts the direct control method, its main command and control variable are all step position (step position); In contrast, the DC motor uses the motor voltage as the control variable, and the position or speed as the command variable. DC motors need a feedback control system, which controls the position of the motor in an indirect manner, and most of the stepper motor system is operated in an “open loop” manner.

DC motors are the most common and lowest cost small motors and are widely used in various applications. The brushless DC motor claims to provide higher reliability and lower noise and cost, but so far, it can only replace the traditional DC motor in a small number of production applications such as disks or computer fans. In some applications, brushless DC motors have many advantages over traditional brush motors. For example, it replaces brushes with electronic components and sensors, which not only extends motor life and reduces maintenance costs, but also has no noise generated by brushes. The characteristics of a DC motor make it the easiest motor to use in a speed control system. (

The excitation current is related to the main DC magnetic flux (magnet flux in a PMSM motor), and the 90° phase shift current can control the torque, which is equivalent to the armature current of the DC motor. When the load changes, the field-oriented control method can achieve precise speed control, and the response speed is fast, so that the stator magnetic flux and the rotor magnetic flux maintain a perfect 90-degree phase difference. Even in a transient working environment, it can still ensure optimized energy efficiency. This is the basic theoretical framework based on the realization of more complex control methods marked by motor topology, especially for PMSM motors. This theory is the basis of sensorless motor drives, which can significantly reduce costs (no need for speed or angle sensors And related wiring), while also improving the reliability of the motor. In this case, only the motor mathematical model, current value and voltage value must be used to estimate the rotor angular position through calculation methods. In the case that the minimum number of revolutions per minute is only a few hundred revolutions, this state observer theory (among other control methods) can realize sensorless speed control. In some cases, the minimum number of revolutions per minute is a static 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. The specific rate depends on the final application bandwidth. Processing Parke and Clarke conversion and implementing multiple PID controllers and software phase-locked loops does require high-strength digital Calculations. This is why digital signal processors, microprocessors or FGPA devices were used as controllers in the past.

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

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 increase code density, while retaining most of the advantages of the original ARM7 instruction set (additional optimized multiplication and addition operations and hardware division instructions).

The motor control system requires the microcontroller to have excellent real-time responsiveness (short interruption delay), pure processing functions (such as single-cycle multiplication), and excellent control performance (when processing non-sequential execution streams and conditional branch instructions). 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 within 25μs, which is equivalent to 25% of the CPU load at a 10 kHz sampling rate.

STMicroelectronics expands the motor vector control function library supported by 32-bit STM32 microcontrollers (MCUs), and adds support for single-pass sensorless control, internal permanent magnet (IPM) motor control, and permanent magnet synchronous (PMSM) motor field weakening Control algorithm. There are currently about 40 motor control applications on the market that use ST’s Cortex-M3-based STM32 microcontroller. Among the new algorithms currently available to designers, the single-bypass current-sensing support function requires only one current-sensing resistor, which saves system cost more than the ordinary sensorless control mechanism that requires three resistors. Single bypass current sensing is a patented technology developed by STMicroelectronics, which has the advantages of high DC bus voltage utilization, low current distortion and low audible noise. By adding a “Maximized Torque Current Ratio” (MTPA) control algorithm, the expanded function library provides designers with greater freedom in design space, enabling them to flexibly define the electrical parameters of brushless IPM motors to meet practical applications The demand for high power density and high-speed performance of the motor. Based on these new algorithms, developers can take full advantage of STM32’s rich motor control peripherals, including two three-phase PWM timers integrated by STM32, so that one microcontroller can control two brushless motors at the same time. By breaking the rule that a microcontroller controls a motor, designers using STM32 can save costs, reduce design size and power consumption, and will not have any impact on performance. The three analog-to-digital converters integrated in the microcontroller can support three-channel sample-and-hold current capture for high-precision motor drivers. Because STM32 uses the advanced ARMCortex-M3CPU industry standard architecture, it is more time-saving for users to develop motor control solutions on STM32 than using enterprise proprietary architecture.

Even the most complex algorithms can hardly correct inaccurate analog measurements, but, to some extent, the overall performance of the motor drive system depends on the quality of the analog-to-digital converter. The STM32F103 chip has three built-in 12-bit analog-to-digital converters with a sampling rate of 1MSps. In the entire temperature and voltage range, the total unadjustable error (TUE) is less than 5 LSB. The digital interface of the analog-to-digital converter has three main functions: first , Make the CPU get rid of simple control tasks and data processing; secondly, connect the remaining components of the chip (interrupt request, DMA request, trigger input); finally, make the STM32 multiplexer operate synchronously.

Among these useful functions for brushless motor control, we first consider the channel read sequence generator. Compared with the traditional scanning circuit (convert a certain number of channels in sequence according to the analog input serial number), the sequence generator can be in any order in a sequence of 16 conversion channels (for example: Ch3, Ch3, Ch0, Ch11) Conversion channel. When the designer is designing the printed circuit board, this function brings greater design flexibility to the designer. For the purpose of average conversion, multiple sampling of the same channel (within a sequence) is allowed. After the sequence conversion is completed, the DMA channel sends the conversion result to the RAM, and the interrupt handler generates an interrupt request.

In the process of detecting the phase current of the motor, the noise generated by the transient voltage on the power switch (in offline switching applications, the typical noise reaches several hundred V/μs) is an important cause of reading errors, which may lead to measurement results The signal-to-noise ratio is very low. The solution is to synchronize the analog-to-digital converter with the timer that controls the power stage: because the commutation time can be predetermined (defined by the compare register of the 3 PWM timer), an additional comparison channel can be used just before or slightly before the commutation time. Then trigger the analog-to-digital conversion operation. For this reason, STM32 enables the second sequencer (also known as the injection sequencer), which has a higher priority than the normal sequencer, and can use a new conversion operation that cannot be delayed to make the current conversion operation Interrupted. Normally, the normal sequencer is responsible for “internal management” conversion, continuously detecting temperature or DC bus voltage (as a background task), and then sending it to RAM through the DMA channel, while the injection sequencer will handle time-critical conversion operations. And store the conversion result in the analog-to-digital converter register (an interrupt will be generated, but the delay cannot be accepted).

For a general-purpose microcontroller that can perform advanced motor control functions, it is one thing to have a microcontroller, but it is another matter to develop easy entry. Both software and hardware tools can be used to handle both aspects of this problem. The first is to have a set of motor control development starter tools, including test tools (JTAG probes and opto-isolators), microcontroller chips, power stage circuit boards and PMSM motors for demonstration. This set of tools is used for product performance evaluation and development purposes. The modular design helps to upgrade demonstration applications (such as dual motor control microcontroller circuit boards) and evaluate multiple (or custom) power stages. Finally, STMicroelectronics provides free motor control software libraries for STM32 customers. The 2.0 version of the motor control software library supports various configurations using a simple and inexpensive #define declaration list in the header file.

The software library contains field-oriented control algorithms for AC induction motors and synchronous motors. In order to simplify the readability and maintainability of the code, these algorithms use the C programming language, which once again proves the efficiency of modern compilers. The software library also provides a robust sensorless control algorithm (based on a flux observer) for PMSM motors, and a special control algorithm for ultra-high-speed internal permanent magnet motors (IPM). Of course, the software also supports ordinary speed and position sensors (incremental encoders, Hall sensors or speed sensors). By using isolated sensors or shunts, STM32 supports three current detection methods. STM32 peripherals can implement an innovative single-current detection method, using the lowest cost configuration (a simple unique resistor) to perform vector control. Because it can minimize the intrinsic current distortion rate, this technology has been patented.

STMicroelectronics’ current main development projects are sensorless permanent magnet motor control that controls the motor to a standstill and dual motor control with built-in power factor correction. Recently, STMicroelectronics successfully demonstrated a single current detection method, only one STM32 microcontroller can perform two single current detection vector control functions, while also using a 40 kHz control loop to manage the PFC stage (see Figure 1 for details).

Design and realization of a kind of STM32 microcontroller to handle motor control
Figure 1: STM32F103HD can handle dual motor control and digital PF at the same time

Design and realization of a kind of STM32 microcontroller to handle motor control
Figure 2: STM32F103 mid-capacity microcontroller structure block diagram

Design and realization of a kind of STM32 microcontroller to handle motor control
Figure 3: STM32: A strong foundation for growth

From discrete power switch 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 demands high performance and faces applications that require higher processing performance, larger storage 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.

The Links:   DMF5010NBU-FW-BD FZ2400R17KE3_B9