CN115618176A - Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium - Google Patents

Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium Download PDF

Info

Publication number
CN115618176A
CN115618176A CN202211368663.XA CN202211368663A CN115618176A CN 115618176 A CN115618176 A CN 115618176A CN 202211368663 A CN202211368663 A CN 202211368663A CN 115618176 A CN115618176 A CN 115618176A
Authority
CN
China
Prior art keywords
value
moire fringe
particle swarm
particle
fitness
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211368663.XA
Other languages
Chinese (zh)
Inventor
慕雨松
候南剑
迟耀丹
吴博琦
王艳杰
洪伟程
毛茏玮
袁迪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jilin Jianzhu University
Original Assignee
Jilin Jianzhu University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jilin Jianzhu University filed Critical Jilin Jianzhu University
Priority to CN202211368663.XA priority Critical patent/CN115618176A/en
Publication of CN115618176A publication Critical patent/CN115618176A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/15Correlation function computation including computation of convolution operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/004Artificial life, i.e. computing arrangements simulating life
    • G06N3/006Artificial life, i.e. computing arrangements simulating life based on simulated virtual individual or collective life forms, e.g. social simulations or particle swarm optimisation [PSO]

Abstract

The invention discloses a moire fringe signal error compensation method, a system and a storage medium based on an improved particle swarm algorithm.

Description

Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium
Technical Field
The invention belongs to the field of photoelectric signal conversion, and relates to a moire fringe signal error compensation method and system based on an improved particle swarm optimization algorithm and a storage medium.
Background
With the continuous development of photoelectric encoders, the real-time precision requirement of the photoelectric encoder in operation is higher and higher, but in the actual use process, due to the influence of many uncertain factors, the moire fringe signal is a non-ideal sinusoidal signal, and the measurement result has a large error. At present, it is a common method to solve the waveform parameters of the moire signal and then compensate the signal error by using the correlation algorithm. The contradictory relation between the complexity of the waveform parameter solving algorithm and the occupation amount of FPGA resources is a critical problem of the method all the time.
Scholars at home and abroad continuously explore and provide various schemes, but most of the schemes focus on the parameters of the algorithm, the algorithm complexity is increased by extra calculation, the convergence of the quantitative analysis algorithm is also very complicated, the parameters are positioned at the deepest layer of an iterative loop, and a large amount of extra resources are consumed and the calculation time is increased when the calculation is carried out on the parameters on an FPGA.
The inventor finds that the calculation result of the existing grating moire signal sine error compensation method based on the Particle Swarm Optimization (PSO) algorithm is not accurate enough; meanwhile, the fitness function generated by the moire fringe mathematical model is complex, the occupied resources in the operation process are often higher than those of the main algorithm, and the application of the particle swarm algorithm for grating moire signal compensation calculation on the FPGA is not mature. On the other hand, the situation that the optimal solution cannot be obtained due to the fact that the traditional particle swarm optimization algorithm is trapped in a local extreme value easily occurs in the iteration process. The existing optimization scheme generally starts from the inertia weight, the optimized inertia weight can be changed linearly or nonlinearly according to the current extreme value and the iteration number, and the calculation precision can be effectively improved. However, when the optimization method is implemented in an FPGA, a complex logic circuit is additionally added, and the dependency between data is enhanced, so that corresponding loop iteration cannot be executed in parallel, and the parallel operation advantage of the FPGA cannot be fully exerted. Not only increases a large amount of FPGA resource occupation, but also prolongs the calculation time.
Disclosure of Invention
The embodiment of the invention aims to provide a moire fringe signal error compensation method, a moire fringe signal error compensation system and a storage medium based on an improved particle swarm algorithm, and aims to solve the problems that in the existing moire fringe signal error compensation method based on the particle swarm algorithm, a moire fringe mathematical model is inaccurate in calculation result, a fitness function is complex, the method is easy to fall into a local extreme value, an optimal solution cannot be obtained, FPGA (field programmable gate array) resource occupation is increased, and calculation time is prolonged.
The technical scheme adopted by the embodiment of the invention is as follows: the moire fringe signal error compensation method based on the improved particle swarm optimization comprises the following steps:
step S1: based on an error source of a moire fringe signal, establishing a moire fringe signal mathematical model considering amplitudes and phases of fundamental waves, second harmonics and third harmonics, as shown in formulas (1) to (2):
u sin(θ) =A 0 +A 1 sin(θ+a 1 )+A 2 sin(2θ+a 2 )+A 3 sin(3θ+a 3 ); (1)
u cos(θ) =B 0 +B 1 cos(θ+b 1 )+B 2 cos(2θ+b 2 )+B 3 cos(3θ+b 3 ); (2)
wherein u is sin(θ) And u cos(θ) Two signals representing moire fringes, theta representing an angle value, A 0 、B 0 As a direct component, A 1 、B 1 Is the fundamental amplitude, A 2 、A 3 、B 2 、B 3 For each harmonic amplitude, a 1 、b 1 Is the phase of the fundamental wave, a 2 、a 3 、b 2 、b 3 For each harmonic phase;
step S2: based on the actual signal sampling value and the calculated value of the mathematical model of the moire fringe signal, determining a fitness function, as shown in formula (3):
Figure BDA0003924764920000021
wherein, fitness represents a fitness function, u k Sampling data for an actual signal, wherein N is the sampling frequency; f (theta) k α) data calculated by a mathematical model of moire fringe signals, θ k Is and u k Corresponding angle value alpha is a parameter to be solved, and a sine signal u is calculated sin(θ) When alpha is A 0 、A 1 、A 2 、A 3 、a 1 、a 2 、a 3 Calculating the cosine signal u cos(θ) When alpha is B 0 、B 1 、B 2 、B 3 、b 1 、b 2 、b 3
And step S3: establishing and storing a trigonometric function lookup table, and associating the established fitness function with the stored trigonometric function lookup table to obtain a fitness function for calculating the trigonometric function value based on the trigonometric function lookup table;
and step S4: based on an improved particle swarm algorithm, calculating a fitness function of a trigonometric function value by adopting a trigonometric function lookup table, calculating a parameter alpha to be calculated in a moire fringe signal mathematical model and outputting a calculation result;
step S5: and reconstructing the moire fringe signal according to the calculated parameter value to be solved in the moire fringe signal mathematical model, so as to realize error compensation of the moire fringe signal.
Further, the improved particle swarm optimization is realized as follows:
step S41: determining the number of particle swarms, the maximum iteration times and learning factors c1 and c2, initializing the particle swarms, initializing the positions of all the particles in a random number given mode, and endowing each particle with a random initial position;
step S42: calculating and comparing the fitness values of all the particles to obtain a first generation individual optimal value Pbest and a group optimal value Gbest;
step S43: judging whether a termination condition is met, if the maximum iteration times is reached or the adaptability value meets the requirement, ending iteration and outputting a calculation result, otherwise, entering the next step;
step S44: updating the position of each particle according to formula (4) or formula (5):
x id (k+1)=wx id (k)+c 1 r 1 (Pbest-x id (k))+c 2 r 2 (Gbest-x id (k)); (4)
Figure BDA0003924764920000031
wherein x is id (k + 1) represents the position of the ith particle corresponding to the d-th parameter to be solved in the (k + 1) -th iteration, x id (k) Representing the position of the ith particle corresponding to the d-th parameter to be solved in the k-th iteration, wherein w is the inertia weight;
step S45: solving the current corresponding fitness value of each particle position, comparing the fitness value with the current individual optimal position Pbest of each particle, if the fitness value of the current position is better, updating the individual optimal value Pbest, otherwise, keeping the individual optimal value Pbest unchanged; meanwhile, comparing the current global optimum value Gbest of the particle swarm, if the fitness value of the current position is better, updating the global optimum value Gbest, otherwise, keeping the global optimum value Gbest unchanged;
step S46: the process returns to step S43.
Further, when a trigonometric function lookup table is established, the calculation range of the angle value in the trigonometric function lookup table is selected to be [0,90 degrees ], and the change step length of the angle value is controlled to be 0.1 degree;
according to the symmetry of the trigonometric function, when the angle values are in the range of [90 degrees and 360 degrees ], the trigonometric function value of each angle value is obtained according to the trigonometric function value corresponding to the range of [0 and 90 degrees ].
Furthermore, when the moire fringe signal is reconstructed, the harmonic part and the direct current component of the moire fringe signal are removed, and the amplitudes are obtained from the two paths of moire fringe signals u which are solved sin(θ) And u cos(θ) The average value and the phase of the fundamental wave amplitude of the signal are two paths of moire fringe signals u sin(θ) And u cos(θ) The calculated amplitude and phase of the average value of the fundamental wave phase are input into a sine-cosine signal generator, and ideal sine signals and cosine signals, namely compensated moire fringe signals, are output.
Further, the fitness values of all the particles in the particle swarm are obtained through parallel synchronous calculation.
The embodiment of the invention adopts another technical scheme that: moire fringe signal error compensation system based on improve particle swarm algorithm includes:
a memory for storing instructions executable by the processor;
a processor for executing the instructions to implement the moire signal error compensation method based on the improved particle swarm optimization as described above.
Further, the memory includes:
a first memory for storing a trigonometric function lookup table;
a second memory for storing the sampled actual signal data;
the third memory is used for storing the particle swarm positions obtained in the last iteration;
the processor includes:
the population particle initialization module is used for determining the number of particle swarms, the maximum iteration times and the learning factors c1 and c2, initializing the particle swarms and endowing each particle with a random initial position;
a random number generation module for giving two random numbers within (0, 1);
the fitness function calculation module is used for associating a trigonometric function lookup table with an actual signal sampling value, calculating a trigonometric function value in the moire fringe signal mathematical model by a lookup method to obtain a calculated value of the moire fringe signal mathematical model, and calculating the fitness value of the particle swarm by adopting the fitness function based on the actual signal sampling value and the calculated value of the moire fringe signal mathematical model;
the individual optimal value and particle swarm optimal value generating module is used for calculating and comparing the fitness values of all the particles and updating the current individual optimal value and particle swarm optimal value;
a position updating module for updating the position of each particle based on the improved particle swarm algorithm according to the current individual optimal value and the particle swarm optimal value, two given random numbers within (0, 1), and the current position of each particle;
and the termination judgment module is used for judging whether the termination condition of the improved particle swarm algorithm is met, if not, inputting the updated position of each particle into the fitness function calculation module, calculating the fitness value of the updated position of each particle, and continuously and iteratively executing the improved particle swarm algorithm until the termination condition of the improved particle swarm algorithm is met.
Further, the processor further includes:
and the moire fringe signal reconstruction module is used for reconstructing the moire fringe signals according to the individual optimal values and the parameter values calculated by the particle swarm optimal value generation module so as to realize error compensation of the moire fringe signals.
Further, the processor comprises an FPGA, and the FPGA is used for realizing parallel calculation of the fitness value of each particle in the particle swarm;
and the DDS IP verification of the FPGA is adopted to realize the reconstruction of the moire fringe signal.
The embodiment of the invention adopts another technical scheme that: a computer readable medium storing computer program code which, when executed by a processor, implements a moire signal error compensation method based on an improved particle swarm algorithm as described above.
The embodiment of the invention has the beneficial effects that:
1. the mathematical model of the moire fringe signal is perfected, the constructed moire fringe signal model comprehensively contains the amplitude and phase parameters of the second harmonic and the third harmonic which have large influence on the error, and the calculation result is more accurate;
2. the algorithm is accelerated through the FPGA, on one hand, the calculation of a trigonometric function is replaced by a table look-up method, and because the fitness function comprises a large number of sine functions, the algorithm can occupy higher resources and longer time sequence in the FPGA, and the delay time of the algorithm cannot meet the requirement; the resource occupation can be effectively reduced through a table look-up method, and the calculation time is shortened; on the other hand, the characteristic that the FPGA can realize parallel operation is utilized, because the calculation of the fitness value of the particles in the process of one iteration has no data dependency, and the calculation of the speed depends on the data generated by the previous iteration, the calculation speed of the algorithm can be accelerated by increasing the population number and reducing the iteration times;
3. the PSO algorithm is improved, the traditional optimization method focuses on research on parameters w, c1 and c2 of the algorithm, dynamically-changed w, c1 and c2 are introduced, an additionally-added formula enables data dependency among iteration loops to be enhanced, parallel execution difficulty is increased, and complexity and resource occupation of FPGA implementation are increased. The original particle swarm algorithm is simplified to a certain degree, the speed concept is abandoned, the mean value strategy is introduced to replace the inertia weight w of the PSO algorithm for dynamic adjustment, the problem that the PSO algorithm is easy to fall into a local optimal value is effectively solved, and meanwhile, the resource occupation is less.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a moire fringe signal error compensation method based on the MSPSO algorithm according to an embodiment of the present invention.
Fig. 2 is a block diagram of a moire fringe signal error compensation system based on the MSPSO algorithm according to an embodiment of the present invention.
Fig. 3 is a convergence graph of the particle swarm algorithm before and after improvement.
FIG. 4 is a normal distribution diagram of the particle swarm optimization run 10000 times before and after improvement.
Figure 5 is a waveform diagram of a simulated raw moire signal.
Figure 6 is a simulated waveform diagram of a moire signal after introducing an error.
Fig. 7 is a waveform diagram of a moire signal after error compensation.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment provides a moire fringe signal error compensation method based on an improved particle swarm optimization algorithm, as shown in fig. 1, including the following steps:
step S1: establishing a moire fringe signal mathematical model considering the amplitudes and phases of fundamental waves, second harmonics and third harmonics based on the error sources of the moire fringe signals:
firstly, analyzing an error source of a moire fringe signal, wherein the error source mainly comprises a harmonic component, a direct current component, an equal amplitude error, an orthogonality error and a phase error, and the influence of higher harmonics more than three times on the signal is small and can be ignored, so that a moire fringe signal mathematical model can be built, and the equations (1) to (2) show:
u sin(θ) =A 0 +A 1 sin(θ+a 1 )+A 2 sin(2θ+a 2 )+A 3 sin(3θ+a 3 ); (1)
u cos(θ) =B 0 +B 1 cos(θ+b 1 )+B 2 cos(2θ+b 2 )+B 3 cos(3θ+b 3 ); (2)
wherein u is sin(θ) And u cos(θ) Two signals representing moire fringes, theta representing an angle value, A 0 、B 0 As a direct component, A 1 、B 1 Is the fundamental amplitude, A 2 、A 3 、B 2 、B 3 For each harmonic amplitude, a 1 、b 1 Is the phase of the fundamental wave, a 2 、a 3 、b 2 、b 3 For each harmonic phase;
step S2: based on the actual signal sampling value and the calculated value of the moire fringe signal mathematical model, determining a fitness function, specifically, performing difference and square on the actual signal sampling value and the calculated value of the moire fringe signal mathematical model, and finally accumulating to obtain the fitness function, as shown in formula (3):
Figure BDA0003924764920000061
wherein, fitness represents a fitness function, u k Actual signal data sampled at the kth time, wherein N is the sampling time; f (theta) k α) represents and u k The data calculated by the mathematical model of the moire fringe signal, i.e. the data expressed by the equations (1) to (2), theta k For the angle value corresponding to uk, alpha being the parameter to be solved, the sinusoidal signal u is calculated sin(θ) When alpha is A 0 、A 1 、A 2 、A 3 、a 1 、a 2 、a 3 Calculating the cosine signal u cos(θ) When alpha is B 0 、B 1 、B 2 、B 3 、b 1 、b 2 、b 3
And step S3: establishing and storing a trigonometric function (sin function and cos function) lookup table, and associating the established fitness function with the stored trigonometric function lookup table, so that when the operation of the trigonometric functions of the corresponding angles in the formulas (1) to (2) is realized by adopting a lookup table method, the trigonometric function value corresponding to the angle value closest to the calculated angle value is directly called from the stored trigonometric function lookup table, and the fitness function for calculating the trigonometric function value based on the trigonometric function lookup table is obtained;
when a trigonometric function lookup table is established, the calculation range of the angle value in the trigonometric function lookup table is selected to be [0,90 degrees ], and the change step length of the angle value in the lookup table is controlled to be 0.1 degree because the difference value of the trigonometric function corresponding to each 0.1 degree is very small; according to the symmetry of the trigonometric function, the trigonometric function value with the angle value in the range of [90 degrees and 360 degrees ] is obtained according to the corresponding trigonometric function value in the range of [0 and 90 degrees ]. Taking sin signals as an example, adopting a lookup table method to replace direct operation of a sin function in formulas (1) to (2), selecting the calculation range of an angle value in a trigonometric function lookup table to be [0,90 degrees ], and subtracting the calculated angle value by 180 degrees and inputting the subtracted angle value into the lookup table to obtain a corresponding sin value according to the symmetry of a sine function when the calculated angle value belongs to [90 degrees and 180 degrees ]; when the calculated angle value belongs to [180 degrees and 270 degrees ], subtracting the calculated angle value by 180 degrees and inputting the subtracted value into a lookup table, and outputting a result to obtain a negative number to obtain a corresponding sin value; when the calculation angle value belongs to 270 degrees and 360 degrees, the calculation angle value is subtracted from 360 degrees and then input into a lookup table, and the output result is negative, so that the corresponding sin value is obtained. The result of the trigonometric function is calculated in advance and stored in the memory, and the corresponding trigonometric function value is directly called from the memory when the trigonometric function is calculated, so that the calculation amount of the algorithm is effectively reduced, and the operation speed of the algorithm is accelerated.
And step S4: based on an improved particle swarm algorithm, calculating a fitness function of a trigonometric function value by adopting a trigonometric function lookup table, calculating a parameter alpha to be calculated in a moire fringe signal mathematical model and outputting a calculation result;
the improved particle swarm optimization is realized as follows:
step S41: determining the number of particle swarms, the maximum iteration times and learning factors c1 and c2, initializing the particle swarms, initializing the positions of all the particles in a random number given mode, and giving a random initial position to each particle, wherein the embodiment does not need to initialize the speed and the inertia weight;
step S42: calculating and comparing the fitness values of all the particles to obtain a first generation individual optimal value Pbest and a particle swarm optimal value Gbest;
step S43: judging whether a termination condition is met, if the maximum iteration times is reached or the adaptability value meets the requirement, ending the iteration and outputting a calculation result, otherwise, entering the next step;
step S44: update the position of each particle: in this embodiment, a simplified particle swarm algorithm (SPSO) is introduced, and it is found through research that an update term of a speed is not a necessary condition of the algorithm, when we abandon a speed update term of a particle and perform global optimization only under the guidance of a position update term, stability of the algorithm is not greatly affected, and meanwhile, because a concept of abandoning the speed update also avoids artificially setting a speed range, and the influence on convergence and precision is avoided to some extent, and the particle swarm algorithm at this time is the simplest, as shown in formula (4), a particle swarm updates a position of each particle according to formula (4):
x id (k+1)=wx id (k)+c 1 r 1 (Pbest-x id (k))+c 2 r 2 (Gbest-x id (k)); (4)
wherein x is id (k + 1) represents the position of the ith particle corresponding to the d-th parameter to be solved in the (k + 1) -th iteration, x id (k) W is the inertial weight, c is the position of the ith particle corresponding to the d-th parameter to be solved in the k-th iteration 1 、c 2 Represents a learning factor;
step S45: solving the current corresponding fitness value of each particle position, comparing the fitness value with the current individual optimal position Pbest of each particle, if the fitness value of the current position is better, updating the individual optimal value Pbest, otherwise, keeping the individual optimal value Pbest unchanged; meanwhile, comparing with the current global optimum value Gbest of the particle swarm, if the adaptability value of the current position is better, updating the global optimum value Gbest, otherwise, keeping the global optimum value Gbest unchanged;
step S46: return is made to step S43.
In some embodiments, another advantage of eliminating the velocity factor is to avoid the problem that the convergence speed of the particles is slow and the convergence accuracy is low due to the "divergence" phenomenon of the particles caused by velocity update in the late stage of convergence. In the process of solving the extreme value of the function, the peak numbers of different fitness functions are different; when the single peak problem is solved, the SPSO has higher convergence speed and higher convergence precision; however, when the multi-peak problem is solved, the particle updating amplitude is large, the population diversity is poor, the global optimization capability is low, and the local optimal solution is easy to fall into due to the fact that the multi-peak problem is not limited by a speed factor. To solve this problem, the present embodiment further introduces a mean search strategy, and guides position update by using linear combination of the individual optimal solution of the particles and the global optimal solution of the particle swarm, so as to obtain a mean simplified particle swarm algorithm (MSPSO), as shown in formula (5):
Figure BDA0003924764920000081
the position of the particle is iteratively updated according to the formula (5), so that the multi-peak problem of the function can be effectively solved.
The embodiment provides the improved MSPSO algorithm aiming at the optimization of the FPGA and the application in the compensation calculation of the moire signal, the algorithm abandons an inertia weight factor w, and balances the global optimization and local optimization capacities of the algorithm by using a mean strategy instead of a mode of adjusting w, thereby simplifying the operation of the algorithm. Compared with the traditional PSO optimization method, the MSPSO algorithm is simplified and optimized to a certain extent on the basis of the original algorithm, the algorithm complexity is relatively low, and the MSPSO algorithm is more suitable for running on a hardware platform. On the premise of ensuring the accuracy of the result, the population is increased, the iteration times are reduced, the hardware resources are effectively reduced, the working clock is reduced, and the working efficiency is improved.
Step S5: according to the calculated parameter value (including the fundamental wave amplitude A of two signals of moire fringe) 1 、B 1 And a fundamental wave phase a 1 、b 1 ) And reconstructing the moire fringe signal so as to realize error compensation of the moire fringe signal.
In some embodiments, when reconstructing the moire fringe signal, the specific reconstruction method is to eliminate the harmonic part and the direct current component of the moire fringe signal, and the two moire fringe signals u with the amplitudes solved are both taken sin(θ) And u cos(θ) The average value and the phase of the fundamental wave amplitude of the signal are two paths of moire fringe signals u sin(θ) And u cos(θ) The calculated amplitude and phase of the average value of the fundamental wave phase are input into a sine and cosine signal generator, and the sine and cosine signal generator of the embodiment outputs two paths of ideal sine signals and cosine signals, namely compensated moire fringe signals, by adopting a DDS IP core of an FPGA.
In order to verify the effectiveness of the fitness function calculated by the table lookup method, the fitness function is written by a method for directly calculating a trigonometric function and the table lookup method under a Vivado HLS environment, wherein 128 sampling points are selected in each period, the resource occupation conditions of the two methods in the comprehensive result are shown in table 1, and the clock period conditions required by the two methods for calculating the fitness function are shown in table 2.
TABLE 1 comparison of resource occupation of fitness function calculated by two methods
Figure BDA0003924764920000091
The DSP48E is an important resource on the FPGA, is precious and limited, can realize functions of addition, subtraction, accumulation, multiplication, shift and the like, has strong logical operation capacity, can be used as a controllable register, comprises independent clock enabling and resetting and has extremely high flexibility. The direct calculation of the trigonometric function has great consumption on the resource, and as can be seen from table 1, the occupation of the DSP48E is obviously reduced after the table lookup method is changed into the table lookup method, and the occupation of other resources is also reduced, so that the validity of the table lookup method is verified.
TABLE 2 comparison of clock cycles required for two methods to calculate fitness function
Required clock period Direct calculation Table lookup method
Single dot operation clock cycle 57 26
Total operation clock period 709 339
By comparing the clock cycles required by the two methods for calculating the fitness function, the clock cycles used by the table look-up method are obviously fewer, the advantages in the whole calculation process are more obvious, and the time delay can be effectively reduced.
In order to further verify the effectiveness of the MSPSO algorithm of the embodiment, the PSO algorithm and the MSPSO algorithm are separately written on matlab, wherein the iteration times are 300 times, the example population number is 30, then a simulated moire fringe signal is used as an input to perform a test, and the convergence curves of the two algorithms are recorded as shown in fig. 3, so that it can be observed that the improved MSPSO algorithm has a faster convergence speed and a better convergence effect no matter in the early stage or the later stage of the iteration, and a normal distribution graph of the iteration times before and after optimization is obtained after 10000 times of simulation respectively to avoid the contingency of the experiment, as shown in fig. 4. It can be obviously seen that the iteration times of the PSO algorithm before optimization are concentrated between 120 times and 180 times, while the iteration times of the optimized MSPSO algorithm are concentrated between 70 times and 90 times, and the optimization effect is obvious.
Example 2
The embodiment provides a moire fringe signal error compensation system based on an improved particle swarm optimization, which includes: a memory for storing instructions executable by the processor; and a processor for executing the instructions to implement the moire signal error compensation method based on the improved particle swarm optimization as described in embodiment 1 above.
The moire fringe signal error compensation system based on the improved particle swarm optimization algorithm can comprise an internal communication bus, a Processor (Processor), a Read Only Memory (ROM), a Random Access Memory (RAM), a communication port and a hard disk. The internal communication bus can realize data communication among the components of the moire fringe signal error compensation system based on the improved particle swarm optimization. The processor may make the determination and issue a prompt. In some embodiments, a processor may be comprised of one or more processors. The communication port can realize data communication outside the moire fringe signal error compensation system based on the improved particle swarm optimization. In some embodiments, the moire signal error compensation system based on the improved particle swarm algorithm may also transmit and receive information and data from the network through the communication port. The moire signal error compensation system based on the modified particle swarm algorithm may further comprise different forms of program storage units as well as data storage units, such as a hard disk, a Read Only Memory (ROM) and a Random Access Memory (RAM), capable of storing various data files used for computer processing and/or communication, as well as possible program instructions executed by a processor. The processor executes these instructions to implement the main parts of the method. The result processed by the processor is transmitted to the device of the testee through the communication port and displayed on the interface of the testee.
Specifically, as shown in fig. 2, the memory of the moire fringe signal error compensation system based on the improved particle swarm optimization comprises:
a first memory (RAM 1) for storing a trigonometric function lookup table;
a second memory (RAM 2) for storing the sampled actual signal data;
and a third memory (RAM 3) for storing the particle group position obtained in the last iteration.
The processor includes:
the population particle initialization module is used for determining the number of particle swarms, the maximum iteration times and the learning factors c1 and c2, initializing the particle swarms and endowing each particle with a random initial position;
a random number generation module for giving two random numbers within (0, 1);
the fitness function calculation module is used for associating a trigonometric function lookup table with the actual signal sampling value, calculating a trigonometric function value in the moire fringe signal mathematical model through a lookup method to obtain a calculated value of the moire fringe signal mathematical model, and calculating the fitness value of the particle swarm by adopting a fitness function based on the actual signal sampling value and the calculated value of the moire fringe signal mathematical model;
the individual optimal value and particle swarm optimal value generation module is used for calculating and comparing the fitness values of all the particles and updating the current individual optimal value and the particle swarm optimal value;
a position updating module for updating the position of each particle based on the improved particle swarm algorithm according to the current individual optimal value and the particle swarm optimal value, two given random numbers within (0, 1), and the current position of each particle;
the termination judgment module is used for judging whether the termination condition of the improved particle swarm algorithm is met, if the termination condition of the improved particle swarm algorithm is not met, the updated position of each particle is input into the fitness function calculation module, the fitness value of the updated position of each particle is calculated, and the improved particle swarm algorithm is continuously executed in an iterative mode until the termination condition of the improved particle swarm algorithm is met;
and the moire fringe signal reconstruction module is used for reconstructing the moire fringe signals according to the individual optimal values and the parameter values calculated by the particle swarm optimal value generation module, so that error compensation of the moire fringe signals is realized, and when parallel calculation of the adaptability value of each particle in the particle swarm is realized through the FPGA, the moire fringe signals can be reconstructed by adopting a DDS IP (digital display data) core of the FPGA.
In FIG. 2, P 1 And P k Compared with the traditional method, the method has the advantages that an inertia weight updating module, a learning factor updating module and a speed updating module are reduced, and a loop structure is simpler. The input end of the fitness function calculating module is additionally provided with a register for storing a trigonometric function lookup table, so that the calculation complexity of the fitness function is greatly reducedAnd hardware resource consumption, and the calculation delay is reduced. The iterative mode of analyzing the particle swarm algorithm can find that the previous generation of data is needed for the calculation of each generation, so that the data between the iterative loops of each generation generate dependency, and the loops cannot be completely executed in parallel by using an FPGA. The calculation of the fitness value of each particle is independent, parallel execution can be realized through the FPGA, and the embodiment adopts a scheme of parallel operation to calculate the fitness value of the particle swarm, so that the particle number of the particle swarm is increased on the premise of ensuring the accuracy of a result, the iteration times are reduced, hardware resources are effectively reduced, the working clock is reduced, and the working efficiency is improved.
The moire fringe signal error compensation method based on the improved particle swarm optimization described in embodiment 1 can be implemented as a computer program, stored in a hard disk, and recorded in a processor for execution. Therefore, an embodiment of the present invention also provides a computer readable medium storing computer program code, which when executed by a processor implements the moire signal error compensation method based on the improved particle swarm optimization algorithm as described above.
The moire fringe signal error compensation method based on the improved particle swarm optimization algorithm can be stored in a computer readable storage medium as a product when being implemented as a computer program. For example, computer-readable storage media can include but are not limited to magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips), optical disks (e.g., compact Disk (CD), digital Versatile Disk (DVD)), smart cards, and flash memory devices (e.g., electrically Erasable Programmable Read Only Memory (EPROM), card, stick, key drive). In addition, various storage media described herein as embodiments of the invention can represent one or more devices and/or other machine-readable media for storing information. The term "machine-readable medium" can include, without being limited to, wireless channels and various other media (and/or storage media) capable of storing, containing, and/or carrying code and/or instructions and/or data.
Example 3
The specific implementation steps of the moire signal error compensation method based on the MSPSO algorithm are described by taking a group of simulated moire fringe signals as an example.
Firstly, two paths of ideal sine and cosine signals are generated through matlab and serve as original moire fringe signals, as shown in fig. 5, the original moire fringe signals are superposed with error factors including third harmonic, phase deviation, direct current components and unequal amplitudes to form new signals, as shown in fig. 6, the signals are sampled, optimized, solved and the like based on the improved particle swarm algorithm-based moire fringe signal error compensation method provided in embodiment 1, and the original signals are finally restored, wherein the specific implementation scheme comprises the following steps:
step 1: taking the square sum of the difference between the sampling values of 128 sampling points of the sinusoidal signal and a corresponding mathematical model, namely a formula (3), as a fitness value, taking the value of a parameter alpha to be solved in the formula (3) as the position of a particle, initializing the position of a particle swarm, setting the number of the particle swarm to be 20, and setting the maximum iteration number to be 200 times;
and 2, step: establishing a trigonometric function lookup table, setting the range of an angle value in the trigonometric function lookup table to be [0,90 degrees ], setting the step length to be 0.1 degree, calculating 900 values of a sin function and a cos function by utilizing matlab, generating a mif file, instantiating an RAM by Vivado, and importing the mif file into the RAM to obtain the lookup table of the sin function and the cos function;
and step 3: inputting the positions of the particle swarms and the actual sampling values into a fitness function calculation module, and calculating by a table look-up method to obtain a fitness value;
and 4, step 4: inputting the fitness value and the particle swarm position into an individual extreme value Pbest and a group extreme value Gbest generation module, comparing the fitness value and the particle swarm position with the current individual optimal position Pbest, updating the individual optimal position Pbest if the fitness value of the current position is better, otherwise keeping the individual optimal position Pbest unchanged; meanwhile, comparing the current best position Gbest of the population particles with the current best position Gbest, if the fitness value of the current position is better, updating the best position Gbest, otherwise, keeping the best position Gbest unchanged;
and 5: individual extreme Pbest, group extreme Gbest and current particle swarm position P k Input to the location update module while using a random numberThe generation module generates two [0,1 ]]The random number is input into a position updating module, the position of each particle is updated according to a formula (4) or a formula (5), and the result is stored in a RAM memory and used for calculating the fitness value in the next iteration;
and 6: inputting the group extreme value Gbest and the current iteration times into a termination judging module, comparing the group extreme value Gbest with a preset ideal adaptability value, terminating iteration when the group extreme value Gbest reaches the ideal adaptability value or the iteration times reaches the maximum times, and otherwise, continuing to execute the iteration;
and 7: according to the final output parameter result, a compensated signal is obtained through restoration, specifically, the parameter is input into a signal compensation module, the reconstruction mode of the signal compensation module is to omit a harmonic part and a direct current component, the amplitude value is an average value of amplitudes of two paths of signal fundamental waves, the phase position is an average value of phases of two paths of signal fundamental waves, the calculated amplitude phase position is input into a DDS IP core of an FPGA to output two paths of ideal sine and cosine signals, namely the compensated Moire fringe signal, the result is shown in FIG. 7, the compensated signal is basically consistent with the original signal, and the fact that the influence of a plurality of error factors on the Moire fringe signal can be effectively compensated through the scheme is verified.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. The moire fringe signal error compensation method based on the improved particle swarm optimization is characterized by comprising the following steps of:
step S1: based on an error source of a moire fringe signal, establishing a moire fringe signal mathematical model considering amplitudes and phases of fundamental waves, second harmonics and third harmonics, as shown in formulas (1) to (2):
u sin(θ) =A 0 +A 1 sin(θ+a 1 )+A 2 sin(2θ+a 2 )+A 3 sin(3θ+a 3 ); (1)
u cos(θ) =B 0 +B 1 cos(θ+b 1 )+B 2 cos(2θ+b 2 )+B 3 cos(3θ+b 3 ); (2)
wherein u is sin(θ) And u cos(θ) Two signals representing moire fringes, theta representing the angle value, A 0 、B 0 As a direct component, A 1 、B 1 Is the fundamental amplitude, A 2 、A 3 、B 2 、B 3 For each harmonic amplitude, a 1 、b 1 Is the phase of the fundamental wave, a 2 、a 3 、b 2 、b 3 For each harmonic phase;
step S2: based on the actual signal sampling value and the calculated value of the mathematical model of the moire fringe signal, determining a fitness function, as shown in formula (3):
Figure FDA0003924764910000011
wherein, fitness represents a fitness function, u k Sampling data for actual signals, wherein N is the sampling frequency; f (theta) k α) data calculated by a mathematical model of moire fringe signals, θ k Is a and u k Corresponding angle value alpha is a parameter to be solved, and a sine signal u is calculated sin(θ) When alpha is A 0 、A 1 、A 2 、A 3 、a 1 、a 2 、a 3 Calculating the cosine signal u cos(θ) When alpha is B 0 、B 1 、B 2 、B 3 、b 1 、b 2 、b 3
And step S3: establishing and storing a trigonometric function lookup table, and associating the established fitness function with the stored trigonometric function lookup table to obtain the fitness function for calculating the trigonometric function value based on the trigonometric function lookup table;
and step S4: based on an improved particle swarm algorithm, calculating a fitness function of a trigonometric function value by adopting a trigonometric function lookup table, calculating a parameter alpha to be calculated in a moire fringe signal mathematical model and outputting a calculation result;
step S5: and reconstructing the moire fringe signal according to the calculated parameter value to be solved in the moire fringe signal mathematical model, so as to realize error compensation of the moire fringe signal.
2. The moire fringe signal error compensation method based on the improved particle swarm optimization algorithm as claimed in claim 1, wherein the improved particle swarm optimization algorithm is realized by the following steps:
step S41: determining the number of particle swarms, the maximum iteration times and learning factors c1 and c2, initializing the particle swarms, initializing the positions of all the particles in a random number given mode, and endowing each particle with a random initial position;
step S42: calculating and comparing the fitness values of all the particles to obtain a first generation individual optimal value Pbest and a group optimal value Gbest;
step S43: judging whether a termination condition is met, if the maximum iteration times is reached or the adaptability value meets the requirement, ending iteration and outputting a calculation result, otherwise, entering the next step;
step S44: updating the position of each particle according to formula (4) or formula (5):
x id (k+1)=wx id (k)+c 1 r 1 (Pbest-x id (k))+c 2 r 2 (Gbest-x id (k)); (4)
Figure FDA0003924764910000021
wherein x is id (k + 1) represents the position of the ith particle corresponding to the d-th parameter to be solved in the (k + 1) -th iteration, x id (k) Representing the position of the ith particle corresponding to the d-th parameter to be solved in the k-th iteration, wherein w is the inertia weight;
step S45: solving the current corresponding fitness value of each particle position, comparing the fitness value with the current individual optimal position Pbest of each particle, if the fitness value of the current position is better, updating the individual optimal value Pbest, otherwise, keeping the individual optimal value Pbest unchanged; meanwhile, comparing with the current global optimum value Gbest of the particle swarm, if the adaptability value of the current position is better, updating the global optimum value Gbest, otherwise, keeping the global optimum value Gbest unchanged;
step S46: the process returns to step S43.
3. The improved particle swarm algorithm-based moire fringe signal error compensation method as claimed in claim 1, wherein when the trigonometric function lookup table is established, the calculation range of the angle value in the trigonometric function lookup table is selected to be [0,90 ° ], and the variation step size of the angle value is controlled to be 0.1 °;
according to the symmetry of the trigonometric function, when the angle values are in the range of [90 degrees and 360 degrees ], the trigonometric function value of each angle value is obtained according to the trigonometric function value corresponding to the range of [0 and 90 degrees ].
4. The improved particle swarm optimization-based moire fringe signal error compensation method as claimed in claim 1, wherein when reconstructing the moire fringe signal, the harmonic part and the direct current component of the moire fringe signal are removed, and the amplitudes are obtained by solving two paths of moire fringe signals u sin(θ) And u cos(θ) The average value and the phase of the fundamental wave amplitude of the signal u are two paths of moire fringe signals sin(θ) And u cos(θ) The calculated amplitude and phase of the average value of the fundamental wave phase are input into a sine-cosine signal generator, and ideal sine signals and cosine signals, namely compensated moire fringe signals, are output.
5. The improved particle swarm algorithm-based moire fringe signal error compensation method as claimed in claim 1, wherein the fitness values of all the particles in the particle swarm are obtained by parallel synchronous computation.
6. Moire fringe signal error compensation system based on improve particle swarm algorithm, its characterized in that includes:
a memory for storing instructions executable by the processor;
a processor for executing the instructions to implement the method of any one of claims 1 to 5.
7. The system of claim 6, wherein the memory comprises:
a first memory for storing a trigonometric function lookup table;
a second memory for storing the sampled actual signal data;
the third memory is used for storing the particle swarm positions obtained in the last iteration;
the processor includes:
the population particle initialization module is used for determining the number of particle swarms, the maximum iteration times and the learning factors c1 and c2, initializing the particle swarms and endowing each particle with a random initial position;
a random number generation module for giving two random numbers within (0, 1);
the fitness function calculation module is used for associating a trigonometric function lookup table with an actual signal sampling value, calculating a trigonometric function value in the moire fringe signal mathematical model by a lookup method to obtain a calculated value of the moire fringe signal mathematical model, and calculating the fitness value of the particle swarm by adopting the fitness function based on the actual signal sampling value and the calculated value of the moire fringe signal mathematical model;
the individual optimal value and particle swarm optimal value generation module is used for calculating and comparing the fitness values of all the particles and updating the current individual optimal value and the particle swarm optimal value;
a position updating module for updating the position of each particle based on the improved particle swarm algorithm according to the current individual optimal value and the particle swarm optimal value, two given random numbers within (0, 1), and the current position of each particle;
and the termination judgment module is used for judging whether the termination condition of the improved particle swarm algorithm is met, if not, inputting the updated position of each particle into the fitness function calculation module, calculating the fitness value of the updated position of each particle, and continuously and iteratively executing the improved particle swarm algorithm until the termination condition of the improved particle swarm algorithm is met.
8. The system of claim 7, wherein the processor further comprises:
and the moire fringe signal reconstruction module is used for reconstructing the moire fringe signals according to the individual optimal values and the parameter values calculated by the particle swarm optimal value generation module so as to realize error compensation of the moire fringe signals.
9. The moire fringe signal error compensation system based on the improved particle swarm optimization algorithm as claimed in claim 7 or 8, wherein the processor comprises an FPGA, through which the parallel calculation of the fitness value of each particle in the particle swarm is realized;
and the DDS IP verification of the FPGA is adopted to realize the reconstruction of the moire fringe signal.
10. A computer-readable medium, characterized in that a computer program code is stored, which, when being executed by a processor, realizes the method according to any one of claims 1 to 4.
CN202211368663.XA 2022-11-03 2022-11-03 Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium Pending CN115618176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211368663.XA CN115618176A (en) 2022-11-03 2022-11-03 Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211368663.XA CN115618176A (en) 2022-11-03 2022-11-03 Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium

Publications (1)

Publication Number Publication Date
CN115618176A true CN115618176A (en) 2023-01-17

Family

ID=84877158

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211368663.XA Pending CN115618176A (en) 2022-11-03 2022-11-03 Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium

Country Status (1)

Country Link
CN (1) CN115618176A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117353455A (en) * 2023-10-17 2024-01-05 济南泉晓电气设备有限公司 Power transmission and transformation system supervision method based on artificial intelligence

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117353455A (en) * 2023-10-17 2024-01-05 济南泉晓电气设备有限公司 Power transmission and transformation system supervision method based on artificial intelligence
CN117353455B (en) * 2023-10-17 2024-03-29 济南泉晓电气设备有限公司 Power transmission and transformation system supervision method based on artificial intelligence

Similar Documents

Publication Publication Date Title
Partzsch et al. A fixed point exponential function accelerator for a neuromorphic many-core system
CN110008440A (en) A kind of convolution algorithm and its application based on analog matrix arithmetic element
CN102831895A (en) Method for achieving MFCC (Mel Frequency Cepstrum Coefficient) parameter extraction by field-programmable gate array
CN115618176A (en) Moire fringe signal error compensation method and system based on improved particle swarm optimization and storage medium
Miao et al. A new parallel implementation for particle filters and its application to adaptive waveform design
CN106528357A (en) FPGA system and implementation method based on on-line training neural network of quasi-newton method
WO2018027706A1 (en) Fft processor and algorithm
Zhang et al. A simple extended compact nonlinear scheme with adaptive dissipation control
Zhang et al. Base-2 softmax function: Suitability for training and efficient hardware implementation
CN106646403A (en) K distributed radar clutter real-time simulation method and system
CN103176949B (en) Realize circuit and the method for FFT/IFFT conversion
CN102129419B (en) Based on the processor of fast fourier transform
CN101286185A (en) Numerical frequency synthesis circuit compiler accomplishing method based on linear interpolation structure
CN113779861B (en) Photovoltaic Power Prediction Method and Terminal Equipment
Abdelhamid et al. Applying the residue number system to network inference
Xu et al. Fpga implementation of a best-precision fixed-point digital pid controller
Wang et al. Can emerging computing paradigms help enhancing reliability towards the end of technology roadmap?
CN110781604A (en) Interference pattern phase extraction PSM-IP core design method and system for improving CORDIC algorithm
Korwar et al. GPU-enabled efficient executions of radiation calculations in climate modeling
Faghih-Naini et al. p-adaptive discontinuous Galerkin method for the shallow water equations on heterogeneous computing architectures
CN109687870A (en) The SARADC capacitance mismatch bearing calibration of charge redistribution type and system
CN108519609B (en) General architecture method of navigation signal simulation source based on GPU
CN108595148A (en) Division function implementation method, circuit, chip and system
CN116735957B (en) Near-frequency harmonic wave and inter-harmonic wave measuring method and system considering main lobe overlapping interference
CN112578431B (en) Method and system for storing full waveform inversion wave field optimization in finite state

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination