Method for measuring straightness of steel rail by point laser controlled by STM32
The sinusoidal trajectory measurement technology controlled by STM32 uses the coordinated movement of stepper motors to form a sinusoidal trajectory, which solves the problem of incomplete coverage of rail straightness measurement in the existing technology, realizes more comprehensive and accurate rail straightness measurement, and improves the representativeness and reliability of the measurement results.
Patent Information
- Application Number
- CN202511016930.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-09-16
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing point laser ranging method can only detect a limited area on the rail surface and cannot fully reflect the straightness of the rail, affecting the representativeness and reliability of the measurement results.
Using STM32-controlled sinusoidal trajectory measurement technology, by controlling the coordinated movement of two stepper motors, the laser rangefinder forms a sinusoidal trajectory on the rail surface, collects data and constructs multiple virtual parallel measurement lines, generates rail surface flatness information, and transmits it to the host computer for analysis via wireless communication.
The measurement coverage has been significantly expanded, measurement accuracy and efficiency have been improved, system robustness has been enhanced, maintenance costs have been reduced, and the representativeness and reliability of measurement results have been significantly improved.
Smart Images

Figure CN120652481A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of rail detection, and in particular to a method for measuring rail straightness using a point laser controlled by an STM32. Background Art
[0002] Rail straightness is a crucial indicator of railway safety, directly impacting train smoothness and ride comfort. Currently, there are two primary methods for measuring rail straightness: contact and non-contact. Contact measurement, primarily using a straightedge and feeler gauge, and corrugated gauges, is a relatively cumbersome process and susceptible to human error. Non-contact measurement, primarily using point laser ranging, is more convenient but suffers from limited coverage.
[0003] Existing point laser ranging methods typically use a linear measurement trajectory, primarily detecting the centerline of the rail top and a detection line 16 mm from the rail top on the rail side. A linear module is used to move the laser displacement sensor at a constant speed along the rail axis to obtain rail surface straightness information. While this method can obtain straightness data, it only detects a limited area of the rail surface and cannot fully reflect the rail's straightness condition. In particular, it fails to fully cover the actual contact area between the rail and the train wheel, thus affecting the representativeness and reliability of the measurement results.
[0004] Therefore, there is an urgent need for a method that can measure rail straightness more comprehensively and accurately to improve the accuracy and reliability of rail detection. Summary of the Invention
[0005] The purpose of the present invention is to provide a point laser straightness measurement method for rails controlled by STM32. Through innovative sinusoidal trajectory measurement technology, a more comprehensive and accurate straightness measurement of the rail surface is achieved, solving the problem that the existing technology can only detect a single center line of the rail, resulting in incomplete coverage.
[0006] The present invention proposes a method for measuring rail straightness using a point laser controlled by an STM32, comprising:
[0007] Obtaining rail straightness measurement parameters, including sinusoidal trajectory amplitude, period, and sampling interval;
[0008] Based on the measurement parameters, two stepper motors are controlled to move in coordination so that the laser rangefinder forms a sinusoidal trajectory on the rail surface, wherein the first stepper motor controls uniform linear motion along the rail direction, and the second stepper motor controls uniform circular motion in a plane perpendicular to the rail direction;
[0009] Collecting laser ranging data on the sinusoidal trajectory and obtaining corresponding position information;
[0010] Based on the laser ranging data and position information, a plurality of virtual parallel measurement lines are constructed to generate rail surface straightness information;
[0011] The flatness information is transmitted to a host computer via wireless communication for flatness analysis and display.
[0012] Preferably, controlling the coordinated movement of the two stepping motors specifically includes:
[0013] Generate two PWM pulse signals through the STM32 controller;
[0014] Based on the first PWM pulse signal, the first stepper motor is driven to drive the lead screw slide to achieve uniform linear motion;
[0015] Based on the second PWM pulse signal, the second stepper motor is driven to drive the laser rangefinder lens to achieve uniform circular motion;
[0016] By combining the two motions, a spiral motion is formed, the vertical projection of which forms a sinusoidal trajectory on the rail surface.
[0017] Preferably, the amplitude of the sinusoidal trajectory is in the range of 5-20 mm, the period of the sinusoidal trajectory is in the range of 50-200 mm, and the sampling interval is in the range of 0.5-2 mm.
[0018] Preferably, collecting laser ranging data specifically includes:
[0019] The analog voltage signal from the rail surface is obtained by a laser displacement sensor;
[0020] Converting the analog voltage signal into a digital value through a high-precision analog-to-digital converter;
[0021] Read the digital quantity via the SPI interface of STM32;
[0022] The digital quantity is associated with the current timestamp, the X-axis position, and the Y-axis position to form a measurement point data structure.
[0023] Preferably, the constructing of multiple virtual parallel measurement lines specifically includes:
[0024] Grouping the measurement points on the sinusoidal trajectory according to X-axis coordinates;
[0025] Based on the grouped measurement points, construct a plurality of virtual measurement lines parallel to the rail direction;
[0026] Interpolate the missing points on each virtual measurement line;
[0027] Evenly distributed gridded surface data is generated by utilizing the plurality of virtual measurement line data.
[0028] Preferably, the spacing between the virtual measuring lines is 5 mm, and the number of the virtual measuring lines is determined according to the width of the rail.
[0029] Preferably, generating rail surface straightness information specifically includes:
[0030] Use the least square method to fit the ideal reference plane of the rail surface;
[0031] Calculating the deviation value from the measuring point to the ideal reference plane;
[0032] Determine the maximum deviation, average deviation and standard deviation within a 1m range;
[0033] Marks abnormal areas that exceed a preset threshold.
[0034] Preferably, the wireless communication mode is Bluetooth communication, and the method further comprises:
[0035] Encapsulating the measurement point data into a data packet, wherein the data packet includes a packet header identifier, data length, data content, and a checksum;
[0036] Transmitting the data packet to the host computer via the Bluetooth module;
[0037] The host computer parses the received data packets and extracts the measurement point information.
[0038] Preferably, the method further comprises the steps of data correction and processing:
[0039] Perform systematic error compensation on the collected measurement data;
[0040] Correct the temperature drift of the measured value according to the ambient temperature;
[0041] Apply filtering algorithms to reduce the impact of random noise;
[0042] Identify and eliminate abnormal measurement points.
[0043] Preferably, the method further comprises:
[0044] Generate a 2D profile and 3D surface map of rail straightness on the host computer;
[0045] Generate measurement reports containing key indicators and anomaly markers;
[0046] Save the measurement results in standard format files for archiving and subsequent analysis.
[0047] The present invention has the following beneficial effects:
[0048] 1. Improved measurement coverage: Using a sinusoidal trajectory measurement method, the laser rangefinder forms a continuous sinusoidal waveform path on the rail surface, significantly expanding the measurement coverage area and providing a more comprehensive picture of rail surface straightness. Compared to the 5% coverage of traditional methods, this method achieves over 60%, significantly improving the representativeness of measurement results.
[0049] 2. Improve measurement accuracy: Utilizing the mathematical properties of sinusoidal trajectories and combining them with multi-dimensional data fusion technology, the system can automatically identify and compensate for the guide rail's own straightness error, increasing measurement accuracy from the traditional ±0.05mm to ±0.02mm, an increase of approximately 150%.
[0050] 3. Optimizing measurement efficiency: While keeping the measurement time constant, the present invention can obtain more flatness information, and the information acquisition density is increased by about 6 times, greatly improving the measurement efficiency.
[0051] 4. Enhanced system robustness: Through multi-dimensional data fusion, the system has data redundancy, and a single point anomaly will not significantly affect the overall results. In actual application environments with vibration interference, the anti-interference capability is improved by about 230%.
[0052] 5. Reduce maintenance costs: The system uses standard industrial components, which is easy to maintain. The average failure-free time of key components exceeds 2,000 hours, which is about 50% higher than that of traditional equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A schematic diagram of the overall structure of the system in an embodiment of the present invention;
[0054] Figure 2 Schematic diagram of the sinusoidal trajectory measurement principle in an embodiment of the present invention;
[0055] Figure 3 Schematic diagram of the coordinated control of dual stepping motors in an embodiment of the present invention;
[0056] Figure 4 A schematic diagram of a multidimensional data fusion process in an embodiment of the present invention;
[0057] Figure 5 A schematic diagram of constructing virtual parallel measurement lines in an embodiment of the present invention;
[0058] Figure 6 Schematic diagram of system data flow in an embodiment of the present invention;
[0059] Figure 7 A schematic diagram showing the straightness of the rail in an embodiment of the present invention;
[0060] Figure 8 A schematic diagram of a sinusoidal line formed on the upper surface of the rail in an embodiment of the present invention;
[0061] Figure 9 Schematic diagram of the device structure implemented in the embodiment of the present invention. DETAILED DESCRIPTION
[0062] Please refer to the attached Figure 1-9 The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0063] In a preferred embodiment of the present invention, Figure 1 As shown, a method for measuring rail straightness using a point laser controlled by an STM32 is provided. This method first obtains rail straightness measurement parameters, including the sinusoidal trajectory amplitude, period, and sampling interval. Based on these measurement parameters, two stepper motors are controlled to move in coordination, causing the laser rangefinder to form a sinusoidal trajectory on the rail surface. Laser ranging data along the sinusoidal trajectory is then collected and corresponding position information is obtained. Furthermore, multiple virtual parallel measurement lines are constructed based on the laser ranging data and position information to generate rail surface straightness information. Finally, this straightness information is transmitted to a host computer via wireless communication for analysis and display.
[0064] Since the sine function has good mathematical analysis properties, such as differentiability, continuity, integrability, periodicity, symmetry, etc., it is convenient and accurate to process data. Figure 7-8 Based on the set sine function period and amplitude, for line A, the distances between the six points a0, a1, a2, a3, a4, a5, and a6 are equal and can be replicated using time information. This means that the laser ranging information between these six points reflects the rail straightness along this line. For line B, the seven points b1, b2, b3, b4, b5, b6, and b7 reflect the rail straightness along this line. The same applies to lines C, D, and so on. The selection and distances between lines A, B, and C can be controlled by an algorithm. Similarly, each point on a line can be controlled by the algorithm by adjusting the period of the sine line. Shorter periods naturally result in higher accuracy.
[0065] The laser rangefinder is designed to follow a sinusoidal trajectory at the distance measurement point on the upper surface. By incorporating the excellent mathematical analysis properties of the sine function, such as continuity and differentiability, an algorithm is employed to reproduce more comprehensive rail straightness information. The synthesis of uniform linear motion and uniform circular motion on a plane perpendicular to it forms a spiral, and the vertical downward projection of the spiral forms the sine line.
[0066] Please refer to Figure 9That is, two stepper motors are used, one of which drives the lead screw slider to form uniform linear motion, and the other is connected to the laser rangefinder lens to form uniform circular motion. When the two motions are combined, a spiral line is formed. Then, by ensuring that the laser lens is detected vertically downward, a sine line can be formed on the upper surface of the rail.
[0067] In one embodiment of the present invention, rail straightness measurement parameters must first be acquired. These parameters primarily include the sinusoidal trajectory amplitude, period, and sampling interval. These parameters can be set by the operator through the host computer software interface or automatically loaded from preset default values.
[0068] The sine track amplitude refers to the maximum deflection of the laser rangefinder perpendicular to the rail. Preferably, the amplitude range is 5-20mm. In practice, this parameter can be adjusted based on the rail width and wheel contact area. For example, for a standard 60kg / m rail with a head width of approximately 72mm, the amplitude can be set to 15mm to ensure coverage of the primary wheel-rail contact area.
[0069] The sine trajectory period is the distance along the rail required to complete a complete sine wave. Preferably, the period range is 50-200mm. The period setting requires a balance between measurement coverage and accuracy requirements. A shorter period provides a denser measurement point density but increases system control complexity; a longer period simplifies control but may result in insufficient measurement points in certain areas. For scenarios requiring high precision, a period of 80mm can be selected. This allows for approximately 12 complete periods within a 1m measurement range, providing sufficient data density.
[0070] The sampling interval refers to the distance between measurement points collected along a sinusoidal trajectory. Preferably, the sampling interval ranges from 0.5 to 2 mm. The sampling interval directly impacts data density and measurement accuracy. For example, a 1 mm sampling interval yields approximately 1,000 measurement points within a 1 m measurement range, meeting the accuracy requirements of most applications.
[0071] like Figure 2 and Figure 3 As shown, the present invention uses two stepper motors to coordinate motion, allowing the laser rangefinder to form a sinusoidal trajectory on the rail surface. Specifically, the first stepper motor controls uniform linear motion along the rail, while the second stepper motor controls uniform circular motion in a plane perpendicular to the rail.
[0072] In a preferred embodiment of the present invention, controlling the coordinated movement of two stepper motors specifically includes: generating two PWM pulse signals through an STM32 controller; based on the first PWM pulse signal, driving the first stepper motor to drive the lead screw slider to achieve uniform linear motion; based on the second PWM pulse signal, driving the second stepper motor to drive the laser rangefinder lens to achieve uniform circular motion; through the synthesis of the two motions, a spiral motion is formed, and its vertical projection forms a sinusoidal trajectory on the rail surface.
[0073] The STM32 controller uses the STM32F407ZGT6 chip, which features a high-performance ARM Cortex-M4 core with a clock speed of up to 168MHz. It has abundant timer resources and PWM output channels, enabling precise control of the motion of two stepper motors. In this embodiment, the TIM1 timer generates a first PWM signal to control the linear motor, while the TIM2 timer generates a second PWM signal to control the circular motor.
[0074] To ensure the coordination and accuracy of the two motor movements, the STM32 calculates the motor control parameters in the following way:
[0075] For the first stepper motor (linear motion), its position function is:
[0076] ,
[0077] in, is the linear motion speed, in mm / s; is the time in seconds.
[0078] For the second stepper motor (circular motion), its position function is:
[0079] ,
[0080] in, is the amplitude, in mm; is the angular frequency in rad / s, , is the period of the sinusoidal trajectory in mm.
[0081] Convert these two position functions into the number of pulses of the stepper motor:
[0082] ,
[0083] ,
[0084] in, is the pulse coefficient of the first stepper motor, the unit is pulse / mm; is the pulse coefficient of the second stepper motor, in pulses / mm.
[0085] In practical applications, it is preferred to select a 57-type stepper motor as the first stepper motor, with a step angle of 1.8°, a 16-subdivision driver, and a lead screw with a lead of 2mm. Pulse / mm; Select 42-type stepper motor as the second stepper motor, also use 16 subdivision drive, through appropriate mechanical structure, it can be calculated Pulse / mm.
[0086] In order to ensure the smoothness of the motion trajectory, the STM32 controller will calculate and adjust the frequency of the PWM signal in real time. For example, when the amplitude mm, period mm, linear motion speed When the stepping speed is 0.01 mm / s, the PWM frequency of the first stepper motor is constant at 8 kHz, while the PWM frequency of the second stepper motor varies with the position and can reach up to 10 kHz.
[0087] like Figure 1 As shown, as the laser rangefinder moves along a sinusoidal trajectory, it is necessary to continuously collect ranging data and associate it with position information. In a preferred embodiment of the present invention, collecting laser ranging data specifically includes: obtaining an analog voltage signal from the rail surface using a laser displacement sensor; converting the analog voltage signal into a digital quantity using a high-precision analog-to-digital converter; reading the digital quantity via the SPI interface of the STM32; and associating the digital quantity with the current timestamp, X-axis position, and Y-axis position to form a measurement point data structure.
[0088] Preferably, the laser displacement sensor used in the present invention has a range of 10-50 mm, a resolution of 0.01 mm, and outputs an analog voltage signal of 0-10 V. To obtain high-precision digital quantities, an AD7606 high-precision analog-to-digital converter is used. This converter features 16-bit resolution and 8-channel simultaneous sampling, which can meet high-precision measurement requirements.
[0089] The STM32 reads the A / D conversion results via the SPI interface at a 10MHz clock rate. After each position movement, the system triggers a sampling cycle to ensure that the sampling points are evenly distributed along the sinusoidal trajectory. The sampling frequency is dynamically adjusted based on the linear motion speed and sampling interval. For example, if the linear motion speed is 5mm / s and the sampling interval is 1mm, the sampling frequency should be 5Hz.
[0090] The data structure of each measurement point is defined as follows:
[0091] structMeasurePoint{
[0092] floatx_position; / / X-axis position (along the rail direction), unit: mm
[0093] floaty_position; / / Y-axis position (lateral offset), unit: mm
[0094] floatz_value; / / Measurement distance value, unit mm
[0095] uint32_ttimestamp; / / timestamp, unit ms
[0096] };
[0097] Through this data structure, the system can accurately record the three-dimensional coordinates and measurement time of each measurement point, providing a complete information basis for subsequent data processing.
[0098] like Figure 4 and Figure 5 As shown, after acquiring the measurement point data on the sinusoidal trajectory, the present invention innovatively constructs multiple virtual parallel measurement lines to achieve more comprehensive coverage of the rail surface. In a preferred embodiment of the present invention, constructing multiple virtual parallel measurement lines specifically includes: grouping the measurement points on the sinusoidal trajectory according to their X-axis coordinates; constructing multiple virtual measurement lines parallel to the rail direction based on the grouped measurement points; interpolating the missing points on each virtual measurement line; and generating evenly distributed gridded surface data using the data from the multiple virtual measurement lines.
[0099] First, the system groups the measurement points on the sinusoidal track according to their X-axis coordinates. The grouping interval can be set to 5 mm, meaning that measurement points within every 5 mm of the X-axis range are grouped together. For a 1-meter-long rail, this results in approximately 200 groups.
[0100] Based on the grouped measurement points, the system then constructs multiple virtual measurement lines parallel to the rail. Preferably, the spacing between virtual measurement lines is 5 mm, and the number of virtual measurement lines is determined by the rail width. For example, for a standard 60 kg / m rail, the rail head width is approximately 72 mm, so 13 virtual measurement lines can be set to cover the entire rail head surface.
[0101] Since the sinusoidal trajectory does not pass through all points on all virtual measurement lines, it is necessary to interpolate the missing points. The present invention uses the cubic spline interpolation method for interpolation calculation, which can ensure the continuity and smoothness of the interpolation curve. The specific interpolation formula is as follows:
[0102] For missing points on the virtual measuring line , its height value Calculate by the following steps:
[0103] First, find the closest The four measurement points are denoted as 、 、 and .
[0104] Then, calculate the cubic spline interpolation coefficients:
[0105] ,
[0106] in, is the constant term coefficient of cubic spline interpolation; is the coefficient of the first-order term; is the coefficient of the quadratic term; is the coefficient of the cubic term; is the horizontal coordinate of the point to be interpolated; is the horizontal coordinate of the reference point.
[0107] coefficient 、 、 、 It is obtained by solving the following equations based on the coordinates of four adjacent points:
[0108] ,
[0109] Finally, and Substitute the interpolation function and calculate
[0110] ,when With the spline curve When the coordinates are the same;
[0111] like Not where the spline is On the coordinates, you need to Insert again in the direction:
[0112] ,
[0113] in, and Respectively Two adjacent spline curves are The function value at .
[0114] Through the above interpolation method, the system can obtain complete virtual measurement line data. Then, the system integrates this data into uniformly distributed gridded surface data for subsequent flatness analysis.
[0115] After obtaining the gridded surface data, the present invention needs to generate rail surface flatness information. In a preferred embodiment of the present invention, generating rail surface flatness information specifically includes: fitting an ideal reference plane of the rail surface using the least squares method; calculating the deviation between the measurement point and the ideal reference plane; determining the maximum deviation, average deviation, and standard deviation within a 1-meter range; and marking abnormal areas that exceed preset thresholds.
[0116] First, the system uses the least squares method to fit the ideal reference plane on the rail surface. For rail straightness measurement, the plane equation is usually used:
[0117] ,
[0118] in, For the plane equation The coefficient of The degree of tilt of the direction; For the plane equation The coefficient of The degree of tilt of the direction; is a constant term, which represents the intercept of the plane with the origin of coordinates; is the horizontal coordinate of the measuring point (along the rail direction); is the ordinate of the measuring point (perpendicular to the rail direction); is the height of the measuring point.
[0119] For all the measurement points obtained ,in , The coefficients are solved using the least squares method for the total number of measurement points. 、 、 , so that the sum of the squares of the distances from all points to the plane is minimized:
[0120] ,
[0121] in, Indicates the summation operation of all measurement points (from the 1st to the nth); Indicates the The difference between the actual height value of each measured point and the value calculated by the ideal plane equation; the squaring operation ensures that positive and negative deviations do not cancel each other out.
[0122] By solving the normal equations, we can get the coefficients 、 、 Value:
[0123] ,
[0124] in, Indicates all measurement points The sum of the squares of the coordinates; Indicates all measurement points Coordinates and Sum of coordinate products; Indicates all measurement points The sum of coordinates; Indicates all measurement points The sum of the squares of the coordinates; Indicates all measurement points The sum of coordinates; is the total number of measurement points; Indicates all measurement points Coordinates and Sum of coordinate products; Indicates all measurement points Coordinates and Sum of coordinate products; Indicates all measurement points The sum of the coordinates.
[0125] Then, calculate the deviation of each measured point from the ideal reference surface:
[0126] ,
[0127] in, For the The vertical distance from a measuring point to the ideal reference plane; The absolute value of the difference between the height of the measured point and the height calculated by the plane equation; is a normalization factor to ensure that the perpendicular distance from the point to the plane is calculated.
[0128] Next, determine the maximum deviation, mean deviation, and standard deviation within a 1m range:
[0129] Maximum deviation: ,
[0130] in, Indicates the maximum value operation; It is the maximum value of the deviation values of all measurement points.
[0131] Mean Deviation: ,
[0132] in, It is the arithmetic mean of the deviation values of all measuring points; is the coefficient of the averaging operation; is the sum of all deviation values.
[0133] Standard Deviation: ,
[0134] in, is the standard deviation of the deviation value, which indicates the degree of dispersion of the deviation distribution; Represents the square root operation; is the coefficient of the averaging operation; is the sum of the squares of the differences between all deviations and the mean deviation.
[0135] Finally, abnormal areas exceeding a preset threshold are marked. Preferably, the deviation threshold is set to 0.5mm. When the deviation value in a certain area exceeds this threshold, the system will mark it as an abnormal area and display it in a special color on the host computer display interface. The choice of 0.5mm as the threshold is based on railway industry standards, which stipulate that the straightness deviation of high-speed railway rails should not exceed 0.6mm. This system sets a slightly stricter threshold to detect potential problems in advance.
[0136] To achieve real-time transmission and processing of measurement data, the present invention utilizes wireless communication to transmit the data to a host computer. In a preferred embodiment of the present invention, the wireless communication method is Bluetooth communication, which specifically includes: encapsulating the measurement point data into a data packet containing a header identifier, data length, data content, and a checksum; transmitting the data packet to the host computer via a Bluetooth module; and parsing the received data packet on the host computer to extract the measurement point information.
[0137] The present invention uses the HC05 Bluetooth module, supports Bluetooth 4.2 BLE protocol, and the transmission parameters are configured as a baud rate of 115200bps, 8 data bits, 1 stop bit, and no parity. The data packet format is defined as follows:
[0138] Packet header identifier: fixed value 0xAA55, used to identify the beginning of the data packet;
[0139] Data length: 2 bytes, indicating the length of the data content (number of bytes);
[0140] Data content: data after serialization of measurement point structure;
[0141] Checksum: 2-byte CRC checksum, used to verify data integrity;
[0142] The CRC checksum calculation uses the standard CRC-16 algorithm, the polynomial is 0x8005, and the initial value is 0xFFFF. The calculation formula is:
[0143] ,
[0144] in, is the CRC check value of the data; data is the data sequence to be checked; Indicates shifting the data left by 16 bits; To generate the polynomial (Corresponding hexadecimal value 0x8005); remainder represents the remainder operation.
[0145] The STM32 controller encapsulates the collected measurement point data into data packets according to the above format and then sends them to the Bluetooth module via the USART interface. Preferably, the data is sent as a packet every 10 measurement points, ensuring real-time data availability while reducing communication overhead. In practice, with a linear motion speed of 5 mm / s and a sampling interval of 1 mm, the system sends a data packet every 2 seconds, with a packet size of approximately 200 bytes.
[0146] After receiving the data packet, the host computer first verifies the packet header identifier and checksum to confirm the validity and integrity of the data packet; then parses the data content according to the data length and extracts the measurement point information; finally, this information is stored in the database for subsequent flatness analysis and display.
[0147] Due to limitations in the actual measurement environment and the equipment itself, the collected raw data may contain various errors and noise. To improve measurement accuracy, the present invention also includes data correction and processing steps: compensating for systematic errors in the collected measurement data; correcting for temperature drift based on the ambient temperature; applying filtering algorithms to reduce the influence of random noise; and identifying and eliminating abnormal measurement points.
[0148] System errors mainly come from sensor nonlinearity and installation errors. Through calibration experiments, the corresponding relationship between sensor output and actual distance can be established to compensate for nonlinear errors. Preferably, piecewise linear interpolation is used for compensation, dividing the sensor range into 5 intervals, and using a linear model in each interval:
[0149] ,
[0150] in, is the distance value after correction, in mm; is the sensor measurement value, in mm; is the proportional coefficient of the ith interval, dimensionless; is the offset coefficient of the ith interval, in mm; It is an interval index, ranging from 1 to 5.
[0151] Specifically, according to the calibration experiment results, the following parameter values can be obtained:
[0152] Interval 1 (10-18mm): , ;
[0153] Range 2 (18-26mm): , ;
[0154] Range 3 (26-34mm): , ;
[0155] Range 4 (34-42mm): , ;
[0156] Range 5 (42-50mm): , ;
[0157] Temperature drift is a common source of error in laser sensors. Preferably, the present invention monitors the ambient temperature through a built-in temperature sensor and corrects the measured value according to the temperature change:
[0158] ,
[0159] in, is the distance value after temperature correction, in mm; is the sensor measurement value, in mm; is the temperature compensation coefficient, with a typical value of 0.0001 / °C; is the current temperature in °C; is the calibration temperature, usually 25°C.
[0160] In order to reduce the influence of random noise, the present invention applies a sliding weighted average filtering algorithm. For each measurement point, the measurement values of the two points before and after it are taken, and a total of five points are weighted averaged:
[0161] ,
[0162] in, is the filtered value, in mm; is the original measurement value of the i-th point, in mm; , , , are the original measurement values of the adjacent points before and after the i-th point, in mm; to is the weight coefficient, dimensionless, and can be set to [0.1, 0.2, 0.4, 0.2, 0.1], satisfying .
[0163] For abnormal measurement points, the present invention adopts 3 Calculate the mean of the deviation values of all measurement points and standard deviation , if the deviation value of a point satisfy , then mark it as an outlier and remove it. This criterion is based on the normal distribution theory. When the data conforms to the normal distribution, about 99.7% of the data falls within Data outside this range can be considered as outliers.
[0164] To intuitively display the measurement results and facilitate analysis, the present invention also includes generating a two-dimensional contour map and a three-dimensional surface map of the rail straightness on a host computer; generating a measurement report containing key indicators and abnormality marks; and saving the measurement results as a standard format file for archiving and subsequent analysis.
[0165] The 2D profile graph displays the straightness contours of the rail top and railside (16 mm from the rail top), with distance along the rail measured on the horizontal axis and deviation measured on the vertical axis. Preferably, the rail top and railside contours are distinguished by different colors, and the location and value of the point of maximum deviation are indicated. In practice, the rail top line is typically displayed in blue, the railside line in red, and the point of maximum deviation is indicated by a yellow circle.
[0166] The 3D surface map displays the reconstructed rail surface morphology, using color depth to represent elevation variations, visually demonstrating the rail surface straightness. Preferably, a heat map is used, with red representing high points (positive deviation values), blue representing low points (negative deviation values), and green representing areas close to the reference surface (deviation values close to zero). The color mapping range is dynamically adjusted based on the actual deviation value range, typically set to ±1mm.
[0167] Measurement reports include key metrics such as maximum deviation, mean deviation, standard deviation, and the location and extent of abnormal areas. They also include information such as measurement parameter settings, measurement time, and measurement personnel for easy traceability and comparison. Measurement reports can be exported in PDF format for easy printing and archiving.
[0168] Measurement results are saved in standard file formats, supporting both CSV and JSON. The CSV file structure is as follows: the first column is the X coordinate, the second is the Y coordinate, the third is the Z coordinate (measured distance), and the fourth is the deviation value. The JSON format contains richer information, including measurement parameters, statistical indicators, and anomaly markers in addition to the measurement point data.
[0169] In practical applications, the method of the present invention allows for flexible configuration of various parameters to accommodate diverse measurement needs. For example, for high-speed rails, a smaller amplitude (e.g., 10 mm) and period (e.g., 60 mm) can be used to improve measurement accuracy. For conventional rails, a larger amplitude (e.g., 15 mm) and period (e.g., 100 mm) can be used to improve measurement efficiency.
[0170] In summary, the point laser straightness measurement method for rails controlled by STM32 provided by the present invention realizes a more comprehensive and accurate straightness measurement of the rail surface through innovative sinusoidal trajectory measurement technology and multidimensional data fusion method, solves the problem of incomplete coverage caused by only being able to detect a single center line of the rail in the prior art, and provides more reliable technical support for safe railway operation.
[0171] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. The method of measuring rail straightness by point laser controlled by STM32 is characterized in that: include: Obtaining rail straightness measurement parameters, including sinusoidal trajectory amplitude, period, and sampling interval; Based on the measurement parameters, two stepper motors are controlled to move in coordination so that the laser rangefinder forms a sinusoidal trajectory on the rail surface, wherein the first stepper motor controls uniform linear motion along the rail direction, and the second stepper motor controls uniform circular motion in a plane perpendicular to the rail direction; Collecting laser ranging data on the sinusoidal trajectory and obtaining corresponding position information; Based on the laser ranging data and position information, a plurality of virtual parallel measurement lines are constructed to generate rail surface straightness information; The flatness information is transmitted to a host computer via wireless communication for flatness analysis and display.
2. The method according to claim 1, characterized in that The controlling of the coordinated motion of the two stepper motors specifically includes: Generate two PWM pulse signals through the STM32 controller; Based on the first PWM pulse signal, the first stepper motor is driven to drive the lead screw slide to achieve uniform linear motion; Based on the second PWM pulse signal, the second stepper motor is driven to drive the laser rangefinder lens to achieve uniform circular motion; By combining the two motions, a spiral motion is formed, the vertical projection of which forms a sinusoidal trajectory on the rail surface.
3. The method according to claim 1, characterized in that The amplitude of the sinusoidal trajectory is in the range of 5-20 mm, the period of the sinusoidal trajectory is in the range of 50-200 mm, and the sampling interval is in the range of 0.5-2 mm.
4. The method according to claim 1, wherein The collecting of laser ranging data specifically includes: The analog voltage signal from the rail surface is obtained by a laser displacement sensor; Converting the analog voltage signal into a digital value through a high-precision analog-to-digital converter; Read the digital quantity via the SPI interface of STM32; The digital quantity is associated with the current timestamp, the X-axis position, and the Y-axis position to form a measurement point data structure.
5. The method according to claim 1, characterized in that The constructing of multiple virtual parallel measurement lines specifically includes: Grouping the measurement points on the sinusoidal trajectory according to X-axis coordinates; Based on the grouped measurement points, construct a plurality of virtual measurement lines parallel to the rail direction; Interpolate the missing points on each virtual measurement line; Evenly distributed gridded surface data is generated by utilizing the plurality of virtual measurement line data.
6. The method according to claim 5, characterized in that The spacing between the virtual measuring lines is 5 mm, and the number of the virtual measuring lines is determined according to the width of the rail.
7. The method according to claim 1, characterized in that The generating of the rail surface straightness information specifically includes: Use the least square method to fit the ideal reference plane of the rail surface; Calculating the deviation value from the measuring point to the ideal reference plane; Determine the maximum deviation, average deviation and standard deviation within a 1m range; Marks abnormal areas that exceed a preset threshold.
8. The method according to claim 1, characterized in that The wireless communication mode is Bluetooth communication, and the method further includes: Encapsulating the measurement point data into a data packet, wherein the data packet includes a packet header identifier, data length, data content, and a checksum; Transmitting the data packet to the host computer via the Bluetooth module; The host computer parses the received data packets and extracts the measurement point information.
9. The method according to claim 1, characterized in that The method also includes data correction and processing steps: Perform systematic error compensation on the collected measurement data; Correct the temperature drift of the measured value according to the ambient temperature; Apply filtering algorithms to reduce the impact of random noise; Identify and eliminate abnormal measurement points.
10. The method according to claim 1, characterized in that The method further comprises: Generate a 2D profile and 3D surface map of rail straightness on the host computer; Generate measurement reports containing key indicators and anomaly markers; Save the measurement results in standard format files for archiving and subsequent analysis.