Tuesday, 5 May 2015

Case study, implementation and example of CAN BUS

Aim: Case study, implementation and example of CAN BUS
1. What is CAN?
CAN,which stands for Controller Area Network, is the serial communication protocol internationally standardized by ISO *1. The automobile industry has hitherto witnessed the advent of various electronic control systems that have been developed in pursuit of safety, comfort, pollution prevention, and low cost. These control systems, however, presented a drawback in that since the communication data types, required reliability, etc. Differed between each system, they were configured in multiple bus lines, resulting in increased wire harnesses. Therefore, the need arose for reducing the number of wire harnesses, transferring large amounts of data at high speed via multiple LANs, and so on. To meet the need, BOSCH, an electrical equipment manufacturer in Germany, developed CAN in 1986 as a communication protocol for automotives. Thereafter, CAN was standardized in ISO 11898 and ISO 11519, establishing itself as the standard protocol for in-vehicle networking in Europe now.
Today, CAN is widely accepted for its high performance and reliability, and is used in a broad range of fields from FA devices and ships to medical and industrial equipment. Figure 1 schematically shows how in-vehicle networking will be conceived. In this conception, CAN and the other communication protocols developed concurrently made it possible for multiple LANs to exchange data efficiently via a gateway.

2. Why CAN?
  • Mature Standard
ü  CAN protocol more than 16 years
ü  Numerous CAN products and tools on the market
  • Hardware implementation of the protocol
ü  Combination of error handling and fault confinement with high transmission speed (up to 1Mb/s)
  • Simple Transmission Medium
ü  Twisted pair of wires is the standard, but also just one wire will work
ü  Other links works, too: Opto - or radio links
  • Excellent Error Handling
ü  CRC error detection mechanism
  • Fault Confinement
ü  Built-in feature to prevent faulty node to block system
  • Most used protocol in industrial and automotive world
Example of CAN bus



Example application of CAN bus
2. Basic Concept of the CAN Protocol
The CAN protocol includes the transport, data link, and physical layers of the basic OSI*1 reference model. Figure 5 shows the defined items of each layer of the basic OSI reference model in the CAN protocol. The data link layer is divided into MAC*2 and LLC*3 sub-layers, of which the MAC sub-layer constitutes the nucleus of the CAN protocol. The function of the data link layer is to put the signals received from the physical layer together into a meaningful message to provide a procedure for data transmission control such as transmission error control. More specifically, this includes assembling messages into a frame, arbitrating data collision, returning ACK, and detecting or notifying errors. These functions of the data link layer normally are executed in hardware by the CAN controller. For the physical layer, the protocol defines the manner in which signals are actually transmitted and the bit timing, bit encoding, and synchronization procedures. However, this does not mean that the signal levels, communication speeds, sampling point values, driver and bus electrical characteristics, and connector forms are defined specifically by the CAN protocol. All of these must be selected for each system by the user.
In CAN specifications of BOSCH, there are no definitions with respect to the electrical characteristics, etc. Of transceivers and buses. In the ISO standards for the CAN protocol, i.e., ISO11898 and ISO11519-2, however, the electrical characteristics, etc. of transceivers and buses are defined in each.
*1 : OSI stands for Open System Interconnection.
*2 : MAC stands for Medium Access Control
*3 : LLC stands for Logical Link Control
Figure2. Basic OSI Reference Model of ISO and the CAN Protocol
3 CAN Protocol
 Types of Frames
Communication is performed using the following five types of frames.
• Data frame
• Remote frame
• Error frame
• Overload frame
• Inter frame space
Of these frames, the data and the remote frames need to be set by the user. The other frames are set by the hardware part of CAN.
The data and the remote frames come in two frame formats: standard and extended. The standard format has a 11-bit ID, and the extended format has a 29-bit ID.

Data Frame
The data frame is used by the transmit unit to send a message to the receive unit, and is the most fundamental frame handled by the user.
The data frame consists of seven fields.
Figure 2 shows the structure of the data frame.
(1) Start of frame (SOF)
This field indicates the beginning of a data frame.
(2) Arbitration field
This field indicates the priority of a frame.
(3) Control field
This field indicates reserved bits and the number of data bytes.
(4) Data field
This is the content of data. Data in the range 0 to 8 bytes can be transmitted.
(5) CRC field
This field is used to check the frame for a transmission error.
(6) ACK field
This field indicates a signal for confirmation that the frame has been received normally.
(7) End of frame
This field indicates the end of a data frame.

Remote frame


Difference between dada frame and remote frame
ž  The remote frame does not have a data field, and that the RTR bit in its arbitration field is of a recessive level.
ž  The data frame without a data field and the remote frame can be discriminated by the RTR bit.
ž   What does the data length code of the remote frame that has no data fields indicate?
         It indicates the data length code of the corresponding data frame.
ž  For what is the data frame without a data field used?
ž  For example, this data frame may be used by each unit to confirm or respond for connection periodically, or to place real information in the arbitration field itself.
Error frame
This frame is used to notify an error that has occurred during transmission. The error frame consists of an
error flag and an error delimiter. Error frames are transmitted by the hardware part of CAN.
Figure 24 shows the structure of the error frame.
(1) Error flag
There are two types of error flags: active-error flag and passive-error flag.
• Active-error flag: 6 dominant bits
• Passive-error flag: 6 recessive bits
(2) Error delimiter
The error delimiter consists of 8 recessive bits

   Overload frame
The overload frame is used by the receive unit to notify that it has not been prepared to receive frames yet.
It consists of an overload flag and an overload delimiter.
(1)   Overload flag - 6 dominant bits.
(2) Overload delimiter - 8 recessive bits.

Error flag overlapping
Depending on timing as for the error flag, overload flags may overlap one on top of another, up to 12 bits in total length.
Interframe space

      Used to separate the data and the remote frames
      Are separated from the preceding frame by an inserted
  Interframe space
CAN message format
  • SOF: Start Of Frame
  • CRC: Cyclic Redundancy Code
  • ACK: Acknowledge
  • EOF: End of Frame
  • IFS: Inter Frame Space 
CAN controller modes
ž  Error  active
         Normal operating mode for a controller
         Messages can be received and transmitted
         On detecting an error an active error flag is sent
ž  Error passive
         A mode entered when the controller has frequent problems in transmitting or receiving messages
          Messages can be received and transmitted
         On detecting an error while receiving, a passive error flag is sent
ž  Bus off
         Entered if the controller has serious problems with transmitting messages.
         No messages can be transmitted or received until the CAN controller is reset by host micro controller or processor.

Higher layer protocol
ž  The CAN protocol defines only the ‘physical’ and low ‘data’ link layers.
ž  The HLP defines:
         Start-up behavior
         Definition of message identifiers for the different nodes
         Flow control
  Transportation of messages greater than 8-bytes
         Definition of contents of data frames
         Status reporting in the system
ž  Some HLP: CANopen , DeviceNet, SAE J1939 (Heavy vehicles)
CAN application
ž  Building Automations
         Heating control, Air conditioning(AC), Security(fire, burglar…), Access control, Light control
ž  Domestic & Food distribution appliances
         Washing machines, Dishes cleaner, self service bottle distributors connected to internet.
ž  Automotive & Transportation
         Dash board electronics, Comfort electronics
ž  Production Automation
         Control and link of production machines, production control, Tool machines.
ž  Medical
ž  Agriculture Harvester Machines
         Seeding/Sowing machines, Tractor control, Control of live stock breeding equipment.
Conclusion

CAN is ideally suited in applications requiring a large number of short messages with high reliability in rugged operating environments. Because CAN is message based and not address based, it is especially well suited when data is needed by more than one location and system-wide data consistency is mandatory. Fault confinement is also a major benefit of CAN. Faulty nodes are automatically dropped from the bus, which prevents any single node from bringing a network down, and ensures that bandwidth is always available for critical message transmission. This error containment also allows nodes to be added to a bus while the system is in operation, otherwise known as hot-plugging. The many features of the TI CAN transceivers make them ideally suited for the many rugged applications to which the CAN protocol is being adapted. Among the applications finding solutions with CAN are automobiles, trucks, motorcycles, snowmobiles trains, buses, airplanes, agriculture, construction, mining.

Monday, 4 May 2015

Troubleshooting & Selection of EtherNet

Troubleshooting & Selection of EtherNet

Abstract
             EtherNet is an application layer protocol built on the standard TCP/IP protocol suite used to communicate high level industrial devices.Ethernet was developed by Xerox Corporation’s Palo Alto Research Center (PARC) in the 1970s. Ethernet was the technological basis for the IEEE 802.3 specification, which was initially released in 1980. Shortly thereafter, Digital Equipment Corporation, Intel Corporation, and Xerox Corporation jointly developed and released an Ethernet specification (Version 2.0) that is substantially compatible with IEEE 802.3. Together, Ethernet and IEEE 802.3 currently maintain the greatest market share of any local-area network (LAN) protocol. Today, the term Ethernet is often used to refer to all carrier sense multiple access collision detect (CSMA/CD) LANs that generally conform to Ethernet specifications, including IEEE 802.3. When it was developed, Ethernet was designed to fill the middle ground between long-distance, low-speed networks and specialized, computer-room networks carrying data at high speeds for very limited distances. Ethernet is well suited to applications on which a local communication medium must carry sporadic, occasionally heavy traffic at high peak data rates.
             When it was developed, Ethernet was designed to fill the middle ground between long-distance, low-speed networks and specialized, computer-room networks carrying data at high speeds for very limited distances. Ethernet is well suited to applications on which a local communication medium must carry sporadic, occasionally heavy traffic at high peak data rates.

TCP/IP Model

The TCP/IP model consists of four layers.
1) Network Layer
The Network layer combines the Data Link layer and Physical layer, including the twisted pair
cable, the Physical layer device (PHY), and the Ethernet Media Access Controller (MAC).
2) Internet Layer
The Internet layer consists primarily of a software implementation. The IP header is
evaluated or generated by software.
3) Transport Layer
The Transport layer defines what should be done with the data. This layer is based on the
following two popular protocols:
UDP is a very simple protocol and is perfect for streaming sequences (e.g., audio or video).
TCP is a highly reliable host-to-host protocol for a controlled connection. TCP is appropriate for
applications that require guaranteed delivery.
4) Application Layer
The Application layer includes all available software implementations (e.g., FTP, HTTP, SMTP, DNS, …) that make up the lower layers.
These applications can work only in combination with the API of TCP or UDP, which form the
software implementation of the Transport layer.

Troubleshooting of EtherNet

           Ethernet networks can present many symptoms, but troubleshooting can be helped by asking some common questions. By applying the principles below, our efforts can be more effective.
1) Is proper power supplied to switch and end devices?
2) Do the link LEDs indicate proper cable connections?
3) Are you having mis-communication along a path through multiple switches and routers? If so, check all link indicators and confirm that settings are consistent on all intervening devices.
4) Is the copper cabling compliant with EIA/TIA 568A or 568B as illustrated in fig.1? Mis-wired cables could show a proper link but may still have communication problems. On straight-through cable. Both ends MUST AGREE do not wire one end 568A and the other end 568B.

           RJ-45 Pin
           Signal
        T568A Colors
       T568B Colors
                1.
            TX
         White/Green
White/Orange
                2.
            TX
         Green
Orange
                3.                
            RX
         White/Orange
White/Green
                4.
              -
         Blue 
Blue
                5.
              -
         White/ Blue
White/ Blue
                6.
           RX
         Orange
Green
                7.
              -
         White/Brown
White/Brown
                8.
              -
         Brown
Brown
Fig 1. T568 Wire Color Variation

5) If you are using fiber optic cables, are they properly connected? The RX port on one device must connect to the TX port on the other device and vice versa.
6) If only one of the 2 devices terminating a fiber optic link indicates a valid link, could you have a “half-break”? when device A shows steady activity or a flashing link but device B shows no link, the TX cable from A could be damaged while its RX cable is intact.
7) Have you check your fiber optic cables to make sure they do not exceed allowable attenuation? Damaged fiber can impair the passage of signal and as fiber ages, its transmission efficiency diminishes.
8) Does your fiber optic link have a 10 Mbps device will generally communicate at different light frequencies and will be incompatible. (Typically 850 nm is used for 10 Mbps data and 1300 nm for 100 Mbps data.)
9) Are you connecting a single-mode fiber optic device to a multimode fiber optic device? These are typically incompatible.
10) Do any of your cables exceed the maximum distances in fig.2? Cables which exceed these distances may provide a proper link while masking possible communication issues.


Medium
Signaling & Data Rate
Minimum Required Cable
Maximum Segment Distance
Copper
10 BASE-TX
Category 3 UTP
100 m (328 ft)

10 Mbps


Copper
100 BASE-TX
Category 5 UTP
100 m (328 ft)

100 Mbps


Fiber
100 BASE-FX
1300 nm, multimode
Full-Duplex:

100 Mbps
50/125 or 62.5 µm
2 km (6562 ft)



Half-Duplex:



412 m(1352 ft)
Fiber
100 BASE-FX
1300 nm, single-mode
Full-Duplex:

100 Mbps

15 km (49213 ft)



Half-Duplex:



412 m (1352 ft)
Fig 2: Ethernet Cabling Parameters

11) Was a cable recently moved from one switch port to another? If so, wait 5 min for the address cache to refresh or cycle power on the switch. This time interval is programmable on managed switches.
12) Have you tried forcing a device or switch port to disregard auto-negotiation and operate in a modest state such as 10 Mbps/half-duplex? To control this at the switch requires a configurable or managed switch. Some high noise environments may have better communications at 10 Mbps. Also some end devices may only communicate at 10 Mbps.
13) Have you tried disabling Auto-MDIX since some devices may not implement this feature properly? This requires a configurable or managed switch.
14) Are your devices utilizing DHCP to assign their IP addresses? If so, is your DHCP server functioning properly so that your devices have properly receive their IP address assignments from your DHCP server?  Can you confirm that they have received IP address assignments?
15) If using TCP/IP for communication, have you checked for proper IP communication? A simple check is to connect computer to the switch & “ping”  those devices. If using a DHCP server, can you ping the server? 
16) Is your ping failing to communicate to all IP devices? If so, look at the counts of port transmissions and receptions for the ports in question (this requires a managed switch). This will help identify a bad port or device.
17) Are you certain your IP addresses allow proper communications between your devices? All devices must be in the same subnet unless a router is present to permit communication between different subnets.
18) Are VLANs active on the switch? All devices must be in the same VLAN if they are to communicate.
19) Is a trunk active on your switch that could be interfacing with your ability to communicate? End devices should not be connected to trunk ports.
20) Are ports disabled on your switch? Although a disabled port may indicating a proper link, it will not pass messages.
21) On a managed switch have you checked the error counts for relevant ports? High noise environments or poorly wired cables could cause errors that might interface with communications. If your cables are routed near high noise sources, try rerouting the cables away from high noise sources.
22) Can you successfully ping devices but failed to communicate at a higher level? Most managed switches allowed you to monitor traffic of specific switch ports. This can be done with port mirroring and application (such as Ethereal) to view the traffic.

Table1: Troubleshooting procedures for common Ethernet media problems


Selection of EtherNet

            Any Category 5 or higher cable will support 10/100BaseT traffic. However, Category 5
cabling will not necessarily provide the level of performance needed or survive long term
in a harsh high noise industrial environment. One of the most important factors in selecting the correct cable is having a thorough understanding the environment where the cables will installed. The planner should already understand the application needs (i.e. 10Mb/s, 100Mb/s…) and will need to focus on environmental and mechanical aspects of the cabling. To aid in understanding the environment, this guide is based on a concept called MICE (Mechanical, Ingress, Climatic/Chemical and Electromagnetic). Cabling attributes and performance can be defined for the industrial areas based on the environments and conditions as defined by MICE severity levels called classifications. This guide will focus on the minimum cabling requirements to provide adequate performance in areas of E1, E2, and E3 Electromagnetic interferences. Harsh attributes
such as Mechanical, Ingress and Chemical (M,I,C) will be relatively straight forward. Given this, it is not adequate to simply specify cabling as Cat 5e, Cat 6, shielded, or unshielded. This document will help the reader to select connectivity components based on zero mitigation. Mitigation is a method of converting one environment into a less harsh environment. Further, this document provides guidance in the selection of cabling components to minimize performance degradation due to effects from EMC.

Steps in Selecting Cables:
1. Determine the channel bandwidth requirements to suit the applications for example Channel Class or Category, see Table 3 below.
2. Determine cable type (shielded or unshielded)
3. Determine additional electrical attributes needed based on E1, E2 or E3 noise types and levels.
4. Select two pair or four pair cabling
5. Determine the M,I,C severity levels where the cables will be deployed
6. Determine additional attributes for the cabling, for example high flex, weld splatter etc.
    Each of the 6 steps will be described in detail in the following paragraphs. To help clarify each step, a cable specification will be determined based on an example justification. At the end of each step, the example will be specified in a table like the one shown here:

Table: Channel Bandwidth VS Cabling Categories

Example Cable Specification
Step 1
Channel
Step 2
Cable type
Step 3
EMI
Performance
Step 4
2/4 pair
Step 5
M.I.C. severity
classifications
Step 6
Additional
Mech.
attributes
Justification
Justification
Justification
Justification
Justification
Justification
Specification
Specification
Specification
Specification
Specification
Specification
There are a total of 6 steps in defining the correct cable(s) for the application(s) and environment(s). A network planner may have a need to specify any where from one or more cables dependent on the applications and number of environmental areas within the communications coverage area. The final number of cables will be based on cost and complexity of the network and level of mitigation. For example, cost may not be as important as having one cable construction in the entire system. In this case, a super cable, “one cable does all” may be specified. The planner may choose to reduce the number of cables needed by protecting the cables through mitigation techniques (Isolation and Separation). Any special attributes (defined in step 6 below), such as high flex, is certain to increase the cable count. Regardless of how many different cables are identified, the planner must consider the environment.
In general, all cabling and cabling components need to be complaint with TIA 568B and or ISO/IEC 11801 with the additional requirements.

Industrial EtherNet Cable Selection


Advantages of Ethernet

1..Conceptually Simple :
Ethernet is simply daisy-chained together with coax cable and "T" adapters. There are usually no hubs, transcievers, or other devices used.
2.Relatively Inexpensive: Due to the simplicity inherent in the design of Ethernet, it can be an inexpensive technology to implement. 
3.Noise Immunity :The coaxial cable used in a Ethernet network is very well shielded, and has a very high immunity from electrical noise caused by outside sources. 

Disadvantages of Ethernet

1.Difficult To Change: 
2.Fault Intolerant :
If any device or cable section attached to the network fails, it will most likely make the entire network go down.
3.Difficult Troubleshooting 
Ethernet networks are very difficult to troubleshoot. There is no easy way to determine what node or cable section is causing a problem, and the network must be troubleshoot by a "process of elimination." This can be very time consuming.
4.Specialized Cable 
The RG-58A/U coaxial cable used in Ethernet networks can not be used for any other purpose. In the event that the network is changed to another type, then the cable will have to be replaced.

Reconfiguring a ethernet is somewhat difficult to do once it is in place. Any changes to the network will result in at least some "down time," as the bus must be broken and a new section spliced in at the point of the break.