A fast implementation method of CANopen master station based on PLC controller

By building an open source protocol stack and designing a CANopen master station system for PLC controllers, the problem of developing a CANopen master station on a small PLC controller is solved, and rapid development and efficient data transmission are achieved, reducing system maintenance costs.

CN119766591APending Publication Date: 2025-04-04NANDA AUTOMATION TECH JIANGSU CO LTD

Patent Information

Application Number
CN202411944965.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The prior art is difficult to develop a CANopen master site based on the existing software or hardware of a small PLC controller, and the system expansion and maintenance costs are high and the compatibility is poor.

Method used

By building the underlying driver files of the open source protocol stack, PLCRuntime designs communication interaction with CANopen master station, and designs the CANopen master station system of the PLC controller, and deploys the master station application using a separate process to realize data interaction with PLCRuntime.

Benefits of technology

It realizes the rapid development of CANopen master station on existing PLC controllers, reducing system upgrade and maintenance costs, improving compatibility between equipment and data transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766591A_ABST
    Figure CN119766591A_ABST
Patent Text Reader

Abstract

The invention discloses a method for quickly realizing a CANopen master station based on a PLC controller, and relates to the technical field of industrial field bus communication. The invention comprises the following steps: step 1, constructing an open source protocol stack bottom-layer driver file; step 2, constructing a PLC Runtime to communicate and interact with the CANopen master station; and step 3, designing a CANopen master station system of the PLC controller. The invention develops a CANopen master station application program only through the CANopen open source protocol stack without modifying the existing hardware, system kernel and bottom-layer driver of the PLC controller, and deploys the CANopen master station application program to the existing small PLC controller, thereby avoiding the compatibility problem between PLC controllers and CANopen devices of different manufacturers, meeting the industrial field demand for the standard CANopen communication protocol of the PLC controller, and having low cost and short development cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of industrial field bus communication, and in particular to a method for quickly realizing a CANopen master station based on a PLC controller. Background Art

[0002] Faced with the increasingly diverse requirements for the use of the standard CANopen protocol in industrial sites, it has become an inevitable trend for PLC controllers to support the CANopen master function. If customers are required to replace the early PLC controllers on site with PLC controllers with CANopen master functions, it will involve various software and hardware upgrades. Although this can solve the problem, it will inevitably bring inconvenience to customers and increase costs. If the software or hardware of an existing small PLC controller is modified to expand the CANopen master function, the project development cycle will be long and the cost will be high. How to expand the CANopen master function only through software based on the software or hardware of the existing PLC controller without increasing customer costs too much has become a practical problem that needs to be solved urgently. Therefore, it is particularly important to invent a method for quickly implementing a CANopen master based on a PLC controller.

[0003] Prior art, such as the invention patent application with announcement number: CN101222510A, discloses a method for realizing a CANopen master station, which belongs to the field of field bus. It is characterized in that the realization of the master station is based on the MC9S12DP512 hardware platform, and is a multi-threaded system built on the UC / OS-II operating system, including a scheduling machine thread, a message writing thread, and a message reading interrupt. The scheduling machine is used to manage the basic tasks of CANopen such as CAN message reception, CAN message transmission, PDO message distribution, SDO message distribution, NMT message distribution, synchronization message generation, PDO processing, SDO processing, and NMT processing. In addition, the object dictionary as the core of the CANopen protocol is constructed in the form of a hash table. This method of constructing an object dictionary meets the requirement that the master station must have the characteristics of being able to quickly search, add, and delete objects in its object dictionary. The superiority of the invention lies in applying task scheduling in the design of the master station, so that it has a high degree of real-time performance, concurrent processing capability, and dynamic flexibility; the object dictionary realized can meet the flexible expansion capability of the network, and objects can be dynamically added to the object dictionary.

[0004] The prior art also has the following disadvantages, which are specifically reflected in: 1. In the prior art, it is impossible to develop a CANopen master station based on a small PLC controller on the basis of existing software or hardware.

[0005] 2. In the existing technology, when the system needs to expand the number of nodes or add new functional modules, the existing implementation method based on the PLC controller may face difficulties. Due to the limitations of the hardware resources and software architecture of the PLC, it may not be easy to expand the system, and the entire system needs to be redesigned and reprogrammed, which increases the cost of system upgrades and maintenance.

[0006] 3. In the existing technology, PLC controllers and CANopen devices from different manufacturers may have differences in the underlying hardware and software implementation, resulting in poor compatibility between certain devices. In a multi-node CANopen network, as the number of nodes increases, the amount of data communication will also increase accordingly. The efficiency is not high when processing large amounts of data communication, resulting in network congestion and affecting the reliability and timeliness of data transmission. Summary of the invention

[0007] The purpose of the present invention is to provide a method for quickly implementing a CANopen master station based on a PLC controller, which solves the problems existing in the background technology.

[0008] To solve the above technical problems, the present invention adopts the following technical solutions: The present invention provides a method for quickly implementing a CANopen master station based on a PLC controller, comprising: Step 1, constructing an open source protocol stack underlying driver file.

[0009] Step 2: Build PLCRuntime to communicate with the CANopen master station.

[0010] Step 3: Design the PLC controller CANopen master system.

[0011] Preferably, the construction of the open source protocol stack underlying driver file, the specific analysis method is: porting the open source protocol stack to the Linux system, building the protocol stack underlying driver file, specifically including designing a CAN receiving driver interface, designing a CAN sending driver interface, designing a basic timer driver interface, and adapting the PLC controller platform system.

[0012] The specific method for designing the CAN receiving driver interface is as follows: create a CAN receiving thread, call the can_init() function at the beginning of the thread to initialize the CAN structure variable pointer, enter the while(1) loop, and receive CAN channel data in a loop. When CAN data is received, call the protocol stack function canDispatch() to send the received CAN frame to the CANopen protocol stack for processing.

[0013] The design of the basic timer driver interface is as follows: create a Timer thread with a period of 1ms, create a timer variable at the beginning of the thread and initialize it to 1ms, enter the while(1) loop, call the nanosleep() function in the loop body to accurately delay for 1ms, and then call the protocol stack function TimeDispatch() to drive the soft timer in the protocol stack.

[0014] The specific method of adapting the PLC controller platform system is as follows: defining the variable types required for use in the protocol stack and applicable to the current hardware processor in the applicfg.h file, and the debugging information output function.

[0015] Preferably, the construction of PLCRuntime and CANopen master station communication interaction, the specific analysis method is: based on the "soft element area" of the PLC controller, establish the data communication area of ​​the PLCRuntime and CANopen master station application, and map the data communication area of ​​the two to the MW area of ​​the PLC controller soft element, including the input data area and the output data area.

[0016] Preferably, the designed PLC controller CANopen master station system includes host computer configuration software and CANopen master station software.

[0017] The host computer configuration software is the CANopen master station system configuration software, which configures parameters and sends the system configuration parameters to the CANopen master station software through the serial port.

[0018] The CANopen master station software accepts configuration parameters sent by the host computer configuration software and responds to software operation commands, and mainly includes a system configuration module, a slave station scanning module, a power-on management module, and a master station management module.

[0019] The system configuration module is used to receive the configuration downloaded by the host computer configuration software and respond to the software operation command.

[0020] The slave scanning module is used to scan the slave devices on the CAN bus and send the scanned slave devices to the host computer software.

[0021] The power-on management module is used to monitor the slave devices on the bus, and when the CANopen slave device is powered on and started, it sends a power-on startup message to the master station.

[0022] The master station management module is used to process the business logic of the master station system.

[0023] The beneficial effects of the present invention are as follows: 1. The present invention develops a CANopen master station based on a small PLC controller on the basis of existing software or hardware, without modifying the hardware and software system of the PLC controller.

[0024] 2. The present invention adopts an open source master station to develop the CANopen master station of the PLC controller. The master station application is deployed in the PLC controller as a separate process, and data interaction with the PLC Runtime is achieved in a "memory mapping" manner. When the system needs to expand the number of nodes or add new functional modules, there is no need to modify the PLC controller Runtime, thereby reducing the cost of system upgrades and maintenance.

[0025] 3. The CANopen master station in the present invention is developed without modifying the existing PLC controller software or hardware, which effectively solves the demand of industrial field equipment for CANopen communication interface; it avoids the compatibility problem between PLC controllers and CANopen devices of different manufacturers, and can be quickly deployed to existing small PLC controllers. The implementation is simple and efficient, with high economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 The present invention is a schematic flow chart of the steps for implementing the method.

[0028] Figure 2 This is the data map of the PLC soft element area. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.

[0030] Reference Figure 1 As shown, the present invention provides a method for quickly implementing a CANopen master station based on a PLC controller, comprising: step one, constructing an open source protocol stack bottom layer driver file.

[0031] It should be noted that the CANopen master station protocol stack used in this solution is free and open source, and can run on various types of software and hardware platforms, including embedded systems or any Unix-like systems. It provides low-level driver examples suitable for various hardware platforms; the source code is written based on the ANSI-C standard, the protocol stack is complete in function, fully compliant with the CANopen standard, and provides developers with a large number of software development tools to facilitate user secondary development.

[0032] This technical solution uses the Linux operating system to develop a CANopen master station based on the existing PLC controller software or hardware platform and the CANopen open source protocol stack. The CANopen master station application is a separate process that implements data and command interaction with the PLC Runtime system through a "memory mapping" method.

[0033] In a specific embodiment, the construction of the open source protocol stack bottom-level driver file, the specific analysis method is: porting the open source protocol stack to the Linux system, building the protocol stack bottom-level driver file, specifically including designing a CAN receive driver interface, designing a CAN send driver interface, designing a basic timer driver interface, and adapting the PLC controller platform system.

[0034] The specific method for designing the CAN receiving driver interface is as follows: create a CAN receiving thread, call the can_init() function at the beginning of the thread to initialize the CAN structure variable pointer, enter the while(1) loop, and receive CAN channel data in a loop. When CAN data is received, call the protocol stack function canDispatch() to send the received CAN frame to the CANopen protocol stack for processing.

[0035] It should be noted that the encapsulated can_send() function is used to send CAN channel data. The process of designing the CAN send driver interface is the same as the process of designing the CAN receive driver interface, so it will not be repeated again.

[0036] The design of the basic timer driver interface is as follows: create a Timer thread with a period of 1ms, create a timer variable at the beginning of the thread and initialize it to 1ms, enter the while(1) loop, call the nanosleep() function in the loop body to accurately delay for 1ms, and then call the protocol stack function TimeDispatch() to drive the soft timer in the protocol stack.

[0037] It should be noted that the encapsulated SetTimer() function is used to set the number of times the reference timer needs to elapse before the next trigger. The encapsulated getElapsedTime() function is used to obtain the number of times the reference timer has elapsed from the last trigger to the current time.

[0038] The specific method of adapting the PLC controller platform system is as follows: defining the variable types required for use in the protocol stack and applicable to the current hardware processor in the applicfg.h file, and the debugging information output function.

[0039] Step 2: Build PLCRuntime to communicate with the CANopen master station.

[0040] In a specific embodiment, the construction of PLCRuntime and CANopen master station communication interaction, the specific analysis method is: based on the "soft component area" of the PLC controller, establish the data communication area of ​​the PLCRuntime and CANopen master station application, refer to Figure 2 , map the data communication areas of the two to the MW area of ​​the PLC controller soft element, including the input data area and the output data area.

[0041] It should be noted that in the PLC controller system, the PLCRuntime and CANopen master station programs are deployed in the control system as processes respectively, so it is necessary to establish data communication between the two so that PLC users can use the CANopen master station.

[0042] When the CANopen master program starts, it obtains the first address of the MW data area of ​​the PLCRuntime soft element, and maps the input or output data area to the program memory according to the input or output area parameters set by the user. The CANopen master program realizes the interaction of the master or slave SDO, PDO data with the PLCRuntime by reading the input data area and writing the output data area.

[0043] After establishing the communication between PLCRuntime and CANopen master station, design the communication protocol of input data area and output data area in CANopen master station. Input data area includes master station information, SDO operation information, slave station information, slave station TxPDO information, etc. Output data area includes SDO operation command, slave station RxPDO information, etc.

[0044] Step 3: Design the PLC controller CANopen master system.

[0045] In a specific embodiment, the designed PLC controller CANopen master station system includes host computer configuration software and CANopen master station software.

[0046] The host computer configuration software is the CANopen master station system configuration software, which configures parameters and sends the system configuration parameters to the CANopen master station software through the serial port.

[0047] It should be noted that the configuration parameters include master station configuration relationship, slave station configuration relationship, master station communication parameters, slave station communication parameters, and slave station PDO data.

[0048] The CANopen master station software accepts configuration parameters sent by the host computer configuration software and responds to software operation commands, and mainly includes a system configuration module, a slave station scanning module, a power-on management module, and a master station management module.

[0049] The system configuration module is used to receive the configuration downloaded by the host configuration software and respond to the software operation command. The host configuration software downloads the master station system parameter configuration, and the system configuration module receives the configuration information and saves it to the configuration file; at the same time, it interprets the master station configuration information, including node ID, communication baud rate, synchronization object, heartbeat protocol, etc.; and resolves the slave station information, including node ID, startup parameters, RxPDO and TxPDO configuration, etc. At the same time, the system configuration module also manages software operation commands, such as slave station online scanning, slave station online operation, etc.

[0050] The slave scanning module is used to scan the slave devices on the CAN bus and send the scanned slave devices to the host computer software. When receiving the slave scanning command from the host computer software, the master system enters the scanning state and scans the slave devices on the bus in sequence with the baud rate parameters set by the user.

[0051] The power-on management module is used to monitor the slave devices on the bus, and when the CANopen slave device is powered on, it sends a power-on startup message to the master station. After the CANopen master station software is started, the power-on management module enters the monitoring slave power-on state, and when the slave device is powered on, it initializes the configuration of the slave device, including configuring the heartbeat or node guard, RxPDO communication parameters, RxPDO data mapping, TxPDO communication parameters, TxPDO data mapping, and finally requests the slave to enter the OP state.

[0052] The master station management module is used to process the business logic of the master station system. When the host computer software downloads the master station system configuration, the master station management module enters the system configuration state, obtains the master station system configuration information, configures the slave station equipment, maps the master station memory space, maps the slave station memory space, initializes the protocol stack timer, etc. After the above business processing is completed, the master station management module enters the cycle mode, periodically processing the slave station status management, slave station status operation, slave station SDO message reading, slave station SDO message writing, slave station RxPDO and TxPDO data reception, TxPDO data transmission.

[0053] The above contents are merely examples and explanations of the concept of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in a similar manner. As long as they do not deviate from the concept of the invention or exceed the scope defined by the present invention, they shall all fall within the protection scope of the present invention.

Claims

1. A method for quickly implementing a CANopen master station based on a PLC controller, characterized in that: include: Step 1: Build the underlying driver file of the open source protocol stack; Step 2: Build the communication interaction between PLCRuntime and CANopen master station; Step 3: Design the PLC controller CANopen master system.

2. According to the method for quickly implementing a CANopen master station based on a PLC controller according to claim 1, it is characterized in that: The specific analysis method for constructing the underlying driver file of the open source protocol stack is as follows: Transplant the open source protocol stack to the Linux system and build the underlying driver files of the protocol stack, including designing the CAN receiving driver interface, designing the CAN sending driver interface, designing the basic timer driver interface, and adapting the PLC controller platform system; The specific method of designing the CAN receiving driver interface is as follows: creating a CAN receiving thread, calling the can_init() function at the beginning of the thread to initialize the CAN structure variable pointer, entering the while(1) loop, cyclically receiving CAN channel data, and when receiving CAN data, calling the protocol stack function canDispatch() to send the received CAN frame to the CANopen protocol stack for processing; The design of the basic timer driver interface is as follows: create a Timer thread with a period of 1ms, create a timer variable at the beginning of the thread and initialize it to 1ms, enter the while(1) loop, call the nanosleep() function in the loop body to accurately delay for 1ms, and then call the protocol stack function TimeDispatch() to drive the soft timer in the protocol stack; The specific method of adapting the PLC controller platform system is as follows: defining the variable types required for use in the protocol stack and applicable to the current hardware processor in the applicfg.h file, and the debugging information output function.

3. The method for quickly implementing a CANopen master station based on a PLC controller according to claim 1, characterized in that: The specific analysis method for constructing the communication interaction between PLCRuntime and CANopen master station is as follows: Based on the "soft element area" of the PLC controller, establish the data communication area of ​​the PLCRuntime and CANopen master station application, and map the data communication areas of the two to the MW area of ​​the PLC controller soft element, including the input data area and the output data area.

4. The method for quickly implementing a CANopen master station based on a PLC controller according to claim 1, characterized in that: The designed PLC controller CANopen master station system includes host computer configuration software and CANopen master station software; The host computer configuration software is a CANopen master station system configuration software, which configures parameters and sends the system configuration parameters to the CANopen master station software through the serial port; The CANopen master station software accepts the configuration parameters issued by the host computer configuration software and responds to the software operation commands, mainly including the system configuration module, the slave station scanning module, the power-on management module, and the master station management module; The system configuration module is used to receive the configuration downloaded by the host computer configuration software and respond to the software operation command; The slave station scanning module is used to scan the slave station devices on the CAN bus and send the scanned slave station devices to the host computer software; The power-on management module is used to monitor the slave devices on the bus, and when the CANopen slave device is powered on, it sends a power-on startup message to the master station; The master station management module is used to process the business logic of the master station system.

Citation Information

Patent Citations

  • Method for implementing CANopen main station

    CN101222510A

Cited By

  • CANopen protocol stack transplantation method and device, equipment and medium

    CN121841900A

  • Method, device and equipment for CANopen protocol stack transplantation and medium

    CN121841900B