Transfer from: http://www.gongkong.com/article/201412/55783.html
TonyZhou: I have always wanted to write an article about CANopen. In view of the lack of personal knowledge, I have done a lot of ideological struggle today.
The plan from the sales staff, technical staff angle to analyze the advantages of CANopen, the article may have no rules, just think where to say where, welcome to clap bricks.
Background: CANopen four questions
1. CANopenWhere does the CANopen come from?
In 1983, German Bosch company developed CAN protocol for network communication of automobile transmission system. Later known as the international standard ISO11898, CANopen is currently drafted and audited by the non-profit organization CiA (CAN in Automaion).The basic CANopen devices and communication sub protocols are defined in CAN in Automation (CiA) draft standard 301.. Sub protocols for individual devices are further expanded on the basis of CiA 301.Such as CiA401 for I/O module and CiA402 for motion control.
2. CANopenWhat is the advantage of hardware?
CANThe most prominent feature of the protocol is error detection, restriction and processing. When the CAN device detects a bus error, it will reject the sequence of bits received before and send the “error frame”, which is completely processed by the CAN chip itself, without the need for human programming.
Supporting multi master stations, similar to Profibus DP, each device on the bus is a master station and a slave station, which eliminates the process of human arbitration and facilitates user development.
Short message frame structure, CAN packets usually have only 8 bytes, data frames are very short, and have inherent advantages in anti-jamming capability. Explain why the short frame structure has good anti-interference capability. If the message is long, sending a frame will take a long time. If you join in the interference, you will not be able to send a message.As a result, the other side had not received the alarm and could only cry loudly.
Low cost, CAN peripherals can basically be found on the mainstream chips. 20 of the MCU supports CAN peripherals, others support two CAN. Here is the positive promotion of CiA.
3. CANopenSoftware advantages?
CANopenThe main CiA is in the promotion, is a non-profit organization, the CANopen agreement data, a pile of Internet, anyone can download to, we commonly used DS301 (Draft Standand), DS402, CAN fans almost one hand, like a sunflower treasure, must be JaneHide one.
CANopenProtocol development, open source projects are very many, CanFestival is one of them, I have done a transplant, in the step MT4414TE-CAN touch screen, used on 8 bit SCM, this source is a bit of resource consumption, the network has a lot of MCU Based Simplified source code.
Developing a complete CANopen stack is hard work. It is very difficult to do well. The difficulty lies in your understanding of CANopen protocol, such as EMCY, reset node, need “NO Initialization”, heartbeat, N.Does ode guard need? How do you deal with it? This is not an advantage.
4. Why are so many companies promoting CANopen?
CANopenFor motion control, it is an excellent communication protocol that uses some object oriented design ideas, such as object dictionary, process data object (PDO), service data object (SDO) and so on.
CANopenIn Europe, it has become the most common agreement. Any automatization company has CANopen communication interface and low allocation. Low matching does not mean that it is not good, but that its cost performance is even higher. CANopen defines a complete synchronization control mechanism to make it a mainstream motion control protocol, in addition toOn the CAN bus, it has been moved to the CANopen over Ethernet, forming the famous PowerLink, EtherCat Industrial Ethernet protocol.
Here is a few words, and the so-called motion control bus standard does not have much significance, because the motion control technology is in the hands of each manufacturer, and every slightly bigger manufacturer has its own special motion control protocol, such as the MITSUBISHI SSCNET, and the MECHATROLINK of an inchuan.CANOPEN and EtherCat, Schneider’s CANopen, SIEMENS’s SiMotion, Begala’s PowerLink, BOSCH Rexroth’s SERCOS.
Because CANopen (can see DS402, servo control standard) in motion control advantages, especially synchronous control, no matter the manufacturers of several streams, in the motion control system, more or less are added to their own things, causing the motion control system to be usually closed, and rarely walk each other.It is very difficult to be interconnected.
Two or three stream manufacturers, develop their own CANopen protocol, according to their own needs, move it to different physical layers to run, form their own motion control system, its performance and performance is the understanding of the CANopen protocol.
The foundation: Nine obscure concepts in the CANopen world
It is the data archive file of CAN network configuration (Config). It has little effect, and this option is available in Codesys software.
An electronic data table is a file describing the attributes and parameters of a slave device, and a description of the slave device object dictionary. For example, a servo driver, if its internal parameter (each parameter corresponds to a position in the object dictionary, is determined by index, sub-index), is not changed.The corresponding EDS file will not be changed. To say more, not all main controllers need to use EDS, such as Beckhoff, not needed, he needs you to CANopen DS301, DS402 is familiar, manual alignment; step FD, JD servo according to DS402 standard sets EDS file, users can directly configure and reduce development cycle.
3. Reset node
When the equipment meets the exception (for example, after reconnecting from the station break line, using the M258 test step FD servo), the main control will send “reset node”, the ED servo reset node of the step, the driver recover the factory value, and even the CAN communication parameter will be restored to the default value. FD, JD servo is the CAN communication parameterOutside the number, other configuration parameters restore the factory value.
An emergency message, from the station such as a servo, will send an emergency message after the power break to tell the master to control its state. After the power is broken, its capacitance can guarantee the transmission of the message.
5. Heartbeat, node protection
Configuring heartbeat parameters, setting heartbeat cycle and heartbeat consumption time, this consumer time is actually a timeout parameter. When the main station receives a heartbeat, it starts the timing. If the next heartbeat is not received in the timeout time, it is considered to be off the station, and the error is reported, according to the user configuration of the error handling party.The method is treated by the method.
Each node in the network can configure the heartbeat, the master station can monitor the slave station, monitor the master station from the station, and monitor the slave station from the station. Here is the concept of a producer and consumer. The device on the bus defines itself as a producer of heartbeat or a consumer. The producer produces a heartbeat, and the consumer monitors the heartbeat.Then, after catching the exception, make corresponding processing.
Personally, I think the heartbeat is not very effective. Suppose a device is disconnected and reset the node after reconnection. Is the device just using the servo function of the origin function? When the power is off, the position of the origin is changed. So in some customer applications, this happens, young man, you are bad, cut off the power and restart.
Node protection, whose function is similar to heartbeat, but can read the CANopen communication state (initialization, pre operation, operation, stop) from the station device, which belongs to the category of DS301.
6. DS301The difference from DS402
DS301It is a communication protocol stack. DS402 is an upper layer protocol built on DS301, which belongs to the servo control protocol. The protocol specifies that each object dictionary is worthy of action, such as 0x6040, which is a control word. DS402 defines the functions that a servo should have.It can be defined according to the definition of the protocol.
7. Object dictionary
From the software point of view, object dictionary is essentially a collection of data structures. It can be understood that the object dictionary is a book. The code of behavior of the CANopen device is to refer to this book, no matter what it does, as long as its behavior is to refer to the object dictionary, we must consult the dictionary first.Decide whether to do it or not. For example, when it sends TPDO, this behavior requires querying the transmission type corresponding to TPDO in the object dictionary and Event timer. There is also the principle of PDO mapping, for example, I want to send the data, is to query this book, see where it writes.What is the content, then I am sending this part in the form of PDO.
For example, your program has received a CAN message. Since you can access the object dictionary with the object of SDO, first to judge that it is a SDO object, then your program needs to find the object dictionary (an arranged data structure set) in accordance with the index and subindex specified in the SDO, and find the corresponding object.Follow the instructions in SDO to manipulate the object, for example, assign a value to the variable in the dictionary.
This is very simple, it is like the serial one to one mode, the main station sends the request frame, and answers the reply from the station.
You see a few examples.
To write the 1 byte data : 0xFD in the object dictionary of node 5, at index 0x1400, subindex 2, sends :
605 2F 00 14 02 FD 00 00 00
If success, the node 5 responds :
585 60 00 14 02 00 00 00 00
To write the 4 bytes data : 0x60120208 in the object dictionary of node 5, at index 0x1603, subindex 1, sends :
605 23 03 16 01 08 02 12 60
If success, the node 5 responds :
585 60 03 16 01 00 00 00 00
It is divided into TX-PDO, RX-PDO.
Above, this is the configuration process of PDO, 0x1402 (receiving PDO communication parameters), cob-id used by PDO, transmission type, Inhibit time, EventTimer.
0x1602（The mapped object) is mapped to Controlword, Target position in the preceding example.
This is mainly about Transmission Type, which is the centralized way supported by CoDeSys:
acyclic sync（The value is 0): synchronous PDO, synchronization mode defined by specific device protocol.
Cyclic sync（The value is 1-240): synchronize PDO and send PDO after each N SYNC cycle.
Sync rtr（Value 253): synchronize PDO and send PDO after receiving remote frame request.
Async（Value 253): asynchronous PDO, after receiving the remote frame, send PDO
The last two Async (254255) are defined by the device manufacturer, which is also the most commonly used to send when events occur. Various manufacturers basically use data transmission mode when they are here. FD and JD servo are two methods, they are all data transmission. Pay attention to setting up”Prohibit time” and reduce CANOPEN communication bandwidth.
The master controller writes target position, mode of operation to the servo, and the PDO cob-id is 0x200 node ID. The transmission mode is 255 or 254, and the time of banning is 100, that is, 10ms.