Académique Documents
Professionnel Documents
Culture Documents
Stephen Olsen, Product Line Manager, Operating System Platforms, Wind River Lalita Godbole, Founder, Octrian LLC
Session Outline
Introduction Design of distributed applications CAN protocol technical overview SocketCAN interface CAN for the Internet of Things CANopen
What is CAN?
Controller Area Network Originated in automotive industry as communications bus in automobiles Used in safety-critical applications Defines how a message is delivered Does not define the meaning of the message
CAN Applications
Proprietary protocols
Example: ECU to ECU communication in a vehicle
Monitoring system
Camera
Devices
Each device in the distributed application has its own processor or programmable logic device To make the application work, devices must be able to send messages to each other
Monitoring system
Camera
Bus Architecture
Bus architecture connects all devices to one communication line Protocol needed to handle ownership of bus
Monitoring system
Camera
Bus
Monitoring system
Temperature reading Weld command
Camera
Proximity reading
Position command
Welding gun
Robot arm
2013 Wind River and Octrian All Rights Reserved
Monitoring system
Camera
Monitoring system
Camera
Media Layer
15
Terminating Resistors
Both ends of the CAN cable is terminated by 120 across the twisted pair 120
2013 Wind River and Octrian All Rights Reserved
120
16
110010110..
Baud Rates
Baud rate = bits per second Typically 100kb/s to 1Mkb/s Faster baud rates need shorter cable lengths
Arbitration process
Occupied Bus
Data takes up the entire bus No other data can be sent until current transmission is finished All nodes receive the same data
Yes
Yes Yes
Messages
Messages are identified by their functionality Functionality is assigned by distributed application (user of CAN protocol) Brake commands
Diagnostic information
Temperature requests
Message Filtering
All nodes receive the same message Upon receiving the message, each node decides whether or not it needs that type of message
Message Priority
All messages are ordered by priority Priority is determined by the identifier Message identifiers are assigned according to priority Smaller identifiers have higher priority Important for distributed application to assign priorities correctly and avoid using the same message identifier
Brake commands
0x220
0x240
0x250
Temperature requests
0x330
Diagnostic information
Arbitration
When two nodes start sending different messages at exact same time, the higher priority message always takes precedence Sender of low priority message backs off and retries when the bus is idle
No Yes Accept
High priority
Message Frames
Error Detection
Nodes that detect errors send out an error signal immediately Sender detects error signal and aborts message immediately Sender retries as soon as bus is idle
Sending message
Sender
Any node
Error detected
Time
Error Types (1 of 2)
Frame error
Message received violates CAN message structure
# Checksum error
Checksum does not match rest of CAN message
ACK error
?
Sender node receives no ACK signal
Error Types (2 of 2)
0011011010100011 0011011010100010
mismatch
Sender, monitoring the bus as it is sending, receives a bit different from the one it sent
Correct: 6th bit after 5 consecutive matching bits is stuffed Bit-stuffing error 000001 111110
Error: 6th consecutive matching bit violates bit-stuffing rule 000000 111111
CAN Properties
Protection against intermittent bus errors Ensures timely delivery of high priority messages Allows multi-casting: All nodes listen to same message Notification of broken network Fault confinement
Controller Functionality
CAN controllers take care of
Sending and receiving messages Message arbitration Message filtering ACK signalling Error-checking Resending of unsent messages Calculating checksum Bit-stuffing Bus-monitoring during send action Keeping track of error count Bus-off when error limit is exceeded
000001 111110
Accept Ignore
SocketCAN
Standard Linux CAN drivers use SocketCAN Uses Sockets with a different protocol family
AF_CAN and not AF_NET
An Interconnected World
Internet of Things Machines talking to Machines What brings smarts within the Machine ?
Remote Control
An Interconnected World
What brings smarts within the Machine ?
actuators
actuators
HMI
sensors
Monitor
sensors
actuators
HMI
sensors
Monitor
sensors
CAN Bus
Controller Area Network
2013 Wind River and Octrian All Rights Reserved
Why CANopen ?
Standard Object Oriented Design Quick and Easy Deployment Plug and Play Ease of application configuration Ease of connectivity Interoperability of devices and tools
Typical Applications
Medical systems Vehicle automation Vending machines Rail vehicles Power generation Maritime electronics Robotics Defense
Robot Arm
Automotive
Medical Systems
2013 Wind River and Octrian All Rights Reserved
CANopen Protocol
Network management Layer management Distributor Device and Application Profiles Electronic Data Sheet Device Configuration File
Object Dictionary
Every device must implement an object dictionary
State Machine
Object Dictionary
Application object
Communication object
(Server / Client SDO)
I/O
Communication object
(Receive/ Transmit PDO)
CAN bus
Application object
Process
Object Dictionary
Index 0000 0001 001F 0020 003F 0040 005F 0060 007F 0080 009F 00A0 0FFF 1000 1FFF 2000 5FFF 6000 9FFF A000 FFFF Object Not used Static Data Types Complex Data Types Manufacturer Specific Data Types Device Profile Static Data Types Device Profile Complex Data Types Reserved Communication Profile Area Manufacturer Specific Profile Area Standardized Profile Area Reserved
1200
RECORD
RW
6000
ARRAY
UNSIGNED8
RO
Byte 3
Sub-Index
Bytes 1, 2
Index
S 0
Data Byte 1
E 1 N 3 .. 2 X 4 CCS 7 .. 5
ID 601
(e.g.)
Server
ID 581
(e.g.)
Byte 0
SCS 7 .. 5 X 4 .. 0
Bytes 1, 2
Index
Byte 3
Sub-Index
Bytes 4 .. 7
Reserved
Producer
Consumer
indication
request
Bytes 0 to 8
Process Data
ID
385 (example)
Initialization
Init Done. Automatic transition to Preoperational state.
Pre-operational
Start Remote Node indication Enter Preoperational state indication
Stopped
Start Remote Node indication
Operational
Electronic Data Sheet (EDS): Template for a device from a particular vendor Manufacturer-independent standardized tools Device Configuration File (DCF): Incarnation of configured device (includes bit-rate and node id)
EDS
Managing project information on different platforms Designing networks with CANopen devices
Application Profiles
Specification of required and optional devices in a system Communication interface between devices
Examples
Device Profiles
CiA 401 CANopen device profile for generic I/O modules CiA 402 CANopen device profile for drives and motion control CiA 425 Set of device profiles for medical add-on devices
Application Profiles
CiA 423 Application profile for rail vehicle power drive systems CiA 436 Application profile for construction machineries
Device Configuration
EDS
Template for different configurati ons for one device type
DCF
ID=2 250Kbps
Device
DEBUGGING TOOLS
Example: Medical
Leading Medical Electronics companys Gantry Controller
Gantry - part of CT scanner with multiple sensors and actuators Automated with CAN and CANopen
OCTRIANs VxWorks 6.9.x CAN driver with POSIX interface OCTRIANs VxWorks port of CANopen stack Hardware used: ARM processor with on-chip CAN controllers
2013 Wind River and Octrian All Rights Reserved
CAN Interfaces
Application
Expert in VxWorks and Linux for CAN Drivers and Protocol Stacks