The application discloses a
sonar-based real-time calculation method and
system for displacement of an oil cylinder, relates to the technical field of
hydraulic equipment measurement and control, and is used to solve the problem of decreased displacement calculation accuracy of a long-
stroke oil cylinder under complex working conditions; before the oil cylinder is put into use, a
piston rod (4) is driven to move point by point at constant steps, a
sonar pulse is emitted at each step position, echo waveforms, time stamps and position indexes are recorded,
oil temperature is collected and sound velocity is converted, and a binding data table is established. Subsequently,
multiple echo waveforms are analyzed, features are extracted, amplitude change rates, peak drift rates and envelope
distortion rates are calculated, wave fluctuation abnormal values are generated and sorted, and a main step position is selected to establish a comprehensive
feature vector. The comprehensive
feature vector is matched in real time, displacement is calculated in combination with real-time sound velocity, and displacement data is smoothed through Kalman filtering and a time window. In the
maintenance stage, the
piston rod (4) is advanced to the limit position, features are re-collected and updated, and synchronous correction of the feature chain is completed.