Communication module, communication system and communication method based on CPLD (Complex Programmable Logic Device)
Through the separate control interface between CPLD and ARM core, communication between the upper computer and the communication module and peripheral control are realized, which solves the problem of poor compatibility of the CPLD communication interface and improves communication stability and universality.
Patent Information
- Application Number
- CN202411866388.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-05-30
AI Technical Summary
The existing CPLD communication module has poor interface compatibility, and requires customized configuration software to achieve normal communication, and the communication rate and stability are not good.
The interface is controlled separately from the embedded ARM core through CPLD, and the communication interface of the CPLD is used to communicate between the host computer and the communication module. The peripherals are connected to the communication module through the I/O interface of the ARM core to realize peripheral control and data acquisition.
It solves the compatibility problem of CPLD communication interface, enhances the universality of the programmable controller, reduces user usage costs, and improves the stability of high-speed transmission.
Smart Images

Figure CN120067005A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer hardware, and more particularly, to a communication module, a communication system, and a communication method based on a CPLD. Background Art
[0002] With the development of the times, the external interfaces of programmable controllers available to users have become diverse. In order to meet the needs of different customers, general programmable controllers generally adopt two forms: one solution is to make the programmable controller compatible with a larger number of external interfaces, but this will greatly increase the cost; the second solution is to classify the programmable controllers so that different types of programmable controllers correspond to different interface combinations, but this will reduce the versatility and increase the user's usage cost.
[0003] During the communication process between different types of modules, due to the large number and difficulty in identifying module types, the CPLD (Complex Programmable Logic Device) has very poor versatility. Often, customized software needs to be configured to achieve normal communication functions, and the communication rate cannot be guaranteed during the communication process, and the stability is also poor.
[0004] Therefore, it is necessary to study a new solution to solve the above communication interface compatibility problem. Summary of the Invention
[0005] In view of the technical problems existing in the prior art, the present invention provides a communication module, a communication system, and a communication method based on a CPLD. By separating the control of its interfaces by the CPLD and the ARM core, the host computer communicates with the communication module and between the communication modules through the communication interfaces of the CPLD, while the peripherals are connected to the communication module through the I / O interfaces of the ARM core to achieve the control of the peripherals and data acquisition, thus solving the communication interface compatibility problem of the CPLD.
[0006] According to a first aspect of the present invention, there is provided a communication module based on a CPLD, including a first type of interface, a second type of interface, and a CPLD module embedded with an ARM core, wherein: The CPLD module is connected to the first type of interface to achieve communication and data transmission between the communication modules; The ARM core is connected to the second type of interface for communicating and data interacting with the peripherals.
[0007] Based on the above technical solutions, the present invention can also be improved as follows.
[0008] Optionally, it further includes an internal RAM, and the CPLD module and the ARM core are respectively connected to the internal RAM, and the CPLD module and the ARM core perform data interaction through the internal RAM.
[0009] Optionally, at least two of the first type of interfaces are provided on the CPLD module, and the two first type of interfaces are used to be respectively connected to two adjacent communication modules in one-to-one correspondence to realize cross-module data transparent transmission.
[0010] Optionally, the second type of interface includes an SPI interface, an analog input / output port, and / or a digital input / output port.
[0011] Optionally, the communication module is preset with unique identification information.
[0012] According to the second aspect of the present invention, based on the above CPLD-based communication module, a CPLD-based communication system is further provided, including a plurality of the above communication modules. The master station and the plurality of communication modules are connected in series through the first type of interface in sequence. The master station serves as the master station, and all the communication modules serve as slave stations. Each communication module is preset with unique identification information.
[0013] According to the third aspect of the present invention, based on the above CPLD-based communication system, a communication method for the CPLD-based communication system is further provided. The method includes: The master station sends search frame data or normal communication frame data, receives and parses the returned data frame, and also executes corresponding actions and / or replies to the data frame according to the parsed data frame; The slave station receives and parses the search frame data or normal communication frame data, and also opens the data transparent transmission function of the corresponding communication module according to the search frame data or normal communication frame data, and executes corresponding actions and / or replies to the data frame according to the parsed data frame.
[0014] Optionally, when the master station and the slave station receive the returned data frame, they also re-verify the data integrity according to the cached data frame: if it is correct data, corresponding actions are executed; if it is incorrect data, the error state is recorded and an error frame is replied.
[0015] Optionally, the master station sends normal communication frame data according to a preset frequency.
[0016] Optionally, the format of the search frame data or normal communication frame data is: ID + function code + slave status + data length + data content + check code, where the ID, function code, and data length of different communication modules are different.
[0017] According to a fourth aspect of the present invention, there is provided an electronic device including a memory and a processor. When the processor executes a computer management program stored in the memory, the steps of the above-mentioned CPLD-based communication method are implemented.
[0018] According to a fifth aspect of the present invention, there is provided a computer-readable storage medium with a computer management program stored thereon. When the computer management program is executed by a processor, the steps of the above-mentioned CPLD-based communication method are implemented.
[0019] A CPLD-based communication module, communication system and communication method provided by the present invention separate the control of its interfaces by the CPLD and its built-in kernel (such as the built-in ARM kernel). The host computer communicates with the communication module and between the communication modules through the communication interface of the CPLD (i.e., the first type of interface), while the peripheral device is connected to the communication module through the I / O interface of the ARM kernel to achieve the control of the peripheral device and data acquisition. For the host computer, only by connecting to the first type of interface connected to the CPLD, it can achieve the connection and control of various peripheral devices, realize the compatibility of different peripheral interfaces, and solve the compatibility problem of the communication interface of the CPLD. Practical applications have shown that this solution not only enhances the versatility of the programmable controller, but also reduces the user's usage cost, and at the same time improves the stability of high-speed transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A block diagram of a CPLD-based communication module provided for a certain embodiment; Figure 2 A schematic diagram of the communication connection relationship between the master station and the slave station in a certain embodiment; Figure 3 A schematic diagram of the connection relationship between each communication module and the host computer in a CPLD-based communication system provided for a certain embodiment; Figure 4 A schematic diagram of the hardware structure of a possible electronic device provided by the present invention; Figure 5 A schematic diagram of the hardware structure of a possible computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] The following will further describe in detail the specific embodiments of the present invention in conjunction with the drawings and embodiments. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0022] Figure 1 A block diagram of a CPLD-based communication module provided by the present invention. As Figure 1As shown in the figure, a communication module based on CPLD provided in this embodiment includes a CPLD module with an embedded ARM core. Data interaction can be achieved between the ARM core and the CPLD module. The communication module further includes a first type of interface and a second type of interface, where: The first type of interface is connected to the CPLD module, and the CPLD module is connected to the first type of interface to achieve communication and data transmission between each communication module. The second type of interface is connected to the ARM core, and the ARM core is connected to the second type of interface for communicating and interacting with peripherals.
[0023] As Figure 2 shown is a schematic diagram of the connection of multiple communication modules as slave stations to a master station. Figure 2 In the figure, master is the master station, and slave1~slaveN are N slave stations, and each communication module serves as a slave station. The first type of interface is only used to implement the communication function, such as communication interface expansion. Therefore, Figure 2 each communication module is connected to each other and to the master station through the first type of interface. As Figure 3 shown is a connection relationship diagram between each communication module and the master station (host computer) and each peripheral. The specific interface type of the second type of interface can be set according to the corresponding peripheral. It can include interfaces directly controlled by the ARM core, such as SPI communication interfaces, AD sampling (analog input / output ports), status led indication interfaces, etc., and can also include interfaces indirectly controlled by the ARM core, such as digital input / output ports. By controlling their corresponding interfaces through the CPLD module and the ARM core respectively, the interface compatibility problem of the CPLD module can be solved.
[0024] In a possible embodiment, as shown in block Figure 1 the CPLD module further includes an internal RAM. The CPLD module and the ARM core are respectively connected to the internal RAM, and the CPLD module and the ARM core perform data interaction through the internal RAM.
[0025] It can be understood that the I / O directly controlled by the CPLD (the first type of interface) is used to expand the reception and transmission of communication. The externally received data and the data to be sent out will be cached in the internal RAM space, so as to perform data interaction with the ARM core.
[0026] In a possible embodiment, as Figure 2 shown, in order to connect multiple communication modules through the first type of interface corresponding to the CPLD module, at least two of the first type of interfaces are provided on the CPLD module. As Figure 2 and Figure 3As shown, the two first - type interfaces on the CPLD module are used to be respectively and correspondingly connected to two adjacent communication modules to achieve cross - module data transparent transmission.
[0027] In a possible implementation manner, as Figure 1 shown, the second - type interfaces include SPI interfaces, analog input / output ports (such as AD sampling ports, status led indication ports), and / or digital input / output ports. By setting diverse second - type interfaces, the communication module can be adapted to a variety of peripherals, improving the applicability of the communication module.
[0028] In a possible implementation manner, the communication module is preset with unique identity identification information, and the identity identification information can be determined according to the peripherals matched by the current communication module.
[0029] It can be understood that when the master station and the slave station are powered on, the status of the corresponding communication module can be identified through the identity identification information.
[0030] Based on the above embodiments, as Figure 2 and Figure 3 shown, this embodiment further provides a communication system based on CPLD. The communication system includes the communication modules provided in the above embodiments. The host computer is serially connected to multiple said communication modules through the first - type interfaces in sequence. The host computer serves as the master station, and all said communication modules serve as slave stations. Each said communication module is preset with unique identity identification information, and the identity identification information is related to its model.
[0031] It can be understood that, as Figure 3 shown, through multiple communication modules, communication between various types of peripherals and the master station can be achieved, and there is no need to expand the CPLD interface types on the communication module, solving the communication interface compatibility problem of CPLD.
[0032] Now, the communication between two certain communication modules is taken as an example for illustration.
[0033] In a certain implementation scenario, the communication between communication module 1 and communication module 2 to be communicated is carried out through the I / O ports directly controlled by CPLD.
[0034] The I / O directly controlled by the ARM core will be used to drive external SPI devices, voltage sampling, and status indication. By sampling the voltage value of the (identification information) of the hardware configuration of each communication module through the ADC pin, the self-model of each communication module can be known (for example, if 1.0V is collected, the communication module model is identified as 16DI; if 1.5V is collected, the communication module model is 16DOT), and the system will execute the corresponding functions of the communication module of this model. External SPI devices include, for example, shift registers, ADCs, and DACs. Taking the shift register as an example, its function is to transmit the on / off state of the LED lights at a fixed time (us). Each communication module has two system indicator lights (for example, a red light and a green light), and the detailed description is shown in Table 1 below. The LEDs of the digital quantity type communication module represent the valid / invalid states of each I / O point, and the analog quantity type communication module has no I / O status indication.
[0035] Table 1
[0036] The I / O indirectly controlled by the ARM can automatically switch the input and output states to match communication modules of different input / output types. For the digital quantity type communication module, both the input and output are controlled by the same pin. According to the self-identified module model, for example, when the identified model is a 16DI module, the attributes of pins 1-16 are input type, which are used to collect external level changes; when the identified model is a 16DOT module, the attributes of pins 1-16 are output type, controlling the output points to conduct to the common terminal. For the analog quantity type communication module, the ADC or DAC chip is controlled by the same SPI communication pin, and according to the self-identified module model, the functions of analog quantity collection or analog quantity output are respectively realized.
[0037] When configuring the interface on the upper computer interface: 1. First, according to the physical connection sequence of the host and each communication module, add communication modules of the corresponding model on the interface, and the system can automatically match the slave station numbers without separately setting the station numbers of each slave station on the interface; 2. According to the user's needs, set the required function parameters for each communication module, such as filtering coefficient, sampling period, output hold, peak hold, etc.; 3. After the program is compiled, it can be downloaded to the host, and log in to view the data status of the host and each communication module.
[0038] Based on the communication system of the foregoing embodiment, the embodiment of the present invention further provides a communication method for a communication system based on CPLD, including: The master station sends search frame data or normal communication frame data, receives and parses the returned data frame, and also executes corresponding actions and / or replies to the data frame according to the parsed data frame; The slave station receives and parses the search frame data or normal communication frame data, and also enables the data transparent transmission function of the corresponding communication module according to the search frame data or normal communication frame data. Moreover, it executes corresponding actions and / or replies to the data frame according to the parsed data frame.
[0039] Now, a specific implementation scenario is used to illustrate the specific working mode of this communication system.
[0040] 1. Self-identification of communication module identity.
[0041] Since the communication module hardware is configured with unique identity identification information, the drivers of each model module are pre-configured in the software of the communication module, such as function codes, refreshing the system indicator light, and whether to update its own I / O status, etc. According to the identity identification information value sampled by the ADC of each communication module after power-on, its own model information is determined, and then it automatically jumps to the program of the corresponding model module to run.
[0042] For example, after power-on, when the ADC of the current communication module samples the identity identification information as 1.0V, it is determined that the model of the communication module powered on at this time is 16DI, and the data stored in its corresponding function code 1 is the logic level of the current input point.
[0043] By pre-configuring the sampling values of the identity identification information of each communication module, the self-identification of the communication module type is realized, and further, all types of communication modules can be plug-and-play.
[0044] 2. Search and initialization of communication modules.
[0045] After the host is powered on, it sends search frame data immediately. The first slave station (communication module) replies with its own type and station number. After the host confirms the information, the first slave station (communication module) enables the data transparent transmission function; continue to search for the next slave station and repeat the above process until the last communication module. In this process, the host will obtain the models, version numbers, and station numbers of each slave station (communication module), and the slave station (communication module) will perform function initialization.
[0046] The data frame format for the host and slave stations to communicate is: ID + function code + slave status + data length + data content + checksum.
[0047] 3. Data verification.
[0048] When the master station and the slave station receive the returned data frame, they also re-verify the data integrity according to the cached data frame: if it is correct data, corresponding actions are executed; if it is incorrect data, the error status is recorded and an error frame is replied.
[0049] 4. Data identification.
[0050] After the data frame verification passes, all data is directly passed through to the next level, and each communication module analyzes the received data frame. If it is determined that the current data frame is sent to itself, corresponding actions are taken and a data frame is replied; if it is determined that the current data frame is not sent to itself, no processing is performed.
[0051] 5. Module communication and function implementation.
[0052] After the communication module initialization is completed, the host sends normal communication frame data according to the preset frequency. For example, after the communication module initialization is completed, the master station communicates with the slave station every 500 us to obtain the function information of each current communication module, such as the DI digital input status, the DO digital output status, etc.
[0053] It should be noted that whether it is search frame data or normal communication frame data, its format is: ID + function code + slave status + data length + data content + check code, where the ID, function code, and data length of different communication modules are different.
[0054] The ID is the station number, which is automatically sorted and generated according to the hardware connection order of each communication module, and the function code is related to the identity identification information of each communication module.
[0055] Please refer to Figure 4 , Figure 4 which is the schematic diagram of the embodiment of the electronic device provided by the embodiment of the present invention. As Figure 4 shown, the embodiment of the present invention provides an electronic device 400, including a memory 410, a processor 420, and a computer program 411 stored on the memory 410 and operable on the processor 420. When the processor 420 executes the computer program 411, the following steps are implemented: The master station sends search frame data or normal communication frame data, receives and analyzes the returned data frame, and also executes corresponding actions and / or replies to the data frame according to the analyzed data frame; The slave station receives and analyzes the search frame data or normal communication frame data, also opens the data pass-through function of the corresponding communication module according to the search frame data or normal communication frame data, and, according to the analyzed data frame, executes corresponding actions and / or replies to the data frame.
[0056] Please refer to Figure 5 , Figure 5 which is the schematic diagram of the embodiment of a computer-readable storage medium provided by the present invention. As Figure 5 shown, this embodiment provides a computer-readable storage medium 500, on which a computer program 511 is stored. When the computer program 511 is executed by a processor, the following steps are implemented: The master station sends search frame data or normal communication frame data, receives and parses the returned data frames, and performs corresponding actions and / or replies to data frames according to the parsed data frames; The slave station receives and parses the search frame data or the normal communication frame data, and also turns on the data transparent transmission function of the corresponding communication module according to the search frame data or the normal communication frame data, and executes corresponding actions and / or replies to the data frame according to the parsed data frame.
[0057] The embodiment of the present invention provides a communication module, a communication system and a communication method based on CPLD. The CPLD and its own kernel (such as the ARM kernel) control their interfaces separately. The host computer and the communication module, as well as the communication modules communicate through the communication interface of the CPLD (i.e., the first-class interface), and the peripherals are connected to the communication module through the I / O interface of the ARM kernel to realize the control and data collection of the peripherals. For the host computer, only the first-class interface connected to the CPLD is required to realize the connection and control with various peripherals, realize the compatibility with different peripheral interfaces, solve the compatibility problem of the communication interface of the CPLD, enhance the scalability of the module, and make it plug-and-play. The module type is self-identified by configuring the sampling value of the module identity information in advance, and the module type can be self-identified according to the hardware, so as to further realize that all types of modules can be plug-and-play, easy to use, high functional integration, simple configuration interface, simplified manual operation process, and improved work efficiency. It has been proved through practical application that this scheme not only enhances the versatility of the programmable controller, but also reduces the user's use cost, and improves the stability of high-speed transmission.
[0058] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0059] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0060] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0061] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0062] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0063] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0064] Obviously, those skilled in the art can make various changes and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these changes and variations.
Claims
1. A communication module based on CPLD, characterized in that: It includes the first type interface, the second type interface, and the CPLD module with embedded ARM core, among which: The CPLD module is connected to the first type interface to realize communication and data transmission between various communication modules; The ARM core is connected to the second type of interface for communicating with peripherals and exchanging data.
2. A CPLD-based communication module according to claim 1, characterized in that: It also includes an internal RAM, the CPLD module and the ARM core are respectively connected to the internal RAM, and the CPLD module and the ARM core perform data exchange through the internal RAM.
3. A CPLD-based communication module according to claim 1, characterized in that: The CPLD module is provided with at least two of the first-type interfaces, and the two first-type interfaces are used to connect with two adjacent communication modules in a one-to-one correspondence to achieve data transparent transmission across modules.
4. A CPLD-based communication module according to claim 1, characterized in that: The second type of interface includes an SPI interface, an analog input / output port, and / or a digital input / output port.
5. A CPLD-based communication module according to claim 1, characterized in that: The communication module is preset with unique identity identification information.
6. A communication system based on CPLD, characterized in that: It comprises a communication module as described in any one of claims 1 to 5, wherein a host computer and a plurality of said communication modules are connected in series in sequence through a first type interface, the host computer serves as a master station, and all said communication modules serve as slave stations, and each of said communication modules has unique identity identification information pre-stored therein.
7. A communication method of a communication system based on CPLD, characterized in that: Based on the communication system as claimed in claim 6, the method comprises: The master station sends search frame data or normal communication frame data, receives and parses the returned data frames, and performs corresponding actions and / or replies to data frames according to the parsed data frames; The slave station receives and parses the search frame data or the normal communication frame data, and also turns on the data transparent transmission function of the corresponding communication module according to the search frame data or the normal communication frame data, and executes corresponding actions and / or replies to the data frame according to the parsed data frame.
8. The communication method according to claim 7, characterized in that: When the master station and the slave station receive the returned data frame, they also re-check the data integrity based on the cached data frame: if the data is correct, the corresponding action is performed; if it is incorrect data, the error status is recorded and the error frame is replied.
9. The communication method according to claim 7, characterized in that: The master station sends normal communication frame data according to a preset frequency.
10. The communication method according to claim 7, characterized in that: The format of the search frame data or normal communication frame data is: ID+function code+slave status+data length+data content+check code, wherein the ID, function code and data length of different communication modules are different.