Share this

Detailed Analysis of Integer Cycle Ratio Implementation Method Based on FPGA

2026-04-06 06:21:50 · · #1

Electric motors are crucial actuators in various CNC machine tools. To achieve precise position control of the motor, the rotor's position must be accurately detected. Photoelectric encoders are currently the most commonly used detection devices. Photoelectric encoders are classified into incremental, absolute, and hybrid types. Among them, incremental encoders are widely used due to their simple construction, long mechanical life, and ease of achieving high resolution. Incremental photoelectric encoders output three-phase signals: A, B, and Z. Phases A and B are 90° out of phase, and phase Z is the encoder's "zero position," outputting only one pulse per revolution. In applications, it is often necessary to divide the orthogonal pulses of phases A and B according to a certain ratio, i.e., the frequency division ratio. The difficulty of frequency division lies in ensuring that the output pulses of phases A' and B' remain orthogonal or approximately orthogonal, regardless of whether the frequency division ratio is set as an integer or fraction. To address this, an integer frequency division ratio implementation method based on FPGA is proposed. This method has a simple logical structure, flexible configuration, and is easy to expand, making it highly practical.

1. Electronic Gear Ratio and Percentage Ratio: Electronic gear ratio and percentage ratio are crucial concepts in CNC machine tools and CNC machining centers. Most servo drives abroad have electronic gear ratio and percentage ratio functions. The electronic gear ratio (KEG) is the ratio of the actual number of pulses executed by the servo motor to the commanded number of pulses. The percentage ratio (KDF) is the ratio of the number of pulses received by the servo drive from the pulse encoder on the servo motor shaft to the number of pulses actually fed back to the host servo control system (CNC). Using electronic gear ratio and percentage ratio functions together, users can easily achieve integer pulse equivalents, thus avoiding quantization errors in intermediate calculations. This allows for direct code porting to machine tools or machining centers equipped with different motor encoder line counts or different lead screw pitches without modifying the G-code.

The electronic gear ratio and the piezoelectric ratio can be calculated using the following formula.

In the formula: PG is the number of lines of the motor photoelectric encoder, in P/rev (pulse/revolution); P is the lead screw pitch, in mm/rev (millimeters/revolution); Δl is the pulse equivalent, in mm/P (millimeters/pulse); m/n is the reduction ratio.

Electronic gear ratios can be achieved by changing the pulse frequency. However, for circumference ratios, since the pulse quantity fed back to the CNC by the driver generally uses an orthogonal pulse sequence, the implementation of circumference ratios is more difficult than that of gear ratios. Various foreign drivers generally have circumference ratio functions. This paper studies and discusses the implementation of circumference ratios using FPGAs. The schematic diagrams of electronic gear ratios and circumference ratio functions are shown in Figure 1.

The principle block diagram of the 2-minute cycle ratio is shown in Figure 2. The implementation structure of the cycle ratio function is shown in Figure 2.

The implementation of the frequency division ratio requires three functional modules: a quadruple frequency multiplier (QDPF) module, a frequency divider (DF) module, and an orthogonal sequence generation (OSG) module. The QDPF module takes an orthogonal pulse sequence as input and outputs a direction signal and a quadruple frequency multiplier pulse. The DF module can divide the input pulse by three. Internally, the DF is an increment/decrement counter that increments or decrements based on the input direction signal. For a positive direction, it outputs a pulse and a positive direction signal after reaching a set positive threshold; for a negative direction, it outputs a pulse and a negative direction signal after reaching a set negative threshold. When the count value is between the positive and negative thresholds, the output direction signal remains unchanged even if the motor direction changes or even jitters.

The OSG module uses input pulses to trigger the internal state machine for state transitions, and determines the state to jump to based on the input direction signal, thereby generating orthogonal signals and direction signals.

3. Simulation Study

Based on Figure 2, using the Libro 8.1 development platform of ACTEL and the VHDL hardware language, the corresponding functional modules were created, and the schematic diagram is shown in Figure 3.

In Figure 3, PA205 and PB206 are the input pins of phase A and phase B of the original differential signal, respectively. After the signal is quadrupled by the QDPF, the direction signal and pulse signal are output to the DF frequency divider module. After being divided by the DF, the pulse and direction signals are output to the quadrature pulse generation module OSG to generate quadrature signals with phase, and finally fed back to the CNC from PA119 and PB120.

The main modules will be introduced separately below.

The Quadruple Frequency Module (QDPF) is a method for quadruple frequency of orthogonal signals. It is covered in many documents and will not be described in detail here.

The frequency divider module DF divides the pulse sequence input to the CLK_IN pin according to the initial configured frequency division ratio or a preset frequency division ratio. Internal up and down counters increment (DIR_IN=1) or decrement (DIR_IN=0) the input pulses based on the direction signal from the DIR_IN pin. When the count reaches a positive threshold, it outputs a pulse and a positive direction signal (DIR_OUT=1); when the count reaches a negative threshold, it outputs a pulse and a negative direction signal (DIR_OUT=0). If the count value is between the positive and negative thresholds, the output direction signal remains unchanged regardless of whether the motor is in reverse or fluctuates around the threshold (i.e., the direction changes repeatedly). This is crucial for correct frequency division; if this step is not handled properly, the motor may continuously send pulses to the CNC after positioning. Taking a three-way frequency division as an example, the counter increments to 3 and outputs a positive pulse (positive direction signal + pulse); the counter decrements to -3 and outputs a negative pulse (negative direction signal + pulse). When the count value is (-3, 3), the counter only counts the pulses and does not output any. The simulation results for QDPF are shown in Figure 4.

After being triggered by the rising edge of the pulse signal, the OSG jumps to the next state according to the current state and the direction signal. When the direction signal is positive, the state is switched in the counterclockwise direction of the outer loop, generating an orthogonal pulse sequence in which phase A' leads phase B' by 90°; when the direction signal is negative, the state is switched in the clockwise direction of the inner loop, generating an orthogonal pulse sequence in which phase B' leads phase A' by 90°, as shown in simulation 6.

In Figure 6, dir represents the direction signal, and its transition edge indicates the point where the direction changes. As shown in Figure 6, when the motor rotates forward, the sequence is 10→11→01→00 (reverse)→01→11→10→…. This achieves phase switching according to the input signal.

Finally, the overall structure of the frequency division function was simulated, with an orthogonal pulse sequence as input. The input simulated the pulse output of an actual motor photoelectric encoder, repeatedly switching the pulse phase to verify the output after motor positioning. The simulation is shown in Figure 7. As can be seen from Figure 7, when the input signals pula and pulab continuously switch phases, the outputs pula1 and pulab1 are divided by 3, and a new orthogonal sequence is output after satisfying 3 or -3. The actual experimental waveform is shown in Figure 8.

In Figure 8, waveforms 1 and 2 are the A-phase and B-phase quadrature pulses output by the photoelectric encoder, respectively. Waveforms 3 and 4 are the A'-phase and B'-phase quadrature pulses after dividing the A-phase and B-phase quadrature pulses by 3, respectively. Observing Figures 7 and 8, the results are consistent. The frequency division ratio achieved by this scheme has been successfully applied to high-precision servo drives, and repeated verification in practical applications has revealed no errors.

4. Conclusion

The frequency division ratio implementation method proposed in this paper can accurately divide the quadrature signal output by the photoelectric encoder according to the set frequency division ratio. By setting the frequency division ratio, a division ratio of 1 to 256 times, or even higher, can be achieved. In practical systems, the frequency division ratio can also be configured online via the bus using an MCU. If a fractional frequency division ratio is to be achieved, only slight modifications are needed to this scheme.

Read next

CATDOLL Emelie Hybrid Silicone Head

The hybrid silicone head is crafted using a soft silicone base combined with a reinforced scalp section, allowing durab...

Articles 2026-02-22
CATDOLL Airi TPE Head

CATDOLL Airi TPE Head

Articles
2026-02-22
CATDOLL 135CM Sasha

CATDOLL 135CM Sasha

Articles
2026-02-22