1、CAN总线外文文献及译稿CAN Bus ProtocolIntroductionController Area Network (CAN) was initially created by German automotive system supplier Robert Bosch in the mid-1980s for automotive applications as a method for enabling robust serial communication. The goal was to make automobiles more reliable, safe and fu
2、el-efficient while decreasing wiring harness weight and complexity. Since its inception, the CAN protocol has gained widespread popularity in industrial automation and automotive/truck applications. Other markets where networked solutions can bring attractive benefits like medical equipment, test eq
3、uipment and mobile machines are also starting to utilize the benefits of CAN. The goal of this application note is to explain some of the basics of CAN and show the benefits of choosing CAN for embedded systems networked applications.CAN OverviewMost network applications follow a layered approach to
4、 system implementation. This system etic approach enables sinter operability between products from different manufacturers. A standard was created by the International Standards Organization (ISO) as a template to follow for this layered approach. It is called the ISO Open Systems Interconnection (O
5、SI) Network Layering Reference Model. The CAN protocol itself implements most of the lower two layers of this reference model. The communication medium portion of the model was purposely left out of the Bosch CAN specification to enable system designers to adapt and optimize the communication protoc
6、ol on multiple media for maximum flexibility (twisted pair, single wire, optically isolated, RF, IR, etc.). With this flexibility, however, comes the possibility of interoperability concerns. To ease some of these concerns, the International Standards Organization and Society of Automotive Engineers
7、 (SAE) have defined some protocols based on CAN that include the Media Dependents Interface definition such that all of the lower two layers are specified.ISO11898 is a standard for high-speed applications, ISO11519 is a standard for low-speed applications, and J1939 (from SAE) is targeted for truck
8、 and bus applications. All three of these protocols specify a 5V differential electrical bus as the physical interface. The rest of the layers of the ISO/OSI protocol stack are left to be implemented by the system software developer. Higher Layer Protocols (HLPs) are generally used to implement the
9、upper five layers of the OSI Reference Model.HLPs are used to:1) Standardize startup procedures including bit rates used,2) Distribute addresses among participating nodes or types of messages,3) Determine the structure of the messages, and4) Provide system-level error handling routines. This is by n
10、o means a full list of the functions HLPs perform; however it does describe some of their basic functionality.CAN Protocol BasicsCarrier Sense Multiple Access with Collision Detection (CSMA/CD)The CAN communication protocol is a CSMA/CD protocol. The CSMA stands for Carrier Sense Multiple Access. Wh
11、at this means is that every node on the network must monitor the bus for a period of no activity before trying to send a message on the bus (Carrier Sense). Also, once this period of no activity occurs, every node on the bus has an equal opportunity to transmit a message (Multiple Access). The CD st
12、ands for Collision Detection. If two nodes on the network start transmitting at the same time, the nodes will detect the collision and take the appropriate action. In CAN protocol, a nondestructive bitwise arbitration method is utilized. This means that messages remain intact after arbitration is co
13、mpleted even if collisions are detected. All of this arbitration takes place without corruption or delay of the higher priority message.There are a couple of things that are required to support non-destructive bitwise arbitration. First, logic states need to be defined as dominant or recessive. Seco
14、nd, the transmitting node must monitor the state of the bus to see if the logic state it is trying to send actually appears on the bus. CAN define a logic bit 0 as a dominant bit and a logic bit 1 as a recessive bit.A dominant bit state will always win arbitration over a recessive bit state, therefo
15、re the lower the value in the Message Identifier (the field used in the message arbitration process), the higher the priority of the message. As an example, suppose two nodes are trying to transmit a message at the same time. Each node will monitor the bus to make sure the bit that it is trying to s
16、end actually appears on the bus. The lower priority message will at some point try to send a recessive bit and the monitored state on the bus will be a dominant. At that point this node loses arbitration and immediately stops transmitting. The higher priority message will continue until completion a
17、nd the node that lost arbitration will wait for the next period of no activity on the bus and try to transmit its message again.Message-Based CommunicationCAN protocol is a message-based protocol, not an address based protocol. This means that messages are not transmitted from one node to another no
18、de based on addresses. Embedded in the CAN message itself is the priority and the contents of the data being transmitted. All nodes in the system receive every message transmitted on the bus (and will acknowledge if the message was properly received). It is up to each node in the system to decide wh
19、ether the message received should be immediately discarded or kept to be processed. A single message can be destined for one particular node to receive, or many nodes based on the way the network and system are designed. For example, an automotive airbag sensor can be connected via CAN to a safety s
20、ystem router node only. This router node takes in other safety system information and routes it to all other nodes on the safety system network. Then all the other nodes on the safety system network can receive the latest airbag sensor information from the router at the same time, acknowledge if the
21、 message was received properly, and decide whether to utilize this information or discard it.Another useful feature built into the CAN protocol is the ability for a node to request information from other nodes. This is called a Remote Transmit Request(RTR). This is different from the example in the
22、previous paragraph because instead of waiting for information to be sent by a particular node, this node specifically requests data to be sent to it.One additional benefit of this message-based protocol is that additional nodes can be added to the system without the necessity to reprogram all other
23、nodes to recognize this addition. This new node will start receiving messages from the network and, based on the message ID, decide whether to process or discard the received information.CAN Message Frame DescriptionCAN protocol define four different types of messages (or Frames). The first and most
24、 common type of frame is a Data Frame. This is used when a node transmits information to any or all other nodes in the system. Second is a Remote Frame, which is basically a Data Frame with the RTR bit set to signify it is a Remote Transmit Request. The other two frame types are for handling errors.
25、 One is called an Error Frame and one is called an Overload Frame. Error Frames are generated by nodes that detect any one of the many protocol errors defined by CAN. Overload errors are generated by nodes that require more time to process messages already received.Data Frames consist of fields that
26、 provide additional information about the message as defined by the CAN specification. Embedded in the Data Frames are Arbitration Fields, Control Fields, Data Fields, CRC Fields, a 2-bit Acknowledge Field and an End of Frame.The Arbitration Field is used to prioritize messages on the bus. Since the
27、 CAN protocol defines a logical 0 as the dominant state, the lower the number in the arbitration field, the higher priority the message has on the bus. The arbitration field consists of 12-bits (11 identifier bits and one RTR bit) or 32-bits (29 identifier bits, 1-bit to define the message as an ext
28、ended data frame, an SRR bit which isunused, and an RTR bit), depending on whether Standard Frames or Extended Frames are being utilized. The current version of the CAN specification, version 2.0B,defines 29-bit identifiers and calls them Extended Frames. Previous versions of the CAN specification d
29、efined 11-bitidentifiers which are called Standard Frames.As described in the preceding section, the Remote Transmit Request (RTR) is used by a node when it requires information to be sent to it from another node. To accomplish an RTR, a Remote Frame is sent with the identifier of the required Data
30、Frame. The RTR bit in the Arbitration Field is utilized to differentiate between a Remote Frame and a Data Frame. If the RTR bit is recessive, then the message is a Remote Frame. If the RTR bit is dominant, the message is a Data Frame. The Control Field consists of six bits. The MSB is the IDE bit (
31、signifies Extended Frame) which should be dominant for Standard Data Frames. This bit determines if the message is a Standard or Extended Frame. In Extended Frames, this bit is RB1 and it is reserved.The next bit is RB0 and it is also reserved. The four LSBs are the Data Length Code (DLC) bits. The
32、Data Length Code bits determine how many data bytes are included in the message. It should be noted that a Remote Frame has no data field, regardless of the value of the DLC bits. The Data Field consists of the number of data bytes described in the Data Length Code of the Control Field. The CRC Fiel
33、d consists of a 15-bit CRC field and a CRC delimiter, and is used by receiving nodes to determine if transmission errors have occurred.The Acknowledge Field is utilized to indicate if the message was received correctly. Any node that has correctly received the message, regardless of whether the node processes or discards the data, puts a domi
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2