Multi-platform laser compatible control system based on STM32 microcontroller platform

Through the STM32 microcontroller platform and FreeRtos real-time operating system, multi-platform laser compatible control is realized, solving the compatibility, safety, maintenance upgrade and operation efficiency problems of traditional laser control systems, and providing high compatibility, high safety and high efficiency laser control solutions.

CN120491531APending Publication Date: 2025-08-15BEIJING NANOINSIGHTS-TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510624646.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Traditional laser control systems have shortcomings in compatibility, safety, maintenance and upgrades, operating efficiency and status monitoring, resulting in poor system stability, inconvenience in use and low overall performance.

Method used

It adopts the STM32 microcontroller platform, combined with FreeRtos real-time operating system and multi-task scheduling, realizes multi-platform laser compatible control, integrates security detection mechanism, remote upgrade capabilities and multi-threaded communication, supports parallel control of multiple lasers, and provides intuitive status feedback through LED light boards.

Benefits of technology

It realizes high compatibility, security, intelligence and high-performance laser control, supports multi-platform lasers without custom development, triple safety detection response time ≤ 50ms, remote firmware upgrade reduces operation and maintenance costs, improves command processing efficiency, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491531A_ABST
    Figure CN120491531A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-platform laser compatible control system based on an STM32 microcontroller platform. The multi-platform laser compatible control system comprises a hardware framework and a software framework. The hardware framework adopts a FreeRtos real-time operating system architecture and comprises a main control unit, a laser interface, a communication interface and a security module. And the main control unit adopts an STM32F4. The software framework comprises a hardware abstraction layer (HAL), a middleware layer, an application layer and a user interface layer. The laser control system aims at overcoming the defects of a traditional laser control system in the aspects of compatibility, safety, maintenance upgrading, operation efficiency, state monitoring and the like, is high in compatibility, high in safety, intelligent and high in efficiency, and meets the requirements of scientific research, industry and medical fields for precise control of the laser.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of laser control technology, and specifically to a multi-platform laser compatible control system based on the STM32 microcontroller platform. Background Art

[0002] Traditional laser control systems, due to limitations in their technical architecture, face numerous issues, including compatibility, security, maintenance and upgrades, processing efficiency, external signal monitoring, and status display. These issues severely impact system stability, ease of use, and overall performance. Specifically, existing technologies suffer from the following major drawbacks: 1. Poor compatibility and high adaptation costs. Due to significant differences in laser communication protocols, control methods, and interface standards across different platforms, traditional systems typically require customized driver and control logic for each brand and model, resulting in significant adaptation difficulties, long development cycles, and high maintenance costs. The lack of a unified protocol adaptation layer hinders compatibility with mainstream lasers on the market, limiting the system's versatility and market adaptability. 2. Inadequate security and a lack of real-time monitoring and protection mechanisms. Lack of multi-layered safety detection mechanisms: Traditional systems typically lack integrated safety features such as shutter status detection, temperature monitoring, and power feedback, exposing the equipment to the risk of overheating damage or laser mis-triggering. Lack of active protection mechanisms: The system fails to proactively implement protective measures in the event of overcurrent, overvoltage, short circuit, or abnormal temperature rise, posing a safety hazard. Lack of laser leakage monitoring: When a laser continues to emit laser light despite visual observation under abnormal circumstances (such as mechanical damage or mirror displacement), this can pose a safety risk to equipment or personnel. Traditional systems generally lack integrated effective leakage monitoring mechanisms. 3. Complex maintenance and upgrades, lacking remote update capabilities. Outdated firmware upgrade methods: Most traditional systems still rely on physical connections (such as serial port downloads and SD card updates) for firmware upgrades, and cannot be updated remotely or online. The upgrade process is complex and risky: Power outages or operational errors can corrupt the firmware during the upgrade process, even requiring factory repairs. A lack of version management and rollback mechanisms makes it difficult to restore to a safe and stable version if an upgrade fails. 4. Low operational efficiency and slow response speed. The serial instruction processing mode cannot handle multiple tasks in parallel, resulting in instruction execution delays. High data exchange delays: Some systems rely solely on a single thread to process instructions, which places an excessive burden on the CPU during communication, affecting overall efficiency. Inefficient task switching: When processing multiple lasers or complex instructions, instruction backlogs are common, impacting the system's real-time performance. 5. Lack of external signal monitoring leads to poor system adaptability. No external signal acquisition capability: Most systems cannot monitor external digital or analog signals, such as external trigger signals, power feedback signals, etc. The power status cannot be monitored: The power supply voltage and current status cannot be obtained in real time, resulting in no early warning of power supply anomalies, which affects the life of the equipment. 6. No intuitive status display, poor user experience. Traditional systems usually lack intuitive LED, OLED or LCD status display interfaces, and the device status can only be queried through PC software. The real-time monitoring interface is not integrated, and users cannot intuitively view key data such as the current status, power, temperature, error information, etc. of the laser on the device body. There is no status log record, and it is difficult to track and analyze the cause after a failure occurs.

[0003] Application Contents

[0004] This application aims to overcome the shortcomings of traditional laser control systems in terms of compatibility, safety, maintenance and upgrades, operational efficiency, and status monitoring, and to provide a highly compatible, safe, intelligent, and efficient laser control system that meets the needs of scientific research, industry, and medical fields for precise laser control. The specific technical solutions and features are as follows:

[0005] A multi-platform laser-compatible control system based on the STM32 microcontroller platform includes a hardware framework and a software framework. The hardware framework adopts the FreeRTOS real-time operating system architecture and includes a main control unit, a laser interface, a communication interface, and a security module. The main control unit adopts the STM32F4 with a main frequency of 180 MHz, which is suitable for high-precision control tasks. The laser interface has multiple laser sub-interfaces. The communication interfaces include UART and USB for data exchange and high-speed data transmission with a host computer. The security module includes a shutter safety shutter interface, a temperature sensor, a laser safety sensor, an interlock, and a key lock. The shutter safety shutter interface controls the opening / closing state of the safety shutter based on the real-time status of the laser safety sensor, interlock, and key lock, ensuring the safety of the laser beam path. The temperature sensor monitors the temperature of the laser and drive circuit to prevent overheating damage. The laser safety sensor detects abnormal laser leakage in real time and triggers an emergency shutdown mechanism. The software framework includes a hardware abstraction layer (HAL), a middleware layer, an application layer, and a user interface layer. The hardware abstraction layer (HAL) encapsulates underlying hardware operations such as GPIO, UART, ADC / DAC, PWM, SPI, and provides a standardized API. The middleware layer includes FreeRTOS task management, communication protocol parsing, and dynamic state machine control. The FreeRTOS task management implements multi-task parallel scheduling and improves system response speed. The communication protocol parses the upper computer instructions including heartbeat packets, remote upgrades, status queries, etc., and uses an XOR check mechanism to verify communication reliability. The dynamic state machine control implements multiple instructions to control the lower computer operations in an orderly manner. The application layer includes a laser control module, a status monitoring module, and a security protection module. The user interface layer provides an internal API interface, including remote firmware upgrades, real-time device status queries, and LED light board status information.

[0006] Furthermore, the FreeRtos operating system adopts a three-segment architecture, including A / B / C partitions: Partition A is the Bootloader program segment, which is allocated an address of 0x0800000-0x801FFFF by the compiler and an internal flash storage space of 0KB-128KB; Partition B is the Bootloader APP program segment, which is allocated an address of 0x8020000-0x809FFFF by the compiler and an internal storage space of 128KB-640KB; Partition C is the Bootloader BACKAPP program segment, which is allocated an address of 0x80A0000-0x80FFFFF by the compiler and the remaining internal storage space is allocated.

[0007] Furthermore, the BootLoader program segment is independently responsible for firmware updates, completely separated from the business logic to ensure that the upgrade process does not interfere with system operation (address range: 0x08000000-0x0801FFFF). The BootLoader APP program segment serves as the main control module, responsible for motor drive, user interaction, and real-time monitoring (address range: 0x08020400-0x080A03FF). The BootLoader BACK APP program segment stores backup APP programs and can be used to repair the BootLoader APP program.

[0008] Furthermore, the communication protocol parsing includes parsing the command console data architecture and the data packet communication architecture. The FreeRTOS operating system is compatible with both data communication architectures. Data packet type data represents primary data interaction commands, while command console data represents commands used during debugging or testing. The communication protocol parsing includes the following steps: S1. Creating a command parsing and processing console task. Based on the interactive serial port created by the user, the corresponding command processing task is initiated. Data from the serial port and USB module are acquired via UART+DMA, using a serial port baud rate of 115200 bps. S2. After acquiring data via the serial port UART+DMA, a 512-byte DMA data buffer is created, using a double-buffered data storage method for a total of 1 KB of buffer space. When the DMA triggers a halfway data interrupt or an idle interrupt, a callback function is triggered to acquire data received from the serial port. The acquired data is stored in the corresponding message queue. Excessive data can lead to packet loss. Therefore, the DMA buffer size and message queue length must be appropriately allocated based on actual usage. Incoming commands are processed sequentially using a first-in, first-out principle. S3. The parsed data is promptly notified to other tasks via semaphores for rapid processing. During the parsing process, a system heartbeat mechanism is also used to monitor the health of the communication link. This system heartbeat mechanism primarily includes heartbeat packets, which use a minimized payload consisting of only a frame header, command type, header type, length field, and a checksum field to reduce communication overhead. These heartbeat packets also include extended heartbeat packets that carry user data. These extended heartbeat packets add an extended field to the original heartbeat packet and can carry specific user data based on actual needs.

[0009] Furthermore, the communication protocol analysis also includes a communication check algorithm based on polynomial convolution, which is used to detect and correct errors in data packets. The communication protocol analysis also includes a communication check algorithm based on BCC XOR check, which is used to detect and correct errors in data packets. The XOR check algorithm specifically performs XOR check on each byte of data to obtain a check code. The specific form of the check code XOR generation is:

[0010]

[0011] Among them, d i The i-th 32-bit uint32_t type data of the input.

[0012] Furthermore, the laser control module reads the external Flash memory to store laser device information, analog signal parameters, temperature sensor data, digital signal status and other configuration data, and dynamically parses and adapts to different laser protocols when the system starts, thereby realizing intelligent initialization and task management. The laser control module has the following steps: S1, external Flash device information parsing and dynamic adaptation: non-volatile storage (External Flash) is used to record laser device parameters, including communication protocol, control mode, power range, status feedback format, etc., to ensure device compatibility. By reading the Flash device information and parsing the data when the system starts, it automatically adapts to laser models from different manufacturers and supports devices with different protocols without additional firmware modification. S2, dynamic task creation and resource optimization scheduling: based on the device type, working mode, and communication protocol parsed by the Flash, the corresponding control tasks are dynamically created to ensure that the system only allocates necessary resources, reduces memory usage, and improves operating efficiency. S3, FreeRTOS task management mechanism: automatically adjusts task priorities according to the protocol characteristics of different lasers to ensure efficient processing and rapid response to instructions. S4. Multi-channel analog signal control and data acquisition: During analog signal acquisition, analog data from external photoelectric detectors, temperature sensors, and other sources is collected in real time and combined with laser feedback data for closed-loop control, improving equipment stability and safety. During digital signal monitoring and event triggering, digital signal monitoring points are recorded via external Flash memory, and GPIO is dynamically configured for functions such as laser status monitoring, external trigger control, and optical shutter safety linkage. When the optical shutter status, temperature anomalies, or digital input signal changes, the system immediately responds and executes corresponding safety measures. Combined with the interrupt trigger mechanism, this improves the real-time performance and reliability of the equipment.

[0013] Furthermore, the laser control module's external Flash device information parsing and dynamic adaptation step also includes an adaptation algorithm based on dynamic protocol parsing. The adaptation algorithm inputs the device information stored in the external Flash, then uses a fuzzy matching algorithm to calculate the similarity of the protocol feature vectors, and dynamically parses the laser's communication protocol to generate the corresponding adaptation control logic. The protocol feature vector similarity calculation method is:

[0014]

[0015] Among them, P1 and P2 are the characteristic vectors of the two protocols respectively.

[0016] Furthermore, the task dynamic creation and resource optimization scheduling steps of the laser control module also include a priority-based multi-task scheduling algorithm. The multi-task scheduling algorithm calculates the task priority in real time by receiving specific task types (such as laser control, safety detection, data communication, etc.), and dynamically adjusts the priority according to the real-time nature and resource occupancy of the task, optimizes the task scheduling order, and improves the real-time nature and efficiency of the system. The task priority calculation method is as follows: Priority (T i )=α·RealTimeFactor(T i )+β·ResourceFactor(T i )

[0017] Among them, α and β are weight coefficients, RealTimeFactor represents the real-time nature of the task, and ResourceFactor represents the resource occupancy of the task.

[0018] Furthermore, the laser control module adopts an independent task architecture. After the main task completes the data parsing, the instructions are packaged and processed according to the laser category to support the parallel control of multiple lasers. The independent task architecture has the following functional modules: 1. Independent task scheduling module. Through the task priority scheduling mechanism, the instruction processing efficiency is ensured to avoid instruction blocking during the laser control process. 2. Adaptive instruction execution management module. Through data parsing and task parallel processing, the main task is responsible for receiving and parsing data packets and extracting laser-related instructions. The subtasks process the control commands of different models of lasers based on the parsing results to achieve parallel execution. 3. Task preemption and real-time guarantee module. Using multi-task scheduling based on FreeRTOS, the main task will not be blocked by subtasks during execution, ensuring that the core control instructions are processed in a timely manner, and the real-time performance of the system will not be affected by the delayed execution of secondary tasks. 4. Instruction hierarchical processing module. A hierarchical architecture of main task + laser subtask is adopted. The main task is only responsible for instruction parsing and task scheduling, while laser control is completed in an independent task, ensuring the stable operation of the main task's instruction parsing and upper-level control logic. After the task is completed, resources are released first to reduce invalid waiting and improve system throughput.

[0019] Furthermore, the state monitoring module includes a fault prediction and active protection algorithm. In order to improve the safety of the system, this application designs a fault prediction algorithm based on time series analysis to monitor the laser state in real time and predict potential faults. The fault prediction algorithm adopts the ARIMA model. Based on the sensor data such as temperature, power, and current, the trend of the sensor data is predicted through the time series analysis model to achieve the purpose of detecting anomalies in advance. The specific form of the ARIMA model is as follows:

[0020] X t =μ+φ1X t-1 +φ2X t-2 +…+φ p X t-p +∈ t

[0021] Among them, μ is the mean, φ i is the model parameter, ∈ t is white noise.

[0022] Furthermore, the safety protection module includes a safety mechanism that employs triple safety checks: key lock status (ON / OFF), interlock digital signal, and host computer safety standards. A safety shutter rapidly isolates laser light, while the signal synchronously records fault events and creates a fault log.

[0023] Furthermore, the LED light board status information is displayed via the LED control board. The LED control board consists of six three-primary-color LEDs, which are used to indicate the laser status and system operation status in real time. Five of these three-primary-color LEDs correspond to the system's maximum supported five lasers, displaying their respective status information. The remaining LED serves as a heartbeat indicator and laser safety indicator, displaying system operation status and indicating laser safety status.

[0024] In summary, this application addresses the deficiencies of traditional laser control systems in terms of compatibility, security, maintenance and upgrades, operational efficiency, and status monitoring, and proposes a highly compatible, highly secure, intelligent, and efficient laser control system. Through hardware optimization (multi-protocol support, real-time monitoring), software optimization (multi-task parallelism, remote maintenance), and visualization enhancement (LED indicator light), the deficiencies of traditional laser control systems are effectively overcome, and comprehensive optimization of system performance is achieved. The multi-platform laser compatible control system based on the STM32 microcontroller platform proposed in this application has many significant advantages and positive effects, and the beneficial effects achieved are as follows:

[0025] 1. High compatibility: Supports multi-platform lasers, reducing customized development costs. Traditional laser control systems often require customized development for different brands of lasers, resulting in poor compatibility and high development costs. This application uses external Flash storage device information and a dynamic task creation mechanism to adapt to a variety of mainstream lasers such as Sapphire and OXXIUS. It can be compatible with lasers on different platforms and their corresponding control modes without modifying the firmware.

[0026] 2. High security: Triple safety detection mechanism, fault response time ≤ 50ms. Traditional systems lack real-time safety detection, which may lead to risks such as laser overload, temperature anomalies, and false triggering. This application integrates a triple safety detection mechanism: Optical shutter status monitoring: Prevents the laser from being accidentally turned on, improving equipment safety. Temperature anomaly detection: A built-in temperature sensor monitors the laser temperature in real time to prevent overheating and damage. Laser safety status monitoring: Combined with the heartbeat packet mechanism, it achieves fault detection and emergency response with a response time of ≤ 50ms.

[0027] 3. Efficient communication: self-developed protocol + multi-threaded scheduling, significantly improving instruction processing efficiency. Traditional laser control systems use serial instruction processing, with low communication efficiency and unable to quickly respond to the control needs of multiple lasers. This application adopts: self-developed data packet protocol (supports read, write, heartbeat, and interrupt data packets) to reduce instruction parsing time. Multi-threaded scheduling + semaphore synchronization supports parallel control of multiple lasers, greatly improving communication efficiency. Optimize DMA + serial port idle interrupt mechanism to reduce CPU load and increase data transmission rate. After comprehensive optimization, the system instruction processing efficiency has been improved to a certain extent, reducing latency and improving real-time performance.

[0028] 4. Remote Maintenance: Supports remote firmware upgrades, reducing operation and maintenance costs. Traditional firmware upgrades require physical intervention, resulting in high operation and maintenance costs and complex equipment maintenance. This technical solution utilizes a dual-segment isolation design to support remote firmware upgrades, reducing maintenance costs and improving system availability.

[0029] 5. Intuitive status feedback to enhance user experience: It uses 6 RGB LED display panels to indicate the status of 5 lasers in real time + 1 LED as a heartbeat and safety indicator, allowing users to intuitively monitor the operating status of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 This is the principle block diagram of the equipment board for this application;

[0031] Figure 2 This is the design drawing of the LED light board for this application; DETAILED DESCRIPTION

[0032] The term "embodiment" is used herein specifically to describe any embodiment as "exemplary," and should not be construed as superior or preferable to other embodiments. Performance indicators in the embodiments of this application were tested using conventional testing methods in the art, unless otherwise specified. It should be understood that the terms used in this application are intended solely to describe specific implementations and are not intended to limit the disclosure herein.

[0033] Unless otherwise specified, the technical and scientific terms used herein have the same meanings as commonly understood by ordinary technicians in the technical field to which this application belongs; other experimental methods and technical means not specifically specified in this application refer to experimental methods and technical means commonly used by ordinary technicians in this field.

[0034] As used herein, the terms "substantially" and "approximately" are used to describe small fluctuations. For example, they can refer to less than or equal to ±5%, such as less than or equal to ±2%, such as less than or equal to ±1%, such as less than or equal to ±0.5%, such as less than or equal to ±0.2%, such as less than or equal to ±0.1%, such as less than or equal to ±0.05%. Numerical data expressed or presented in range format herein are used for convenience and brevity only and should therefore be interpreted flexibly to include not only the values explicitly listed as the limits of the range, but also all independent values or subranges contained within the range. For example, a numerical range of "1-5%" should be interpreted to include not only the explicitly listed values of 1% to 5%, but also the independent values and subranges within the indicated range. Thus, included in this numerical range are independent values such as 2%, 3.5%, and 4%, and subranges such as 1% to 3%, 2% to 4%, and 3% to 5%, etc. This principle also applies to ranges that only list a single value. Furthermore, this interpretation applies regardless of the width of the range or the characteristics described.

[0035] Throughout this document, including in the claims, transitional terms such as "comprises," "includes," "with," "having," "contains," "involving," and "accommodating" are understood to be open-ended, meaning "including but not limited to." Only the transitional terms "consisting of" and "composed of" are closed transitional terms.

[0036] In order to better illustrate the content of this application, numerous specific details are provided in the specific examples below. It should be understood by those skilled in the art that this application can be implemented without certain specific details. In the examples, some methods, means, instruments, equipment, etc. well known to those skilled in the art are not described in detail in order to highlight the main purpose of this application.

[0037] Under the premise of no conflict, the technical features disclosed in the embodiments of the present application can be arbitrarily combined, and the resulting technical solutions belong to the contents disclosed in the embodiments of the present application. It should be noted that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like mentioned in this application indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the technical features and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application, unless it conflicts with the context. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance, unless it conflicts with the context.

[0038] The specific implementation methods of the present application are described below to facilitate understanding of the present application by those skilled in the art. However, it should be clear that the present application is not limited to the scope of the specific implementation methods. For those skilled in the art in the present technology, as long as various changes are within the spirit and scope of the present application as defined and determined by the attached claims, these changes are obvious, and all application creations based on the concept of the present application are protected.

[0039] Example

[0040] See also Figure 1 and Figure 2 In order to realize the multi-platform laser compatible control system based on the STM32 microcontroller platform proposed in this application, this application has made a customized design of the equipment board and LED light board.

[0041] This application provides an embodiment, and the specific implementation is as follows:

[0042] Three-segment startup process: Run the BootLoader program after power-on to check whether a firmware update is required. If the system's RCC register has a corresponding firmware upgrade flag, enter the firmware upgrade step, and then enter the program to jump to the BootLoader APP program segment; if there is no update requirement, jump to the BootLoader APP program segment, initialize the peripherals (HAL library, FreeRTOS scheduler), and verify the correctness of the APP program segment through XOR before jumping. If correct, adjust it. If an exception occurs in the APP program segment, check the backup APP firmware area. If correct, replace the firmware and complete the program jump startup. Otherwise, stay in the Bootloader program area and wait for firmware upgrade.

[0043] Command console data parsing architecture: When creating a user interaction port, a command storage system is created using xQueueCreate(uxQueueLength, uxItemSize). Data received by the serial port + DMA and USB is stored in the corresponding message queue. Commands are parsed by obtaining data from the corresponding message queues. To increase communication speed, characters '1' to 'Z' are defined as fast-processing commands, compatible with conventional command line commands. The command console is developed using the official CLI (Command Line Interface). Conventional commands end with the string "\r\n". If data ending with "\r\n" is detected, it is parsed and processed using the FreeRTOS_CLIProcessCommand function provided by FreeRTOS.

[0044] Data packet communication architecture: Utilizing a structured data packet communication architecture, all control instructions are encapsulated and parsed according to a proprietary data frame format. Compared to traditional single-character instructions or fixed-length command parsing methods, this architecture offers greater scalability, adapting to diverse protocol requirements and reducing ongoing maintenance costs. Each data packet includes key components such as a frame header, instruction type, header type, payload, checksum field, and extension field, ensuring standardized and reliable communication.

[0045]

[0046] Through the above improvements based on standardized data frames, the system can easily add new instruction types and be compatible with more frames of data without modifying the underlying parsing logic, thereby greatly improving the scalability of the instructions. When operating instructions, the following instructions can be used: (1) Read instruction (query device status): The instruction type is 0x02, which is used to query the working status of the laser (such as current power, temperature, mode, etc.). After receiving the read request, the device will return a data packet with the corresponding status information. (2) Write instruction (parameter setting): The instruction type is 0x01, which is used to set the working parameters of the laser, such as laser on / off status, upper computer laser safety, etc. After receiving the write request, the device extracts the type and extended data content to perform the corresponding write operation and returns information on whether the operation is successful. The data packet can quickly expand new instructions through a unified data packet structure without modifying the underlying communication code. (3) Heartbeat instruction (device online detection): The instruction type is 0x00. The device sends a heartbeat packet regularly. After receiving it, the upper computer returns a confirmation response to ensure the stability of the communication link. At the same time, the host computer also sends heartbeat packets regularly. The time in the heartbeat packet can be obtained to refresh the real-time time of the device and complete the time synchronization. (4) Interrupt data packet (abnormality and alarm notification): The instruction type is 0x04. When the device detects an abnormality (such as overtemperature, laser safety abnormality, current overload), it actively sends an interrupt data packet to the host computer to realize real-time fault alarm.

[0047] Introduce a data verification mechanism to improve data reliability: The XOR verification mechanism can effectively detect communication anomalies such as bit flipping, loss, and error insertion. The check field is located in the check field of the data packet, and the receiving end verifies the integrity of the data packet by calculating the XOR value. An additional data length field is introduced to ensure that data truncation does not occur during the parsing process. Key control instructions (such as laser switches) can adopt a two-way confirmation mechanism to avoid erroneous execution. After adopting the data packet architecture, system maintenance and upgrades are more convenient: new instructions do not require modification of the underlying logic. Since the data packet format is unified and standardized, adding new functions (such as new control instructions or status queries) only requires adding a header type without modifying the core code of the communication protocol, reducing maintenance costs. Before the data packet is sent, the system uses the BCC XOR verification communication verification algorithm to obtain the BCC value and fill it in the check field. The XOR verification algorithm specifically performs an XOR check on each byte of data to obtain a check code. The specific form of the check code XOR generation is:

[0048]

[0049] Among them, d i The i-th 32-bit uint32_t type data of the input.

[0050] System Heartbeat Mechanism: Based on FreeRTOS development, a heartbeat task function is created to periodically send device heartbeat information to the host computer. A software timer callback function is also created. The timer callback function is set to 1 second. Upon entering the callback function, the system's runtime is refreshed and the watchdog program is fed to ensure proper operation. If the watchdog is not fed in time, the program automatically restarts the system, resolving any unexpected restart issues and ensuring system reliability. The instruction receiving function is wired to the heartbeat data packets sent by the host computer, parsing and extracting the real-time time for synchronous refresh.

[0051] Safety Mechanism: This laser safety mechanism utilizes digital signal detection and a safety shutter blocking mechanism. This mechanism polls digital signal status values within a short period of time to determine whether a laser safety event has occurred. The collected digital signal is filtered to ensure signal reliability. A safety shutter with a color filter and a shutter switching mechanism blocks the laser light, which can be switched in 50ms. The device offers three laser safety features: key lock, interlock, and host laser safety. The key lock meets international laser safety standards. The interlock provides a ring-shaped digital signal detection mechanism that can be used to connect multiple laser safety signals in series, providing scalability. The host laser safety standard is compatible with third-party lower-level laser safety mechanisms, enhancing scalability. The safety shutter task continuously polls to determine whether the laser safety event has been triggered. If triggered, a PWM-like control method is used to switch the safety shutter within 50ms. The system collects temperature and power data in real time and uses an ARIMA model to predict trends over the next five seconds. If the predicted value exceeds the safety threshold (laser temperature > 80°C), the active protection mechanism is triggered to shut down the laser, shut down the laser and record the fault log. The user can query the fault information through the host computer and take corresponding measures. The specific form of the ARIMA model is as follows:

[0052] X t =μ+φ1X t-1 +φ2X t-2 +…+φ p X t-p +∈ t

[0053] Among them, μ is the mean, φ i is the model parameter, ∈ t is white noise.

[0054] Multi-platform laser and peripheral signal driver library: W25Q128 is used as an external storage flash to store device information (multi-platform laser and peripheral signal driver library), and the device information is acquired, parsed, and initialized in the main control task of power-on. The device information is divided into a device information block area with a data size of 512Byte, and is stored in W25Q128 according to the position serial number based on the number of device information. The data structure of each block of device information is 4+488Byte, and 4byte is the length of the current valid data. When the device information data is read subsequently, the entire block data is not required, and only the valid data is read out. The data format of the device information is in key-value pair format. The device information driver library supports modification and control by self-developed upper computer software. When a new laser is connected, the system reads the device information from the Flash and parses the protocol feature vector. Through similarity calculation, if the similarity is greater than 0.8, the existing adaptation logic is directly reused; otherwise, new adaptation logic is dynamically generated to ensure that the system can quickly adapt to lasers on different platforms. The similarity calculation method of the protocol feature vector is:

[0055]

[0056] Among them, P1 and P2 are the characteristic vectors of the two protocols respectively.

[0057] The data communication format was developed using a command console parsing data architecture. The data structure framework also uses the JSON data structure as the internal data format, enabling fast data parsing by both the device and host software, reducing parsing time. Modifying device information is divided into three instruction architectures: control instructions, read device information instructions, and write device information instructions. Modifying device information involves accessing and occupying public resources, necessitating appropriate resource scheduling strategies to ensure system stability and consistency. This can be mitigated by modifying certain logic criteria and suspending and unsuspending certain tasks. Control instructions (system mode switching): Before executing device information modifications, the system can adjust the operating mode (such as entering maintenance mode or safe mode) using control instructions to mitigate concurrent access to public resources and ensure data security. Read device information instructions (query mode): Utilizing a non-blocking mechanism, the system ensures secure access to device information in any state without impacting system operation. Write Device Information Instruction (Modify Mode): This write operation involves public resources and requires access control via a mutex or critical section to ensure write integrity. Furthermore, the device information verification function can be used to overwrite and restore the default configuration if a modification fails, enhancing system robustness. Before writing data, each new device information is verified for correctness to ensure the correct data, further enhancing device information security. The main task dynamically initializes the laser control structure, temperature data structure, and other structures by obtaining device information data. Each 512-byte block is read using the SPI communication protocol, reading the first 4 bytes of the first block of device information by address. After parsing the valid data length, the key device information is read again based on the valid data length and parsed. The corresponding structures are initialized by parsing the key-value pairs. After reading the first block, the address offset by 512 bytes is read to read the next block of device information. This process continues until the first 4 bytes of the device information are all 0xFF, indicating no new device information exists and the reading stops.

[0058] Independent control and parallel processing of multiple lasers. In the main task, device information data is parsed to dynamically initialize system resources such as the laser control structure and temperature data structure. A laser control task is then dynamically created based on the configuration parameters in the laser structure. This laser control task is specifically responsible for executing laser write operations, including common instructions such as on / off control, power adjustment, and operating mode switching. Creation and initialization of the independent laser control task architecture: The main task parses device information and dynamically creates independent laser control parallel tasks based on the laser model and configuration parameters. Each laser control task runs independently, processing the corresponding laser's write operation, preventing the main task from being blocked while waiting for laser responses and improving overall response efficiency. Inter-task semaphore synchronization mechanism: The laser control task uses two semaphores (an execution semaphore and a mutex semaphore) to achieve resource sharing and access control with the main task and other tasks. Execution semaphore (BinarySemaphore): After the main task parses the laser write instruction, it copies the data to the corresponding laser structure and releases the execution semaphore to notify the laser control task to proceed. Mutex: Before executing a write operation, the laser control task must successfully obtain a mutex to ensure safe access to public resources. Execution process: The main task parses the data packet: parses the laser write instruction and copies the data to the corresponding laser structure. Release the execution semaphore to notify the corresponding laser control task to execute. Laser control task: Wait for the execution semaphore to ensure that there are new instructions to be executed. After successfully obtaining the execution semaphore, continue to try to obtain the mutex semaphore. After successfully obtaining the mutex semaphore, perform the laser write operation (such as ON / OFF, power adjustment, etc.). After the write operation is completed, release the synchronization semaphore to allow subsequent tasks to continue to access public resources. When the system detects control requests for multiple lasers, the main task parses the data packet and creates the corresponding laser control task. Each task is scheduled according to priority to ensure that high-priority tasks (such as safety detection) are executed first. After the task is completed, release the mutex semaphore to allow subsequent tasks to continue to access public resources. The task priority calculation method is as follows:

[0059] Priority(T i )=α·RealTimeFactor(T i )+β·ResourceFactor(T i )

[0060] Among them, α and β are weight coefficients, generally α = 0.7, β = 0.3, RealTimeFactor represents the real-time nature of the task, and ResourceFactor represents the resource occupancy of the task.

[0061] LED control: The LEDs are connected via the SN74HC595PWR chip, an 8-bit shift register with a three-state output. Data sent via SPI changes the output pins, controlling the voltage levels of the LED pins and, consequently, the LED status display, displaying eight different colors. Two SN74HC595PWR chips connected in series can control a total of 16 pins, or six LEDs. A task-driven and event-triggered mechanism updates the LED status upon state changes, reducing CPU load. Sending 16-bit data via SPI simultaneously modifies the output data of both SN74HC595PWR chips, thereby controlling the status of all six LEDs. LED status update logic: LEDs 1 through 5 automatically update based on the laser status register. The latest laser status message is sent to the data buffer. LED 6 serves as the system heartbeat and safety indicator, sending data in a timed manner based on whether the latest data precedes the laser's intended data, thus providing a timed update of the LED board's status information.

[0062] In summary, this application addresses the shortcomings of traditional laser control systems in terms of compatibility, security, maintenance and upgrades, operational efficiency, and status monitoring. It proposes a highly compatible, secure, intelligent, and efficient laser control system. Through hardware optimization (multi-protocol support and real-time monitoring), software optimization (multi-tasking and remote maintenance), and enhanced visualization (LED indicator lights), this application effectively overcomes the shortcomings of traditional laser control systems and achieves comprehensive optimization of system performance.

[0063] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.

[0064] The technical solutions disclosed in this application and the technical details disclosed in the embodiments are merely illustrative of the application concept of this application and do not constitute a limitation on the technical solutions of this application. Any conventional changes, replacements or combinations of the technical details disclosed in the embodiments of this application have the same application concept as this application and are within the scope of protection of the claims of this application.

Claims

1. A multi-platform laser compatible control system based on the STM32 microcontroller platform, characterized by: The system comprises a hardware framework and a software framework. The hardware framework adopts the FreeRTOS real-time operating system architecture and includes a main control unit, a laser interface, a communication interface, and a security module. The main control unit adopts an STM32F4 with a main frequency of 180MHz. The laser interface provides multiple laser sub-interfaces. The communication interfaces include UART and USB for data exchange and high-speed data transmission with the host computer. The security module includes a shutter safety shutter interface, a temperature sensor, a laser safety sensor, an Interlock interlock, and a key lock. The shutter safety shutter interface controls the opening / closing state of the safety shutter based on the real-time status of the laser safety sensor, Interlock interlock, and key lock. The temperature sensor monitors the temperature of the laser and drive circuit. The laser safety sensor detects abnormal laser leakage in real time and triggers an emergency shutdown mechanism if laser leakage is detected. The software framework comprises a hardware abstraction layer (HAL), a middleware layer, an application layer, and a user interface layer. The hardware abstraction layer (HAL) encapsulates underlying hardware operations such as GPIO, UART, ADC / DAC, PWM, SPI, and provides a standardized API. The middleware layer includes FreeRTOS task management, communication signal management, and dynamic state machine control. The FreeRTOS task management implements multi-task parallel scheduling and improves system response speed. The communication protocol parses host computer instructions including heartbeat packets, remote upgrades, and status queries, and uses an XOR check mechanism to verify communication reliability. The dynamic state machine control implements multiple instructions to control the operations of the lower computer in an orderly manner. The application layer includes a laser control module, a status monitoring module, and a security protection module. The user interface layer provides an internal API interface, including remote firmware upgrades, real-time device status queries, and LED light board status information.

2. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The FreeRtos operating system adopts a three-segment architecture, including A / B / C partitions: Partition A is the Bootloader program segment, which is allocated an address of 0x0800000-0x801FFFF by the compiler and a space of 0KB-128KB of internal flash storage space; Partition B is the Bootloader APP program segment, which is allocated an address of 0x8020000-0x809FFFF by the compiler and a space of 128KB-640KB of internal storage space; Partition C is the Bootloader BACK APP program segment, which is allocated an address of 0x80A0000-0x80FFFFF by the compiler and allocates the remaining internal storage space. The BootLoader program segment is independently responsible for firmware updates and is completely separated from the business logic to ensure that the upgrade process does not interfere with system operation (address range: 0x08000000-0x0801FFFF). The BootLoader APP program segment serves as the main control module, responsible for laser control, user interaction, and real-time monitoring (address range: 0x08020400-0x080A03FF). The BootLoader BACK APP program segment stores the backup APP program and can be used to repair the BootLoader APP program.

3. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The communication protocol parsing includes parsing the command console data architecture and the data packet communication architecture. The FreeRTOS operating system is compatible with both data communication architectures. Data packet types represent primary data interaction commands, while command console data represents commands used during debugging or testing. The communication protocol parsing includes the following steps: S1. Creating a command parsing and processing console task. Based on the user-created interactive serial port, the corresponding command processing task is initiated. Data from the serial port and USB module are acquired via UART+DMA, using a serial port baud rate of 115200 bps. S2. After acquiring data via the serial port UART+DMA, a 512-byte DMA data buffer is created, using a double-buffered data storage method for a total of 1 KB of buffer space. When the DMA triggers a halfway data interrupt or an idle interrupt, a callback function is triggered to acquire the data received from the serial port. The acquired data is then stored in the corresponding message queue. Excessive data can lead to packet loss, so the DMA buffer size and message queue length must be appropriately allocated based on actual usage. Incoming commands are processed sequentially using a first-in, first-out principle. S3. The parsed data is promptly notified to other tasks via semaphores for rapid processing. During the parsing process, a system heartbeat mechanism is used to detect the health status of the communication link. The system heartbeat mechanism mainly includes a heartbeat data packet. The heartbeat data packet uses a minimized payload and only contains a frame header, instruction type, header type, length field, and check field. The heartbeat data packet also has an extended heartbeat data packet that carries user data. The extended heartbeat data packet adds an extended field on the basis of the original heartbeat data packet and can carry specific user data according to actual needs. The communication protocol parsing also includes a BCC XOR check communication check algorithm for detecting and correcting errors in data packets. The XOR check algorithm specifically performs an XOR check on each byte of data to obtain a check code. The specific form of the check code XOR generation is: Among them, d i The i-th 32-bit uint32_t type data of the input.

4. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The laser control module reads configuration data such as laser device information, analog signal parameters, temperature sensor data, and digital signal status stored in external Flash memory, and dynamically parses and adapts to different laser protocols during system startup, achieving intelligent initialization and task management. The laser control module includes the following steps: S1. External Flash device information parsing and dynamic adaptation: Non-volatile storage (External Flash) is used to record laser device parameters, including communication protocol, control mode, power range, and status feedback format. By reading and parsing Flash device information during system startup, it automatically adapts to laser models from different manufacturers. S2. Dynamic task creation and resource optimization scheduling: Based on the device type, operating mode, and communication protocol parsed from Flash memory, corresponding control tasks are dynamically created, and the control system only allocates necessary resources. S3. FreeRTOS task management mechanism: Task priorities are automatically adjusted based on the protocol characteristics of different lasers, enabling efficient processing and rapid instruction response. S4. Multi-channel analog signal control and data acquisition: During analog signal acquisition, analog data from external photodetectors, temperature sensors, and other devices are collected in real time, and closed-loop control is performed in combination with laser feedback data. When digital signal monitoring and event triggering occur, the digital signal monitoring points are recorded through external Flash, and GPIO is dynamically configured for laser status monitoring, external trigger control, and optical shutter safety linkage functions.

5. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The laser control module's external Flash device information parsing and dynamic adaptation steps also include an adaptation algorithm based on dynamic protocol parsing. The adaptation algorithm inputs the device information stored in the external Flash, then uses a fuzzy matching algorithm to calculate the similarity of the protocol feature vectors, dynamically parses the laser's communication protocol, and generates the corresponding adaptive control logic. The protocol feature vector similarity calculation method is: Among them, P1 and P2 are the characteristic vectors of the two protocols respectively.

6. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The laser control module's dynamic task creation and resource optimization scheduling steps also include a priority-based multi-task scheduling algorithm. The multi-task scheduling algorithm calculates task priorities in real time by receiving specific task types, and dynamically adjusts priorities based on the task's real-time nature and resource usage to optimize the task scheduling order. The task priority calculation method is as follows: Priority(T i )=α·RealTimeFactor(T i )+β·ResourceFactor(T i ) Among them, α and β are weight coefficients, RealTimeFactor represents the real-time nature of the task, and ResourceFactor represents the resource occupancy of the task. Generally, α = 0.7 and β = 0.

3.

7. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The laser control module adopts an independent task architecture. After the main task completes data parsing, the instructions are packaged and processed according to the laser category. The independent task architecture has the following functional modules:

1. Independent task scheduling module. Through the task priority scheduling mechanism, the efficiency of instruction processing is ensured to avoid instruction blocking during the laser control process.

2. Adaptive instruction execution management module. Through data parsing and task parallel processing, the main task is responsible for receiving and parsing data packets and extracting laser-related instructions. Based on the parsing results, the subtasks process the control commands of different types of lasers respectively to achieve parallel execution.

3. Task preemption and real-time performance guarantee module. Using multi-task scheduling based on FreeRTOS, the main task will not be blocked by subtasks during execution, the core control instructions are processed in a timely manner, and the real-time performance of the system will not be affected by the delayed execution of secondary tasks.

4. Instruction hierarchical processing module. Using a hierarchical architecture of main task + laser subtask, the main task is only responsible for instruction parsing and task scheduling, and laser control is completed in independent tasks.

8. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The state monitoring module includes a fault prediction and active protection algorithm. It is used to monitor the laser status in real time and predict potential faults. The fault prediction algorithm uses an ARIMA model to predict the trend of sensor data based on temperature, power, and current sensor data using a time series analysis model. This allows for real-time monitoring of the laser status and prediction of potential faults. The ARIMA model is specifically formulated as follows: X t =μ+φ1 X t-1 +φ2 X t-2 +…+φ p X t-p +∈ t Among them, μ is the mean, φ i is the model parameter, ∈ t is white noise.

9. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The safety protection module includes a safety mechanism that employs triple safety checks: key lock status (ON / OFF), interlock digital signal, and host computer safety standards. A safety shutter rapidly isolates laser light, while the signal synchronously records fault events and creates a fault log.

10. The multi-platform laser compatible control system based on the STM32 microcontroller platform according to claim 1, characterized in that: The LED light board status information is displayed on the LED control board. The LED control board consists of six three-primary-color LEDs, which are used to indicate the laser status and system operation status in real time. Five of the three-primary-color LEDs correspond to the maximum five lasers supported by the system, displaying their respective status information. The remaining LED lamp bead is used as a heartbeat data and laser safety indicator to display the system operation status and indicate the laser safety status.

Citation Information

Cited By

  • Method and device for managing JBOG by BMC

    CN122111801A