- Controller-area network
Controller-area network (CAN or CAN-bus) is a computer
network protocol and bus standard designed to allowmicrocontroller s and devices to communicate with each other without ahost computer .It was designed specifically for automotive applications but is now also used in other areas.
CAN is also supported in the
Linux Kernel since version 2.6.25.Origins
Development of the CAN-bus started originally in
1983 atRobert Bosch GmbH . [ cite web
url = http://www.can-cia.de/index.php?id=161
title = CAN History
publisher = CAN in Automation] The protocol was officially released in 1986 at the SAE (Society of Automotive Engineers) congress in Detroit. The first CAN controller chips, produced by Intel and Philips, came on the market in 1987. Bosch published the CAN 2.0 specification in 1991.Applications
Automotive
A modern automobile may have as many as 50
electronic control unit s (ECU) for various subsystems. Typically the biggest processor is theengine control unit , which is also referred to as "ECU" in the context of automobiles; others are used fortransmission ,airbag s,antilock braking ,cruise control , audio systems, windows, mirror adjustment, etc. Some of these form independent subsystems, but communications among others are essential. A subsystem may need to control actuators or receive feedback from sensors. The CAN standard was devised to fill this need.The CAN bus may be used in vehicles to connect engine control unit and transmission, or (on a different bus) to connect the door locks, climate control, seat control, etc. Today the CAN bus is also used as a
fieldbus in general automation environments, primarily due to the low cost of some CAN Controllers and processors.Bosch holds patents on the technology, and manufacturers of CAN-compatible microprocessors pay licence fees to Bosch, which are normally passed on to the customer in the price of the chip. Manufacturers of products with custom ASICs or FPGAs containing CAN-compatible modules, may need to pay a fee for the " [http://www.semiconductors.bosch.de/en/20/can/2-license.asp CAN Protocol License] ".
CAN Network Testing
Unforeseen problems incorporated into CAN-based system are often attributed to the design methods used for the system and the individual component implementations. Scheduling methods which take into account the timing related to ECU software and hardware architecture, communication driver performance, and the network arbitration are required for minimizing the effort of testing required prior to manufacturing.
The development of distributed network-based systems often utilizes multiple suppliers for the prototyping of different modules and sub-systems. In order to best control the complexities incorporated from such a distributed developmental process, the Original Equipment Manufacturer usually requires a set of standard tests and procedures to be run on the prototypes prior to delivery.
These tests usually require the prototype ECU to be connected to a simulated system where performance measurements can be made for consideration of the physical layer, communication layer, and application layer. The standard tests are run repeatedly until the Device Under Test (DUT) passes all necessary tests. The requirements for testing vary depending on the Original Equipment Manufacturers focus and may include portions of the following sample test sequence:
Voltage Characteristic Protection Tests:
* Hardware Immunity to Ground Short,
* Hardware Damage Immunity to Source Voltage Short,
* Hardware under voltage operation characteristicsCommunication Waveform Characteristics:
* Transceiver tests (short to GND, short to VBAT, etc.),
* Signal Integrity (I-diagrams),
* Signal Jitter Analysis,
* Noise Injection Tests Software Recovery from Error Conditions:
* Bus Off ConditionsResponse Times:
* Functional Ages,
* Publisher Delays,
* Subscriber Delays,
* Gateway DelaysCommunication:
* First Frame Timing,
* Wakeup Sequence,
* Periodic Frame Times,
* Event FramesNetwork Management:
* Startup,
* Participation,
* Modes,
* ShutdownDiagnostics:
* Recognition of faults,
* Module ReflashingThe supplier module level testing cleans up a majority of issues, however the greatest task of identifying and troubleshooting issues is often confronted during the integration testing phase. The integration testing phase requires that the “live” ECU’s be interconnected for the first time and the ultimate goal of this phase is to eliminate all causes of system behavior which may negatively impact the manufactured products reliability.
Time constraints require efficient use of test processes, available resources and tools to ensure the highest levels of product quality are delivered at the conclusion of the integration testing phase. Testing teams must possess a means for identification and isolation of faults, along with the experience needed for quickly assessing possible root causes. The time required for actually tracking down and solving the root failure mode can often be extremely difficult and not time effective in widely distributed processes.
Testing tools must be scalable, flexible, and integrate able to provide test coverage for all pertinent levels of the OSI model. The ideal test tools themselves must provide the knowledge and know-how of skilled engineers by identifying questionable conditions, and then using reasoning to guide the test engineer in solving the issue. The tool should also be easily configurable, comprehensive, include predefined test libraries, and provide extremely reliable measurements..
Technology
CAN is a broadcast, differential serial bus standard for connecting
electronic control unit s (ECUs).Each node is able to send and receive messages, but not simultaneously: a message (consisting primarily of an ID — usually chosen to identify the message-type/sender — and up to eight message bytes) is transmitted serially onto the bus, one bit after another — this signal-pattern codes the message (in NRZ) and is sensed by all nodes.
The devices that are connected by a CAN network are typically
sensors ,actuators and control devices. A CAN message never reaches these devices directly, but instead a host-processor and a CAN Controller is needed between these devices and the bus.If the bus is free, any node may begin to transmit. If two or more nodes begin sending messages at the same time, the message with the more dominant ID (which has more dominant bits i.e. bit 0) will overwrite other nodes' less dominant IDs, so that eventually (after this arbitration on the ID) only the dominant message remains and is received by all nodes.
Each node requires
*a host-processor
**The host-processor decides what received messages mean, and which messages it wants to transmit itself
**Sensors, actuators and control devices can be connected to the host-processor (if desired)
*a CAN Controller (hardware with a synchronous clock)
**"Receiving": the CAN Controller stores received bits (one by one) from the bus until an entire message is available, that can then be fetched by the host processor (usually after the CAN Controller has triggered an interrupt)
**"Sending": the host-processor stores its transmit-messages into a CAN Controller, which transmits the bits serially onto the bus
*aTransceiver (possibly integrated into the CAN Controller)
**"Receiving": it adapts signal levels from the bus, to levels that the CAN Controller expects and has protective circuitry that protect the CAN Controller
**"Sending": it converts the transmit-bit signal received from the CAN Controller into a signal that is sent onto the busBit rate s up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g. 125 kbit/s at 500 m).The CAN data link layer protocol is standardized in
ISO 11898 -1 (2003). This standard describes mainly thedata link layer — composed of theLogical Link Control (LLC)sublayer and theMedia Access Control (MAC)sublayer — and some aspects of thephysical layer of theOSI Reference Model . All the other protocol layers are left to the network designer's choice.Certain microcontrollers, like some models of the
PIC microcontroller family byMicrochip Technology , some models of anyRenesas family andAtmel AVR , manyFreescale Semiconductor microcontrollers, as well as several ARM based microcontrollers have built-in CAN support.Data transmission
CAN features an automatic 'arbitration free' transmission. A CAN message that is transmitted with highest priority will 'win' the arbitration, and the node transmitting the lower priority message will sense this and back off and wait.
This is achieved by CAN transmitting data through a binary model of "dominant" bits and "recessive" bits where dominant is a logical 0 and recessive is a logical 1. This means
open collector , or 'wired or' physical implementation of the bus (but since dominant is 0 this is sometimes referred to as wired-AND). If one node transmits a dominant bit and another node transmits a recessive bit then the dominant bit "wins" (a logical AND between the two).So, if you are transmitting a recessive bit, and someone sends a dominant bit, you see a dominant bit, and you know there was a collision. (All other collisions are invisible.) The way this works is that a dominant bit is asserted by creating a voltage across the wires while a recessive bit is simply not asserted on the bus. If anyone sets a voltage difference, everyone sees it, hence, dominant.Thus there is no delay to the higher priority messages, and the node transmitting the lower priority message automatically attempts to re-transmit 6 bit clocks after the end of the dominant message.
When used with a differential bus, a
Carrier Sense Multiple Access /Bitwise Arbitration (CSMA/BA) scheme is often implemented: if two or more devices start transmitting at the same time, there is a priority based arbitration scheme to decide which one will be granted permission to continue transmitting. The CAN solution to this is prioritised arbitration (and for the dominant message delay free), making CAN very suitable for real time prioritised communications systems.During arbitration, each transmitting node monitors the bus state and compares the received bit with the transmitted bit.If a dominant bit is received when a recessive bit is transmitted then the node stops transmitting (i.e., it lost arbitration).Arbitration is performed during the transmission of the identifier field. Each node starting to transmit at the same time sends an ID with dominant as binary 0, starting from the high bit. As soon as their ID is a larger number (lower priority) they'll be sending 1 (recessive) and see 0 (dominant), so they back off. At the end of ID transmission, all nodes but one have backed off, and the highest priority message gets through unimpeded
Bit timing
Each node in a CAN network has its own clock, and no clock is sent during data transmission. Synchronization is done by dividing each bit of the frame into a number of segments: Synchronization, Propagation, Phase 1 and Phase 2. The Length of each "phase" segment can be adjusted based on network and node conditions. The sample point falls between Phase Buffer Segment 1 and Phase Buffer Segment 2, which helps facilitate continuous synchronization. Continuous synchronization in turn enables the receiver to be able to properly read the messages.
Layers
Based on levels of abstraction, the structure of the CAN protocol can be described in terms of the following layers:
* Application Layer
* Object Layer
**Message Filtering
**Message and Status Handling*Transfer Layer
The Transfer Layer represents the kernel of the CAN protocol. It presents messages received to the object layer and accepts messages to be transmitted from the object layer. The transfer layer is responsible for bit timing and synchronization, message framing, arbitration, acknowledgment, error detection and signaling, and fault confinement. It performs:
**Fault Confinement
**Error Detection
**Message Validation
**Acknowledgment
**Arbitration
**Message Framing
**Transfer Rate and Timing
**Information Routing*Physical Layer
The physical layer defines how the signals are actually transmitted. Tasks include:
**Signal Level and Bit Representation
**Transmission MediumFrames
A CAN network can be configured to work with two different message (or "frame") formats: the standard or base frame format (or CAN 2.0 A), and the extended frame format (or CAN 2.0 B). The only difference between the two formats is that the “CAN base frame” supports a length of 11 bits for the identifier, and the “CAN extended frame” supports a length of 29 bits for the identifier, made up of the 11-bit identifier (“base identifier”) and an 18-bit extension (“identifier extension”). The distinction between CAN base frame format and CAN extended frame format is made by using the IDE bit, which is transmitted as dominant in case of an 11-bit frame, and transmitted as recessive in case of a 29-bit frame. CAN controllers that support extended frame format messages are also able to send and receive messages in CAN base frame format. All frames begin with a start-of-frame (SOF) bit that denotes the start of the frame transmission.
CAN has four frame types:
* Data frame: a frame containing node data for transmission
* Remote frame: a frame requesting the transmission of a specific identifier
* Error frame: a frame transmitted by any node detecting an error
* Overload frame: a frame to inject a delay between data and/or remote framesData frame
The data frame is the only frame for actual data transmission. There are two message formats:
* Base frame format: with 11 identifier bits
* Extended frame format: with 29 identifier bitsThe CAN standard requires the implementation must accept the base frame format and may accept the extended frame format, but must tolerate the extended frame format.
Base frame format
The frame format is as follows:
One restriction placed on the identifier is that the first seven bits cannot be all recessive bits. (I.e., the 16 identifiers 1111111xxxx are invalid.)
Extended frame format
The frame format is as follows:
The two identifier fields (A & B) combined form a 29-bit identifier.
"*" It is physically possible for a value between 9-15 to be transmitted in the 4-bit DLC, although the data is still limited to 8 bytes. Certain controllers allow the transmission and/or reception of a DLC greater than 8, but the actual data length is always limited to 8 bytes.
Remote frame
•Generally data transmission is performed on an autonomous basis withthe data source node (e.g. a sensor) sending out a Data Frame. It isalso possible, however, for a destination node to request the data fromthe source by sending a Remote Frame.
•There are 2 differences between a Data Frame and a Remote Frame.Firstly the RTR-bit is transmitted as a dominant bit in the Data Frameand secondly in the Remote Frame there is no Data Field.
i.e. :RTR = 0 ; DOMINANT in data frame:RTR = 1 ; RECESSIVE in remote frame
In the very unlikely event of a Data Frame and a Remote Frame with the same identifier being transmitted at the same time, the Data Frame wins arbitration due to the dominant RTR bit following the identifier. In this way, the node that transmitted the Remote Frame receives the desired data immediately.
Error frame
;Error frame consists of two different fields:
The first field is given by the superposition of ERROR FLAGS contributed from different stations. The following second field is the ERROR DELIMITER.
;There are two types of error flags:
; Active Error Flag : Transmitted by a node detecting an error on the network that is in error state "error active".; Passive Error Flag : Transmitted by a node detecting an active error frame on the network that is in error state "error passive".
Overload frame
The overload frame contains the two bit fields Overload Flag and Overload Delimiter. There are two kinds of overload conditions that can lead to the transmission of an overload flag:
#The internal conditions of a receiver, which requires a delay of the next data frame or remote frame.
#Detection of a dominant bit during intermission.The start of an overload frame due to case 1 is only allowed to be started at the first bit time of an expected intermission, whereas overload frames due to case 2 start one bit after detecting the dominant bit. Overload Flag consists of six dominant bits. The overall form corresponds to that of the active error flag. The overload flag’s form destroys the fixed form of the intermission field. As a consequence, all other stations also detect an overload condition and on their part start transmission of an overload flag. Overload Delimiter consists of eight recessive bits. The overload delimiter is of the same form as the error delimiter.
Interframe spacing
Data frames and remote frames are separated from preceding frames by a bit field called interframe space. Overload frames and error frames are not preceded by an interframe space and multiple overload frames are not separated by an interframe space. Interframe space contains the bit fields intermission and bus idle and, for error passive stations, which have been transmitter of the previous message, suspend transmission.
Bit stuffing
In CAN frames, a bit of opposite polarity is inserted after five consecutive bits of the same polarity. This practice is called
bit stuffing , and is due to the "Non Return to Zero" (NRZ) coding adopted. The "stuffed" data frames are destuffed by the receiver. Since bit stuffing is used, six consecutive bits of the same type (111111 or 000000) are considered an error. Bit stuffing implies that sent data frames could be larger than one would expect by simply enumerating the bits shown in the tables above.Standards
There are several CAN
physical layer standards:
* ISO 11898-1: CAN Data Link Layer and Physical Signalling
* ISO 11898-2: CAN High-Speed Medium Access Unit
* ISO 11898-3: CAN Low-Speed, Fault-Tolerant, Medium-Dependent Interface
* ISO 11898-4: CAN Time-Triggered Communication
* ISO 11898-5: CAN High-Speed Medium Access Unit with Low-Power Mode
* ISO 11992-1: CAN fault-tolerant for truck/trailer communication
* ISO 11783-2: 250 kbit/s, Agricultural Standard
* SAE J1939-11: 250 kbit/s, Shielded Twisted Pair (STP)
* SAE J1939-15: 250 kbit/s, UnShielded Twisted Pair (UTP) (reduced layer)
* SAE J2411: Single-wire CAN (SWC)ISO 11898-2 uses a two-wire balanced signaling scheme. It is the most used physical layer in car powertrain applications and industrial control networks.
ISO 11898-4 standard defines the time-triggered communication on CAN (TTCAN). It is based on the CAN data link layer protocol providing a system clock for the scheduling of messages.
SAE J1939 standard uses a two-wire twisted pair, -11 has a shield around the pair while -15 does not. SAE 1939 is widely used in agricultural & construction equipment.
ISO 11783-2 uses four unshielded twisted wires; two for CAN and two for terminating bias circuit (TBC) power and ground. This bus is used on agricultural tractors. This bus is intended to provide interconnectivity with any implementation adhering to the standard.
Higher layer implementations
As the CAN standard does not include tasks of application layer protocols, such as
flow control , device addressing, and transportation of data blocks larger than one message, many implementations of higher layer protocols were created. Among these areDeviceNet ,CANopen , SDS (Smart Distributed System),CANaerospace ,J1939 ,NMEA 2000 ,CAN Kingdom ,SafetyBUS p , andMilCAN .An ARINC technical working group develops the ARINC 825 standard with special requirements for the aviation industry.
ee also
*
FlexCAN - An alternative implementation.
*CANopen - A higher-layer protocol.
*Local Interconnect Network - A low cost alternative.
*FlexRay - A possible future direction
*GMLAN - A customized version by GM
*Socketcan - a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel.
*OSEK References
External links
* [http://www.can-cia.org/ CAN in Automation (CiA) international users' and manufacturers' group]
* [http://www.kvaser.com/can/protocol/index.htm CAN educational page (1)]
* [http://www.softing.com/home/en/industrial-automation/products/can-bus/more-can-bus/communication/broadcast.php?navanchor=3010076 CAN educational page (2)]
* [http://www.canbus.com.br/ CAN educational page (3)]
* [http://www.cans.com.my/modules.php?name=FAQ&myfaq=yes&id_cat=1&categories=CAN CAN FAQ]
* [http://www.mjschofield.com/ CAN - The bits and bytes]
* [http://www.semiconductors.bosch.de/pdf/can2spec.pdf Bosch specification] (old document — slightly ambiguous/unclear in some points, superseded by the standard [http://www.iso.org/iso/search.htm?qt=Controller+Area+Network&searchSubmit=Search&sort=rel&type=simple&published=true ISO 11898] )
* [http://www.milcan.org/ MilCAN working group]
* [http://www.j1939forum.com/ J1939 Forum]
* [http://www.j1939standardscollection.com/ J1939 Documentation Project]
* [http://www.cancapture.com/forum.html CAN Technical Discussion]
* [http://paginas.terra.com.br/educacao/ee/ On-Board Electronics related papers] (Portuguese)
* [http://www.canaerospace.net CANaerospace]
* [http://www.wellandpower.net/forums/ CAN Engine Discussions]
* [http://www.glass-cockpit.org/ G1000-Simulator - A Open Source Project] A Flight simulator based on CAN-Bus technology.
* [https://forums.tm.agilent.com/phpbb2/index.php?c=19&sid=06ec72f1d7598d3c169d521ccb3fc203 Controller Area Network Discussion Forum] Network Testing Discussion Forum
Wikimedia Foundation. 2010.