Downhole stm32f407 laser radar point cloud data acquisition, storage and transmission system
The downhole lidar point cloud data acquisition, storage and transmission system using STM32F407 microcontroller solves the stability and data loss problems of downhole lidar data acquisition equipment in harsh environments, realizes high-speed continuous data acquisition and stable transmission, and improves the reliability and real-time performance of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA COAL SCIENCE & TECHNOLOGY (TIANJIN) ROCK FORMATION INTELLIGENT CONTROL TECHNOLOGY CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-05-29
Smart Images

Figure CN122111323A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of underground safety monitoring in coal mines, specifically to an underground STM32F407 lidar point cloud data acquisition, storage, and transmission system. Background Technology
[0002] LiDAR technology, with its high-precision ranging and spatial modeling capabilities, has been applied in scenarios such as deformation monitoring of underground coal mine roadways, goaf detection, and geological disaster early warning. By deploying LiDAR sensors in key monitoring areas where the roof is sinking or the roadway walls are converging, geometric point cloud data of the roadway cross-section can be acquired, thereby enabling real-time quantitative analysis and early warning of surrounding rock stability.
[0003] However, underground coal mines are typical confined spaces and explosive environments, placing stringent demands on the reliability of electronic equipment due to their unique operating conditions. High humidity, high concentrations of dust, and corrosive gases are present year-round in the tunnels, accompanied by intense mechanical vibrations and electromagnetic interference from the operating mining equipment. Existing general-purpose data acquisition equipment typically lacks specific intrinsically safe explosion-proof designs and high-level physical protection. During long-term underground operation, it is prone to circuit failures due to moisture intrusion or dust accumulation, making it difficult to guarantee long-term stable operation under unattended conditions.
[0004] The stability of the underground power supply network is also a key factor restricting the reliable operation of the monitoring system. Due to the frequent start-up and shutdown of high-power mining equipment, the voltage fluctuation of the underground power grid is large, and voltage surges or sudden power outages often occur. Most traditional data acquisition systems lack independent power failure protection mechanisms. When an unexpected power outage occurs, the data in the cache cannot be written to non-volatile storage media in a timely manner, which can easily lead to the loss of critical monitoring data or even file system corruption, seriously disrupting the continuity of monitoring data.
[0005] Furthermore, underground tunnels are long, branching, and narrow, making the installation of fiber optic or standard Ethernet cables not only costly but also difficult to maintain. Existing data acquisition systems are bulky, consume a lot of power, and lack robust self-diagnostic and remote maintenance logic. When equipment malfunctions underground, such as crashes or communication interruptions, manual intervention is often required for troubleshooting and resetting, which is inefficient and increases safety risks for maintenance personnel. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides an underground STM32F407 lidar point cloud data acquisition, storage, and transmission system, which solves the problems of high-speed continuous acquisition of massive lidar point cloud data, power-off protection storage, and real-time stable transmission under low-bandwidth networks in the harsh environment of underground coal mines.
[0007] To achieve the above objectives, this invention provides the following technical solution: an underground STM32F407 lidar point cloud data acquisition, storage, and transmission system. This system includes a core control unit, a power management unit, a data acquisition interface unit, a local storage interface unit, a data transmission interface unit, and an environmental monitoring unit. The core control unit uses an STM32F407 microcontroller and establishes electrical connections with the power management unit, data acquisition interface unit, local storage interface unit, data transmission interface unit, and environmental monitoring unit. The power management unit's input is connected to an external power source, and its output supplies power to the system. This unit integrates a voltage monitoring circuit and a supercapacitor energy storage circuit. The data acquisition interface unit uses an Ethernet interface circuit and connects to the core control unit via a simplified media independent interface (SDI) to receive point cloud data packets sent by the lidar. The local storage interface unit uses an SD card interface circuit and connects to the core control unit via an SDIO interface to connect a memory card and write point cloud data files. The data transmission interface unit uses a CAN bus interface circuit and connects to the core control unit via a CAN controller to send data to the underground communication network. The environmental monitoring unit includes a temperature sensor and a voltage detection circuit, which are used to collect system temperature and power supply voltage and feed them back to the core control unit.
[0008] The power management unit includes a power path switching circuit. The core control unit executes power-down protection logic: it polls the input voltage value fed back by the environmental monitoring unit in real time; when the input voltage is detected to be lower than the power-down protection threshold, it controls the power path switching circuit to cut off the external input path and conduct the discharge circuit of the supercapacitor, using the power provided by the supercapacitor to maintain system operation, and forcibly executes data cache writing and file system shutdown operations. The effective power supply maintenance time of the supercapacitor energy storage circuit is calculated based on the total capacity of the supercapacitor, the difference between the square of the initial voltage and the square of the cutoff voltage, and the average power consumption of the system, and this effective power supply maintenance time is greater than the physical time required to complete the writing of critical data to the memory card.
[0009] The core control unit constructs a three-level buffer management architecture in its internal static random access memory: the first-level buffer is a network receiving buffer pool, which adopts a ring buffer structure based on direct memory access management to temporarily store the raw network packets received through the data acquisition interface unit; the second-level buffer is a dual data processing buffer, which adopts a ping-pong switching mechanism and includes two independent contiguous storage areas, which are used to receive valid point cloud data after parsing and verification and to lock it for subsequent tasks to read, and the two alternately switch; the third-level buffer is a disk storage queue, which adopts a first-in-first-out queue structure to cache the pointers of data blocks to be written to the local storage interface unit in order to adapt to the write latency of the memory card.
[0010] The core control unit integrates edge computing logic to monitor the stability of the surrounding rock in the roadway. Internally, the core control unit stores baseline distance data for the roadway under safe conditions. During data processing, the core control unit reads the current measured distance data, matches it with the corresponding baseline distance data using angle indexing, and calculates the radial deformation between the current measured distance data and the baseline distance data using an absolute difference algorithm. When the radial deformation exceeds a safe threshold, the core control unit generates an alarm flag and writes this alarm flag into the status value of the data packet.
[0011] The core control unit implements a hierarchical storage strategy based on power state for the local storage interface unit: dividing the power state into normal operation, warning state, and critical protection state. In normal operation, the core control unit allocates contiguous cluster space in the file allocation table through the file system interface and writes data using a pre-allocation strategy. In warning state, the LiDAR acquisition task is suspended, buffered data is written to the storage card, and the file system metadata is forcibly refreshed. In critical protection state, backup power is used to execute file synchronization functions and file closing operations. The written point cloud data files use a custom binary format, including a file header recording the file type and a reference timestamp, a data entity area consisting of several data blocks, and a file tail containing a cyclic redundancy check (CRC) code.
[0012] The data transmission interface unit has an optocoupler isolation chip and a terminal matching resistor at the physical layer. The core control unit executes baud rate adaptive logic at the link layer: during system initialization, it controls the CAN controller to enter silent mode, only listening to bus data and not sending dominant bits; it configures bit timing parameters sequentially according to the internally stored baud rate table, monitoring the bus for valid messages under each configuration; when a valid message is successfully captured, it locks the current baud rate parameter and switches the CAN controller to normal transmit / receive mode. The core control unit runs a large data packet fragmentation and reassembly protocol at the application layer: the sending end calculates the total number of frames by rounding up the total byte length by the single-frame payload length, dividing the data packet to be sent into several CAN data frames. Each CAN data frame contains a 2-byte protocol header and a 6-byte data field; the protocol header contains a frame type identifier and a sequence number, which identifies the offset position of the current fragment in the original data packet; the receiving end maintains a mapping table recording the sequence numbers of received fragments. When a fragment is detected as missing, a retransmission request frame containing the missing sequence number is constructed, and the sending end retransmits only the corresponding fragment data accordingly.
[0013] In addition, the core control unit executes a weighted dynamic priority scheduling and adaptive compression strategy: it maintains a transmission waiting queue, calculates a real-time transmission priority score for each data packet in the queue based on the data type weight value and the waiting time value using a linear weighted summation algorithm, and sorts the queue according to the score for transmission; it evaluates the load rate of the CAN bus in real time, and uses raw data transmission when the load rate is low; when the load rate exceeds the load rate threshold or a transmission conflict occurs, it calls a lossless compression algorithm to encode the point cloud data before transmission.
[0014] The core control unit operates a health status monitoring module, defining a state vector that includes chip junction temperature, input voltage, remaining storage space, and network error counts. The system allocates a circular log storage area in the onboard serial flash memory, periodically collecting the state vector and writing it to this circular log storage area. When a component in the state vector exceeds a safety threshold, an exception event log containing abnormal parameters and task stack information is forcibly inserted. The core control unit has a tiered fault self-healing logic: when a fault is detected in the data acquisition interface unit and the data transmission interface unit, a first-level recovery strategy is executed, resetting the protocol stack and clearing the error counter; when a non-responsive data acquisition interface unit, local storage interface unit, and data transmission interface unit is detected, a second-level recovery strategy is executed, resetting the clock and register configuration of the corresponding interface unit; when a program execution abnormality or deadlock is detected, a third-level recovery strategy is executed, triggering a global reset of the microcontroller using an independent hardware watchdog.
[0015] This invention provides a downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system. It has the following beneficial effects: 1. This invention solves the problem of data loss caused by sudden power outages in downhole systems by integrating a power management unit containing a supercapacitor and executing state transition logic based on voltage thresholds. The system accurately calculates the effective maintenance time of the supercapacitor based on the principle of energy conservation, ensuring it covers the physical time required for critical data to be written to disk and the file system to be closed. Combined with a tiered storage strategy, metadata is refreshed in advance during the early warning stage of voltage drop, and backup power is used to close files during the critical stage, effectively preventing file system corruption caused by abnormal power outages and ensuring the integrity of monitoring data.
[0016] 2. The three-level buffer management architecture constructed in this invention achieves rate matching between the high-speed data stream of the LiDAR and the low-speed write characteristics of the SD card. A circular buffer managed by direct memory access is used to receive network packets, reducing CPU interrupt load; a ping-pong buffer is used for parallel data parsing and verification, eliminating processing wait time; and a first-in-first-out queue is used to smooth out random write latency of the memory card. This layered buffering mechanism avoids packet loss in front-end acquisition caused by back-end write blocking, achieving continuous acquisition and reliable storage of massive point cloud data with limited embedded resources.
[0017] 3. This invention employs a weighted dynamic priority scheduling and adaptive compression strategy to optimize CAN bus transmission efficiency under limited bandwidth. By combining a scoring algorithm based on data type and waiting time, it ensures that critical information such as roadway deformation alarms can immediately preempt the bus, while preventing historical point cloud data from being held up for extended periods due to low priority. Simultaneously, it dynamically switches between raw and compressed transmission modes based on bus load rate and implements a fragmentation and reassembly protocol at the application layer, effectively solving the problem of transparent transmission of large data packets on low-speed industrial buses and improving the real-time performance and stability of the underground communication network. Attached Figure Description
[0018] Figure 1 This is a block diagram of the system hardware structure of the present invention; Figure 2 This is a system software architecture diagram of the present invention; Figure 3 This is a flowchart of the main control program processing of the present invention; Figure 4 This is a power failure protection state transition and voltage curve diagram of the present invention.
[0019] Among them, 10 is the core control unit; 20 is the power management unit; 30 is the data acquisition interface unit; 40 is the local storage interface unit; 50 is the data transmission interface unit; and 60 is the environmental monitoring unit. Detailed Implementation
[0020] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] To better understand the present invention, the above content will be described in detail below with reference to specific embodiments.
[0022] Please see the appendix Figure 1 This invention provides a downhole STM32F407 lidar point cloud data acquisition, storage and transmission system, which mainly includes: a core control unit 10, a power management unit 20, a data acquisition interface unit 30, a local storage interface unit 40, a data transmission interface unit 50 and an environmental monitoring unit 60.
[0023] The core control unit 10 uses an STM32F407 microcontroller as the main control chip, which integrates a floating-point arithmetic unit and a direct memory access controller. The core control unit 10 establishes electrical connections with the power management unit 20, the data acquisition interface unit 30, the local storage interface unit 40, the data transmission interface unit 50, and the environmental monitoring unit 60, respectively, and is used to perform system scheduling, data bus control, and protocol processing.
[0024] The power management unit 20 provides a stable operating voltage for all parts of the system. The input of the power management unit 20 is connected to an external intrinsically safe mining power supply or battery pack, and its outputs power the core control unit 10 and other peripherals. The power management unit 20 internally includes a voltage monitoring circuit and a supercapacitor energy storage circuit to provide instantaneous backup power in case of external power supply failure.
[0025] The data acquisition interface unit 30 is configured with a 100 Mbps Ethernet interface circuit. The data acquisition interface unit 30 is connected to the core control unit 10 via an RMII interface, and its physical interface is connected to the underground explosion-proof lidar. The core control unit 10 receives point cloud data packets sent by the lidar through the data acquisition interface unit 30.
[0026] The local storage interface unit 40 is configured as an SDIO interface circuit. The local storage interface unit 40 is used to connect an industrial-grade MicroSD memory card. The core control unit 10 writes the processed point cloud data into the memory card as a file through the local storage interface unit 40.
[0027] The data transmission interface unit 50 is configured as a CAN bus interface circuit. The data transmission interface unit 50 is connected to the core control unit 10 via a CAN controller and to the downhole communication network via an isolation transceiver. The core control unit 10 sends status information, alarm information, and sampled point cloud data to the remote monitoring host through the data transmission interface unit 50.
[0028] The environmental monitoring unit 60 includes an onboard temperature sensor and voltage detection circuit. The environmental monitoring unit 60 collects the temperature data inside the system and the output voltage data of the power management unit 20 in real time, and feeds the collection results back to the core control unit 10.
[0029] Please see the appendix Figure 3 The specific working process of this system includes the following steps: S1. System Power-On Initialization. After the core control unit 10 is reset, it initializes the system clock, interrupt controller, direct memory access controller, and various peripheral interfaces in sequence. The core control unit 10 reads the pre-stored configuration file and configures the sampling frequency and resolution parameters of the lidar.
[0030] S2. System Self-Test and Environmental Scan. The core control unit 10 reads the current power supply voltage and internal temperature value through the environmental monitoring unit 60. The core control unit 10 determines whether the voltage value is within the set operating range and checks the mounting status and remaining space of the memory card in the local storage interface unit 40. If the self-test passes, it enters the normal operating mode; if the self-test fails, it sends a fault code through the data transmission interface unit 50.
[0031] S3. Data Reception and Buffering. The core control unit 10 initiates an Ethernet receive interrupt. When the data packet from the LiDAR arrives at the data acquisition interface unit 30, the direct memory access controller transfers the data to the primary receive buffer pool inside the core control unit 10.
[0032] S4. Data Parsing and Processing. The core control unit 10 reads data from the primary receive buffer pool, performs protocol parsing and CRC verification. The core control unit 10 extracts the distance and intensity information of the point cloud and, combined with the current RTC timestamp, reassembles the data into data blocks of a custom format. Simultaneously, the core control unit 10 calculates the change in the current point cloud data relative to the reference data; if the change exceeds a preset threshold, an alarm indicator is generated.
[0033] S5. Data Storage and Management. The core control unit 10 writes the processed data blocks to the secondary working buffer. When the data volume in the secondary working buffer reaches a set threshold, the core control unit 10 writes the data to the data file on the memory card through the local storage interface unit 40. After each write operation is completed, the core control unit 10 updates the status record of the file system.
[0034] S6. Data Distribution and Transmission. The core control unit 10 extracts status data, alarm data, or compressed point cloud data from the processed data according to the data transmission strategy. The core control unit 10 encapsulates the data to be sent into CAN data frames and transmits them to the bus network through the data transmission interface unit 50.
[0035] S7. Power Status Cyclic Monitoring. During the execution of steps S3 to S6, the core control unit 10 continuously polls the voltage data fed back by the environmental monitoring unit 60. Once the voltage is detected to be lower than the power-down protection threshold, the core control unit 10 immediately triggers an external interrupt, suspends the data receiving task of step S3, and uses the remaining power of the supercapacitor in the power management unit 20 to force file saving and system hibernation operations.
[0036] Please see the appendix Figure 2 In response to the damp, dusty, mechanically vibrating, and electromagnetically interfering environments in underground coal mines, the system constructs a protection system through three dimensions: physical structure, circuit technology, and component selection.
[0037] The primary protection of this system focuses on physical isolation and enclosure. The main body of the system is made of all-metal aluminum alloy, which provides mechanical strength while utilizing the conductive properties of metal to create a Faraday cage effect, achieving electrostatic shielding against external low-frequency electromagnetic interference. At the cable entry port of the enclosure, an aviation connector conforming to IP67 protection standards is installed, using sealing rings to prevent external moisture and dust from entering the enclosure. Furthermore, a waterproof and breathable valve is installed on the surface of the enclosure. This valve body contains a microporous membrane structure that blocks liquid water molecules while allowing gas molecules to diffuse freely, thereby balancing the air pressure inside and outside the enclosure and preventing the equipment from drawing in external moisture due to negative pressure generated inside the enclosure when the downhole temperature changes drastically.
[0038] The secondary protection of this system focuses on board-level circuit insulation and interface anti-interference design. The printed circuit boards of the core control unit 10, data acquisition interface unit 30, and data transmission interface unit 50 are coated with conformal coating. This coating covers the component pins and traces, forming a dense insulating protective layer to prevent micro-short circuits or electrochemical corrosion caused by condensation in high-humidity environments. For electrical interface protection, the circuit design employs a protection topology combining transient suppression diodes and gas discharge tubes for Ethernet and CAN bus interfaces connecting external cables. When a high-energy pulse is generated on the signal line by lightning surges or electrostatic discharge, the gas discharge tube first activates to dissipate most of the energy, and the transient suppression diode then clamps the residual voltage to the safe voltage range of the downstream transceiver chip. Simultaneously, a multi-stage LC filter circuit is connected in series at the power input to filter out high-frequency conducted interference in the power supply network. The specific parameter selection and PCB layout specifications for the above-mentioned protective devices are well-known in this field and will not be elaborated upon here.
[0039] The three-tiered protection system prioritizes the environmental tolerance and operational reliability of components. Key internal components, including the STM32F407 microcontroller, memory chips, and power management chips, are all industrial-grade chips with an operating temperature range of -40℃ to 85℃, ensuring that electrical characteristics do not drift under extreme downhole temperature conditions. To ensure the system program's self-recovery capability after interference, an independent hardware watchdog circuit is configured. This watchdog circuit has an independent clock source and power supply loop, independent of the main clock of the core control unit 10, and can forcibly trigger a hardware reset signal when the main program crashes or deadlocks. Furthermore, the onboard temperature monitoring circuit collects the PCB surface temperature in real time, providing environmental data support for the system's thermal management and fault prediction.
[0040] To address the issues of fluctuating power supply networks and data loss due to sudden power outages in mines, the power management unit 20 employs a dual-power supply architecture consisting of a main power supply and backup energy storage. This architecture integrates a wide-voltage input DC-DC converter, a supercapacitor bank, charging management circuitry, and power path switching circuitry at the hardware level.
[0041] In normal operating mode, an external intrinsically safe power supply for mining is input to the front end of the power management unit 20. After passing through a first-stage DC-DC converter, the voltage is converted into the system's internal bus voltage. This voltage powers the core control unit 10 and various peripherals, and also charges the supercapacitor bank through a constant current / constant voltage charging circuit. The system uses a voltage divider circuit in conjunction with the analog-to-digital converter inside the core control unit 10 to sample the input voltage value in real time. When the input voltage is detected to be normal, the power path switching circuit activates the main power supply path, cutting off the supercapacitor's discharge circuit. At this time, the supercapacitor is in an energy storage state.
[0042] When the input voltage is detected to drop to the preset power-off protection threshold In the event of a power failure, the power management unit 20 immediately triggers the power-down protection mechanism. The hardware-level power path switching circuit (such as an ideal diode controller or a switching switch within the PMIC) automatically cuts off the external input path and opens the discharge circuit of the supercapacitor. The energy stored in the supercapacitor continuously supplies power to the core control unit 10 and the local storage interface unit 40 via a boost or voltage regulation circuit to maintain short-term system operation after a power outage. During this period, the core control unit 10 utilizes this buffer time to perform data cache writing and file system shutdown operations.
[0043] To ensure that the supercapacitors provide sufficient power to support the critical data write-to-disk operation (i.e., meeting the system's minimum sustaining time of 100ms), this embodiment precisely matches the supercapacitor capacity with the discharge time. The total capacity of the supercapacitor bank is set to... The starting voltage (i.e., the voltage at the current terminal of the capacitor) when the system triggers the power-down protection is: The system's voltage regulator circuit can maintain the lowest possible output cutoff voltage. The average power consumption of the system during the power failure protection task is The power conversion efficiency of the discharge circuit is The effective sustaining time that a supercapacitor can provide. Calculate according to the following formula: ; The core control unit 10 reads configuration parameters during the system initialization phase, combined with real-time monitoring. Values, ensuring the calculated values The duration is always greater than the physical time required to write critical data to the SD card. If the duration calculated based on the real-time voltage is insufficient, the system will proactively reduce the time by adjusting the operating frequency or disabling unnecessary peripherals. This extends the effective power supply duration. The specific DC-DC chip selection and the series-parallel balancing circuit of the supercapacitor involved in the above power management circuit are well-known technologies in this field and will not be elaborated upon here.
[0044] To achieve high-speed and uninterrupted acquisition of the massive point cloud data output by the downhole lidar, the data acquisition interface unit 30 is configured with a hardware communication architecture based on 100 Mbps Ethernet. This architecture utilizes the Ethernet media access controller integrated within the core control unit 10 to establish a high-speed communication link with the onboard physical layer transceiver through a simplified media-independent interface.
[0045] At the hardware physical connection level, the data acquisition interface unit 30 adopts an electrical isolation design that meets the intrinsically safe explosion-proof requirements for underground applications. Data signals from the external lidar first enter the system through an industrial-grade RJ45 interface, and then undergo magnetic coupling transmission via a network isolation transformer. This network isolation transformer physically disconnects the direct electrical connection between external cables and internal digital circuits. On the one hand, it utilizes the differential signal transmission characteristics to suppress common-mode interference, ensuring the stability of signal transmission in the underground environment where motors frequently start and stop; on the other hand, it provides a high level of insulation withstand voltage to prevent external line surges from damaging the core control unit 10. The signal processed by the isolation transformer is transmitted to the physical layer transceiver chip, which is responsible for demodulating the analog differential signal into a digital logic signal and transmitting it to the core control unit 10 via the RMII interface. The system uses the RMII interface mode instead of the standard MII interface, mainly based on pin multiplexing considerations. This mode reduces the occupation of microcontroller GPIO pins by Ethernet peripherals, thereby ensuring that the core control unit 10 reserves sufficient pin resources to drive the local storage interface unit 40 and external SRAM expansion.
[0046] At the data reception logic and driver configuration level, to address the CPU overload issue caused by high-speed point cloud data streams, the system constructs a hardware-automated reception channel based on direct memory access. During system startup, the core control unit 1010 configures a dedicated DMA engine for the Ethernet MAC controller and builds a linked list of receive descriptors in memory. Each descriptor contains an address pointer to the memory receive buffer and status control bits. When UDP or TCP packets sent by the LiDAR arrive at the physical layer, the MAC controller, based on the descriptor information, directly moves the data frame to the pre-allocated SRAM memory area via the internal bus matrix. This process is entirely handled by hardware logic, eliminating the need for the CPU to execute byte-by-byte copy instructions. The MAC controller only generates a reception completion interrupt request when a complete data frame reception is completed or the receive buffer is half-full / full. The CPU only needs to read the descriptor status and update the pointer in the interrupt service routine to complete the data packet acquisition. This DMA-based zero-copy reception mechanism maximizes the release of the core control unit 10's computing resources, ensuring that the system still has sufficient computing power to perform data parsing, alarm calculation, and file storage tasks in parallel when receiving point cloud data streams at speeds up to hundreds of megabits per second. The specific physical layer transceiver register configuration and PCB differential trace impedance matching in the above circuit are well-known technologies and will not be elaborated here.
[0047] Given that the point cloud data output by LiDAR has the characteristics of high instantaneous throughput and high real-time requirements, while the industrial-grade MicroSD card used as local storage medium has random sector erase / write latency during write operations, there is a speed mismatch between the two. To resolve this contradiction and prevent data loss due to write blocking, the system constructs a hierarchical three-level buffer management architecture in the internal static random access memory of the core control unit 10, achieving temporal smoothing of the data flow through memory space swapping.
[0048] The first-level buffer in this three-level buffer architecture is defined as the network receive buffer pool, and its physical implementation adopts a ring buffer structure based on direct memory access management. This buffer is directly mapped to the receive descriptor list of the Ethernet MAC controller. When the network interface receives raw data packets from the LiDAR, the DMA controller automatically fills the free segment of this ring buffer with the data stream and updates the write pointer. This first-level buffer is mainly used to temporarily store bursty raw network packets, acting as the first data reservoir between the hardware interface and the software protocol stack, which can absorb network jitter and reduce the CPU interrupt response frequency.
[0049] The second level of this three-level buffer architecture is defined as a dual-buffer for data processing, operating using a ping-pong switching mechanism. The system allocates two independent, contiguous storage areas of 36KB each in memory, labeled BufferA and BufferB respectively. The system maintains a state machine to manage the read and write permissions of these two buffers. At any given time, one buffer acts as the input area, responsible for receiving valid point cloud data after CPU protocol parsing, verification, and header removal; simultaneously, the other buffer is locked and awaiting processing, ready for subsequent data compression or storage tasks. When BufferA is full, the system immediately triggers a switching interrupt, swapping the role pointers of the two buffers; BufferA enters the locked state, and BufferB enters the input state. This dual-buffering mechanism eliminates waiting time during data processing, achieving seamless data pipeline integration.
[0050] The three-level buffer architecture defines the three-level buffer as a disk-based storage queue, implemented using a first-in, first-out (FIFO) queue structure. This queue consists of 32 fixed-size storage blocks linked together to smooth out uncertain latency during SD card writes. When data in the second-level buffer is ready, the system does not directly call the file system write interface, but instead pushes the pointer of the data block to the tail of the third-level storage queue. An independently running file storage task continuously monitors the queue's status; once the queue is not empty, it retrieves the data block from the head and writes it to the physical storage card via the SDIO interface. If the SD card is performing a time-consuming garbage collection or bad block management operation, causing a temporary pause in writing, subsequently generated point cloud data can still be pushed into the queue for caching. As long as the queue is not full, the high-speed acquisition and data parsing tasks at the front end will not be blocked, thus achieving reliable buffering and storage of high-throughput data with limited microcontroller resources. The specific linked list operations and memory barrier settings involved in the above buffer management are well-known technologies and will not be elaborated upon here.
[0051] To monitor the stability of the surrounding rock in underground roadways in real time and promptly detect potential collapse risks without relying on post-processing by ground servers, the core control unit 10 integrates an edge computing algorithm during the data processing stage. This algorithm utilizes the floating-point unit inside the STM32F407 to perform real-time analysis of the geometry of the current cross-section before the point cloud data is written to storage media or sent to the network.
[0052] The execution of this real-time calculation algorithm relies on pre-acquired baseline data. During initial system deployment or periodic calibration, the core control unit 10 executes an environmental scan procedure to acquire initial contour data of the roadway under safe conditions. This initial data, after filtering and smoothing, is constructed into a baseline distance array. And stored in non-volatile memory, where This represents the scanning angle index of the lidar. After the system enters normal monitoring operation mode, the core control unit 10 reads the current time from the secondary buffer. The scanning angle is Measured distance data .
[0053] The core control unit 10 uses index matching to find the reference distance value corresponding to the current scanning angle and calculates the radial deformation of the monitoring point relative to the reference profile. The system defines the radial deformation at a specific angle at that moment. The calculation formula is as follows: ; in, Indicates at time And the scanning angle is The actual distance value measured by the lidar at that time. This represents the reference distance value for the corresponding angle. The absolute value operation is used to simultaneously monitor the inward convergence or outward collapse of the tunnel wall.
[0054] After calculating the deformation, the system immediately compares this value with a preset safety threshold. Compare this to the security threshold. Stored in the system's configuration register, it can be remotely set according to roadway safety standards under different geological conditions. When the calculated deformation... Exceeding the safety threshold At this time, the core control unit 10 triggers the alarm response mechanism. The specific actions of this mechanism include: first, setting the alarm flag in the status word of the current point cloud data packet header, making the data packet carry a visible abnormality identifier; second, calling the scheduling interface of the data transmission interface unit 50 to increase the transmission priority of the data containing the abnormality, ensuring that the data frame can preferentially occupy the CAN bus bandwidth and be sent to the ground monitoring host, thereby achieving millisecond-level early warning of tunnel deformation disasters. The specific code implementation of the above algorithm in the microcontroller is well-known in this field and will not be elaborated upon here.
[0055] To accommodate the limited storage resources and power-loss protection requirements of downhole embedded systems, the system abandons the traditional text format and adopts a compact, custom binary file format. This format, through rigorous byte definitions and structural layout, minimizes storage overhead and provides underlying support for subsequent data verification and breakpoint recovery.
[0056] The beginning of this custom binary file is defined as the file header, occupying a fixed number of bytes at the beginning of the file's physical address space. The file header contains a magic number and version number to identify the file type, ensuring that the parsing software can correctly recognize the data format version. Following this are the device's unique identifier and installation location coordinates, used to map the point cloud data to the specific downhole geographic space during later data processing. Furthermore, the file header records the baseline RTC timestamp at the time of file creation. This absolute time value serves as the basis for calculating the relative timestamps of all subsequent data blocks, avoiding the repeated recording of long integer time data at each data sampling point, thereby reducing data redundancy.
[0057] Following the file header is the data entity area, which consists of several consecutively arranged data blocks, carrying the system's core observation data. Each data block corresponds to a complete scan or packetized data frame from the LiDAR. The internal structure of the data block includes a synchronization frame header, a data length field, a relative timestamp, a payload, and a status word. The synchronization frame header helps the parsing algorithm reposition the data boundaries when partial file corruption or pointer offset occurs; the relative timestamp records the millisecond-level offset of the current data acquisition time relative to the file header's reference time; the payload stores compressed and encoded point cloud distance and intensity information; and the status word directly maps to alarm identifiers calculated in memory, including the tunnel deformation alarm bit and equipment fault status bit mentioned in the previous embodiment, allowing for rapid indexing to the time period of the abnormal event without decompressing all point cloud data.
[0058] The end of the file is defined as the checksum, containing the cyclic redundancy check (CRC) code for the entire file and a write completion identifier. The system only writes this part to the storage medium when the normal file closing process is about to end. This write completion identifier is a specific hexadecimal sequence, serving as a key criterion for determining whether the file is completely closed. When the system restarts after an unexpected power outage and performs a self-test, if it detects that a data file is missing this end identifier, it can determine that the file is in an abnormal state of incomplete writing, thereby triggering file repair or truncation logic to prevent corrupted data from disrupting the overall consistency of the file system. The specific CRC32 checksum algorithm implementation and byte order processing in the above format are well-known technologies in this field and will not be elaborated upon here.
[0059] To address the issue of file system corruption or data loss due to untimely updates of the file allocation table in scenarios of unstable power supply or unexpected power outages in underground coal mines, the system implements an atomic operation-based write strategy in the driver layer of the local storage interface unit 40, and combines power supply voltage monitoring to implement tiered power outage protection logic.
[0060] The system divides the power state into a finite set of states. This collection contains information about normal operating conditions. Warning status and critical protection status Three sub-states, namely The core control unit 10 utilizes its internal high-precision analog-to-digital converter to monitor the voltage value at the input terminal of the power management unit 20 in real time at a set sampling rate. The state transition logic is defined by the following piecewise function: ; in, Indicates the system voltage warning threshold. Indicates the system power failure protection activation threshold (and The core control unit 10 calculates data in real time. Status values dynamically adjust the write behavior of the MicroSD card and the peripheral control strategy.
[0061] Please see the appendix Figure 4 This figure illustrates the power state transition and voltage change curves within the system's power-down protection logic. The horizontal axis of the figure... Represents the time window index, vertical axis This indicates the system monitoring voltage. The core control unit divides the system operation process into three consecutive logical stages by polling the voltage values fed back by the environmental monitoring unit in real time: The first stage is the normal working state. ): During this stage, the input voltage stabilizes at Near or above the warning threshold The system performs routine point cloud data acquisition and storage tasks. To improve write efficiency and prevent file fragmentation, the core control unit pre-allocates contiguous cluster space in the SD card's file allocation table via the file system interface. At this time, data is written at the normal rate without forced synchronization.
[0062] The second stage is the early warning state. ): When the external power supply is disconnected or unstable, causing the monitoring voltage to drop to the warning threshold. At this point, the system enters an early warning state. The core control unit immediately suspends the lidar's data acquisition task and stops receiving new network packets to reduce system power consumption. Simultaneously, the system executes a primary protection strategy: writing valid data remaining in the buffer to the storage card and forcibly refreshing the file system's metadata to ensure the integrity of the file directory structure.
[0063] The third stage is the critical protection state. ): As the voltage continued to drop to the power failure protection threshold... The system enters a critical protection state. At this time, the core control unit controls the power path switching circuit to cut off the external input path, relying entirely on the supercapacitor energy storage circuit for power. During this period, the system executes a secondary protection strategy: using the energy released by the supercapacitor to complete the final data write to disk, calling the file synchronization function, performing a file close operation, and writing the CRC checksum at the end of the file.
[0064] Among them, from arrive The effective duration is defined by the range specified in the text. This duration is determined by the discharge characteristics of the supercapacitor and must be significantly longer than the physical time required to complete the critical data writing and file closing operations described above. When the voltage further drops to the system's minimum operating voltage... At this point, the microcontroller stops working and the system is completely powered off, but the data has been safely stored and the file structure remains intact.
[0065] When the system is in normal working condition To improve write throughput and reduce frequent erasures and writes to memory card sectors, the system employs a pre-allocation strategy to ensure the atomicity of write operations. When creating a new data file, the core control unit 10 pre-allocates contiguous cluster space in the FAT table via the file system interface, rather than gradually expanding the file size as data is written. This mechanism decouples the metadata operations modifying the FAT table from the actual operations of writing point cloud data in time, ensuring that if an abnormal interruption occurs during data writing, only the last data blocks not yet written to disk are lost, without damaging the entire file system's index structure.
[0066] When the input voltage Fall to Below but still higher At this time, the system enters an early warning state. In this state, the core control unit 10 actively suspends the lidar acquisition task and non-essential communication peripherals to reduce system power consumption, and quickly writes the data blocks currently held in the secondary buffer to the storage card. After each write operation, the system forcibly executes a file synchronization command, immediately refreshing the metadata in the file system cache to the physical medium to ensure the consistency between the file allocation table and the data area.
[0067] When the input voltage Continue to fall to When the power supply is interrupted or drops below a certain level, the system determines that the external power supply is about to be completely cut off and then enters a critical protection state. At this point, the system utilizes the remaining power provided by the supercapacitor mentioned in the previous embodiment to maintain operation. The core control unit 10 immediately executes the emergency disk write procedure: first, it calls the file system synchronization function to physically write all data to be written to the SD card, and then performs a file closing operation to update directory entries and release file handles. After confirming that the memory card has entered an idle state, the system enters a deep sleep mode or stops the MCU clock until the power is exhausted. The specific FATFS file system underlying driver instructions and SD card SPI / SDIO protocol timings involved in the above process are well-known technologies in the field and will not be described further here.
[0068] To adapt to the characteristics of large cable impedance variations and numerous network node branches in long underground coal mine tunnels, the data transmission interface unit 50 adopts a differential signal transmission architecture with strong anti-interference capabilities at the physical layer, and is configured with an intelligent baud rate adaptive and hardware filtering mechanism at the link layer.
[0069] At the physical connection level, the core control unit 10 communicates with the external bus network through an internally integrated bxCAN controller. Considering downhole electrical safety and intrinsically safe explosion-proof requirements, a high-speed optocoupler isolation chip is embedded between the microcontroller's CAN_TX and CAN_RX pins and the CAN bus transceiver. This isolation chip provides electrical insulation between the system's digital ground and the bus signal ground, effectively blocking high-voltage common-mode interference introduced from the bus side and preventing equipment damage due to ground potential differences. The CAN bus transceiver uses an industrial-grade chip that supports wide voltage supply and high electrostatic discharge protection, converting logic levels into CAN_H and CAN_L differential voltage signals. At the end of the bus network, the system is equipped with an ohm terminating resistor to eliminate reflected waves generated at the end of long-distance transmission cables, ensuring signal integrity.
[0070] Regarding baud rate configuration at the link layer, to address the issue of inconsistent baud rates among downhole network devices due to different manufacturers and deployment periods, the system employs an adaptive baud rate negotiation logic. Upon system power-on initialization, the CAN controller enters silent mode by default. In this mode, the controller only listens to the data stream on the bus and does not send any dominant bits to the bus, thus avoiding interference with existing network communication. The core control unit 10 configures the controller's bit timing parameters sequentially according to a preset baud rate table, including synchronization segment, time period 1, time period 2, and synchronization jump width. Under each baud rate configuration, the controller monitors the bus for valid start-of-frame bits or error-free data frames. Once a valid message conforming to the CAN protocol specification is successfully captured at a certain baud rate, the system locks that baud rate parameter and switches the controller to normal transmit / receive mode.
[0071] Regarding message reception filtering configuration, to prevent broadcast data from irrelevant nodes from occupying the processing resources of the core control unit 10, the system implements a whitelist mechanism using the hardware filter group inside the bxCAN controller. The system configures the filter in identifier masking mode. By setting specific identifier registers and mask bit registers, the hardware logic only allows point-to-point control commands matching the device ID, as well as specific network-wide emergency broadcast messages, to pass through the filter. Messages intercepted by the hardware filter will be directly discarded without triggering CPU interrupts or occupying receive FIFO (First-In-First-Out) resources. This hardware-level filtering strategy reduces the CPU interrupt frequency in high-load network environments, ensuring that the core control unit 10 can concentrate its computing power to process local LiDAR acquisition and storage tasks. The specific bit timing calculation method and filter register mapping in the above configuration are well-known technologies in the field and will not be elaborated here.
[0072] Given that the effective payload of a single frame in the CAN2.0B standard frame protocol is only 8 bytes, while the data packets of the lidar point cloud collected by the system are usually in the kilobyte range, in order to achieve transparent transmission of large data streams on the bandwidth-limited CAN bus, the system designed a custom transmission protocol based on the fragmentation and reassembly mechanism at the application layer.
[0073] This protocol redefines the payload structure of CAN data frames, dividing it into a protocol header and a data field. To balance the effective data rate per frame with fragment addressing capability, the system designs the protocol header to be 2 bytes, with the remaining 6 bytes used as the effective data field. The protocol header is internally compactly encoded bit-wise, including: a 4-bit frame type identifier to distinguish between start frames, data frames, check frames, and flow control frames; and a 12-bit sequence number to identify the offset position of the current fragment within the original data packet. The 12-bit sequence number supports a maximum of 4096 fragments in a single transmission, sufficient to cover the data volume requirements of a single point cloud slice in this system.
[0074] When executing the fragmentation logic at the sending end, the core control unit 10 first stores the application layer data packets to be sent into the sending buffer and obtains their total byte length. Because the effective payload of a single frame is fixed. (In this embodiment) (bytes), the system calculates the total number of frames to be transmitted according to the following formula. : ; The core control unit 10 then activates the data slicing engine, sequentially extracting raw data and filling it into the data field of the CAN message. For the sequence number field, the system increments the count from 0 until... Specifically, for the last fragment, if the data is less than 6 bytes, the system pads it with 0xFF and sets the end flag in the frame type identifier.
[0075] When the receiving end executes the reassembly logic, the system allocates a reassembly buffer in memory corresponding to that of the sending end. Upon receiving the first fragment, the system parses the total length information in the frame header, initializes the reassembly session, and starts the receive timeout timer. As subsequent fragments arrive, the system calculates the offset address based on the 12-bit sequence number in the protocol header and directly writes the data field content to the corresponding location in the reassembly buffer via DMA, avoiding frequent memory copies.
[0076] To ensure transmission reliability in the high-interference environment of underground mining, the system introduces a bitmap-based selective retransmission mechanism. The receiver maintains a mapping table to record the sequence number status of received fragments. When transmission is detected to have ended but a missing node exists in the mapping table, the receiver does not request a retransmission of the entire data packet. Instead, it constructs a retransmission request frame containing a list of missing sequence numbers or missing bitmap intervals. After parsing the request, the sender only extracts fragments with specific sequence numbers from the buffer and retransmits them. This mechanism reduces the probability of overall data packet loss due to single-frame errors, improving the throughput of effective data. The specific CRC checksum algorithm and sliding window flow control implementation in the above protocol are well-known technologies and will not be elaborated upon here.
[0077] To address the challenges of ensuring timely delivery of critical alarm information and prevent congestion of massive point cloud data in downhole environments with limited CAN bus bandwidth (typically up to 1Mbps) and volatile network loads, the system employs a weighted dynamic priority scheduling strategy and an adaptive compression mechanism above the data link layer.
[0078] This dynamic priority scheduling strategy changes the traditional first-in-first-out (FIFO) transmission mode, establishing a transmission waiting queue that supports random access. The core control unit 10 assigns initial weights to data packets based on their content type. In this embodiment, the system defines alarm information as having the highest weight, followed by device status information, and ordinary point cloud data as having the lowest weight. To prevent low-priority point cloud data from being stuck for extended periods due to frequent insertion of high-priority packets, leading to starvation, the scheduling algorithm introduces waiting time as a dynamic compensation factor. The system maintains a timer for each data packet in the transmission queue, recording the waiting time after its generation. .
[0079] Before each CAN transmission is initiated, the system iterates through the transmission queue and calculates the number of bytes in the queue. Real-time transmission priority score of each data packet The formula for calculating this fraction is defined as follows: ; in, For type weight coefficients, These are time compensation coefficients. These two coefficients are stored in the system's configuration register and can be adjusted according to actual downhole communication needs. The core control unit 10 compares all data packets in the queue... The system selects the data packet with the highest score and loads it into the CAN controller's transmit mailbox. This algorithm ensures that sudden gas exceedances or tunnel deformation alarms can immediately seize control of the bus, while also ensuring that long-accumulated historical data can be readily transmitted. The addition of this component increases its priority, thus ensuring it is ultimately sent.
[0080] This adaptive compression transmission mechanism aims to balance the computational resource consumption of the core control unit 10 with the communication bandwidth usage of the CAN bus. The system utilizes the error counter and bus busy / idle detection logic built into the CAN controller to evaluate the current network load rate and bit error rate in real time. When the network is detected to be idle and the signal quality is good, the system transmits data in either raw or low-compression mode to reduce the computational burden on the microcontroller.
[0081] When the bus load rate exceeds a preset threshold or continuous transmission conflicts occur, the system automatically switches to a high compression level. The core control unit 10 calls a lossless compression algorithm (such as differential coding or Run-Length Encoding, RLE) to encode the point cloud data. The system calculates the compression effect and compression ratio in real time. The definition is as follows: ; in This represents the number of bytes in the original point cloud data block. This represents the number of bytes after compression. In bandwidth-constrained congestion mode, the system attempts to increase the compression depth of the algorithm, trading higher CPU computation time for a smaller data transmission volume, thereby reducing the physical occupancy time of data frames on the bus and improving the transmission success rate. The specific code implementation of the above compression algorithm and the statistical methods for CAN bus load rate are well-known technologies in this field and will not be elaborated upon here.
[0082] In response to the situation where underground coal mine equipment is often unattended and maintenance personnel have difficulty obtaining real-time information on equipment operation details, the system integrates a health status monitoring module within the core control unit 10. By constructing a multi-dimensional status vector and a cyclic log storage mechanism, it achieves operation monitoring and fault tracing throughout the entire lifecycle of the equipment.
[0083] The core control unit 10 periodically collects key physical parameters and logical states of the system using low-priority background tasks. The system defines a state vector containing four key dimensions. This state vector is used to digitally represent the system's health status at the current moment. The definition of this state vector is as follows: ; in, This indicates the chip junction temperature collected by the temperature sensor integrated inside the microcontroller, used to assess the heat dissipation status; This indicates the input voltage value fed back by the power management unit 20, used to monitor power supply stability; This indicates the current percentage of remaining space on the local storage card, used to predict the risk of storage overflow. This represents the sum of the transmit error count and receive error count read from the CAN bus controller register, used to reflect the quality of network communication.
[0084] To preserve long-term operational records within limited non-volatile storage resources, the system allocates a fixed log storage area in the onboard serial Flash memory and designs a circular log file structure based on a ring buffer. This storage area is divided into several fixed-length sectors, and the system maintains a write pointer pointing to the address of the currently writable sector. When the core control unit 10 completes one cycle... After the vector is acquired, a current timestamp is appended, and the data is serialized and written to the storage location pointed to by the pointer. When the write pointer reaches the end address of the log storage area, the system automatically wraps it back to the beginning address, overwriting the oldest historical record. This mechanism ensures that the system always retains complete runtime state data for the most recent period without requiring manual intervention for space cleanup.
[0085] In addition, this log management module also has an event-triggered logging function. Besides periodic status sampling, when the system detects... Any component in the data exceeds a preset safety threshold (e.g.) Temperatures exceeding 85°C or When the voltage drops to the warning level, the system immediately inserts an exception event log with a special marker. This log not only records the current exception parameters but also saves a snapshot of the system at the moment before the exception occurred, including task stack usage and the address of the most recently executed function call, providing breakpoints for subsequent troubleshooting. The specific code implementation of the Flash read / write driver and circular queue involved in the above process is well-known in the field and will not be elaborated upon here.
[0086] Given the unique working conditions in underground coal mines, once the equipment is deployed, it is difficult for maintenance personnel to frequently reach the site for reset or debugging. The system incorporates autonomous fault diagnosis and hierarchical self-healing logic in the core control unit 10 to ensure the long-term availability of the system under unattended conditions.
[0087] Based on the system state vector and interrupt flags of each peripheral controller collected in the aforementioned embodiments, the core control unit 10 identifies the current fault type in real time and matches the corresponding recovery strategy according to the severity of the fault. The system divides the fault recovery behavior into three progressive levels: Level 1 communication link recovery, Level 2 peripheral module recovery, and Level 3 system global reset.
[0088] When the system detects a non-fatal communication fault, such as the CAN bus controller entering Bus-Off state, the transmit mailbox timing out due to full load, or the Ethernet PHY chip link interruption, the system triggers a first-level recovery strategy. In this mode, the core control unit 10 does not reset the entire microcontroller, but only performs a protocol stack reset operation for the faulty communication interface. The system clears the CAN controller's error counter register and transmit FIFO queue, or reinitializes the underlying driver structure of the LwIP network protocol stack, attempting to re-establish the physical link connection. This lightweight recovery method can eliminate network transient interference within milliseconds without interrupting ongoing LiDAR point cloud acquisition and storage tasks, ensuring data continuity.
[0089] When the system detects a logical stagnation or unresponsiveness in an onboard peripheral, such as the DMA controller's data transfer counter not changing within a preset time (meaning the LiDAR data stream is interrupted) or the SD card controller returning a busy state timeout, the system upgrades to a secondary recovery strategy. At this time, the core control unit 10 performs a module-level soft reboot on the faulty peripheral. The system resets the peripheral's clock tree and register configuration by calling standard peripheral library functions, and may even perform a power-off reboot by controlling the MOSFET switch on the peripheral's power supply circuit (if the hardware design supports it), subsequently reloading the initialization parameters. This strategy aims to isolate the fault point and prevent a local peripheral malfunction from causing the entire embedded operating system to crash.
[0090] When the system encounters fatal faults that cannot be resolved by software logic itself, such as program crashes, deadlocks, or severe power fluctuations, the system relies on an independent hardware watchdog to trigger a three-level recovery strategy. This watchdog is driven by an independent low-speed clock source, and the main loop task of the core control unit 10 needs to refresh the watchdog counter within a specified time window. If the system crashes and cannot perform the refresh operation, the watchdog timer overflow will directly pull low the microcontroller's reset pin, forcing a global system restart.
[0091] To prevent the system from entering an infinite loop of rebooting, crashing, and rebooting due to hardware damage or configuration errors, a safe mode determination logic is introduced during the system boot process. Each time the system resets and boots, it reads the reset control status register to determine the reset source. If the reset is detected as being triggered by a watchdog timeout, the system increments the reset count in the backup domain register. When the number of consecutive resets exceeds a set threshold, the system automatically enters safe mode during the next boot. In safe mode, the system loads only the minimum driver set, disables high-power tasks such as LiDAR acquisition and large-capacity storage, and remains in a state of waiting for external commands. At this time, ground maintenance personnel can send remote maintenance commands via the CAN bus or Ethernet interface. The system utilizes in-app programming (IAP) technology to receive new firmware data packets through the bootloader and write them to the application area of the on-chip Flash, thereby enabling remote repair and upgrades of the device firmware without opening the cover or disassembling the device. The watchdog configuration parameter calculations and IAP partition address mapping involved in the above process are well-known technologies in the field and will not be elaborated upon here.
[0092] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system, characterized in that, include: The core control unit, power management unit, data acquisition interface unit, local storage interface unit, data transmission interface unit, and environmental monitoring unit; The core control unit uses an STM32F407 microcontroller, which is electrically connected to the power management unit, data acquisition interface unit, local storage interface unit, data transmission interface unit, and environmental monitoring unit, respectively. The input terminal of the power management unit is connected to an external power source, and the output terminal supplies power to the system. The power management unit integrates a voltage monitoring circuit and a supercapacitor energy storage circuit to provide backup power when the external power source fails. The data acquisition interface unit adopts an Ethernet interface circuit and is connected to the core control unit through a simplified media independent interface to receive point cloud data packets sent by the lidar. The local storage interface unit adopts an SD card interface circuit and is connected to the core control unit through the SDIO interface, which is used to connect the storage card to write point cloud data files. The data transmission interface unit adopts a CAN bus interface circuit and is connected to the core control unit through a CAN controller, used to send data to the downhole communication network. The environmental monitoring unit includes a temperature sensor and a voltage detection circuit, which are used to collect system temperature and power supply voltage and feed them back to the core control unit.
2. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The power management unit includes a power path switching circuit; the core control unit executes the following power-down protection logic: The input voltage value fed back by the environmental monitoring unit is polled in real time; When the input voltage is detected to be lower than the power failure protection threshold, the power path switching circuit is controlled to cut off the external input path and open the discharge circuit of the supercapacitor. The system is kept running by using the power provided by the supercapacitor, and data cache writes and file system shutdown operations are forced to be performed. The effective power supply time of the supercapacitor energy storage circuit is calculated using the capacitor discharge time formula based on the total capacity, the difference between the square of the initial voltage and the square of the cutoff voltage, and the average power consumption. The effective power supply time is greater than the physical time required to complete the writing of key data to the memory card.
3. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit has a three-level buffer management architecture built in its internal static random access memory: The first-level buffer is a network receive buffer pool, which adopts a ring buffer structure based on direct memory access management, and is used to temporarily store the raw network packets received through the data acquisition interface unit. The secondary buffer is a dual buffer for data processing, which adopts a ping-pong switching mechanism. It includes two independent and contiguous storage areas. One area is used to receive valid point cloud data after parsing and verification, while the other area is locked for subsequent tasks to read. The two switch alternately. The three-level buffer is a disk storage queue, which adopts a first-in-first-out queue structure to cache the pointers of data blocks to be written to the local storage interface unit, thereby reducing the write latency of the memory card.
4. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit integrates edge computing logic for monitoring the stability of the surrounding rock in the tunnel. The core control unit internally stores a reference distance array for the roadway under safe conditions; During the data processing phase, the core control unit reads the current measured distance data and searches for the corresponding reference distance data by matching the angle index. The radial deformation between the current measured distance data and the reference distance data is calculated using the absolute difference algorithm. The radial deformation is compared with a safety threshold. If the radial deformation exceeds the safety threshold, an alarm flag is generated and written into the status value of the data packet.
5. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit executes a hierarchical storage strategy based on power state on the local storage interface unit: The power supply status is divided into normal operating status, early warning status, and critical protection status. Under normal operating conditions, contiguous cluster space is allocated in the file allocation table through the file system interface, and data is written using a pre-allocation strategy. In the early warning state, suspend the lidar acquisition task, write the buffer data to the storage card and force refresh the file system metadata; In critical protection mode, the backup power is used to execute file synchronization function and file closing operation; The point cloud data file being written uses a custom binary format. The point cloud data file includes a file header that records the file type and a reference timestamp, a data entity area consisting of several data blocks, and a file tail containing a cyclic redundancy check code.
6. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The data transmission interface unit has an optocoupler isolation chip and a terminal matching resistor at the physical layer. The core control unit executes baud rate adaptive logic at the link layer. During system initialization, the CAN controller is controlled to enter silent mode, only listening to bus data and not sending dominant bits; Configure the bit timing parameters sequentially according to the internally stored baud rate table, and monitor whether there are valid messages on the bus under each configuration; When a valid message is successfully captured, the current baud rate parameter is locked and the CAN controller is switched to normal transmit / receive mode.
7. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit runs a large data packet fragmentation and reassembly protocol at the application layer: The sending end calculates the total number of frames by rounding up the total byte length divided by the effective payload length of a single frame, and divides the data packet to be sent into several CAN data frames. Each CAN data frame contains a 2-byte protocol header and a 6-byte data field. The protocol header contains a 4-bit frame type identifier and a 12-bit sequence number, which is used to identify the offset position of the current fragment in the original data packet; The receiving end maintains a mapping table to record the sequence numbers of the received fragments. When a missing fragment is detected, it constructs a retransmission request frame containing the missing sequence number information. The sending end then retransmits only the corresponding fragment data based on this frame.
8. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit executes a weight-based dynamic priority scheduling and adaptive compression strategy: Maintain a sending waiting queue, calculate a real-time transmission priority score for each data packet in the queue based on the data type weight value and the waiting time value using a linear weighted summation formula, and sort the queue according to the real-time transmission priority score before sending. The load rate of the CAN bus is evaluated in real time. When the load rate is low, the raw data is transmitted. When the load rate exceeds the load rate threshold or a transmission conflict occurs, the lossless compression algorithm is called to encode the point cloud data before transmission.
9. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit runs a health status monitoring module, which defines a status vector that includes chip junction temperature, input voltage, remaining storage space, and network error count. The system allocates a circular log storage area in the onboard serial flash memory, periodically collects the state vector and writes it into the circular log storage area; When a component in the state vector is detected to exceed a safety threshold, an exception event log containing abnormal parameters and task stack information is forcibly inserted.
10. The downhole STM32F407 lidar point cloud data acquisition, storage, and transmission system according to claim 1, characterized in that, The core control unit has a graded fault self-healing logic: When a fault is detected in the data acquisition interface unit and the data transmission interface unit, a first-level recovery strategy of resetting the protocol stack and clearing the error counter is executed; When the data acquisition interface unit, the local storage interface unit, and the data transmission interface unit are found to be unresponsive, a two-level recovery strategy is executed to reset the clock and register configuration of the corresponding interface unit. When program malfunctions or deadlocks are detected, a three-level recovery strategy is employed to trigger a global reset of the microcontroller using an independent hardware watchdog.