Most microcontrollers have at least one pulse width modulation (PWM) peripheral that generates multiple waveforms in the form of square waves. These PWM outputs can be used to drive synchronous loads such as stepper motors in mechanical systems and power MOSFETs in power converters. For these loads, it is very important that the PWM waveforms are precisely synchronized for the target load to work properly.
If the PWM peripheral is not carefully programmed, it may occasionally produce phase delays between waveforms, resulting in loss of synchronization when the waveform edges are not properly aligned. These phase delays will reduce the efficiency of driving the load, thereby wasting power and potentially generating excessive heat. With common PWM peripherals, a PWM can be enabled or disabled, but this will cause phase delays in other PWM outputs.
This is particularly a problem for small form factor, battery powered Internet of Things (IoT) applications where a single PWM peripheral with 16 or 32 outputs is used to control multiple external loads. Phase delays in these IoT applications can waste battery power. Furthermore, because phase delays are not detected, network diagnostics at IoT endpoints can miss these delays.
This article will discuss some applications of microcontroller PWM peripherals and when it is important to keep the PWM waveforms synchronized in such applications. It will then introduce a microcontroller from Maxim Integrated that has a pulse train peripheral designed to prevent loss of waveform synchronization in such applications, and finally discuss how to configure this peripheral to ensure that the target load is driven efficiently.
Microcontroller PWM peripherals and their target loads
Most general-purpose microcontrollers have at least one PWM peripheral for generating a regular, repeating square wave. PWM drives can be used for many loads—from simple loads to more complex mechanical drive systems.
Light Emitting Diodes (LEDs) are one example of a simple load that can be driven efficiently with a PWM signal, especially in applications where dimming of colored LEDs is required. Compared to dimming an LED by varying the forward DC current, PWM dimming can more accurately maintain light quality without noticeably changing the color. A single PWM peripheral can easily drive one or more LEDs. If these LEDs are used as visual indicators for operators, the phase difference between two or more LEDs is not very noticeable. However, if these LEDs are used in more complex applications, such as multiple LEDs transmitting data to a photoreceiver in the form of light modulation, then LED synchronization can be a very important design consideration.
Another simple load for microcontroller PWM is a DC motor driven through a motor driver IC. Although the speed of a DC motor can be easily changed by varying the voltage across it, PWM control allows for more precise control of the motor rotation. If a speed sensor is used in a closed-loop control system, the motor speed can be maintained more accurately. If two or more DC motors are used and they must run together, it may be necessary to synchronize the PWM waveforms in order to maintain precise speed control between the motors.
Driving bipolar stepper motors
The design situation becomes more complicated when driving a bipolar stepper motor. A bipolar stepper motor is driven by two reversible current windings (Figure 1). Two PWMs are required for each winding, so four PWMs are required.
Figure 1: A bipolar stepper motor is rotated by two current windings (represented as red and green coils) that carry current in each direction. By controlling the phase and duration of the current in the windings, the speed and position of the motor can be easily controlled. (Image source: Digi-Key)
As shown in Figure 1, the two current windings represented by the red and green coils must be driven in the correct sequence for the motor to operate properly. The sequence shown in Figure 2 drives the bipolar stepper motor one full step at each waveform change.
Figure 2: The two coils on a bipolar stepper motor must be driven separately as shown above in order for the motor to move a full step with each waveform change. First the current in each coil is driven in one direction; next the coil is idle; then the current is driven in the opposite direction. (Image source: Digi-Key)
Each step of the motor begins with each waveform transition. The polarity of the voltage across the windings, and therefore the current flowing through each winding, changes at each step, as shown in Figure 2. Any phase delay in the PWM signal can cause the motor to slip, resulting in a loss of torque, especially at low speeds.
When a microcontroller has a PWM peripheral that uses only four outputs, it is easy to control a stepper motor with only moderate care to maintain synchronization. However, the situation becomes more complicated when the same PWM peripheral is used to control multiple loads. For example, a 16-output PWM might have four PWM outputs assigned to stepper motors and other PWM outputs assigned to other loads, such as DC motors or LEDs. After the frequency and duty cycle of the PWM outputs are configured using the appropriate registers, a bit is set in the enable/disable register for each PWM. In Arm® microcontrollers, the firmware can set the corresponding bits by using bit-banding. However, bit-banding performs a read/modify/write (RMW) operation on the target register. If there are other PWM outputs programmed to start or end during the RMW operation, this can lead to unpredictable results and, in some cases, can even enable or disable the PWM in a manner contrary to firmware control.
Maxim Integrated has addressed this problem with the MAX32650 Arm Cortex®-M4F microcontroller, which runs at 120 megahertz (MHz). It has a wide range of peripherals, including three standard SPI interfaces, one quad-SPI, three UARTs, two I2C ports, a USB 2.0 high-speed interface with physical layer (PHY), six 32-bit timers, and an AES-256 encryption unit (Figure 3).
Figure 3: The Maxim Integrated MAX32650 is based on a 120 MHz Arm Cortex-M4F and features a full range of peripherals and memory options for high-performance IoT edge computing applications. (Image source: Maxim Integrated)
The MAX32650 has 3 MB of flash and 1 MB of SRAM and is targeted at complex Internet of Things (IoT) endpoints that require edge computing. The MAX32650 also has a 16-output pulse train peripheral that can generate complex PWM signals. It can generate square waves with configurable frequency and 50% duty cycle, as well as pulse trains based on programmable bit patterns up to 32 bits in length.
Preventing phase delay
The pulse train generator can individually enable or disable any of the 16 PWM outputs using the 32-bit PTG_ENABLE register. Writing a 1 to any bit position enables that pulse train, causing it to operate as configured. Writing a 0 stops the pulse train clock and logic, freezing the outputs at their current logic states. This register has the same RMW limitations as the enable/disable registers in most microcontrollers, so bit-banding is not recommended.
To maintain phase synchronization between waveforms, the pulse train peripheral of the MAX32650 supports a unique feature called “safe enable” when using the 32-bit register PTG_SAFE_EN and “safe disable” when using the 32-bit register PTG_SAFE_DIS. The upper 16 bits of each of these registers are unused and it is recommended that these unused locations always be written with zeros.
To safely enable any output, the firmware writes a 1 to the corresponding bit position in PTG_SAFE_EN. This also immediately sets the bit positions in PTG_ENABLE for those outputs, thus starting the PWM outputs. Writing a 0 to any bit position in PTG_SAFE_EN has no effect on any pulse train outputs.
To safely disable any output, the firmware writes a 1 to the corresponding bit position in PTG_SAFE_DIS. This also immediately clears the bit positions in PTG_ENABLE for those outputs, thereby stopping the PWM outputs. Writing a 0 to any bit position in PTG_SAFE_DIS has no effect on any pulse train outputs.
Writing to these registers does not perform a RMW. The safe enable/disable feature allows one or more pulse trains to be started or stopped immediately while guaranteeing that any other pulse trains will not be affected. The PTG_SAFE_EN and PTG_SAFE_DIS registers do not support bit strapping.
Referring again to the bipolar stepper motor in Figure 1, pulse train outputs 0 and 1 can be used for the green current windings corresponding to A and B, and pulse train outputs 2 and 3 can be used for the red current windings corresponding to C and D. Since the waveform in Figure 2 contains dead spots, it is appropriate to use the pulse train feature to program a pattern that can be configured to repeat any number of times without firmware intervention.
Once set, the motor can be started by writing 0000000Fh to PTG_SAFE_EN. This simultaneously starts pulse train outputs 0 to 3, starting the motor without affecting any other running pulse train outputs. The motor can be stopped by writing 0000000Fh to PTG_SAFE_DIS. Both actions will not affect any other running pulse trains.
If any of the other 12 pulse train outputs need to be enabled or disabled, they can also be safely controlled using these two registers. As long as 1 is not written to the lower four bit positions of these registers, the operation of the stepper motor will not be affected. This is completely different from using the standard enable registers with RMW, when the outputs may stutter, causing phase shifts, which may have an adverse effect on torque. The safe enable/disable function is like an atomic operation, so it ensures that the stepper motor runs efficiently, does not waste power, and always maintains maximum torque.
Previous article:Position Sensor Selection for BLDC Motor Control
Next article:Explanation of PLC basic signal concepts
Recommended ReadingLatest update time:2024-11-16 15:31
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Intelligent Control Technology of Permanent Magnet Synchronous Motor (Written by Wang Jun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【NXP Rapid IoT Review】Environmental Quality Test
- [ATmega4809 Curiosity Nano Review] Installing MCC
- GD32E231C-START Unboxing
- X-NUCLEO-IKS01A3 sensor test based on STM32F401RE development board 5L
- Simulation failed with no results
- Principle of Dialogue Communication
- Voltage jump problem
- 【McQueen Trial】Main functions corresponding to driver pins
- ti dsp (tms320VC5502) + isp1581 usb2.0 high speed data acquisition solution
- Tesla's electric motor