Design and Implementation of Single-Axis Position Servo System

1 Overview

Modern position servo systems often employ what is known as a "soft servo" system, which limits the position gain to ensure system stability. A closed-loop speed control unit is integrated, allowing for a high-speed loop gain. This means that even small position errors can lead to significant speed deviations, which are then corrected by the speed loop with a high gain, resulting in a high level of position resolution [1]. In the development of a CNC gear planer, the author designed and implemented a single-axis position servo system. The system uses a semi-closed-loop structure, as shown in Figure 1. This text will elaborate on the composition and hardware implementation of the position servo system based on this design.

1

Figure 1 Block diagram of a single axis position control system

2 Composition of the Position Servo System

In Figure 1, the position controller and speed controller are programmed using a 486 personal microcomputer. The motor used is a FANUC-BESK (model 15) DC servo motor from Beijing Numerical Control Equipment Factory, with the A06B-6054-H005 power driver module. Since the speed control unit is an analog system, a 12-bit D/A converter is used to convert the digital output of the microcomputer into an appropriate analog voltage, which controls the motor to rotate in a direction that reduces the positional deviation. The position feedback uses a photoelectric encoder with a resolution of 4000 lines per revolution. After a frequency quadrupling circuit, the position pulse count is recorded by the programmable counter 8254. The position controller calculates the speed command voltage based on the number of pulses and the command pulses, and outputs it to a 12-bit D/A converter, generating an analog speed command voltage. The speed feedback also uses the same photoelectric encoder and counting circuit. The speed controller calculates the actual speed using the first-order difference of the position and then outputs it to another 12-bit D/A converter. The analog voltage is fed back to the speed control unit. The actual speed ω is calculated as ω = ΔN / Ts, where ΔN is the position pulse increment during the sampling period and Ts is the sampling period, which is set to 8 milliseconds. The CNC control program written by the author adopts a front-and-back office software structure. The front desk program is an interrupt service routine, and the hardware implements an 8-millisecond timer interrupt, primarily responsible for fine interpolation and position control functions. The background program is a circular operation program, mainly handling data input and rough interpolation and other auxiliary functions.

3 Implementation of the Servo System

Digital-to-analog conversion is performed using the DAC1210 chip. To avoid reducing the resolution, an electronic switch CD4052 is used to handle the sign, enabling bipolar 12-bit digital-to-analog conversion. To improve drive capability and suppress interference, the output is configured as an emitter follower using the integrated operational amplifier OP07, as shown in Figure 2.

1

Figure 2 Bipolar 12-bit D/A Conversion

3.1 Quadruplers
Quadruplers [2, 3] are typically implemented using differential circuits, but their anti-jamming performance is poor. The author designed a quadrupler using an integral monostable circuit, as shown in Figure 3. The working principle involves square wave pulses A and B with a 90° phase difference. When the motor rotates forward, A leads B; when it rotates backward, B leads A. The circuit connects the inverted-A of A and the inverted-B of B, respectively, and integrates a monostable circuit to generate short pulses A' and -A' at the rising and falling edges of A, and similarly for B. When A is low, Va is high, G2 is low; when A rises, G1 is low, but due to the capacitor's voltage not changing abruptly, Va remains above the threshold for a period, keeping G2 high. As the capacitor discharges, Va drops until it falls below the threshold, causing G2 to go low. Once A returns to low, G1 goes high, and the capacitor begins charging again. When Va returns to a high level, the circuit reaches a steady state. From this analysis, we can see that the pulse width TW of A' is determined by the time from when the capacitor starts discharging to when Va drops below the threshold. According to the RC circuit transient analysis, the discharge time of the capacitor voltage is given by:

1(1)

In the formula, R’ is the resistance of the RC discharge loop, C’ is the capacitance, VC(∞) is the steady-state voltage, VC(0) is the initial voltage, and VC(t) is the voltage after t-time discharge. By substituting VOH, VOL, VTH, and R0 into equation (1), the pulse width TW is obtained as:

1(2)

Considering the circuit recovery time, the square wave pulse period should be 7–8 times TW to ensure reliable operation. Appropriate resistors and capacitors can then be selected. The four short pulse sequences A', -A', B', -B' are logically combined using NOR gates, as shown in Figure 3, producing positive and negative rotation quadruple frequency pulse sequences, as illustrated in Figure 4. This circuit has strong anti-interference performance, as the capacitive reactance is very small at high frequencies, and the pulse is selected by the second AND gate.

1

Figure 3 Integral Quadrupling Frequency Counting Circuit

1

Figure 4 Positive and Negative Quadrupler Pulse Waveform (Left: Forward, Right: Reverse)

3.2 Pulse Counting Circuit and Initial Value Bouncing The 8254 is a programmable counter that is convenient to interface with a microcomputer. In mode 2, it can automatically repeat counting. Using its two counting channels, it records forward and reverse pulses separately, which can be read in the program. By entering the count value and subtracting the two, the position pulse increment during the sampling period can be obtained, and further processed by the subsequent program. However, the author found a flaw in the application of the 8254: after initialization, the output latch contains a random number, which the program may read, leading to incorrect counts. When the first count pulse arrives, the counter starts from the initialized value and decrements by one. If no actual position pulse is present, the position pulse value read by the program is random. When the actual position pulse is input, the sampling program reads the correct value, but the first count is inaccurate, causing a sudden jump in the system, known as "initial value bounce." This is unacceptable for CNC machines and must be eliminated.

The author solved this issue through program processing. The method involves recording the initial contents of the output latch after initialization and comparing them with the read-in values in the sampling program. If the value does not change, it indicates no count pulse has arrived, and the position increment is zero. If the value changes, it means a count pulse has been received, and the first position increment is calculated via the program. Afterward, no more checks for "initial value bounce" are performed, and normal counting resumes. The following is the procedure for solving the "initial value bounce" (implemented in Turbo C language):

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)

{ ... }

Else

Dsp0 = 0;

......

Initialization procedure:

......

Unsigned char ch, cl;

Cl = inportb(P8254);

Ch = inportb(P8254);

Old-clk0 = cl | (ch << 8);

......

Variable description:

Old-clk0: Initial value of the output latch

clk0: Output latch read value

first: Logical variable to determine if the first pulse has arrived

dsp0: Position increment

P8254: Chip select address of 8254

The three count channels of 8254 are used to generate an 8 millisecond timer interrupt to trigger the interrupt service routine.

4 Experiments and Conclusions

The servo system uses a 4000-line-per-revolution photoelectric encoder, followed by a frequency quadrupling circuit. The pulse equivalent is δ = 360° / (4000 × 4) = 0.0225°/pulse. The position control algorithm employs a forward differential control method. Adjusting the D/A conversion of the speed feedback ensures 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, allowing the motor to operate stably under various constant speed command voltages. The linearity is 2000r/min/7V.

After experiments, the position gain was adjusted to 2, and the motor positioning error was ±8 pulses, or ±0.18°. The measured steady-state tracking error at different feedrate commands is shown in the table below. The motor to worktable has a 150:1 reduction ratio, and the above performance indicators meet the actual processing requirements. Additionally, after software processing, the system completely eliminated the "initial value jump" phenomenon.

Table: Steady-State Tracking Error at Different Speeds

Input Command Speed (r/min)Steady-State Tracking Error (angle °)
100.81
201.00
301.26
401.44
501.80

Curved Welded Mesh Fence

Curved Welded Mesh Fence,Pvc Coated Wire Mesh Fence,Decorative Garden Fence,Garden Border Fence

HEBEI CONQUER HARDWARE WIRE MESH CO.,LTD , https://www.anjiahardware.com