Design and Implementation of a Single-Axis Position Servo System
2026-04-06 05:17:15··#1
1 Overview The current position servo system generally adopts the so-called "soft servo" system, so that the position gain is not very large, so the system is easy to stabilize, and a closed-loop speed control unit is added, and the speed loop gain is very large. Therefore, a small position deviation can produce a significant speed deviation, and the speed loop corrects it with a high gain, thereby achieving a high position resolution of the system [1]. When developing a CNC gear planer, the author designed and completed a single-axis position servo system. The system adopts a semi-closed-loop structure, and the block diagram is shown in Figure 1. This paper will combine the system to explain the composition and hardware implementation of the position servo system. Figure 1 Block diagram of single-axis position control system 2 Composition of position servo system In Figure 1, the position controller and speed controller are both implemented by 486 microcomputer programming. The motor adopts the FANUC-BESK (Type 15) DC servo motor of Beijing CNC Equipment Factory, and the factory's A06B-6054-H005 is used as the power drive module. Since the speed control unit is an analog system, a 12-bit D/A converter is used to convert the digital output from the microcomputer according to the control algorithm into a suitable analog voltage to control the motor to rotate in the direction that reduces position deviation. Position feedback uses a photoelectric encoder with a resolution of 4000 lines/revolution. After passing through a frequency quadrupling circuit, a programmable counter 8254 records the number of position pulses. The position controller calculates the speed command voltage based on this pulse count and the command pulse count, and then outputs it to a 12-bit D/A converter to obtain the analog speed command voltage. Speed feedback also utilizes the same photoelectric encoder and counting circuit. The speed controller calculates the actual rotational speed by taking the first-order difference of the position, and then outputs it to another 12-bit D/A converter, feeding the obtained analog voltage back to the speed feedback input of the speed control unit. The actual rotational speed ω is calculated according to the formula ω=ΔN/Ts, where ΔN is the position pulse increment within the sampling period, and Ts is the sampling period, which is 8 milliseconds in this system. The CNC control program written by the author adopts a front-end and back-end software structure. The front-end program is an interrupt service program, which is implemented by hardware with an 8-millisecond timer interrupt. It mainly completes fine interpolation and position control functions. The back-end program is a loop program, which mainly completes data input, coarse interpolation and other auxiliary functions. 3 Implementation of Servo System The digital-to-analog conversion uses the DAC1210 chip. In order not to reduce the resolution, an electronic switch CD4052 is used to handle the positive and negative signs, so that the digital-to-analog conversion reaches bipolar 12-bit. In order to improve the driving capability and suppress interference, the output uses an integrated operational amplifier OP07 to make it into an emitter follower. The circuit is shown in Figure 2. Figure 2 Bipolar 12-bit D/A conversion 3.1 Quadruple Frequency Multiplier The quadruple frequency multiplier [2,3] is implemented by a differentiating circuit, which has poor anti-interference capability. The author designed a quadruple frequency multiplier, which uses an integrating monostable circuit, as shown in Figure 3. The working principle of the circuit: Two square wave pulses with a 90° phase difference, A and B, when the motor rotates in the forward direction, A leads B; when the motor rotates in the reverse direction, B leads A. The circuit has an integrating monostable circuit connected to A and its inverted-A and B and its inverted-B [4]. A short pulse A′ and -A′ are generated at the rising and falling edges of A, respectively, and a short pulse B′ and -B′ are generated at the rising and falling edges of B, respectively. When A is low, Va is high and G2 output is low. When the rising edge of A arrives, G1 output is low, but since the voltage across the capacitor cannot change abruptly, Va remains above the threshold level for a period of time, and G2 output is high, and the circuit enters a metastable state. As the capacitor discharges, Va continues to decrease. When Va is below the threshold level, G2 output is low. After A returns to low level, G1 output is high, and the capacitor starts charging again. When Va returns to high level, the circuit reaches a steady state again, preparing for the next rising edge. From the above analysis, it can be seen that the pulse width TW of A′ is equal to the time taken from the start of capacitor discharge to Va dropping to the threshold level. According to the analysis of the transient process of RC circuit, it can be seen that the discharge time of the voltage Va on the capacitor is determined by the following formula [4]: (1) Where R′——the resistance of the discharge loop of RC circuit C′——the capacitance of the discharge loop of RC circuit VC(∞)——the steady state value of capacitor voltage VC(0)——the initial value of capacitor voltage VC(t)——the value of capacitor voltage after discharge for t time Let the output high level of LSTTL circuit be VOH, the output low level be VOL, VTH be the threshold level, R0 be the output resistance when G1 outputs low level, substitute R′=R0+R, C′=C, VC(∞)=VOL, VC(0)=VOH, VC(t)=VTH into formula (1) to get the pulse width TW as: (2) Considering the circuit recovery time, the period of the square wave pulse sequence should be 7 to 8 times TW so that the circuit can work reliably. Appropriate resistors and capacitors can be selected accordingly. The four short pulse sequences A′, -A′, B′, -B′ are combined using AND, OR, and NOT logic as shown in Figure 3. This generates a fourfold frequency multiplier pulse sequence representing forward and reverse rotation at the outputs of U1 and U2, as shown in Figure 4. This circuit has good anti-interference performance because the capacitive reactance is very small at high frequencies, and the pulses are selected through two AND gates. Figure 3 Integrating type fourfold frequency multiplier circuit Figure 4 Forward and reverse fourfold frequency multiplier pulse waveforms (left: forward rotation, right: reverse rotation) 3.2 Pulse counting circuit and initial value jump The 8254 is a programmable counter that is very convenient to interface with a microcomputer. In mode 2, the counter can automatically repeat counting. Its two counting channels record the forward and reverse pulses respectively. By reading the count value into the program and subtracting the two, the position pulse increment within the sampling period can be obtained for further processing in subsequent programs. The author discovered a flaw in the 8254 during application: after initialization, a random number remains in the output latch. The program then reads this random number, causing the counter to decrement from its initial value upon the arrival of the first counting pulse. When the actual position pulse hasn't arrived, the program reads a random position pulse value. When an actual position pulse is input to the counter, the sampling program reads the correct position pulse value. Therefore, the first calculation of the forward or reverse pulse count by the sampling program is incorrect, and subsequent counting only enters a normal state. This randomness in the first reading causes severe system fluctuations, known as "initial value fluctuations." Such fluctuations are unacceptable for CNC machine tools and must be eliminated. The author solved this problem through program processing: after initialization, the initial value of the output latch is recorded. In the sampling program, the value read from the output latch is compared with this initial value. If the value remains unchanged, it indicates no counting pulse, and the position increment is zero; if the value changes, it indicates a counting pulse has arrived, and the program calculates the first position increment. Afterward, "initial value fluctuations" are no longer considered, and normal counting continues. The program to solve the "initial value jump" is as follows (implemented in Turbo C): Real-time sampling program: ... unsigned char cl,ch; unsigned int clk0; outportb(P8254+3,0xd6); cl=inportb(P8254); ch=inportb(p8254); clk0=cl|(ch<<8); if(clk0!=Old-clk0)first=1; if(first) {... dsp0=...; ... } else dsp0=0; ... Initialization program: ... unsigned char ch,cl; cl=inportb(P8254); ch=inportb(P8254); Old-clk0=cl|(ch<<8); ... Explanation of variables: Old-clk0: Initial value of the output latch; clk0: Read value of the output latch; first: Logic variable to determine if the first pulse has arrived; dsp0: Position increment; P8254: Chip select address of 8254; The third counting channel of 8254 is used to generate an 8-millisecond timer interrupt to trigger the interrupt service routine. 4. Experiment and Conclusion This servo system uses a 4000 lines/revolution photoelectric encoder, which, after passing through a quadruple frequency circuit, has a pulse equivalent of δ=360°/(4000×4)=0.0225°/pulse. The position control algorithm uses a forward differential control algorithm. The D/A conversion of the speed feedback is adjusted to ensure the output meets the requirements of the speed control unit A06B-6054-H005: 3V/1000r/min. The speed loop feedback coefficient is adjusted to 1.2. The motor can operate smoothly under different constant speed command voltages, with a linearity of 2000r/min/7V. The steady-state tracking error at different speeds was determined experimentally. With the position gain adjusted to 2, the motor positioning error was ±8 pulses, or ±0.18°. The measured steady-state tracking errors under different feed speed commands are shown in the table below. The motor-to-worktable reduction ratio is 150:1, and the above performance indicators meet the actual machining requirements. Furthermore, through software processing, the system completely eliminates the phenomenon of "initial value jumps."