CN116319150A - Remote I/O node development method - Google Patents
Remote I/O node development method Download PDFInfo
- Publication number
- CN116319150A CN116319150A CN202310171383.8A CN202310171383A CN116319150A CN 116319150 A CN116319150 A CN 116319150A CN 202310171383 A CN202310171383 A CN 202310171383A CN 116319150 A CN116319150 A CN 116319150A
- Authority
- CN
- China
- Prior art keywords
- node
- data
- task
- receiving
- bus
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000011161 development Methods 0.000 title claims abstract description 12
- 230000005540 biological transmission Effects 0.000 claims abstract description 46
- 238000013461 design Methods 0.000 claims abstract description 9
- 238000006243 chemical reaction Methods 0.000 claims abstract description 8
- 230000006870 function Effects 0.000 claims description 40
- 230000008569 process Effects 0.000 claims description 30
- 238000012360 testing method Methods 0.000 claims description 21
- 238000012545 processing Methods 0.000 claims description 17
- 238000004891 communication Methods 0.000 claims description 16
- 101150063504 CAN2 gene Proteins 0.000 claims description 7
- 230000000903 blocking effect Effects 0.000 claims description 7
- 238000012544 monitoring process Methods 0.000 claims description 7
- 230000001360 synchronised effect Effects 0.000 claims description 7
- 230000000737 periodic effect Effects 0.000 claims description 3
- 230000003139 buffering effect Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 4
- 238000013508 migration Methods 0.000 description 4
- 230000005012 migration Effects 0.000 description 4
- 230000002618 waking effect Effects 0.000 description 4
- 230000006855 networking Effects 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40006—Architecture of a communication node
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40215—Controller Area Network CAN
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention discloses a development method of a remote I/O node, which comprises the following steps that hardware of the remote I/O node with a CAN bus interface is adopted by an I/O hardware interface part, a MCP2515 controller with an SPI serial interface is used as a control chip, connection with the CAN bus CAN be simplified, level conversion between a data level on the CAN bus and the controller is completed by a transceiver MCP2551, an interrupt mode is adopted for transmission and reception, and an interrupt signal is usually generated and transmitted after a frame of information is transmitted; the invention designs a CAN bus driving program based on uCOS II, adopts a multitasking mode and cooperates with a CANOPEN protocol stack library in CANFESTIVAL to realize the development of a remote I/O node.
Description
Technical Field
The invention relates to the technical field of communication, in particular to a development method of a remote I/O node.
Background
Among various field bus networks, the CAN bus originally developed for interconnection of automobile electronic devices is widely used in various automation fields due to simple and flexible configuration and strong real-time control and error detection and correction capability, the high performance and reliability of CAN are well recognized and widely applied to aspects of industrial automation, ships, medical equipment, industrial equipment and the like, the field bus is one of hot spots of technical development in the current automation field, is known as a computer local area network in the automation field, provides strong technical support for realizing real-time and reliable data communication among nodes of a distributed control system, and CANOPEN is used as one of CAN bus high-level protocols in the industry;
along with industrial development and scale expansion of factories, a remote I/O data acquisition mode is increasingly adopted, and in the development process of the existing I/O nodes, huge wiring quantity and networking are needed to form a management layer, a control layer and a field layer, and in practical application, the huge wiring quantity and networking can lead to the increase of the normal use and maintenance cost of the nodes, so that a development method of the remote I/O nodes is necessary to be provided to solve the problems.
Disclosure of Invention
In order to achieve the above purpose, the present invention provides the following technical solutions: a method for developing remote I/O node includes such steps as,
step 1: hardware of remote I/O node with CAN bus interface: the I/O hardware interface part adopts an MCP2515 controller which completely supports CAN2.OB. Communication rate to be 1Mb/s and is provided with an SPI serial interface as a control chip, so that the connection with a CAN bus CAN be simplified, the level conversion between the data level on the CAN bus and the controller is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, and interrupt signals are generated and transmitted after one frame of information is transmitted;
step 2: CAN bus driver based on μCOSII: canfiest iv AL is written in C language, supports all functions of CANOPEN CIA301 protocol, can realize functions of master station and slave station, and has simple transplanting and cross-platform;
considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data;
in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups;
the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task;
in the canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, analyzing which message the data extracted from the buffer belongs to, and then entering a corresponding message processing program;
step 3: transmitting and receiving CAN bus driver: the sending task can be scheduled and executed asynchronously, and can be scheduled and executed at regular time in the timer task;
step 4: testing of CAN bus driver: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling;
the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send a 64-bit input state to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
Preferably, in step 1, an interrupt signal is generated before a frame of message is sent, and the receive interrupt is generated when a buffered message is received, with 64 inputs and 16 outputs per I/O node.
Preferably, in step 2, the drive in μcosii has mainly two parts, one for receiving an interrupt and one for timer interrupt.
Preferably, in step 2, the receiving ring buffer is used for buffering the received bus message, waiting for processing by the application program, and the sending ring buffer is used for buffering the message sent by the application program, waiting for processing of the sending task.
Preferably, in step 2, the transmission task is suspended when the transmission buffer has no transmission content, and the reception task is suspended when the reception buffer has no transmission content.
Preferably, in step 2, when there is data to be transmitted, the transmitting task is awakened, and the receiving task is scheduled after receiving the interrupt, and the receiving task is awakened after receiving the interrupt.
Preferably, in step 3, to implement periodic transmission of the process data message, the system uses a timer with a period of 10ms to manage transmission and reception of the process data.
Preferably, in step 3, after the transmission function flow is one added to the transmission semaphore txsum, a task scheduling is performed once, so that the transmission task enters a ready state, and the receiving interrupt flow is performed once after the receiving interrupt is finished, so that the receiving task enters the ready state.
Preferably, in step 3, the timer task flow is a time dispatch function to complete the timer task, when the timer sends a timing message, the timer scans the timer attribute value of the process data, when the timing time is up, the process data message is sent, and the time window interval between two adjacent process data sending processes is set in the time dispatch function, so that the high-priority message does not occupy the bus for a long time.
Preferably, in step 4, the transmitted data bit, 1, indicates a high level, and 0 indicates a low level.
Compared with the prior art, the invention has the beneficial effects that:
the invention designs a CAN bus driving program based on uCOS II, adopts a multitasking mode and cooperates with a CANOPEN protocol stack library in CANFESTIVAL to realize the development of a remote I/O node.
Drawings
FIG. 1 is a schematic diagram of a hardware block of a remote I/O node of the present invention;
FIG. 2 is a general flow chart of a μCOSII-based CAN driver of the present invention;
FIG. 3 is a transmission flow chart of the present invention;
FIG. 4 is a flow chart of the present invention for receiving interrupts;
FIG. 5 is a timer task flow diagram of the present invention;
FIG. 6 is a node initialization message according to the present invention;
FIG. 7 is a diagram illustrating the transmission of an ingress synchronization message from a node in accordance with the present invention;
fig. 8 is a diagram illustrating the receipt of a data message from a node in accordance with the present invention.
Detailed Description
The invention will now be described in more detail by way of examples which are illustrative only and are not intended to limit the scope of the invention in any way.
As shown in fig. 1-8, the present invention provides a technical solution: a development method of a remote I/O node comprises the following steps:
step 1: hardware of remote I/O node with CAN bus interface: the I/O hardware interface part adopts an MCP2515 controller which completely supports CAN2.OB. Communication rate to be 1Mb/s and is provided with an SPI serial interface as a control chip, so that the connection with a CAN bus CAN be simplified, the level conversion between the data level on the CAN bus and the controller is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, and interrupt signals are generated and transmitted after one frame of information is transmitted;
step 2: CAN bus driver based on μCOSII: canfiest iv AL is written in C language, supports all functions of CANOPEN CIA301 protocol, can realize functions of master station and slave station, has simple migration and cross-platform, and CANOPEN content is not discussed here, please refer to CIA related protocol;
considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data;
in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups;
the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task;
in the canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, analyzing which message the data extracted from the buffer belongs to, and then entering a corresponding message processing program;
step 3: transmitting and receiving CAN bus driver: the sending task can be scheduled and executed asynchronously, and can be scheduled and executed at regular time in the timer task;
step 4: testing of CAN bus driver: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling;
the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send a 64-bit input state to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
Embodiment one:
the hardware of the remote I/O node with the CAN bus interface, the I/O hardware interface part adopts an MCP2515 controller which completely supports CAN2.OB. Communication rate to be 1Mb/s and is provided with an SPI serial interface as a control chip, CAN simplify the connection with the CAN bus, the level conversion between the data level on the CAN bus and the controller is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, an interrupt signal is generated and transmitted after one frame of message is usually transmitted, and the CAN bus driver based on mu COSII: cancest ival is written in C language, supports all functions of CANOPENCIA301 protocol, can realize functions of master station and slave station, has simple migration and cross-platform, and the CANOPEN content is not discussed here, please refer to the related protocol; considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data; in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups; the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task; in the canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, it is analyzed which message the data fetched from the buffer belongs to, and then the corresponding message processing program is entered, and the sending and receiving of the CAN bus driver: the sending task CAN be scheduled and executed asynchronously, and also CAN be scheduled and executed at regular time in the timer task, and the test of the CAN bus driver is as follows: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling; the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send a 64-bit input state to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
Embodiment two:
in the first embodiment, the following steps are added:
in step 1, an interrupt signal is generated before a frame of message is sent, and the receive interrupt is generated when the message is buffered, each I/O node has 64 inputs and 16 outputs, and the driver in μcosii has mainly two parts, one is the receive interrupt and the other is the timer interrupt.
The hardware of the remote I/O node with the CAN bus interface, the I/O hardware interface part adopts an MCP2515 controller which fully supports CAN2.OB. Communication speed is 1Mb/s, the MCP2515 controller with the SPI serial interface is used as a control chip, the connection with the CAN bus CAN be simplified, the level conversion between the data level and the controller on the CAN bus is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, an interrupt signal is usually generated and sent after one frame of information is sent, an interrupt signal is generated before one frame of information is sent, the interrupt is generated when the information is buffered, each I/O node has 64 inputs and 16 outputs, the driving in the MuCOSI mainly has two parts, one is the interrupt receiving, and the other is the timer interrupt, and is based on the CAN bus driving program of the MuCOSII: cancest ival is written in C language, supports all functions of CANOPENCIA301 protocol, can realize functions of master station and slave station, has simple migration and cross-platform, and the CANOPEN content is not discussed herein, please refer to CIA related protocol; considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data; in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups; the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task; in the canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, it is analyzed which message the data fetched from the buffer belongs to, and then the corresponding message processing program is entered, and the sending and receiving of the CAN bus driver: the sending task CAN be scheduled and executed asynchronously, and also CAN be scheduled and executed at regular time in the timer task, and the test of the CAN bus driver is as follows: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling; the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send a 64-bit input state to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
Embodiment III:
in the second embodiment, the following steps are added:
in step 2, the receiving ring buffer is used for buffering the received bus message, waiting for processing of the application program, the sending ring buffer is used for buffering the message sent by the application program, waiting for processing of the sending task, when the sending buffer has no content to send, the sending task is suspended, when the receiving buffer has no content, the receiving task is suspended, when data is needed to send, the sending task is awakened, and the receiving task is scheduled after receiving the interrupt, and awakening the receiving task after receiving the interrupt.
The hardware of the remote I/O node with the CAN bus interface, the I/O hardware interface part adopts an MCP2515 controller which fully supports CAN2.OB. Communication speed is 1Mb/s, the MCP2515 controller with the SPI serial interface is used as a control chip, the connection with the CAN bus CAN be simplified, the level conversion between the data level and the controller on the CAN bus is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, an interrupt signal is usually generated and sent after one frame of information is sent, an interrupt signal is generated before one frame of information is sent, the interrupt is generated when the information is buffered, each I/O node has 64 inputs and 16 outputs, the driving in the MuCOSI mainly has two parts, one is the interrupt receiving, and the other is the timer interrupt, and is based on the CAN bus driving program of the MuCOSII: cancest ival is written in C language, supports all functions of CANOPENCIA301 protocol, can realize functions of master station and slave station, has simple migration and cross-platform, and the CANOPEN content is not discussed herein, please refer to CIA related protocol; considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data; in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups; the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in CANFESTIVA L in the receiving task; in canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, analyzing which message the data fetched from the buffer belongs to, then entering the corresponding message processing program, receiving the ring buffer for buffering the received bus message, waiting for processing by the application program, sending the ring buffer for buffering the message sent by the application program, waiting for processing by the sending task, when the sending buffer has no sending content, the sending task is suspended, when the receiving buffer has no content, the receiving task is suspended, when there is data to be sent, waking up the sending task, and when the receiving task is scheduled after receiving interrupt, waking up the receiving task after receiving interrupt, sending and receiving by the CAN bus driver: the sending task CAN be scheduled and executed asynchronously, and also CAN be scheduled and executed at regular time in the timer task, and the test of the CAN bus driver is as follows: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling; the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send a 64-bit input state to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
Embodiment four:
in example three, the following procedure was added:
in step 3, in order to implement periodic transmission of the process data packet, the system uses a timer with a period of 10ms to manage transmission and reception of the process data, the transmission function flow adds one to the transmission semaphore txsum, and then performs task scheduling once to make the transmission task enter a ready state, the reception interrupt flow performs task scheduling once after the reception interrupt is ended, and makes the reception task enter the ready state, the timer task flow is a timer task completion timer function, and when the timer packet is transmitted, the timer scans the timer attribute value of the process data, when the timer time is up, the process data packet is transmitted, and the time window interval between two adjacent process data transmissions is set in the timer task function, so that the packet with high priority does not occupy the bus for a long time.
In step 4, the transmitted data bit, 1, indicates a high level, and 0 indicates a low level.
The hardware of the remote I/O node with the CAN bus interface, the I/O hardware interface part adopts an MCP2515 controller which fully supports CAN2.OB. Communication speed is 1Mb/s, the MCP2515 controller with the SPI serial interface is used as a control chip, the connection with the CAN bus CAN be simplified, the level conversion between the data level and the controller on the CAN bus is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, an interrupt signal is usually generated and sent after one frame of information is sent, an interrupt signal is generated before one frame of information is sent, the interrupt is generated when the information is buffered, each I node has 64 inputs and 16 outputs, the driving in the μCOS mainly has two parts, one is the interrupt receiving, the other is the timer interrupt, and the CAN bus driving program based on the μCOSII: canfosta is written by a C language, supports all functions of a CANOPENCIA301 protocol, can realize functions of a master station and a slave station, and is simple to transplant and cross-platform; considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data; in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups; the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task; in canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, analyzing which message the data fetched from the buffer belongs to, then entering the corresponding message processing program, receiving the ring buffer for buffering the received bus message, waiting for processing by the application program, sending the ring buffer for buffering the message sent by the application program, waiting for processing by the sending task, when the sending buffer has no sending content, the sending task is suspended, when the receiving buffer has no content, the receiving task is suspended, when there is data to be sent, waking up the sending task, and when the receiving task is scheduled after receiving interrupt, waking up the receiving task after receiving interrupt, sending and receiving by the CAN bus driver: the sending task CAN be asynchronously scheduled and executed, and also CAN be scheduled and executed at regular time in the timer task, in order to realize the periodical sending of the process data message, the system uses a timer with a period of 10ms to manage the sending and receiving of the process data, the sending function flow is to schedule once after adding one for the sending signal quantity TXSem, the sending task is enabled to enter a ready state, the receiving interrupt flow is enabled to schedule once after ending the receiving interrupt, the receiving task is enabled to enter the ready state, the timer task flow is a TimeDispatch function to complete the timer task, when the timer message is sent, the timer will scan the timer attribute value of the process data, when the timer time arrives, the process data message is sent, the time window interval of sending of two adjacent process data is set in the TimeDispatch function, so that the high priority message does not occupy the bus for a long time, and the test of the CAN bus driving program: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling; the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an I/O node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send 64-bit input states to a master station in a period of 10ms, the I node receives output port data sent by the master station, the value of an output port is updated after the data is received, each received data bit is output in a high level mode, 0 corresponds to low level mode, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, the slave node ID is 02, the sent data bit is high level, and 0 represents low level.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (10)
1. A development method of a remote IO node is characterized in that: comprises the steps of,
step 1: hardware of remote IO node with CAN bus interface: the IO hardware interface part adopts an MCP2515 controller which completely supports CAN2.OB. Communication rate to be 1Mb/s and is provided with an SPI serial interface as a control chip, CAN be connected with a CAN bus in a simplified way, the level conversion between the data level on the CAN bus and the controller is completed by a transceiver MCP2551, the transmission and the reception are both in an interrupt mode, and an interrupt signal is generated and sent after one frame of information is usually sent;
step 2: CAN bus driver based on μCOSII: canfiest iv AL is written in C language, supports all functions of CANOPEN CIA301 protocol, can realize functions of master station and slave station, and has simple transplanting and cross-platform;
considering the structure of the CANFEST IVAL, in the driving design, the data sent and received on the CAN bus are realized in a non-blocking mode, and FIFO buffer structures are respectively used for the sent data and the received data;
in order to improve the reliability of data receiving and transmitting on the CAN bus, the receiving and transmitting are realized in the form of an annular buffer zone, and the annular buffer zone consists of a plurality of CAN data frame number groups;
the overall framework of the driver is divided into a sending task and a receiving task, the sending task is scheduled in a timer task TimerLoop0, and the processing of data is realized by calling a canDispatch0 function in a CanfESTIVAL in the receiving task;
in the canDispatch (& objDictdata, & m), according to the CANOPEN communication protocol, analyzing which message the data extracted from the buffer belongs to, and then entering a corresponding message processing program;
step 3: transmitting and receiving CAN bus driver: the sending task can be scheduled and executed asynchronously, and can be scheduled and executed at regular time in the timer task;
step 4: testing of CAN bus driver: setting a master node and a slave node for testing, wherein the node number of the master node is 1, the node number of the slave node is 2, 8-byte variables are defined to represent 64 inputs, 2 8-byte variables are used to represent 16 outputs, 1 Process Data (PDO) is used for transmitting input data (64 bits), node initialization is carried out when the system is started, node number distribution is carried out, then data transmission is started, data on a bus can be obtained on a monitoring terminal, 64 input data are configured to be transmitted once every 10ms, and the data are transmitted by the timing synchronous transmission of CANOPEN, and 64-bit input data are transmitted through timer task scheduling;
the 16-bit output data is updated to the output port after being processed in the receiving task, and the test result is as follows: the method comprises the steps that a node is initialized, a working state can be entered after the node is specified in CANOPEN, an IO node is started and initialized, a master node finds a slave node, the slave node enters a pre-operation mode, a sync callback function is called to send 64-bit input states to a master station in a period of 10ms, an I node receives output port data sent by the master station, the value of an output port is updated after the data is received, 1 corresponds to high-level output, 0 corresponds to low-level output, the master node is represented by 0, the slave node is represented by 1, the node ID of the master node is 01, and the slave node ID is 02.
2. The method for developing a remote IO node according to claim 1, wherein: in step 1 an interrupt signal is generated before a frame of message is sent, whereas a receive interrupt is generated when a buffered message is received, with 64 inputs and 16 outputs per I node.
3. The method for developing a remote IO node according to claim 1, wherein: in step 2, the drive in μcosii has mainly two parts, one for receiving interrupts and one for timer interrupts.
4. The method for developing a remote IO node according to claim 1, wherein: in step 2, the receiving ring buffer is used to buffer the received bus message, waiting for processing by the application program, and the sending ring buffer is used to buffer the message sent by the application program, waiting for processing by the sending task.
5. The method for developing a remote IO node according to claim 1, wherein: in step 2, the transmission task is suspended when the transmission buffer does not transmit content, and the reception task is suspended when the reception buffer does not transmit content.
6. The method for developing a remote IO node according to claim 1, wherein: in step 2, when there is data to be transmitted, the transmitting task is awakened, and the receiving task is scheduled after receiving the interrupt, and the receiving task is awakened after receiving the interrupt.
7. The method for developing a remote IO node according to claim 1, wherein: in step 3, to achieve periodic transmission of the process data message, the system uses a timer with a period of 10ms to manage transmission and reception of the process data.
8. The method for developing a remote IO node according to claim 1, wherein: in step 3, after the transmission function flow is one added to the transmission semaphore txsum, a task scheduling is performed once to make the transmission task enter a ready state, and the receiving interrupt flow is performed once after the receiving interrupt is finished to make the receiving task enter the ready state.
9. The method for developing a remote IO node according to claim 1, wherein: in step 3, the timer task flow is the TimeDispatch function to complete the timer task, when the timing message is sent, the timer scans the timer attribute value of the process data, when the timing time is up, the process data message is sent, and the time window interval between two adjacent process data sending processes is set in the TimeDispatch function, so that the high-priority message does not occupy the bus for a long time.
10. The method for developing a remote IO node according to claim 1, wherein: in step 4, the transmitted data bit, 1, indicates a high level, and 0 indicates a low level.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310171383.8A CN116319150A (en) | 2023-02-28 | 2023-02-28 | Remote I/O node development method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310171383.8A CN116319150A (en) | 2023-02-28 | 2023-02-28 | Remote I/O node development method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116319150A true CN116319150A (en) | 2023-06-23 |
Family
ID=86825073
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310171383.8A Pending CN116319150A (en) | 2023-02-28 | 2023-02-28 | Remote I/O node development method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116319150A (en) |
-
2023
- 2023-02-28 CN CN202310171383.8A patent/CN116319150A/en active Pending
Non-Patent Citations (1)
Title |
---|
林忠: "基于CANFESTIVAL的远程I/O节点的设计与实现", 赤峰学院学报(自然科学版), vol. 27, no. 04 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP0622713B1 (en) | Method and apparatus for exchanging different classes of data during different time intervals | |
CN111030909A (en) | Method for time synchronization among CAN bus multi-master device communication | |
JP2831070B2 (en) | Heterogeneous signal conversion method and apparatus | |
CN114500151B (en) | Motion control communication system and communication method based on CAN bus | |
CN114124279B (en) | Time-triggered Ethernet TT service time deterministic transmission design method | |
CN112367236B (en) | Data scheduling method and system of LIN bus | |
CN116319150A (en) | Remote I/O node development method | |
JP5372699B2 (en) | In-vehicle network device | |
CN111327476B (en) | Bandwidth dynamic adjustment system and method based on frame reservation | |
CN115657646B (en) | Test method and device of CAN controller | |
CN111988113B (en) | EtherCAT protocol and ASI protocol communication system and method | |
CN1275434C (en) | Method of transmitting asychronous linking data and its performance device | |
CN113726408B (en) | Self-adaptive synchronization method for cooperative synchronization and self-synchronization of satellite load system | |
CN214586463U (en) | ET 5000-based communication system | |
CN218734340U (en) | EtherCAT main station and EtherCAT bus system | |
CN111917504B (en) | Double-line synchronous high-speed transmission system for transmitting multi-path data | |
CN111711550B (en) | ID sequence sharing method for vehicle-mounted CAN network messages | |
CN117762099A (en) | Wire drawing machine control system and method | |
CN116155834A (en) | Deterministic resource scheduling method for industrial Internet of things heterogeneous data | |
CN118746934A (en) | System and method for connecting microprocessor with field bus | |
CN114915365A (en) | Time synchronization method and medium | |
CN114253771A (en) | Output data smooth switching method based on two-by-two-out-of-two safety platform | |
CN114536322A (en) | Robot control cabinet and robot system | |
JPS6384228A (en) | Data transmission system between master station and plural slave stations | |
Yuan | Analysis of Can Bus Frame Loss Compensation Method in 5g Environment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20230623 |
|
RJ01 | Rejection of invention patent application after publication |