Dual-processor hot backup AD acquisition system and method
Through the dual-processor hot backup AD acquisition system, the GPIO interconnection and bus access between processors is used to solve the problems of poor real-time acquisition and high circuit complexity in the existing technology, and efficient and reliable AD acquisition is achieved, reducing the Risk of data loss.
Patent Information
- Application Number
- CN202410992224.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-29
AI Technical Summary
The existing AD acquisition system has poor real-time acquisition performance during the acquisition process, and additional isolation drive devices are needed to achieve time-sharing access, resulting in complex circuit and high cost problems.
The AD acquisition system adopts dual processor hot backup, through the GPIO interconnection between the first processor and the second processor, uses SPI or I2C bus to access the AD acquisition chip in time, ensuring that the other processor is abnormal when one processor is abnormal. The processor can run independently and access the AD acquisition chip.
It improves the real-time and accuracy of acquisition, realizes dual-machine hot backup, reduces circuit complexity and cost, and ensures data integrity and consistency.
Smart Images

Figure CN119046059A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of AD acquisition, and relates to an AD acquisition system and method with dual-processor hot backup. Background Art
[0002] In actual engineering applications, it is necessary to convert electrical signal analog quantities such as current or voltage, as well as non-electrical signal analog quantities such as pressure, temperature, humidity, displacement, and sound into digital signals. By collecting the above parameters, the operating status of the equipment can be mastered and tracked, and then the equipment can be analyzed and diagnosed.
[0003] Existing AD acquisition usually involves a single machine communicating with an AD acquisition chip, reading the AD acquisition results, and sending the acquisition results to another single machine through a communication interface. However, during the acquisition process, based on the single machine accessing the AD acquisition chip, there is a problem of poor real-time acquisition. When one of the single machines works abnormally, the other single machine cannot obtain the AD acquisition results, and the dual-machine backup function cannot be realized.
[0004] Chinese patent CN104579343A discloses a dual-chip shared serial A / D conversion circuit, including single-chip A, single-chip B, an isolation drive device and a serial A / D converter; single-chip A and single-chip B are connected in serial communication, the serial A / D converter is connected to the isolation drive device, the isolation drive device is respectively connected to single-chip A and single-chip B, the isolation drive device isolates the serial A / D converter from the two single-chips, single-chip A and single-chip B connect the serial A / D converter by alternately controlling the isolation drive device, and control the serial A / D converter to obtain sampling data. However, the problem is that an additional isolation drive device is required to achieve time-sharing access, the circuit is complex and the cost is high. Summary of the invention
[0005] In view of the deficiencies in the prior art, the purpose of the present invention is to provide a dual-processor hot-backup AD acquisition system and method to solve the technical problems of poor real-time performance of AD acquisition during the acquisition process, the need for additional isolation drive devices to achieve time-sharing access, complex circuits and high costs.
[0006] In order to achieve the above object, the present invention adopts the following technical solution:
[0007] The present invention provides an AD acquisition system with dual-processor hot backup, comprising a first processor, a second processor and an AD acquisition chip; the first processor, the second processor and the AD acquisition chip; the GPIO1 output by the first processor is connected to the GPIO2 input by the second processor, and the GPIO1 output by the second processor is connected to the GPIO2 input by the first processor; the first processor and the second processor access the AD acquisition chip through a bus, and the first processor and the second processor can operate independently.
[0008] Furthermore, the first processor and the second processor access the AD acquisition chip through the bus, including: the first processor and the second processor access the AD acquisition chip through the SPI bus or I 2 The C bus is connected to the AD acquisition chip and accesses the AD acquisition chip.
[0009] The present invention also provides an AD acquisition method with dual-processor hot backup, the AD acquisition method comprising: a first processor accesses an AD acquisition chip, and a second processor accesses the AD acquisition chip; the first processor accesses the AD acquisition chip comprising: the first processor checks whether the GPIO2 input by the second processor to the first processor is at a low level, if it is at a low level, the second processor is not accessing the AD acquisition chip, the first processor sets the output GPIO1 to a high level, the first processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
[0010] Furthermore, the first processor accessing the AD acquisition chip also includes: the first processor checks whether the GPIO2 input by the second processor to the first processor is at a low level. If it is at a high level, the second processor is accessing the AD acquisition chip, the first processor waits, and cyclically detects the status of the input to GPIO2. After the second processor access ends and the status of GPIO2 is low, the first processor sets the output GPIO1 to a high level, the first processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
[0011] Furthermore, the second processor accesses the AD acquisition chip, including: the second processor checks whether the GPIO2 input by the first processor to the second processor is at a low level; if it is at a low level, the first processor is not accessing the AD acquisition chip, the second processor sets the output GPIO1 to a high level, the second processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
[0012] Furthermore, the second processor accessing the AD acquisition chip also includes: the second processor checks whether the GPIO2 input by the first processor to the second processor is at a low level. If it is at a high level, the first processor is accessing the AD acquisition chip, the second processor waits, and cyclically detects the status of the input to GPIO2. After the first processor access ends and the status of GPIO2 is low, the second processor sets the output GPIO1 to a high level, and the second processor starts to access the AD acquisition chip. When the access ends, the output GPIO1 is set to a low level.
[0013] Furthermore, if one of the first processor and the second processor works abnormally, the other processor will start to access the AD acquisition chip after the preset time after cyclically detecting that the input GPIO2 is always at a high level within the preset time.
[0014] Furthermore, before the first processor accesses the AD acquisition chip, it also includes: the first processor initializes the output GPIO1 to the output mode and sets GPIO1 to a low level; before the second processor accesses the AD acquisition chip, it also includes: the second processor initializes the output GPIO1 to the output mode and sets GPIO1 to a low level.
[0015] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the device is special in that when the processor executes the computer program, the steps of the AD acquisition method with dual processor hot backup described in any one of the above items are implemented.
[0016] The present invention also provides a computer-readable storage medium, which stores a computer program. The special feature of the computer program is that when the computer program is executed by a processor, the steps of the dual-processor hot backup AD acquisition method described in any one of the above are implemented.
[0017] Compared with the prior art, the present invention has the following beneficial technical effects:
[0018] In the dual-processor hot backup AD acquisition system of the present invention, both the first processor and the second processor can access the AD acquisition chip, thereby improving the real-time performance of the acquisition and realizing dual-machine hot backup. In addition, one of the first processor and the second processor can run independently without the other processor.
[0019] The present invention discloses a dual-processor hot-backup AD acquisition system, in which a first processor and a second processor are interconnected through GPIO1 and GPIO2 to achieve time-sharing access of the two processors to an AD acquisition chip, thereby avoiding bus abnormalities caused by the two processors accessing the AD acquisition chip at the same time and improving the accuracy and reliability of AD acquisition.
[0020] The invention discloses an AD acquisition method with dual processor hot backup, wherein the codes of the first processor and the second processor are consistent, thereby improving the operability of code burning and the system reliability.
[0021] The invention provides an AD acquisition method with dual processor hot backup, in which data and status information of a first processor and a second processor are synchronized in real time to ensure the integrity and consistency of data during the switching process, thereby reducing the risk of data loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a functional block diagram of a dual-processor hot backup AD acquisition system of the present invention;
[0023] Figure 2 It is a functional block diagram of a dual program-controlled power supply in an embodiment of the present invention;
[0024] Figure 3 A schematic diagram of a power supply in an embodiment of the present invention;
[0025] Figure 4 1 is a step diagram of a cyclic detection mechanism of the first processor and the second processor in an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] Example 1
[0028] like Figure 1 As shown, the present invention is a dual-processor hot backup AD acquisition system, including a first processor, a second processor and an AD acquisition chip, GPIO1 output by the first processor is connected to GPIO2 input by the second processor, GPIO1 output by the second processor is connected to GPIO2 input by the first processor, the first processor and the second processor are interconnected with the AD acquisition chip through a bus, and the AD acquisition chip is accessed, thereby improving the real-time performance of the acquisition, and at the same time, the first processor or the second processor can be separated from the other processor and run independently, thereby realizing dual-machine hot backup. In addition, the AD acquisition chip is accessed in a time-sharing manner through the IO port between the first processor and the second processor for reading and writing, thereby avoiding the bus abnormality problem caused by simultaneous access to the AD acquisition chip, improving the accuracy and reliability of AD acquisition, and reducing the circuit complexity and cost.
[0029] Based on a dual-processor hot backup AD acquisition system, a power supply was developed. Figure 2 As shown in the figure, the power supply converts the +28V input into +12V output through DC / DC isolation. The output voltage and current enter the AD acquisition chip after the conditioning circuit. The AD acquisition chip performs analog / digital conversion on the input voltage signal and sends the conversion result to processor A and processor B. The processor finally reports the voltage and current information to the host computer through the CAN bus. Among them, processor A and processor B use CS32F103CB microcontrollers, and the AD acquisition chip uses LC2991-A. Processor A, processor B and AD acquisition chip are connected through I 2 C bus interconnect, I 2 The C bus includes the SCL clock line and the SDA data line. Processor A and processor B act as master devices, and the AD acquisition chip acts as a slave device.
[0030] A power supply principle such as Figure 3 As shown in the figure, SDA is connected to the PB11 pin of MCU A and MCU B, and SCL is connected to the PB10 pin of MCU A and MCU B. V1 is the GLb1250 chip, which is I 2 C bus isolator, realize electrical isolation between LC2991-A and MCU. Pin 1 of V2 is connected to the collection point of 12V output voltage, which is single-ended collection, pins 3 and 4 are connected to the collection point of 12V output current, which is differential collection, pins 13, 14, and 15 are all grounded, then the address of LC2991-A is 0X90.
[0031] Example 2
[0032] A dual-processor hot backup AD acquisition method includes: a first processor accesses an AD acquisition chip, and a second processor accesses the AD acquisition chip; the first processor accesses the AD acquisition chip including two situations: the second processor does not access the AD acquisition chip and the second processor is accessing the AD acquisition chip; the second processor accesses the AD acquisition chip including two situations: the first processor does not access the AD acquisition chip and the first processor is accessing the AD acquisition chip.
[0033] First, initialize the GPIO1 output by the first processor to output mode and set GPIO1 to a low level. When the first processor accesses the AD acquisition chip, first check whether the GPIO2 input by the second processor to the first processor is at a low level. If it is at a low level, the second processor is not currently accessing the AD acquisition chip. The first processor sets the output GPIO1 to a high level, and the first processor starts to access the AD acquisition chip. After the access is completed, the first processor sets the output GPIO1 to a low level.
[0034] If it is checked that the GPIO2 input by the second processor to the first processor is at a high level, the second processor is accessing the AD acquisition chip. The first processor waits and cyclically detects the status of the input to GPIO2. After the second processor completes the access and the status of GPIO2 is low, the first processor sets the output GPIO1 to a high level, and the first processor starts to access the AD acquisition chip. After the access is completed, the first processor sets the output GPIO1 to a low level.
[0035] First, initialize the GPIO1 output by the second processor to output mode and set GPIO1 to a low level. When the second processor accesses the AD acquisition chip, first check whether the GPIO2 input by the first processor to the second processor is at a low level. If it is at a low level, the first processor is not currently accessing the AD acquisition chip. The second processor sets the output GPIO1 to a high level and starts accessing the AD acquisition chip. After the access is completed, the second processor sets the output GPIO1 to a low level.
[0036] If it is checked that the GPIO2 input from the first processor to the second processor is at a high level, the first processor is accessing the AD acquisition chip, then the second processor enters a waiting state and cyclically detects the state of the input to GPIO2. After the first processor access is completed and the state of GPIO2 is low, the second processor sets the output GPIO1 to a high level, and the second processor starts to access the AD acquisition chip. After the access is completed, the second processor sets the output GPIO1 to a low level.
[0037] When the first processor and the second processor access the AD acquisition chip, one of the first processor and the second processor will work abnormally. If the other processor detects that the input GPIO2 is always high within a preset time, it will start to access the AD acquisition chip after the preset time. The first processor and the second processor have the same cyclic detection process for accessing the AD acquisition chip. Take the first processor as an example. Figure 4 shown.
[0038] First, the program starts and enters the "delay" stage, the time is 1ms, then the first processor checks the state of the GPI02 pin input to the first processor by the second processor, if the GPI02 pin is not low level or timeout state, the program will jump to the "delay" stage, if the GPI02 pin is low level or timeout state, the program will set GPI01 high, where the timeout is 50ms, then configure the AD acquisition chip, pull GPI01 low, the timer starts timing, the timing period is the sampling period, set to 500ms, once the timer reaches the set time, it will trigger the "timer clear" stage , clear the timer and restart the timing, enter the "delay" stage, the time is the loop detection cycle, set to 1ms, in the "delay" stage, the program will check the status of the GPI02 pin again, and decide whether to continue based on its status. If the GPI02 pin is low or in a timeout state, the program will set GPI01 high, with a timeout of 200ms, and then read the AD acquisition result. After reading, pull GPI01 low. If the GPI02 pin is not low or in a timeout state, the program will jump to the "delay" stage. Finally, when the acquisition is completed, it will wait for the timing cycle to expire again and start a new round of acquisition.
[0039] In a power supply, the GPIO1 of processor A and processor B uses GPIOA9, and the GPIO2 uses GPIOA10.
[0040] The process of configuring LC2991-A is as follows: the MCU first sends the 7-bit slave address (0X90), and after LC2991-A confirms it, it sends the internal configuration register address and configuration value to LC2991-A. Configure the 0x06 register to 0x10, that is, V3-V4 is differential sampling, and V1 is single-ended sampling; configure the 0x08 register to 0x10, that is, repeated sampling mode; configure the 0x01 register to 0x30, that is, V1 and V3-V4 are enabled. The process of segmenting the MCU to read the AD acquisition results is as follows: the MCU first sends the 7-bit slave address (0X90) and the register address (0X0A and 0XOB) that stores the internal voltage acquisition value to LC2991-A, and the MCU then sends the 7-bit slave address (0X90), LC2991-A confirms and sends the contents of the requested register (0X0A and 0XOB) to the MCU, so that the MCU obtains the AD acquisition value of the voltage. The AD acquisition value of the current can also be obtained in the same way. The current register addresses are 0X10 and 0X11. The acquisition value is averaged and filtered five times and then converted according to the conversion formula to finally obtain the actual output voltage value and output current value.
[0041] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the device is special in that when the processor executes the computer program, the steps of the dual-processor hot backup AD acquisition method described in any one of the above embodiments are implemented.
[0042] In another embodiment of the present invention, a terminal device is provided, the terminal device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, which are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding functions; the processor described in the embodiment of the present invention can control the operation of the AD acquisition method of dual-processor hot backup.
[0043] The present invention also provides a computer-readable storage medium, which stores a computer program, characterized in that when the computer program is executed by a processor, the steps of the dual-processor hot backup AD acquisition method described in any one of the above embodiments are implemented.
[0044] In another embodiment of the present invention, the present invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It is understandable that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the AD acquisition method for dual-processor hot backup in the above embodiment.
[0045] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0046] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0047] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0048] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0049] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
Claims
1. A dual-processor hot backup AD acquisition system, characterized in that: include: A first processor, a second processor and an AD acquisition chip; The GPIO1 output by the first processor is connected to the GPIO2 input by the second processor, and the GPIO1 output by the second processor is connected to the GPIO2 input by the first processor; The first processor and the second processor access the AD acquisition chip through a bus, and the first processor and the second processor can operate independently.
2. The dual-processor hot backup AD acquisition system according to claim 1, characterized in that: The first processor and the second processor access the AD acquisition chip through the bus, including: The first processor and the second processor are connected via the SPI bus or I 2 The C bus is connected to the AD acquisition chip and accesses the AD acquisition chip.
3. A dual-processor hot backup AD acquisition method, characterized in that: The AD acquisition method comprises: a first processor accesses an AD acquisition chip, and a second processor accesses an AD acquisition chip; The first processor accesses the AD acquisition chip, including: the first processor checks whether the GPIO2 input by the second processor to the first processor is at a low level; if it is at a low level, the second processor is not accessing the AD acquisition chip, the first processor sets the output GPIO1 to a high level, the first processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
4. The AD acquisition method with dual processor hot backup according to claim 3, characterized in that: The first processor accessing the AD acquisition chip also includes: the first processor checks whether the GPIO2 input by the second processor to the first processor is at a low level. If it is at a high level, the second processor is accessing the AD acquisition chip, the first processor waits, and cyclically detects the status of the input to GPIO2. After the second processor access ends and the status of GPIO2 is low, the first processor sets the output GPIO1 to a high level, the first processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
5. The AD acquisition method of dual processor hot backup according to claim 3, characterized in that: The second processor accesses the AD acquisition chip, including: the second processor checks whether the GPIO2 input by the first processor to the second processor is at a low level. If it is at a low level, the first processor is not accessing the AD acquisition chip, the second processor sets the output GPIO1 to a high level, the second processor starts to access the AD acquisition chip, and sets the output GPIO1 to a low level when the access ends.
6. The AD acquisition method with dual processor hot backup according to claim 5, characterized in that: The second processor accessing the AD acquisition chip also includes: the second processor checks whether the GPIO2 input by the first processor to the second processor is at a low level. If it is at a high level, the first processor is accessing the AD acquisition chip, the second processor waits, and cyclically detects the status of the input to GPIO2. After the first processor access ends and the status of GPIO2 is low, the second processor sets the output GPIO1 to a high level, and the second processor starts to access the AD acquisition chip. When the access ends, the output GPIO1 is set to a low level.
7. The AD acquisition method with dual processor hot backup according to claim 3, characterized in that: The AD acquisition method further comprises: One of the first processor and the second processor works abnormally. If the other processor detects that the input GPIO2 is always at a high level within a preset time, it will start to access the AD acquisition chip after the preset time.
8. The AD acquisition method with dual processor hot backup according to claim 3, characterized in that: Before the first processor accesses the AD acquisition chip, the first processor also includes: initializing the output GPIO1 to an output mode and setting GPIO1 to a low level; Before the second processor accesses the AD acquisition chip, the second processor also initializes the output GPIO1 to an output mode and sets GPIO1 to a low level.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the dual-processor hot-standby AD acquisition method as claimed in any one of claims 3 to 8 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the dual-processor hot-standby AD acquisition method as claimed in any one of claims 3 to 8 are implemented.
