TPC unit and its application in stepper motor speed regulation

Publisher:camuspycLatest update time:2007-01-24 Source: 单片机及嵌入式系统应用Keywords:pulse Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Stepper motors are widely used in various automation control systems and are key components in mechatronics devices. This is a digitally controlled motor, which is an actuator that converts electrical pulses into angular displacement. It controls the angular displacement and rotation speed of the motor by controlling the number and frequency of pulses, thereby achieving accurate positioning and speed regulation. .

The digital electrical pulse signals (i.e., square wave control signals) required by traditional stepper motors are generally generated with the help of digital logic circuits. With the continuous development of embedded technology, microcontrollers are more widely used, and there are more and more occasions where such pulse signals are generated by microcontrollers at regular intervals. Microcontroller timing control pulses generally have two methods: software timing and timer timing. The former method takes up most of the CPU's working time, so timer interrupts are often used to generate pulse signals. Since most of the interrupt response times of general microcontroller systems are above 10Us, the accuracy of pulses generated by timer interrupts is generally above 10Us, which often cannot meet the high-precision requirements of stepper motor speed control. In order to improve the accuracy of pulse control, the author uses the programmable timing controller in the H8/3062F microcontroller of Renesas' H8/300H series for pulse control, so that the corresponding time of the pulse signal output reaches 0. 1Us level, thus meeting the high-precision requirements of stepper motor speed control.

1 Programmable Timing Pattern Controller TPC

Programmable Timing Pattern Controller TPC is a functional module unique to Renesas' H8/300H series microcontrollers. It uses a 16-bit timer as a time base to provide various patterns of pulse output. Figure 1 is the structural block diagram of TPC. The pulse output of TPC is divided into 4 groups that can operate independently at the same time. Each group has 4 bits and is triggered by the comparison match signal of the 4 channels of the timer. TPC borrows a total of 16 pins TP15~TP0 from port B and port A as its output, which can be opened bit by bit and can control up to 16 pulse outputs. The output data is composed of the data registers PBDR and PADR of the two ports and subsequent data registers. Provided by NDRB and NDRA. The port data direction registers PADDR and PBDDR are used to control the input or output of the pin; the subsequent data enable registers NDERA and NDERB are used to open or close the TPC port output; the TPC output mode register TPMR is used to select the output mode of each group of TPC ; The output control register TPCR is used to select the trigger signal source of each group of TPC, that is, which channel of the timer is triggered. Among them, the timer of the microcontroller H8/3062F has 3 channels, and each channel has 3 registers: timing counter TCNT, general registers GRA and GRB.

After the timer starts, the counting register TCNT of a channel selected in the timer will count the pulses of the clock source. When TCNT is equal to the value in the general register GRA (GRB) of the channel, it is said that the A (B) compare match event of the channel occurs. In this way, the value previously placed in the subsequent data register NDRA (NDRB) is automatically transferred to the corresponding bit of the data register PADR (PBDR) of the corresponding port A (B), thus updating the output value of the TPC.

TPC has two output modes, namely non-overlapping output and normal output. The output mode of each group of TPC can be selected through the output mode register TPMR. The non-overlapping output method ensures a non-overlapping margin between pulse outputs. In the general register GRB of this channel, set the output trigger period of the non-overlapping TPC output waveform, then the non-overlapping margin is placed in GRA, and the output value will be triggered when the A comparison match event and the B comparison match event occur. In the normal output mode, the output trigger period of the TPC output waveform is set in GRA, and the TPC outputs the signal when the A comparison match event occurs. According to the pulse control requirements of the stepper motor, the normal output mode is used here.

The principle of TPC for stepper motor pulse control is as follows: first, select the general register GRA as the output comparison register; then, place the next output port value of TPC into the subsequent data register NDRA (NDRB), and then start the timer. A compare match event occurs when an interrupt request is issued. In the process of studying the TPC output timing, it was discovered that the TPC does not send the value to the TPC port during the interrupt response process, but 3 clock cycles after the A comparison match event occurs, the value placed in the subsequent data register is placed in advance. Sent to the port data register PADR (PBDR), the output value of the TPC is updated. Since the clock frequencies of the H8/3062F series microcontrollers are above 20 MHz, this requires less than 0. The port signal can be sent in 2ms, which greatly shortens the response time. It is dozens or even hundreds of times faster than the general microcontroller that sends the port signal during the scheduled interrupt process, thus making the pulse control more accurate. In the interrupt subroutine, the values ​​of the subsequent data register NDRA (NDRB) and the output comparison register GRA are updated, thereby changing the pulse frequency to achieve speed regulation of the asynchronous motor. Figure 2 is a schematic diagram of generating pulse frequency changes. In the figure, GRA, GRA' and GRA" abstractly represent three different GRA values, thus demonstrating the impact of changes in GRA values ​​on the pulse frequency.
2. The starting, speed regulation and acceleration and deceleration pulse control scheme of the stepper motor

adopts the TP15 pin of the TPC of H8/3062F and the P1 of the I/O port. O controls the speed and direction of the stepper motor respectively. The pulses output by TP15 are sent to the motor drive control circuit composed of power tubes, so that the power tubes work in the switching state. When the stepper motor stops, the output of TP15 remains high. In this way, when TP15 outputs a negative pulse, the power tube is turned on, thereby making the stepper motor move forward one step. The speed regulation of the stepper motor is achieved by controlling the pulse frequency output by TP15. P1.0 controls the running direction of the stepper motor. When P1.When the O output is high, the stepper motor moves forward; otherwise, it moves backward.

The pulse frequency at which a stepper motor can start normally under load is called the "stepper motor starting frequency". If the pulse frequency is higher than this value, the motor will not start normally and may lose steps or stall; similarly, the stepper motor should brake at the starting frequency when braking. If the motor is to rotate at high speed, the pulse frequency should have an acceleration process, that is, the starting frequency is low, and then rises to the desired high frequency at a certain acceleration (the deceleration process is reversed). A more ideal starting curve should start according to the exponential law. Different starting frequencies and different exponential curves should be selected according to the user's load conditions to find the most ideal curve.

Generally, during the operation control process, the "step-up speed method" is used to continuously increase the speed to the required speed, and the operating speed conversion time according to the preset curve should be as short as possible. In order to shorten the speed conversion time, the method of establishing a data table can be used. A continuous data table can be established by combining the frequency of each curve segment and the step frequency between each segment. After many "test runs", the GRA values ​​corresponding to 256 pulse frequencies were calculated. Among them: the first one is the GRA value corresponding to the starting frequency of the stepper motor; the last one is the GRA value corresponding to the maximum pulse frequency of the stepper motor, which is stored in the array during software programming and is used to change the pulse frequency to realize control of the stepper motor. acceleration and deceleration control. The deceleration and braking process is the same as the acceleration and start-up process. Figure 3 is a schematic diagram of the step speed up start.
3. Software programming

The software part consists of 1 main program and 3 subprograms (TPC initialization subprogram, timer initialization subprogram and interrupt subprogram). The program is written in C language. The TPC initialization subroutine sets TP15 as the output mode and the potential of the next output, and selects the output signal trigger source. The timer initialization subroutine selects the timer clock source and its counter clearing source, and turns on the scheduled interrupt. The interrupt subroutine realizes pulse output control, thereby realizing the speed regulation of the stepper motor. An important issue to consider in programming is the relationship between the distance from the target point and the pulse frequency position variable. This is the basis for whether to accelerate or decelerate. After calculation, it was found that when the distance from the target point is greater than the value in the pulse position variable plus 1, the stepper motor accelerates or maintains the highest operating speed; otherwise, it must slow down, otherwise it may not be able to stop at the starting frequency when it reaches the target point, thus causing braking failure.

Conclusion

Using the TPC in the H8/3062F microcontroller to control the pulse sequence of the stepper motor can make the stepper motor run faster and more accurately. It is dozens or even hundreds of times faster than the response speed of the general microcontroller control pulse, thus satisfying the need for stepper motor adjustment. Speed ​​control accuracy requirements, and TPC can control up to 16 stepper motors to run synchronously, so it will be widely used in stepper motor speed regulation.

Keywords:pulse Reference address:TPC unit and its application in stepper motor speed regulation

Previous article:Design of direct digital control system for SR motor based on two-step commutation control strategy
Next article:Field-oriented control of brushless motors using an ARM7 processor

Recommended ReadingLatest update time:2024-11-17 00:05

US mobile phone chip maker Cirrus Logic announced that it has agreed to acquire Lion Semiconductor
According to Jiwei.com, today (9), Cirrus Logic announced that it has reached an agreement to acquire California-based Lion Semiconductor for US$335 million in cash. Cirrus Logic mentioned that the acquisition brings unique intellectual property and products for power applications in smartphones, laptops and other dev
[Mobile phone portable]
Latest Industrial Control 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号