“Timers and counters are perhaps the most common peripherals in MCU design. Almost any application can use a timer or counter to improve performance, reduce power, or simplify the design by replacing the repetiTIve-weaving or crocheting CPU operation with a simple timer or counter interrupt. You may not. However, using some of the newer timer/counter units, as well as some of the now advanced features can improve your design even more.This article will quickly review some, you can use it to improve your design with popular microcontroller series with special emphasis on autonomous operation and motor control illustrative examples in
Timers and counters are perhaps the most common peripherals in MCU design. Almost any application can use a timer or counter to improve performance, reduce power, or simplify the design by replacing the repetiTIve-weaving or crocheting CPU operation with a simple timer or counter interrupt. You may not. However, using some of the newer timer/counter units, as well as some of the now advanced features can improve your design even more. This article will quickly review some of the new timer/counter functions you can use to improve your design with illustrative examples of popular microcontroller series with special emphasis on autonomous operation and motor control.
Timer and counter modes: from simple to advanced
Timers and counters have begun to operate in some very simple ways to replace the loop counting of external events in ordinary programs, timing internal and external business and key MCU operations to collect various statistical information. Some of the most familiar counting modes are illustrated by the features on the Maxim MAXQ612 MCU and some examples are shown in Figure 1 below. The table at the bottom of the figure shows three common autonomous operation modes when Timer B, MAXQ612 timer/counter module: auto-reload, capture and PP/count down. The figure in the upper right corner shows the block diagram of the automatic reload mode. The clock input of Timer B can come from a clock divider, which can divide the system clock with eight different settings, or from an external pin. The control bit, TRB, enables or disables timer B operation. The timer value register (TVB) counts up the clock and when it reaches the value stored in the timer B load register (TBR), an interrupt is generated and the TVB resets to zero. This provides an easy way to create a delay without using precious CPU cycles. An external pin can be used to selectively reset the TVB to zero as well, so that this mode can be used to create a timeout if the expected input is not displayed in the expected amount of time.
Image of Maxim MAXQ612 microcontroller
Improve the design performance of microcontrollers based on timers and counters
Figure 1: Maxim MAXQ612 MCU as an example of counter/timer mode.
The block diagram in the upper right corner of Figure 1 illustrates the action in the capture mode. In this mode, the clock divider and enable/disable functions are the same, in auto-reload mode. The TBV register counts and resets to zero when it overflows and generates an optional interrupt. On the falling edge of the external pin TBB, the value in the TBV register is loaded into the capture register, TBR and interrupt, EXFB, can be generated. This mode is useful for counting the external signal to determine the signal frequency or the number of clocks between rising edges of signal delay. The timer thus frees the CPU from doing cycle-intensive computing operations, so it can become more efficient for the work it really needs.
Several other common timer/counter operations are supported by MAXQ612 such as up/down auto-reloading, in which an external pin controls the direction of counting. This mode is suitable for a variety of pulse width modulated signals, such as those used in electromechanical sensors, the decoding is very helpful. The clock output mode can be used to use the system clock, a divider and the terminal count of timer B. Finally, a pulse width modulation (PWM) output mode can generate edge-aligned signals to generate a simple output clock for use in common PWM applications , Such as those used for motor control.
PWM counter/timer function motor control
Some of the most advanced timer/counter functions are used in PWM applications for motor control. These counters use dedicated hardware to release the processor to perform higher-level functions to achieve as many motor-related PWM functions as possible. The basic operation of the motor control PWM timer/counter is realized by most manufacturers and those found in common between the NXP LPC 17XX PWM timers, which are optimized for three-phase AC and DC motor control applications, provide a Good example. As shown in Figure 2, the function of the motor control PWM module can be quite complicated until you know that there are three copies of a basic PWM timer channel; one on the left, one in the middle, and one on the right. Having three channels makes it possible to use a single timer/counter for a very effective realization of the control of a three-phase motor. A pair of output terminals controlled by each channel, in turn, can be controlled off-chip, like a motor in a set of coils. Each channel includes a timer/counter (TC) register, which is incremented by a processor clock (timer mode) or by an input pin (counter mode).
Image of NXP LPC 17XX PWM Timer/Counter
Figure 2: NXP LPC 17XX PWM timer/counter.
Each channel has a limit register relative to the TC value, and when a match occurs, the TC is “reset” in one of two ways. In the edge-aligned mode, the TC is reset to 0, and the mode in the center is matched to switch TC until it reaches 0, at which point it will start counting down again on each processor’s clock or input pin transition.
Each channel also includes a matching register, which is used to store a value smaller than the limit register. In the edge-aligned mode, the channel output switches whenever the TC value matches either the match or limit register, while in the center-aligned mode, they are switched only when it matches the register. Therefore, the limit register controls the output period, while the matching register controls how much output per cycle is spent in each state. Having a small value in the limit register minimizes the ripple if the output is integrated into a voltage, and allows the motor control PWM timer to control the device operating at high speed.
The hardware components of all these channels work together to control the two outputs, A and B, which can drive the control points for switching between the two power rails of a pair of transistors. Most of the time the two outputs have opposite polarities, but a dead time function can be enabled (on a per channel basis) to delay the transition of the two signals from passive to active state, so that the transistor is from Not at the same time. The state of each pair of outputs can be considered as high, low, and floating or up, down, and center off. The mapping of each channel from active and passive high to low is programmable, and each can perform edge-aligned center-aligned pulse width modulation. Figure 3 shows two examples of output configurations. In a center on the left, there is no consistent stagnation time. There is an insert on the right to ensure that the two outputs will not actively dead time (DT) at the same time.
Image of NXP LPC17xx Motor Control PWM Timer/Counter
Figure 3: NXP LPC17xx motor control PWM timer/counter, such as output configuration.
The motor control PWM timer also includes several interrupt sources, which can easily notify the processor required for higher-level motor control functions. These interrupts are organized on a channel basis, and can indicate when a TC matches the match register, when the TC limit register matches, when the channel captures the TC value to its capture register or the interrupt input becomes active. The LPC17xx also has some supporting peripherals to simplify higher-level control functions, including quadrature encoder interface, additional PWM module, timer interrupt and watchdog timer. This wide range of professional timing functions indicates how important timing functions have become MCU-based designs.
Other professional timing functions
In many modern MCU timing and counting functions, manufacturers are increasingly specialized in specific application areas. As an example, Freescale’s KineTIs K10 family (such as MK10DN512ZVLQ10) has a variety of timings and numbers of peripheral devices with specialized functions. These peripherals include: programmable delay blocks used to control ADC and DAC operations to free the processor useful from managing these low-level processes; flexible timing modules that provide multiple channels for timing, counting, input capture, and output comparison support Power management and control of lighting and electric motors; periodic interrupt timer, which can automatically manage peripheral interrupts and DMA transfer; very low power consumption timer, when the MCU is in the lowest power consumption state, to provide a simple periodic ” “Wake-up” events can also work; and real-time clock to maintain accurate time, even when the MCU is disconnected from the battery, the MCU can be completely powered off, making the source of system operation and life data convenient.
The K10 series also provides dedicated and specific blocks so that other timing resources do not consume dedicated clock and timing functions. For example, the carrier modulator transmitter block is used to create the protocol used in various signal coding schemes, such as in infrared communication, has its own dedicated timing and counting functions, much like a pulse width modulation counter to manage Change the pulse width related to the frequency shift key coding scheme. This trend of dedicated professional timing and counting functions is expected to continue as microcontrollers become more specific for applications and market segments.
Development kits accelerate time to market
As microcontrollers become more application specific, manufacturers have created more application-oriented development kits and reference designs. The motor control application is perhaps one of the most common examples in the specific application kit. To give just one example, Renesas provides a complete motor control development kit. In Figure 4, it even includes the YMCRPRX62T shown in an example motor. The kit is equipped with all you need to evaluate the Renesas RX62T MCU in several motor control design software and reference designs. A PC host demonstration graphical user interface shows the motor speed, voltage and current, while allowing users to adjust parameters and algorithms to directly view the results to help adjust the motor to run in a specific design for the best results. Many other manufacturers also have some similar functions, Renesas RX62T motor control evaluation kit. Find the best match between your target application and development environment to take advantage of a significant amount of work and the manufacturer’s “bundled” toolkit to help you speed up your next motor control design.