Embedded systems applications growing rapidly in the automotive industry. Many vehicle designs use CAN, LIN or FlexRay to communicate among electronic control units (ECUs), and between ECUs and sensors, actuators and displays. These buses are critical in providing real-time communications in and among important subsystems from braking systems to infotainment systems.
CAN, LIN, and FlexRay are relatively mature bus protocols and are designed to be robust and easy to integrate. Even so, communications can be impacted by noise, board layout, and power-up/down timing. Problems can include excessive bus errors and lock-ups. Unlike basic protocol analyzers, oscilloscopes equipped with protocol decoding, can be used to see both the decoded bus traffic, as well as signal quality. This ability to see bus signals and decoded traffic makes oscilloscopes the best choice for troubleshooting.
Perhaps more importantly, oscilloscopes can be used to troubleshoot problems at the system level. Automobiles rely on extensive networks of sensors, actuators and displays, and many problems involve bus timing relative to I/O events or values. Oscilloscopes are well-suited for looking at I/O signals and bus transactions at the same instant. Because of this capability, they are the instrument of choice for system-level debugging.
THIS APPLICATION NOTE
- Gives a brief orientation on the physical layer and packet structures of CAN / CAN FD, LIN, and FlexRay buses, with a goal of providing just enough detail to help with troubleshooting
- Explains how to set up decoding on an oscilloscope equipped with CAN / CAN FD, LIN or FlexRay decoding
- Explains how to interpret decoded serial bus data on an appropriatelyequipped oscilloscope
- Explains what triggering and searching options are available
With optional serial triggering and analysis capability, Tektronix oscilloscopes become powerful tools for embedded system designers working with CAN, LIN, and FlexRay buses. In this application note the 5 Series MSO is used to demonstrate decoding and triggering on these buses.
Other Tektronix oscilloscopes also support CAN, LIN, and FlexRay triggering and analysis. See "Serial Support Using Oscilloscopes and Optional Software" for a complete listing.
The Controller Area Network (CAN) was originally developed in the 1980s by the Robert Bosch GmbH as a low cost communications bus between devices in electrically noisy environments. Mercedes-Benz became the first automobile manufacturer in 1992 to employ CAN in their automotive systems. Today, every automotive manufacturer uses CAN controllers and networks to control a variety of Electronic Control Units (ECUs) in their automobiles. It is the primary bus used for engine timing controls, anti-lock braking systems and power train controls to name a few. And due to its electrical noise tolerance, minimal wiring, excellent error detection capabilities and high data transfer speeds, CAN is expanding into other applications such as industrial control, marine, medical, aerospace, and more.
As vehicle networks have evolved to support many more functions, an urgent need has arisen to support faster data communication between nodes. This has led to CAN FD, a higher speed version of CAN which can achieve a max data rate of 8 Mbps with a payload up to 64 bytes long compared to the max data rate of 1 Mbps and payload of 8 bytes for CAN. The first version of the CAN FD standard was released in 2012 but it was later updated into an ISO standard called ISO CAN FD in 2015. The ISO version introduced additional safeguards to improve communication reliability. The original version is now known as non-ISO CAN FD and is not compatible with ISO CAN FD.
HOW IT WORKS
The CAN/CAN FD bus is a balanced (differential) 2-wire interface running over a Shielded Twisted Pair (STP), Un- shielded Twisted Pair (UTP), or ribbon cable. Each node uses a male 9-pin D connector. . A number of different data rates are defined, with 1Mb/s being the fastest for CAN and 8 Mb/s the fastest for CAN FD. All modules must support at least 20 kb/s. Normally all devices in a system transfer information at uniform and fixed bit rates. Maximum cable length depends on the data rate used. The maximum line length can be thousands of meters at low speeds; 40 meters at 1 Mb/s is typical. Termination resistors are used at each end of the cable.
Non Return to Zero (NRZ) bit encoding is used with bit stuffing to ensure compact messages with a minimum number of transitions and high noise immunity. The CAN bus interface uses an asynchronous transmission scheme where any node may begin transmitting anytime the bus is free. Messages are broadcast to all nodes on the network. In cases where multiple nodes initiate messages at the same time, bitwise arbitration is used to determine which message is higher priority. Messages can be one of four types:
The intermission (INT) field of three recessive bits indicates the bus is free. Bus Idle time may be any arbitrary length including zero.
SETTING UP CAN / CAN FD BUS DECODING
On Tektronix oscilloscopes equipped with CAN decoding and triggering, pressing the front panel Bus button lets you define inputs to the scope as a bus. To enable the oscilloscope to decode information being transferred, you enter some basic parameters:
- CAN standard
- Type of signal
- Input channel
- Bit rate(s)
- Voltage threshold
- Sample point (as a percent of bit time)
The CAN bus is a differential signal. Although the oscilloscope can acquire and decode the bus using single-ended probing, the signal fidelity and noise immunity is improved by using differential probing.
INTERPRETING CAN / CAN FD BUS INFORMATION
The decoded bus waveform indicates the elements of a CAN message using color-coded graphics.
For firmware engineers, the Results Table format may be more useful.This time-stamped display of bus activity can be easily compared to the software listings, and provides easy calculation of the execution speed.
The Results Table also provides linkage back to the waveform displays.You can tap a line in the tabular display and the oscilloscope automatically zooms in on the corresponding bus signals and resulting decoded bus waveform, shown in the lower section of the screen.
SYMBOLIC CAN BUS DECODING
Symbolic decoding, as defined in .dbc database files, can be used to display CAN and CAN FD bus traffic in an easy to read format. By loading a .dbc database file into the scope, you can view CAN traffic as text, rather than raw hex values. The file syntax is standardized, but the specific encoding and translation is proprietary and closely held by manufacturers.
In this example, a few symbolic message and signal values are shown in the bus waveform and results table displays.
TRIGGERING ON CAN BUS ACTIVITY
Begin able to trigger an acquisition based on specific bus activity makes the oscilloscope an important tool in system-level debugging. When the bus trigger is correctly set up, the oscilloscope will capture all input signals synchronized to the specified bus activity. This example shows the oscilloscope triggering on a write to extended identifier 12345678 hex.
The full CAN / CAN FD bus triggering capabilities include the following trigger types.
SEARCHING FOR CAN BUS ACTIVITY
On a Tektronix oscilloscope equipped with CAN / CAN FD decoding, you can use the automated Wave Inspector search to find all of the bus events that meet specific search criteria and determine how many of them occurred during an acquisition. The setup is similar to bus trigger setup, with the same alternatives for specifying criteria. In this example the search function is set to automatically search for data values of 00 hex. It found and marked 10 occurrences.
In addition to searching on hex and binary values, when symbolic decoding is used Wave Inspector can automatically search on symbolic messages and signal values. In this example, search found the MOTOR_STATUS message with the MOTOR_STATUS_speed_kph signal value of 44.476 kph.
The Local Interconnect Network (LIN) bus was developed by the LIN consortium in 1999 as a lower cost alternative to the CAN bus for applications where the cost, versatility, and speed of CAN were overkill. These applications typically include communications between intelligent sensors and actuators such as window controls, door locks, rain sensors, windshield wiper controls, and climate control, to name a few.
However, due to its electrical noise tolerance, error detection capabilities, and high speed data transfer, CAN is still used today for engine timing controls, anti-lock braking systems, power train controls and more.
HOW IT WORKS
The LIN bus is a low-cost, single-wire implementation based on the Enhanced ISO9141 standard. LIN networks have a single master and one or more slaves. All messages are initiated by the master with only one slave responding to each message, so collision detection and arbitration capabilities are not needed as they are in CAN. Communication is based on UART/SCI with data being sent in eight-bit bytes along with a start bit, stop bit and no parity. Data rates range from 1 kb/s to 20 kb/s. While this may sound slow, it is suitable for the intended applications and minimizes EMI.
The LIN bus is always in one of two states: active or sleep. When it’s active, all nodes on the bus are awake and listening for relevant bus commands. Nodes on the bus can be put to sleep by either the Master issuing a Sleep Frame or the bus going inactive for longer than a predetermined amount of time. The bus is then awakened by any node requesting a wakeup or by the master node issuing a break field.
LIN frames consist of two main parts, the header and the response. The header is sent by the master while the response is sent by the slave. The header and response each have subcomponents:
SETTING UP LIN BUS DECODING
On Tektronix oscilloscopes equipped with LIN decoding and triggering, pressing the front panel Bus button lets you to define inputs to the scope as a bus. To enable the oscilloscope to decode the information being transferred on the bus, you enter some basic parameters:
- Input channel
- LIN version being used
- Bit rate
- Where to sample the data (as a percent of bit time), LIN signals can be captured using passive or active analog probes, but digital logic probes can also be used for acquiring LIN signals.
INTERPRETING THE LIN BUS
The decoded bus waveform graphically indicates the different elements of a LIN message.
TRIGGERING ON LIN BUS ACTIVITY
With the LIN bus properly set up, the oscilloscope will be able to capture all of the input signals, based on the occurrence of a bus trigger event. In this example, the oscilloscope has triggered when the identifier 01 hex is followed by a data value of 1E hex.
The full LIN bus triggering capabilities include the following trigger types:
These trigger types allow you to isolate different types of events a LIN bus and use them as triggers to view system activity. And with the other advanced serial features found in Tektronix oscilloscopes such as results tables and Wave Inspector search, you can easily debug LIN based automotive designs.
As cars get smarter and electronics find their way into more and more automotive applications, manufacturers are finding that existing automotive serial standards such as CAN and LIN do not have the speed, reliability, or redundancy required to address X-by-wire applications such as brake-by-wire or steer- by-wire. Today, these functions are dominated by mechanical and hydraulic systems. In the future they will be replaced by a network of sensors and highly reliable electronics that will not only lower the cost of the automobile, but also significantly increase passenger safety due to intelligent electronic based features such as anticipatory braking, collision avoidance, adaptive cruise control, etc.
HOW IT WORKS
FlexRay is a differential bus running over either a Shielded Twisted Pair (STP) or an Unshielded Twisted Pair (UTP) at speeds up to 10 Mb/s, significantly faster than LIN’s 20 kb/s or CAN’s 1 Mb/s rates. FlexRay uses a dual channel architecture which has two major benefits. First, the two channels can be configured to provide redundant communication in safety critical applications such as X-by-wire to ensure the message gets through. Second, the two channels can be configured to send unique information on each at 10 Mb/s, giving an overall bus transfer rate of 20 Mb/s in less safety-critical applications.
FlexRay uses a time triggered protocol that incorporates the advantages of prior synchronous and asynchronous protocols via communication cycles that include both static and dynamic frames. Static frames are time slots of predetermined length allocated for each device on the bus to communicate during each cycle. Each device on the bus is also given a chance to communicate during each cycle via a Dynamic frame which can vary in length (and time). The FlexRay frame is made up of three major segments; the header segment, the payload segment, and the trailer segment. Each segment is made up of one or more components:
SETTING UP FLEXRAY BUS DECODING
To set up decoding, you must specify some basic parameters describing the bus:
- Specify the FlexRay channel A or B
- Type of signal we’re probing (differential, half the differential pair, or the logic signal between the controller and the bus driver)
- Voltage thresholds. FlexRay requires two thresholds to be set when looking at nonTx/Rx signals as it is a three-level bus. This enables the oscilloscope to recognize Data High and Data Low as well as the idle state where both signals are at the same voltage.
- Bit rate
DECODING AND TRIGGERING ON FLEXRAY
Once the bus is set up the oscilloscope will be able to isolate, capture, and display specific FlexRay bus events, as well as any other coincident signals. Such a time-correlated display allows you to verify causes and effects in the design. In this example the oscilloscope was set to trigger on the Frame ID value 002 hex. The oscilloscope's FlexRay triggering capability includes the following types:
But how many of the events occurred? To find all of the bus events that meet a specific search criteria, you can use automated Wave Inspector search. The setup is similar to the bus trigger setup, allowing the oscilloscope to find and mark all of the specified bus events.
In the example above the oscilloscope was set up to trigger on a specific Frame ID. It captured and decoded approximately 80 FlexRay frames. Then Wave Inspector search was set up to go through the acquisition and and marked 49 occurrences within a range of data values. Each of the data values in the specified range is shown with the pink bracket icon. Using the arrow keys, you can instantly navigate between marked values.
And all of this was done with only 250,000 point record lengths. The 5 Series MSO, for example, can capture 62.5 Mpoints with standard record length, or 125 M points when equipped with extended record length.
DECODING MULTIPLE BUSES AT ONCE
A powerful feature of the oscilloscope is the ability to define and decode many serial buses simultaneously. Going back to our earlier example with CAN bus; now imagine that the window controls are operated by a LIN bus. When the driver presses the Passenger Window Down control, a message is initiated on a LIN bus in the driver door, passed through a central CAN gateway and then sent on to another LIN network in the passenger door. In this case, we can trigger on the relevant message on one of the buses and capture and decode all three buses simultaneously, making it exceptionally easy to view traffic as it goes from one bus to another through the system. In this example, the scope has triggered on the first LIN message and captured all three buses.