Compression Ratio Control of an Opposed-Piston Free-Piston Engine Generator Based on Artificial Neural Networks

Opposed-piston free-piston engine generator (FPEG), as an energy conversion device, has attracted the attention of researchers with its advantages of variable compression ratio (CR) and good dynamic balance performance. At the same time, the variable compression ratio poses a challenge to the stable operation of the engine. The controller needs to overcome the interference caused by the combustion variations to the piston movement, so that the compression ratio of the engine remains stable. This paper proposes an opposed-piston synchronous motion control strategy based on master-slave position following and a compression ratio control strategy based on artificial neural networks. A test prototype and simulation model were established, and the model was verified by the prototype. The performance of the control strategy was studied through simulation analysis. The results showed that the engine achieved stable operation and the compression ratio was well controlled. Compared with the reported control strategies in the literature, the artificial neural network algorithm applied in free-piston engine generator system shows better control accuracy and good response characteristics.


I. INTRODUCTION
Free-Piston Engine Generator (FPEG) is an energy conversion device with simple structure and high thermal efficiency, which can be used as range extender for electric vehicles or portable power generation device [1]. Compared to traditional internal combustion engines, FPEG eliminates the crank-link mechanism, and the free-piston is directly connected to the linear electric machine (LEM) [2]. When the engine is operating, the high-frequency reciprocating motion of the free-piston assembly converts the chemical energy of the fuel into electrical energy. The special structure makes it have the advantages of variable compression ratio, variable fuel and high thermal efficiency [3]. But the adverse effect of combustion pressure variations on the free-piston movement also poses greater challenges to the control strategy. In recent decades, with the advancement of computer technology and the development of artificial intelligence, the accuracy and response speed of electronic control have The associate editor coordinating the review of this manuscript and approving it for publication was Md. Rabiul Islam . been improving. More and more research institutions have noticed FPEG [4], [5]. According to a review article by Newcastle University [6], many well-known vehicle companies such as Volvo, Ford and Honda are interested in this novel engine technology and have conducted some degree of theoretical research.
Sandia National Laboratory has designed an opposedpiston FPEG [7]. The prototype is mainly composed of a central combustion chamber, two LEMs and two air springs, and operates in one-way scavenging two-stroke mode. The non-combustion test results showed that the synchronous movement of the opposed-piston achieved without active control, and the magnetic resistance of the LEM reduced the relative position error of the pistons passively. However, the power generation was reduced in the elimination process of the synchronous motion error, and passive synchronization had no good effect, which makes the engine unable to run stably for a long time. The German Aerospace Center has carried out similar research work [8], [9].
In recent years, Toyota Research Institute has designed a single-cylinder two-stroke FPEG [10], and has carried out VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ research on piston motion control strategies based on the prototype. The research group proposed a control strategy based on trajectory following [11]. The target motion trajectory was set according to the simulation results, and the target power generation load coefficient was calculated based on the piston position and speed signals to adjust the power generation current to achieve stable operation of the piston. Subsequently, the team proposed a resonant pendulum control strategy to adjust the dead center position by controlling the piston speed [12]. In order not to reduce the efficiency of the LEM, the control strategy is only effective in the middle stroke area where the piston speed is higher. In the remaining strokes, the current is zero and the piston moves freely following the principle of simple resonance. The control algorithm calculates the target speed of the next cycle based on the feedback of the dead center position of each cycle. The test results showed that the control strategy had a good control effect.
The research group of Nanjing University of Science and Technology has conducted a large number of prototype tests on FPEG [13]- [16]. The prototype can achieve continuous and stable operation. Different from the trajectory following control strategy mentioned above, the research group proposed a piston reciprocation control strategy based on dead center control [17]. The motion control during the stable operation of the engine was embodied in the accurate control of the piston dead center position. A control strategy based on iterative learning was applied to the end of the compression stroke, and a control strategy based on in-cylinder pressure to estimate combustion energy was applied to the end of the expansion stroke. The controller adjusts the power generation current of the LEM online according to the control strategy, which can realize the stable control of the piston dead center position. In the prototype test research, the piston motion was well controlled [18].
Compared with references, the control strategy based on artificial neural networks proposed in this paper has good anti-interference and adaptive capabilities. In previous researches, the control strategy was given fixed parameters through offline testing, and FPEG can only run with a specific trajectory or stroke length. When environmental factors such as temperature and pressure change, the engine CR will be disturbed. The neural network algorithm can update the weight matrices online, so that the engine can still run stably in a complex and changeable environment. At the same time, the target CR can be changed reasonably according to different working conditions, so that the feature of ''variable CR'' can be applied to reality.
In this paper, an opposing-piston FPEG prototype has been designed, and the simulation model has been established. The synchronous motion control strategy of opposed-piston and the compression ratio (CR) control strategy based on artificial neural networks are proposed. Through simulation research, the reciprocating motion of free-piston has been deeply researched.

II. SYSTEM STRUCTURE AND WORKING PRINCIPLE
A. STRUCTURE AND COMPONENTS Fig.1 shows the overall structure of the prototype studied in this paper. The prototype is mainly composed of a central combustion chamber, two single-phase LEMs, two air spring chambers, and opposed-piston moving components. One end of the rod was connected to the piston, and the other end was a mover of the LEM. The control system consists of power converter, super capacitor and DSP (Digital Signal Processor) controller. When the engine is running, the piston mover assembly converts the chemical energy of the fuel into electrical energy through reciprocating motion. Fig.2 shows an elementary structure of the combustion system. The central combustion chamber consists of a tubular combustion chamber and opposed-pistons on both sides. There are two intake ports on the left side of the combustion chamber and two exhaust ports on the right side. The intake pressure is boosted to 1.3 bar by external booster. When both the intake port and the exhaust port are open, the high-pressure intake gas enters the combustion chamber, and at the same time, the residual exhaust gas in the cylinder is squeezed out from the exhaust port to complete the one-way  scavenging process. The combustion system operates in twostroke, direct-injection, gasoline, spark plug ignition modes. The structural parameters of the combustion system are listed in Table 1. FPEG uses a plate moving-magnet linear generator as energy conversion devices. As shown in Fig.3, the structure is mainly composed of stators and coils on both sides and plate-shaped permanent magnets in the middle. When the LEM is running, the permanent magnets and metal skeleton located in the middle can move in parallel under the driving of electromagnetic force. The generator has the advantages of small mover mass and small cogging force, which is beneficial to control when applied to FPEG [19], [20]. The main parameters of LEM are shown in Table 2, where EMF is the electromotive force.

B. TWO-STROKE WORKING CYCLE
As shown in Fig.4, a standard two-stroke working cycle is divided into compression stroke and expansion stroke, and the LEM operates as a generator during stable running process. During the compression stroke, the air spring releases the elastic potential energy, pushes the free piston from outer turning center (OTC) to inner turning center (ITC), and converts the excess energy into electrical energy. When the intake and exhaust ports are closed, the injector injects fuel into the cylinder to form a combustible mixture. When the free-piston moves to the ignition position, the spark plug ignites the  mixture, and then the high-pressure gas in the cylinder pushes the free piston into the expansion stroke and moves from ITC to OTC, converting thermal energy into electrical energy. When the free-piston reciprocates between ITC and OTC at high frequency, FPEG converts the internal energy of the fuel into electrical energy.
Because the linear generator has a higher speed in the middle stroke area, the power generation efficiency in this area is higher [12]. The use of sinusoidal current curve can make the generator have more power in the middle stroke area, so it is conducive to improving the efficiency of FPEG.

III. CONTROLLER DESIGN
The FPEG system controller must have certain accuracy and timeliness. The controller must be able to accurately control the current and operating mode of LEM online, so that the free piston can reciprocate at high frequency. It is also necessary to overcome the cyclic combustion variations to stabilize the value of CR, otherwise the mixture in the cylinder cannot burn and the engine cannot run stably. VOLUME 8, 2020

A. SYSTEM CONTROLLER STRUCTURE DESIGN
The FPEG system controller consists of a master controller and a slave controller. As shown in Fig.5, the master controller controls the motion of the right generator, which is mainly composed of CR observer, CR controller and current controller module. The CR observer observes the ITC position from the piston trajectory, and calculates the CR value of each cycle based on the exhaust port closed position and the ITC position. Then the CR controller calculates the target current of the generator according to the CR values of the previous cycles.
As shown in Fig.6, the slave controller controls the motion of the left generator, which is mainly composed of position following controller and current controller module. The slave controller takes the position of the master generator as the target position, compares it with the actual position of the slave generator, and calculates the target compensation current based on the position following controller to achieve the synchronous movement of the opposed-piston. Among them, the master-slave position following control strategy was designed based on PID control law. Fig.7 shows the structure of CR control strategy based on artificial neural networks. There are 2 neurons in the input layer, 12 neurons in the hidden layer, and 1 neuron in the output layer. As shown in Fig.7, the algorithm takes the OTC position and the ITC target position as input, and passes the neurons to obtain the output value of the generated current in the compression stroke. The neural network algorithm has the ability to train weights and memory weights online. Each time the controller runs, the ITC position error is used as a feedback amount, and the weights between neurons are updated to improve the control accuracy. This process is called the training process. When the weight training is completed, it is stored and the weight is directly called when adjacent input values appear, which can achieve higher control accuracy. Fig.8 shows the flowchart of the neural network algorithm, and the calculation process is described as follows:

B. THE CR CONTROL STRATEGY BASED ON ARTIFICIAL NEURAL NETWORKS
a. Map the input and output values between (−1, 1) for standardization. b. Generate initial weight matrices with random numbers, as shown in Equation 1.
where W ij represents the weight matrix between the input layer and hidden layer neurons, and W jo represents the weight matrix between the hidden layer and the output layer neurons. c. Forward propagation process. First, calculate the hidden layer neuron input value, as shown in Equation 2; then calculate the hidden layer output value according to the excitation function, as shown in Equation 3; finally calculate the output value, as shown in Equation 4.
where X i is the value of each neuron in the input layer, X j is the input value of each neuron in the hidden layer, X j is the output value of each neuron in the hidden layer, and Y is the value of neuron in the output layer. d. Back propagation process. The weight matrices is updated according to the ITC control error and error performance index. Equations 7 to 10 represent the update process of the weight matrices.
where β is the learning rate, and α is the momentum factor, which can avoid oscillation during the weight update process.    When FPEG is in the stable operation phase, the LEM works as a generator. As shown in Fig.10, during the power generation process of compression stroke, K1, K2 and K4 are turned off, and K3 is controlled by the PWM signal generated by the controller. When K3 is turned off, the current flow path is indicated by a green line in the figure to realize the charging process of the battery. When K3 is turned on, the current flow path is indicated by a red line in the figure, and a boost circuit is formed between K1 and K3. Because the moving direction of the mover in the compression stroke is opposite to that in the expansion stroke, the flow direction of the generated current is opposite to the Fig.10. K2, K3 and K4 are turned off, and the charging process and boost process are realized by controlling the state of K1.

IV. SYSTEM MODELING A. DYNAMIC MODEL OF THE FREE-PISTON MOVEMENT
When the engine is working, the free-piston achieves dynamic balance under the combined effects of in-cylinder pressure, air spring force, electromagnetic force and friction force, and the piston can reciprocate at high frequency. It is stipulated that the direction of motion from ITC to OTC is positive. When the free piston moves in the positive direction, according to Newton's second law, the dynamic equation of the mover assembly is expressed as: where M is the mass of the mover assembly, x is the piston position, t is the time variable, F c is the force of the in-cylinder pressure on the piston, F mag is the electromagnetic force of the linear generator, F s is the force of the pressure in the air spring chamber on the piston, and F f represents the friction of the motion system.

B. THERMODYNAMIC MODEL
The thermodynamic model of the combustion chamber includes the process of exothermic combustion of the mixed gas in the cylinder and the process of gas expansion in the cylinder. In the experiment, this is a very complicated physicochemical phenomenon. In order to facilitate simulation modeling, the actual heat transfer process is simplified.
The following is the specific modeling process. It is assumed that the combustion heat release rate of the gas in the cylinder during the combustion process conforms to the Weber semi-empirical formula [11]. As shown in Equation 12.
where Q is the cyclic combustion heat release, 6.908 is the Weber constant, H u represents the low calorific value of the fuel, g f is the cyclic fuel supplied, n u is the combustion efficiency, η represents the combustion quality factor, T represents the combustion duration, and t c represents the start time of combustion. It is assumed that the working medium in the cylinder is a uniform gas, so the pressure and temperature in the cylinder conform to the ideal gas state equation (Equation 13). The in-cylinder temperature change rate derived from Equation 13 is shown in Equation 14.
where P c is the instantaneous in-cylinder pressure, V c is the instantaneous in-cylinder volume, n is amount of substance of in-cylinder gas, R is the ideal gas constant, and T c is the instantaneous in-cylinder temperature. The change rate of the internal energy of the in-cylinder gas can be described as: where U is the internal energy of the in-cylinder gas, and C v is the constant volume molar specific heat. The external work performed by the high-pressure gas in the cylinder can be described as: where W is the work done by the gas in the cylinder.
For an enclosed space, ignoring the ventilation loss in the combustion chamber during the combustion process, according to the first law of thermodynamics, there is Equation 17: From Equations 14, 15, 16 and 17, Equation 18 can be obtained.
According to the ideal gas relationship, Equation 19 can be obtained, where γ is the adiabatic index.
The instantaneous volume of the combustion chamber can be described as: where A c is the cross-sectional area of the free piston in the combustion chamber, and x L , x R are the positions of two opposed-pistons. According to Equation 18, 19 and 20, the change rate of the in-cylinder pressure can be obtained: By performing integral calculation on Equation 21, the incylinder pressure characteristics during free piston movement can be obtained.

C. CYCLIC COMBUSTION VARIATIONS MODEL
For free-piston engines, cyclic combustion variation is the main factor affecting the piston motion. The in-cylinder pressure variations between cycles can affect the turning center position of the free-piston. With the reciprocating movement of the free piston, the position error of the ITC gradually accumulates, eventually affecting the compression ratio in the cylinder, resulting in the in-cylinder mixture not burning normally. Based on previous research results [21], the main causes of cyclic combustion variations include the fuel injection quantity and combustion duration. In the simulation model, a variation module of the fuel injection quantity and the combustion duration is added to the combustion chamber model in the form of random numbers. The designed fuel injection quantity of the prototype studied in this paper is 6.5mg. Considering the actual error of the injector and the influence of various disturbances in the test, a variation of ±5% is added to the simulation model. The standard combustion duration designed in the simulation is 4ms. Considering the variation of the piston ITC position on the combustion, a variation of ±15% is added to the simulation model. The uniform distribution range of the fuel injection quantity and the combustion duration in the model is described by the following equation. g f ∈ (6.2mg, 6.8mg) (22) T ∈ (3.4ms, 4.6ms) (23)

D. LINEAR ELECTRIC MACHINE MODEL
As a load of free piston engine, LEM is an important energy conversion device of the system. In order to improve the accuracy of the simulation model, a finite element method was used to build a physical model of the LEM based on electromagnetic analysis software during the modeling process, and the mesh was divided. In the simulation, the finite element model of the LEM can calculate the electromagnetic force online based on input signals such as terminal voltage, mover position, and mover speed. The calculation process of the electromagnetic force can be described as: where u is the instantaneous voltage across the LEM coil, and v is the speed of the mover.

E. AIR-SPRING AND FRICTION MODEL
The FPEG prototype studied in this paper uses an air spring as the energy storage device. The elastic characteristics of air springs approximate the law of exponential function. When the free piston approaches the OTC position, the highpressure gas stored in the air spring chamber can generate a large elastic resistance, which is conducive to overcoming the impact of combustion variations on the OTC position, and can also avoid collision between the free piston and the LEM. The pressure change law of the air spring chamber is the same as that of the combustion chamber without a combustion process. According to the modeling process in Section IV.B, the elastic force of each air spring can be described as: where L s is the maximum effective length of the air spring chamber, P s is the pressure in the air spring chamber, and A s is the cross-sectional area of the free piston in the air spring chamber. When the free piston reciprocates, the friction force received by the piston is mainly divided into dynamic friction force and static friction force. As shown in Equation 27.
where K f is the friction coefficient of dynamic friction, and f is the static friction.

V. SYSTEM SIMULATION RESEARCH A. MODEL VALIDATION
Based on the modeling analysis in Section IV, a simulation model of FPEG was established in MATLAB (mathematical analysis software). As shown in Fig.11, the model is mainly  composed of an ECU (Electronic Control Unit) module, a combustion chamber module, two LEM modules, two air spring modules, and two piston motion modules. The LEM module is a finite element model, and it forms a joint simulation model with the mathematical model in MATLAB. The simulation cycle of the ECU module in the model is 0.1 ms, and the simulation cycle of other modules is 1 µs. The prototype of FPEG has completed the non-ignition test. As shown in Fig.12, 13, 14, the test results are approximately consistent with the simulation results, which also verifies the accuracy of the simulation model. Fig.11 shows a cycle displacement and current verification, where the ITC position is 2 mm, the OTC position is 35 mm, a simulated cycle period is 28 ms, the power generation current amplitude of the compression stroke is 25 A, and the drive current amplitude of the expansion stroke without ignition is 45 A. Fig.13 shows the internal pressure changes of the combustion chamber and the air spring chamber in one cycle. In the no-combustion cycle, the peak pressure in the combustion chamber is 13 bar, and the peak pressure in the air spring chamber is close to 9 bar. The low peak pressure of the air VOLUME 8, 2020   spring chamber will reduce the gas temperature, which will help reduce the heat transfer loss of the wall surface. Fig.14 shows the verification of LEM power. The peak generating power of the compression stroke is about 3 kW, and the peak driving power of the expansion stroke is about 7 kW. The main simulation parameters are shown in Table 3.

B. ANALYSIS OF COMBUSTION VARIATIONS
The interference of combustion variations on CR is a challenge in FPEG control. According to the description in  Section 3.3, the fuel injection quantity is evenly distributed between 6.2 mg to 6.8mg, and the combustion duration is evenly distributed between 3.4 ms to 4.6 ms. With the random changes of these two parameters, the combustion heat release rate of each cycle will be different. During the stable operation of FPEG, the variations of combustion parameters in different cycles are shown in Fig.15. It can be seen that the indicated mean effective pressure (IMEP) is evenly distributed between 8 to 9 bar, and CA50 (crank angle corresponding to 50% heat release) is randomly distributed between 2 to 8 • AITC (After ITC). The Coefficient of vibration (COV) of IMEP is approximately 6%. Fig.16 shows the dynamic characteristics of CR based on step response when controlled by traditional PID control law. When the target CR changed from 7 to 11, the original steady state of the system was disrupted, and eventually the CR did not have a steady state around 11. It can be seen that the PID control algorithm cannot quickly respond to changes in the target value of the FPEG system, or that the PID algorithm has poor anti-interference ability.

C. ANALYSIS OF CR CONTROL RESPONSE
The dynamic characteristics of CR based on step response when controlled by artificial neural network are shown in Fig.17. When the target CR changes, the initial steady state of the system is disrupted, and then the neural network starts to train the weights online. After about 30 cycles, CR is stable again near the target value, and the control error is less than ±1. It can be seen that the neural network algorithm applied in the FPEG system has certain control accuracy and response characteristics. Table 4 shows the performance comparison between the control strategy proposed in this paper and the control strategy in the report [11]. Compared with the dead center control strategy, the trajectory following control strategy needs to adjust the work mode of LEM every servo step, so the energy in the power converter will flow in both directions in one stroke and it is not conducive to improving power generation efficiency. As an intelligent algorithm, the neural network algorithm have the ability of online learning to overcome the interference of various environmental factors, and has good adaptive ability. In the initial stage, the control strategy based on neural networks requires about 30 cycles to train the weight matrices, so it has a slow response speed.

D. COMPARISON OF CONTROL STRATEGIES
A dual-core 32-bit floating-point DSP with the model number TMS320F28377 was used in the test, and the CPU (Central Processing Unit) frequency was up to 200 MHz. In the test, a CPU is used to adjust the FPEG's generated current every step time, and the servo frequency is 0.1ms. Another CPU obtains the current amplitude of the next cycle by running the neural network algorithm. This process needs to be completed during the movement of the piston between dead centers. After testing, it takes 29 µs to execute the neural network algorithm when the CPU frequency is 200MHz. Therefore, the algorithm can be used in prototype test. Fig.18 and Fig.19 show the piston position, generating power and cylinder pressure of FPEG in one cycle. The OTC position is 38 mm, the ITC position is 2 mm, and the CR is 11.   As can be seen from Fig.18, the opposed-piston based on the master-slave position following control strategy can achieve synchronous movement, and the position deviation of the movers is less than 0.2 mm. The piston movement period is 16.5 ms, where the compression stroke lasts 9.5 ms and the expansion stroke lasts 7 ms, because the piston has a higher movement speed during the expansion stroke.

E. SYSTEM PERFORMANCE ANALYSIS
As shown in Fig.19, the peak generating power of the compression stroke reaches 5kw, and the peak generating power of the expansion stroke reaches 8kw. The difference VOLUME 8, 2020 in performance between the two opposed generators leads to a certain deviation in their generated power.
After theoretical calculation of cyclic simulation results, the performance parameters in Table 5 are obtained. When the reciprocating frequency of the piston is 60 Hz. The FPEG system has an output power of 6.3kw, the system thermal efficiency reaches 42.8%, and the power generation efficiency is 37.4%.

VI. CONCLUSION
In this paper, based on previous theoretical research, a prototype of an opposed-piston free-piston engine generator was designed through dynamic analysis and calculation, and a joint simulation model was established in MATLAB. The model includes interference modules including combustion variations and differences in opposed-piston movements. The simulation model was verified by the prototype test results.
Aiming at the opposed-piston, a synchronous motion control strategy based on master-slave position following and a CR control strategy based on artificial neural network were proposed. The CR control strategy takes the starting position of the compression stroke and the target ITC position as the input characteristic values of the neural network, and uses the target generating current amplitude of the compression stroke as the output value. The neural network updates the weights through online training. After the weight matrix training is completed, the interference of cyclic combustion variations on the CR has a good control effect.
The simulation results showed that the control strategy can effectively control the synchronous movement of the opposed-piston and the engine CR. The opposed-piston can achieve synchronous movement, and there were no oscillations and static errors during adjustment. The neural network algorithm applied in the FPEG system has certain control accuracy and response characteristics. After about 50 combustion cycles, the artificial neural network completed the training process, and the CR can achieve a control error of ±1. Based on theoretical calculation of cyclic simulation results, the FPEG system has an output power of 6.3kw, the system thermal efficiency reaches 42.8%, and the power generation efficiency is 37.4%.
At present, the simulation model was verified through noncombustion testing, and the prototype test with combustion was not completed. In the future, the establishment of test bench and the combustion test of prototype will be conducted, and the control strategy will be further studied in combination with the test results. The specific research progress will be explained in subsequent papers.