A method and device for receiving a timing signal
By using the serial communication module of the equipment in the system, the reception and processing of time-system signals are realized, and the problems of large redundancy of special time-system board functions and small structure equipment adaptation are solved, and the simple reception and real-time response of time-system signals are realized, reducing the problem of time-system signals. Equipment cost and volume.
Patent Information
- Application Number
- CN202111238274.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-10-25
AI Technical Summary
In the prior art, the system board function is very redundant when configured specifically in the prior art, and it is not suitable for equipment with smaller structures, making it difficult to meet the time response requirements.
By using the CPU on-board serial port or serial port expansion board of the equipment in the system, determine the serial port type and perform RS-422 or RS-232 type conversion, the reception and processing of time-based system signals are realized, and the dependence on special time-based system boards is reduced.
It realizes a simple method of receiving time-system signals, which is suitable for a variety of real-time control systems, reduces equipment cost and volume, and improves equipment reliability.
Smart Images

Figure CN114201216B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of time synchronization signals, and in particular to a method and device for receiving time synchronization signals. Background Art
[0002] Existing control systems all use time synchronization when time response requirements are high. All devices in the system respond to the time synchronization signal within the system. The system is equipped with dedicated time synchronization equipment to provide a unified time synchronization source for the devices in the system. Currently, all devices that respond to time synchronization use powerful and dedicated time synchronization boards. This type of time synchronization board can modify the control program according to user needs, receive or generate time synchronization signals of different frequencies and duty cycles, and meet the requirements of different systems for time synchronization signals. This type of time synchronization board can be used as the active party of time synchronization control, and also has the function of passively receiving time synchronization pulses. However, as a single machine in the system, equipped with such a time synchronization board, firstly, the functional redundancy is too large, and secondly, it is not suitable for some smaller devices. Summary of the invention
[0003] In order to solve the above technical problems, the present invention proposes a method and device for receiving timing signals, which are used to solve the technical problem that when a timing board is specially configured in the prior art, the functional redundancy is large and it is not suitable for installation on some smaller devices.
[0004] According to a first aspect of the present invention, a method for receiving a timing signal is provided, the method comprising the following steps:
[0005] Step S101: Determine the serial port type of the device in the system that responds to the timing signal, the serial port of the device in the system that responds to the timing signal is the CPU onboard serial port of the device or the onboard serial port of the serial port expansion board; if the serial port type is RS-422, proceed to step S102; if the serial port type is RS-232, proceed to step S103;
[0006] Step S102: Connect the differential signal +, differential signal - and end line of the external timing source to the CTS+, CTS- and end line of the serial port of the device in the system; proceed to step S104;
[0007] Step S103: Perform timing pulse type conversion, connect the differential signal +, differential signal - and end line of the external timing source to the +, - and end lines of the RS-422 type conversion board, and then connect the output signal CTS and end line of the RS-422 type conversion board to the CTS and end lines of the serial port of the device in the system;
[0008] Step S104: Initialize the serial ports of the devices in the system;
[0009] Step S105: The CPU monitors, and when an interrupt is detected, responds to the interrupt, and reads the interrupt identification register (IIR) information;
[0010] Step S106: First, determine whether the interrupt is caused by the change of the Modem state; if so, proceed to step S107; if not, perform a second determination, the content of the second determination is: whether the interrupt is caused by receiving communication data or the sending register is empty, if the result of the second determination is yes, perform corresponding processing; if the result of the second determination is no, exit the interrupt, and this processing is completed;
[0011] Step S107: respond to the interrupt caused by the modem status change, that is, read the modem status register, first determine the modem status change information, and then determine the CTS status information. If it is a CTS signal rising delay signal, enter the timing signal processing program; otherwise, exit the interrupt and complete this processing.
[0012] According to a second aspect of the present invention, there is provided a device for receiving a timing signal, the device comprising:
[0013] A serial port unit, the serial port unit is located on a CPU board or a serial port expansion board, and is used to realize the function of the device in the system responding to the timing signal responding to the timing signal of an external timing source;
[0014] An interface type determination module, which is connected to the connection module and the type conversion module, and is used to determine whether a type conversion module is needed; if the interface type is RS-422, the connection module is directly triggered; otherwise, the interface type determination module needs to trigger the type conversion module;
[0015] Type conversion module, connected to the CPU board or serial port expansion board, used to realize differential signal conversion;
[0016] A connection module, connected to the external timing signal and the interface type determination module, for enabling the CPU to receive the external timing signal;
[0017] Initialization module, used to initialize the serial port of the CPU board or serial port expansion board, set the EDSSI bit of the interrupt enable register IER to 1, enable the Modem status interrupt, and generate an interrupt when the MODEM status changes;
[0018] The interrupt response module adopts the interrupt mode. When the differential signal of the system has a rising edge or a falling edge, it responds to the interrupt response program;
[0019] The judgment module is used to judge the rising edge and falling edge of the timing signal. If it is a rising edge, the response module is triggered; if it is a falling edge, the interrupt response program is exited;
[0020] The response module is used for real-time control of the device and releases control signals according to the device function.
[0021] According to the above scheme of the present invention, a simple method for passively receiving a timing signal is provided, which is applicable to the in-system equipment that responds to the timing signal. The present invention utilizes the existing serial communication module of the in-system equipment that responds to the timing signal to realize the function of responding to the timing signal, and there is no need to configure a special timing board in the in-system equipment that responds to the timing signal. The present invention can be applied to a variety of real-time control systems; the method for receiving a timing signal according to the present invention can reduce the equipment cost, and improve the reliability of the equipment by reducing the equipment components, which is a good choice for smaller equipment.
[0022] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention, and the present invention is described by providing the following accompanying drawings. In the accompanying drawings:
[0024] Figure 1 A schematic diagram of a flow chart of a method for receiving a timing signal according to an embodiment of the present invention;
[0025] Figure 2 This is a wiring diagram of an RS-422 interface type according to an embodiment of the present invention;
[0026] Figure 3 This is a wiring diagram of an RS-232 interface type according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] First combine Figure 1 A method flow for receiving a timing signal according to an embodiment of the present invention is described, and the method comprises the following steps:
[0028] Step S101: Determine the serial port type of the device in the system that responds to the timing signal, the serial port of the device in the system that responds to the timing signal is the CPU onboard serial port of the device or the onboard serial port of the serial port expansion board; if the serial port type is RS-422, proceed to step S102; if the serial port type is RS-232, proceed to step S103;
[0029] Step S102: Connect the differential signal +, differential signal - and end line of the external timing source to the CTS+, CTS- and end line of the serial port of the device in the system; proceed to step S104;
[0030] Step S103: Perform timing pulse type conversion, connect the differential signal +, differential signal - and end line of the external timing source to the +, - and end lines of the RS-422 type conversion board, and then connect the output signal CTS and end line of the RS-422 type conversion board to the CTS and end lines of the serial port of the device in the system;
[0031] Step S104: Initialize the serial ports of the devices in the system;
[0032] Step S105: The CPU monitors, and when an interrupt is detected, responds to the interrupt, and reads the interrupt identification register (IIR) information;
[0033] Step S106: First, determine whether the interrupt is caused by the change of the Modem state; if so, proceed to step S107; if not, perform a second determination, the content of the second determination is: whether the interrupt is caused by receiving communication data or the sending register is empty, if the result of the second determination is yes, perform corresponding processing; if the result of the second determination is no, exit the interrupt, and this processing is completed;
[0034] Step S107: respond to the interrupt caused by the modem status change, that is, read the modem status register, first determine the modem status change information, and then determine the CTS status information. If it is a CTS signal rising delay signal, enter the timing signal processing program; otherwise, exit the interrupt and complete this processing.
[0035] Furthermore, the method also includes, if multiple serial ports use a shared interrupt number mechanism, it is necessary to determine whether the serial port where the interrupt occurs is the current serial port.
[0036] Furthermore, in this embodiment, there is no requirement on the serial port baud rate.
[0037] In the step S101, the system that responds to the timing signal is an independent, closed system with a fire control solution function. The in-system device that responds to the timing signal is, for example, a tracking radar or a fire control console in a certain type of fire control solution system. The serial port of the in-system device that responds to the timing signal is the onboard serial port of the CPU or the onboard serial port of a serial port expansion board. For example, the serial port of the CPU in the in-system device that responds to the timing signal receives the timing signal sent by the external timing source, thereby realizing the function of the in-system device that responds to the timing signal responding to the timing signal of the external timing source.
[0038] In this embodiment, the external timing source may be a timing board or an auxiliary device of the system.
[0039] In this embodiment, the timing signals provided by the external timing source all adopt the RS-422 level standard.
[0040] like Figure 2-3 As shown in the figure, because the external timing source is of RS-422 type, if the serial port type is RS-422, the interface type is consistent, so the timing signal can be directly connected to the device without any signal conversion circuit. If the serial port type is RS-232, the timing pulse type conversion is required before it can be connected to the serial port CTS signal.
[0041] The step S104: initializing the serial ports of the devices in the system includes:
[0042] Set the EDSSI control bit of the interrupt enable register IER of the CPU onboard serial port or the onboard serial port of the serial port expansion board to 1. At this time, the Modem status interrupt is enabled.
[0043] In this embodiment, the EDSSI control bit of the interrupt enable register (IER) is set to 1, at which time the Modem status interrupt is enabled, and an interrupt is generated when the Modem status changes.
[0044] Step S105: the CPU monitors, and when an interrupt is detected, responds to the interrupt, and reads the interrupt identification register (IIR) information;
[0045] Step S106: First, determine whether the interruption is caused by the change of the Modem state; if so, proceed to step S107; if not, perform a second determination, the content of which is: whether the interruption is caused by receiving communication data or the sending register is empty. If the result of the second determination is yes, perform corresponding processing; if the result of the second determination is no, exit the interruption;
[0046] Step S107: respond to the interrupt caused by the change of the modem status, that is, read the modem status register, first determine the modem status change information, and then determine the CTS status information. If it is a CTS signal rising delay signal, enter the timing signal processing program; otherwise, exit the interrupt. The principle is:
[0047] The function multiplexing of the serial communication module is the control principle of the present invention. The external timing signal is connected to the CTS signal of the serial port. If the types match, they can be directly connected; if the types do not match, a type conversion module is required to match the types before connecting; the present invention detects the MSR0 of the Modem status register by interrupt mode to identify the rising and falling edges of the external timing, thereby responding to the external timing. There are three types of internal working registers used by the serial asynchronous communication unit ACE (Serial Asynchronous communications element): control, status and data. The present invention only involves these two types of registers: interrupt enable register (IER), interrupt identification register (IIR), modem control register (MCR) and modem status register (MSR).
[0048] a) Interrupt Enable Register (IER)
[0049] The bit definition of the interrupt enable register is shown in Table 1:
[0050] B7 B6 B5 B4 B3 B2 B1 B0 0 0 0 0 EDSSI ERLSI ETBEI ERBFI
[0051] Table 1 Interrupt Enable Register IER bit definition
[0052] In this embodiment, EDSSI of the interrupt enable register IER is involved: when set, the "Modem status" interrupt is enabled, and an interrupt will be generated when the "MODEM status" changes.
[0053] b) Interrupt Identification Register (IIR)
[0054] In this embodiment, the Modem status interrupt source related to the interrupt identification register IIR is identified as a response time interrupt, and the interrupt is reset by reading the MSR.
[0055] The interrupt flag register IIR bit interrupt flag, priority and reset control are shown in Table 2.
[0056]
[0057] Table 2 Interrupt flag register IIR bit interrupt flag, priority and reset control
[0058] c) Modem Control Register (MCR)
[0059] In this embodiment, the "interrupt enable output" interrupt is enabled when it is set, and an interrupt will be generated when the "MODEM state" changes. The bit definition of the Modem control register MCR is shown in Table 3.
[0060] B7 B6 B5 B4 B3 B2 B1 B0 0 0 0 Self-loop test Interrupt enable output OUT1 control / RTS control / DTR Control
[0061] Table 3 Modem control register MCR bit definition
[0062] d) Modem Status Register (MSR)
[0063] In this embodiment, the Modem status interrupt source of the Modem status register, MSR0: is set to 1, which indicates △CTS. Under the premise that the interrupt enable register IER3 = 1, when any of the above bits is 1, a MODEM status change interrupt (interrupt priority 4, the lowest) will be generated. The bit definition of the Modem status register MSR is shown in Table 4.
[0064] B7 B6 B5 B4 B3 B2 B1 B0 / DCD Status / RI Status / DSR Status / CTS Status △DCD changes △RI change △DSR changes △CTS changes
[0065] Table 4 Modem Status Register MSR bit definition
[0066] This embodiment uses the serial port to implement the time synchronization function. This is based on the fact that the serial port can detect the current state of the modem control signal in an interrupt manner. Based on this technology, this embodiment implements the real-time response of the time synchronization function.
[0067] The embodiment of the present invention further provides a device for receiving a timing signal, the device comprising:
[0068] A serial port unit, the serial port unit is located on a CPU board or a serial port expansion board, and is used to realize the function of the device in the system responding to the timing signal responding to the timing signal of an external timing source;
[0069] An interface type determination module, which is connected to the connection module and the type conversion module, and is used to determine whether a type conversion module is needed; if the interface type is RS-422, the connection module is directly triggered; otherwise, the interface type determination module needs to trigger the type conversion module;
[0070] Type conversion module, connected to the CPU board or serial port expansion board, used to realize differential signal conversion;
[0071] A connection module, connected to the external timing signal and the interface type determination module, for enabling the CPU to receive the external timing signal;
[0072] Initialization module, used to initialize the serial port of the CPU board or serial port expansion board, set the EDSSI bit of the interrupt enable register IER to 1, enable the Modem status interrupt, and generate an interrupt when the MODEM status changes;
[0073] The interrupt response module adopts the interrupt mode. When the differential signal of the system has a rising edge or a falling edge, it responds to the interrupt response program;
[0074] The judgment module is used to judge the rising edge and falling edge of the timing signal. If it is a rising edge, the response module is triggered; if it is a falling edge, the interrupt response program is exited;
[0075] The response module is used for real-time control of the device and releases control signals according to the device function.
[0076] Furthermore, in this embodiment, the control principle is implemented by hardware interface and software control. The hardware interface implementation is divided into two serial port type wiring methods, and the software control is implemented by code programming.
[0077] The code is implemented in two parts: serial port initialization and interrupt response.
[0078] a)Serial port initialization
[0079] Below is the initialization code using COM1, the serial port base address is 0x3f8.
[0080]
[0081] b) Interrupt response
[0082] The following is the interrupt response code.
[0083]
[0084]
[0085] The embodiment of the present invention further provides a system for receiving a timing signal, including:
[0086] A processor, which is used to execute multiple instructions;
[0087] A memory for storing a plurality of instructions;
[0088] The plurality of instructions are used to be stored by the memory, and loaded and executed by the processor to implement the method for receiving a timing signal as described above.
[0089] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the processor is used to execute the method for receiving a timing signal as described above.
[0090] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0091] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0092] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0093] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0094] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a physical server, or a network cloud server, etc., which needs to be installed with Windows or Windows Server operating system) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store program codes.
[0095] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. A method for receiving a timing signal, characterized in that: The method comprises the following steps: Step S101: Determine the serial port type of the device in the system that responds to the timing signal, the serial port of the device in the system that responds to the timing signal is the CPU onboard serial port of the device or the onboard serial port of the serial port expansion board; if the serial port type is RS-422, proceed to step S102; if the serial port type is RS-232, proceed to step S103; Step S102: Connect the differential signal +, differential signal - and end line of the external timing source to the CTS+, CTS- and end line of the serial port of the device in the system; proceed to step S104; Step S103: Perform timing pulse type conversion, connect the differential signal +, differential signal - and end line of the external timing source to the +, - and end lines of the RS-422 type conversion board, and then connect the output signal CTS and end line of the RS-422 type conversion board to the CTS and end lines of the serial port of the device in the system; Step S104: Initialize the serial ports of the devices in the system; Step S105: The CPU monitors, and when an interrupt is detected, responds to the interrupt, and reads the interrupt identification register (IIR) information; Step S106: First, determine whether the interrupt is caused by the change of the Modem state; if so, proceed to step S107; if not, perform a second determination, the content of the second determination is: whether the interrupt is caused by receiving communication data or the sending register is empty, if the result of the second determination is yes, perform corresponding processing; if the result of the second determination is no, exit the interrupt, and this processing is completed; Step S107: respond to the interrupt caused by the modem status change, that is, read the modem status register, first determine the modem status change information, and then determine the CTS status information. If it is a CTS signal rising delay signal, enter the timing signal processing program; otherwise, exit the interrupt and complete this processing.
2. The method for receiving a timing signal according to claim 1, wherein: In step S101, the system that responds to the timing signal is an independent, closed system with fire control solution function.
3. The method for receiving a timing signal according to claim 2, wherein: The external timing source is a timing board or an auxiliary device of the system.
4. The method for receiving a timing signal according to claim 3, wherein: The timing signal provided by the external timing source adopts the RS-422 level standard.
5. The method for receiving a timing signal according to claim 4, characterized in that: The step S104: initializing the serial ports of the devices in the system includes: Set the EDSSI control bit of the interrupt enable register IER of the CPU onboard serial port or the onboard serial port of the serial port expansion board to 1. At this time, the Modem status interrupt is enabled.
6. A device for receiving a timing signal, characterized in that: The device comprises: A serial port unit, which is located on a CPU board or a serial port expansion board and is used to realize the function of a device in the system that responds to a timing signal responding to a timing signal from an external timing source; An interface type determination module, which is connected to the connection module and the type conversion module, and is used to determine whether a type conversion module is needed; if the interface type is RS-422, the connection module is directly triggered; otherwise, the interface type determination module needs to trigger the type conversion module; Type conversion module, connected to the CPU board or serial port expansion board, used to realize differential signal conversion; A connection module, connected to the external timing signal and the interface type determination module, for enabling the CPU to receive the external timing signal; Initialization module, used to initialize the serial port of the CPU board or serial port expansion board, set the EDSSI bit of the interrupt enable register IER to 1, enable the Modem status interrupt, and generate an interrupt when the MODEM status changes; The interrupt response module adopts the interrupt mode. When the differential signal of the system has a rising edge or a falling edge, it responds to the interrupt response program; The judgment module is used to judge the rising edge and falling edge of the timing signal. If it is a rising edge, the response module is triggered; if it is a falling edge, the interrupt response program is exited; The response module is used for real-time control of the device and releases control signals according to the device function.
