Photoelectric encoders are widely used in high-precision measurement fields such as industry and aerospace because of their high precision and reliability. In order to improve the subdivision accuracy of moiré grating signals, a particle swarm optimization compensation model for grating the subdivision error of a photoelectric encoder based on parallel iteration is proposed. In the paper, an adaptive subdivision method of a particle swarm search domain based on the honeycomb structure is proposed, and a raster signal subdivision error compensation model based on the multi-swarm particle swarm optimization algorithm based on parallel iteration is established. The optimization algorithm can effectively improve the convergence speed and system accuracy of traditional particle swarm optimization. Finally, according to the subdivision error compensation algorithm, the subdivision error of the grating system caused by the sinusoidal error in the system is quickly corrected by taking advantage of the high-speed parallel processing of the FPGA pipeline architecture. The design experiment uses a 25-bit photoelectric encoder to verify the subdivision error algorithm. The experimental results show that the actual dynamic subdivision error can be reduced to ½ before compensation, and the static subdivision error can be reduced from 1.264” to 0.487” before detection.