# Design and Experiment of Variable-Spray System Based on Deep Learning
## 2 Materials and Methods
### Variable-Spray Regulation Decision  
The variable-spray control system is used mainly to determine the spray level of each nozzle using weed density and the forward speed of the spray bar. In this study, PWM variable-spray technology was used; a spray volume model with duty cycle, flow rate, density data, and speed was established; a spray level decision-making method was designed; and the transformation of the flow level was realized. Calculation method of weed density. To obtain the weed density, the captured images were divided into two rows \(\times\) four columns in the system, and the percentage of weed pixels in each region was calculated. The percentage of pixels obtained represents the density of weeds in each region division. The density of weeds in each region can be expressed as follows:  
\[D=\frac{A_{i}}{A} \tag{4}\]  
where \(A_{i}\) denotes the area covered by weeds in the area and \(A\) is the total area. \(A_{i}\) and \(A\) can be run in correlation with pixel points of the image as a substitute. The impact of weed density on the flow rate. The nozzle flow rate needs to be matched with the weed density, and the required amount of spray per unit of weed density is a set value, which is related to the type of drug to be sprayed and the target to be sprayed. Based on the above conditions, the formula for calculating the amount of chemical required for normal spraying per unit area is  
\[u=\frac{q}{60 wv} \tag{5}\]  
where \(u\) is the amount of drug required for normal spraying in the unit area in L/m\({}^{2}\). \(q\) is the nozzle flow rate in ml/min. \(w\) is the width of a single nozzle in m, and \(v\) is the speed of travel in m/s. In this study, the nozzle flow rate \(q\) used is 615 mL/min, and the standard traveling speed \(v\) is set to 1 m/s. The width \(w\) of a single nozzle is selected to be 0.5 m, and \(u\) is 0.0205 L/m\({}^{2}\) from Equation (5). In the actual spraying process, the density of weeds is different in different plots. The amount of drug required per unit area under weed cover \(D\) is  
\[Q=\frac{Du}{k} \tag{6}\]  
where \(Q\) is the dose required per unit area in L/m\({}^{2}\) and \(k\) is the maximum weed cover during the spraying period. The impact of speed on flow rate. The relationship between the amount of chemical per unit area \(Q\) and the speed \(v\) is expressed as  
\[Q=\frac{q}{60 wv} \tag{7}\]  
From Equations (6) and (7), it can be derived that  
\[q=\frac{60 Dwvu}{k} \tag{8}\]  
In the actual spraying process, two variables--weed density \(D\) and speed \(v\)--affect the spray rate, and it is necessary to finally determine the spray-rating decision according to these two variables. (4) Nozzle-flow duty-cycle flow curve. PWM adjusts the actual flow rate of the nozzle by controlling the duty cycle of the solenoid valve's opening and closing times [30]. Taking into account the uniformity of spraying and the response effect of the solenoid valve during actual debugging, the PWM control frequency of the solenoid valve was set to 5 Hz. [PERSON] et al. [31] found that when the duty cycle is low, with the increase in spraying pressure, the response effect of the solenoid valve will become worse and the spraying effect will be seriously distorted. After the nozzle model, the system spray pressure, solenoid valve model, and PWM control signal frequency and other conditions are determined, and the flow rate and duty cycle of the PWM signal are calibrated. The linear equation between the nozzle flow rate and the PWM duty cycle is  
\[q=As+b \tag{9}\]  
where \(A\) represents the slope of the flow-duty cycle curve at a specific pressure and frequency, \(b\) is the intercept of the flow-duty cycle curve, and \(s\) is the duty cycle. The pressure of the spray system was 0.4 MPa. A single-factor linear fitting method was employed to establish the corresponding relationship model between the duty cycle and the nozzle spray flow rate. In the calibration process, flow rates were determined for each PWM duty cycle by adjusting the PWM duty cycle settings.