TPC unit and its application in stepper motor speed regulation
stepper motor is widely used in various automatic control systems and is a key component in electromechanical integration devices. This is a digital controlled motor, which is an actuator that converts electric pulses into angular displacement. It controls the angular displacement and rotation speed of the motor by controlling the number and frequency of pulses, so as to achieve the purpose of accurate positioning and speed regulation
the digital electric pulse signal (i.e. square wave control signal) required by the traditional stepping motor is generally generated by digital logic circuit. With the continuous development of embedded technology, the application of single chip microcomputer is more extensive. There are more and more occasions for single chip microcomputer to generate this kind of pulse signal. SCM timing control pulse generally has two ways: software timing and timer timing. The former method takes up most of the working time of the CPU, so the timer is often interrupted to generate pulse signals. Because the interrupt response time of general single-chip microcomputer system is mostly above 10us level, the accuracy of timer timing interrupt to generate pulse is roughly above 10us level, which often can not 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 pattern controller in the H8/3062f single chip microcomputer of H8/300h series of Renesas company for pulse control, so that the corresponding time of pulse signal output reaches O. China has made a breakthrough in the external wall insulation technology of 1US level, which can meet the high-precision requirements of stepper motor speed control
1 programmable timing style controller TPC
programmable timing style controller TPC is a special function module of H8/300h series single chip microcomputer of Renesas company. It uses 16 bit timer as time base to provide various types of pulse output. Figure 1 is the structure block diagram of TPC. The pulse output of TPC is divided into 4 groups of 4 bits, which can operate independently at the same time. Each group is triggered by the comparison and matching signals of 4 channels of the timer. TPC uses a total of 16 pins tp15 ~ tp0 of port B and port a as its output, which can be opened by bit, and can control up to 16 pulse outputs. The output data is provided by the data registers pbdr and Padr of the two ports and the subsequent data registers ndrb and NDRA. Port data direction registers paddr and pbddr are used to control the input or output of pins; The subsequent data allows the registers ndera and nderb to open or close the port output of TPC; The output mode register tpmr of TPC 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 triggers. Among them, the timer of single chip microcomputer H8/3062f has three channels, and each channel has three registers: timing counter TCNT, general registers GRA and GRB
after the timer is started, the counting force value of a selected channel in the timer is generally used to count the pulses of the clock source with the spoke sensor memory TCNT. When TCNT is equal to the value in the general register GRA (GRB) of the channel, a (b) comparison matching 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), so the output value of the TPC is updated
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 mode ensures a non overlapping margin between pulse outputs. In the general register GRB of this channel, set the output trigger cycle 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 matching event and the B comparison matching event occur. The normal output mode is to set the output trigger cycle of TPC output waveform in GRA, and TPC output signal when a comparison matching event occurs. According to the pulse control requirements of stepping motor, the normal output mode is adopted here
the principle of TPC for pulse control of stepping motor is as follows: first, select the general register gra as the output comparison register; Then, put the port value of the next output of the TPC into the subsequent data register NDRA (ndrb), and then start the timer to send an interrupt request when the a comparison matching event occurs. In the process of studying the TPC output timing, it is found that the TPC does not send values to the TPC port during the interrupt response process, but sends the values previously placed in the subsequent data register to the port data register Padr (pbdr) after a compares the three clock cycles of the matching event, so the output value of the TPC is updated. Because the clock frequency of the H8/3062f series single chip microcomputer is above 20 MHz, it can send the port signal in less than o.2ms, which greatly shortens the response time. It is dozens of times or even hundreds of times faster than the general single chip microcomputer in the process of timing interruption, so that the pulse control is more accurate. In the interrupt subroutine, the values of the subsequent data register NDRA (ndrb) and the output comparison register gra are updated, so as to change the frequency of the pulse and realize the speed regulation of the asynchronous motor. Figure 2 is the schematic diagram of generating pulse frequency change. GRA Gra'and gra "Three different gra values are represented abstractly, which demonstrates the influence of the change of gra value on the pulse frequency.
2 pulse control scheme for the start, speed regulation, acceleration and deceleration of stepping motor
tp15 pin of TPC of H8/3062f and p1.o of I/O port are used to control the speed and direction of stepping motor respectively. The pulse output by tp15 is sent to the motor drive control circuit composed of power tube, so that the power tube works in the on-off state and the stepping motor stops The output of tp15 remains high when. In this way, when tp15 outputs a negative pulse, the power tube is turned on, so that the stepper motor moves forward one step, and the speed regulation of the stepper motor is realized by controlling the pulse frequency output by tp15. P1.0 controls the running direction of the stepping motor. When p1.o output is high, the stepping motor advances; Otherwise, it will retreat
the pulse frequency at which the stepping motor can start normally under load is called "stepping motor starting frequency". If the pulse frequency is higher than this value, the motor will not start normally, and step loss or locked rotor may occur; Similarly, the stepping motor should also be braked at the starting frequency at the end of braking. If you want to make the motor rotate at a high speed, the pulse frequency should have an acceleration process, that is, the starting frequency is low, and then rise to the desired high frequency according to a certain acceleration (the speed reduction process is opposite). The ideal start-up curve should be based on the exponential law. Therefore, the treatment of waste plastic particles will become a hot start-up in the future. Choose different start-up frequencies and different exponential curves according to the user's load situation to find the most ideal curve
generally, in the process of operation control, the "step speed increase method" is used to continuously increase the speed to the required speed, and the conversion time of running speed according to the preset curve should be as short as possible. In order to shorten the time of speed conversion, a data table can be established by combining the frequency of each curve segment and the step frequency between each segment. After several "test runs", the gra values corresponding to 256 pulse frequencies are calculated. Among them: the first is the gra value corresponding to the starting frequency of the stepping motor; The last one is the gra value corresponding to the maximum pulse frequency of the stepping motor, which is stored in the array in the software programming to change the pulse frequency and realize the acceleration and deceleration control of the stepping motor. The deceleration braking process is the same as the acceleration starting process. Figure 3 is the schematic diagram of step speed up startup
3 software programming
the software part is composed of a main program and three subprograms (TPC initialization subprogram, timer initialization subprogram and interrupt subprogram), and the program is written in C language. 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 the clear o source of its counter, and turns on the timing interrupt. The interrupt subroutine realizes the output control of the pulse, so as to realize the speed regulation of the stepping motor. In programming, we should focus on 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 is 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 maximum running speed; Otherwise, it is necessary to slow down, otherwise it may not be able to stop at the starting frequency when reaching the target point, resulting in braking failure
conclusion
using the TPC in the H8/3062f single chip microcomputer to control the pulse sequence of the stepping motor can make the operation of the stepping motor faster and more accurate, which is tens of times or even hundreds of times the response speed of the optimistic pulse that the general single chip microcomputer controls the shipment in 2017 and 2018, so as to meet the accuracy requirements of the speed regulation control of the stepping motor, and the TPC can control the synchronous operation of 16 stepping motors at most, Therefore, it will be widely used in stepping motor speed regulation. (end)
Copyright © 2011 JIN SHI