## 2 Materials and Methods
### Electro-Hydraulic Integrated Sowing Depth Measurement and Control System Design
#### 2.4.2 Software Design  
(a) Design of the Control System Structure  
At present, although the cost of the PLC controller for vehicle engineering is higher than a micro-controller, it has the characteristics of fast computing speed, large storage capacity, simple and intuitive programming and easy modification, strong anti-interference ability and short development cycle, so it has been widely used in the industrial electrical automation field [43]. This sowing depth measurement and control system adopts the SPC-SFMC-X2214A vehicle controller as the seeder control unit, which complies with the IEC-61131-3 standard, supports CoDeSys programming and is waterproof at the IP67 level. The controller has 2 CAN buses, 1 RS232 serial communication, 7 PWM and 29 IO resource ports. In addition, the port is highly multiplexed and can directly drive the solenoid valve. The controller core  
Figure 7: (a) Load pin, (b) tilt angle sensor. is developed and manufactured by STW, Germany, with a built-in PID control algorithm and PWM output function with current feedback, so it can develop an independent proportional control system and can be applied to agricultural machinery under a harsh working environment. During operation, one control unit corresponds to controlling one row unit. The electronic components such as the sensors installed on one row unit share a CAN bus communication network. The control programs are all written, downloaded and debugged in the CODESYS V3.5 SP14 programming environment, using the ST structured text language. Due to the signal time lag, hydraulic system nonlinear changes and the presence of inertial loads on the machine, we introduced a PID closed-loop control algorithm that can be better adapted to complex field environments. In addition, based on the feedback PID regulation, a feedforward compensation algorithm is introduced to superimpose the fitted F-I model with the PID output, which can converge to the target downforce faster and make the system enter the steady-state quickly. The closed-loop PID depth control system with feedforward compensation is shown in Figure 8.  
In PID controllers, the determination of the control parameters directly affects the speed, accuracy and stability of the depth control system. There are various methods to adjust the PID parameters. We use the most commonly used trial method in closed-loop control systems, also called the empirical method. In this method, \(K_{p}\) is used to improve the response speed of the downforce and reduce the deviation in the compressive force; \(K_{i}\) is used to reduce the downforce overload, as the overshoot is difficult to suppress, and a smaller \(K_{i}\) and a larger \(K_{d}\) should be taken to prevent the system from overshoot and reach the target compressive force quickly; \(K_{d}\) is used to regulate the downforce in the future, and a smaller \(K_{d}\) should be taken to avoid the high-frequency oscillation of the downforce. We conducted the tests in the order of \(K_{\text{ff}}\), \(K_{p}\), \(K_{i}\), \(K_{d}\) accordingly, and the combination of parameters with the fastest response and highest accuracy were as follows: the feedforward control gain constant \(K_{\text{ff}}\) is 0.1, proportional gain constant \(K_{p}\) is 0.25, integral gain constant \(K_{i}\) is 0.04 and differential gain constant \(K_{d}\) is 130. To improve the real-time performance of the system, the PID control cycle time is set to 5 Hz by default, and the output range of the effective current with the deadband removed is 500-1400 mA. the number of steps was 18. The weighing instrument readings were recorded and the data were imported into the MATLAB 2018 linear fitting tool, and the relationship between the input current value \(y\) of the IPRC and the downforce \(x\) was obtained as  
\[y=1.231x-614.666\ (500\ \leq\ x\ \leq\ 1400) \tag{14}\]  
where \(y\) is the measured downforce value, N; and \(x\) is the input current value of the pressure-reducing valve, mA.