Documente Academic
Documente Profesional
Documente Cultură
Introduction slave or inputs to the slave per clock cycle. For example, to
The AEAS-7000 is a 16-bit gray code Absolute Encoder transfer 16-bits of data, a 16-clock cycle is required to move
backbone with SSI (Synchronous-Serial-Interface) com- the data. The data is latched on either the falling edge or
munication interface. The SSI interface is a synchronous rising edge of the clock signal based on the device setup.
serial communication where the master (host) and slave The communication speed is based on the maximum band-
(AEAS-7000) devices are synchronous to each other and width of the slave device. The SSI communication speed of
the data is output 1-bit per clock cycle. the AEAS-7000 is up to 16 MHz, meaning that it only takes
62.5 ns to transfer 1-bit of data. But the communication
In this application note, it is shown how hardware can be speed varies depending on the master device with which
added to make the AEAS-7000 compatible with the CAN it is communicating. Figure 1 illustrates the SSI communi-
bus system. Further details are presented in the System cation state diagram for the AEAS-7000 absolute encoder.
Design Considerations section.
Based on the SSI communication state diagram as shown
Introduction— in Figure 1, the data is available at the AEAS-7000 output
Communication Protocol at the falling edge of the clock (SCL) signal. The clock high
state is an idle state and the clock low state is an active
Synchronous Serial Interface (SSI) state. The chip select (NSL) line is required to be pulled
SSI, as the name suggests, is a serial communication format down in order for the communication to be active; oth-
where the master and slave devices are synchronous to erwise, no activities are observed even though the clock
each other. The master device provides a clock signal to (SCL) signal exits.
the slave device and 1-bit of data either outputs from the
2
CAN communication protocol only The Physical Medium Attachment Control Area Network (CAN) Controller
defines the Data Link layer and the (PMA) and Medium Dependent Basically, the CAN Controller imple-
Physical layer in the OSI model. It is Interface (MDI) are two physical ments the CAN specifications in
up to the system designers to define layers that are undefined in CAN hardware. CAN protocol is a CSMA/
the remaining physical layers and the specifications. Physical Signaling CD (Carrier Sense Multiple Access/
higher layers. Alternatively, they can (PS) is defined in the CAN specifica- Collision Detection) protocol, which
be implemented using the existing tions and the system designers are means:
non-proprietary higher layer proto- free to choose any driver/receiver • Each of the nodes is required to
cols (HLPs) and physical layers. and transport medium as long as check the bus activity for a period
the Physical Signaling requirements before sending messages on the
The HLPs are used to: are met. bus (Carrier Sense).
1. standardize startup procedures • If there is no bus activity, all
including bit rates used The CAN Controller implements all nodes have an equal opportunity
2. distribute addresses among the CAN specifications in hardware. to transmit a message (Multiple
participating nodes or types of The PMA is undefined in the CAN Access).
messages specifications, but it is defined by • If two nodes start to transmit at
3. determine the structure of the the ISO-11898. The ISO-11898 is a the same time, the nodes will de-
messages standard for high-speed CAN com- tect the collision and appropriate
4. provide system-level error han- munications in road vehicles and actions will be taken (Collision
dling routines. specifies a 5V differential electrical Detection).
bus as the physical interface. The
ISO-11898 also ensures compatibil-
ity with the CAN transceiver.
3
In CAN protocol, the collision is re- and waits for the next period of Embedded in the CAN messages are
solved by utilizing a non-destructive no activity on the bus to trans- four types of frame:
bitwise arbitration method. This mit the message again. Figure 4 1. Data Frame transmits data from
means that the messages remain illustrates the arbitration method. a transmitting node to any or all
intact after arbitration is completed, other nodes, either Standard or
even if collision is detected and CAN protocol is a message-based Extended Data Frames. Figure 5
no delay or corruption is observed protocol where the transmitted illustrates the structure of a Data
for high priority messages. Non- messages are not based on Frame. The Data Frames consist
destructive bitwise arbitration addresses where the priority bits of fields that provide specific
method follows: and content of the data are embed- information embedded in the
ded into the CAN message. All the messages as defined in the CAN
1. Logic state needs to be defined
nodes in the system receive every specifications. They are Arbitra-
as Dominant or Recessive. In CAN
message transmitted on the bus and tion Field, Control Field, Data
protocol, logic bit 0 is defined as
acknowledge if the messages are Field, CRC Field, Acknowledge
Dominant bit, and logic bit 1 is
received properly. Each of the nodes Field, and an End of Frame. The
defined as Recessive bit.
determine whether to discard the Arbitration Field is used to pri-
2. Transmitting nodes need to message or perform further pro- oritize the messages on the bus.
check whether the logic state out cessing. Each of the nodes can also As mentioned previously, logic
from its node appears in the bus. request information from each other 0 bit is defined as the Dominant
3. Dominant bit state always wins with the built-in feature in CAN bit and logic 1 bit is defined as
the arbitration over the Recessive protocol known as Remote Transmit the Recessive bit, meaning that
bit state. The lower the value in Request (RTR). Instead of waiting for messages with a lower number in
the Message Identifier, the higher messages to be received, each node the arbitration field have a higher
the message priority. specifically requests the message to priority on the bus. The Arbitra-
4. A node that loses the arbitration be sent to it. tion Field consists of 12-bits
stops transmitting immediately (11-bit Identifier and 1-bit RTR)
or 32-bits (29-bit Identifier, 1-bit
extended data frame identifier,
1-bit unused SRR, and 1-bit RTR),
depending on whether Standard
Frames or Extended Frames are
chosen.
4
The Data Field consists of data 2. Remote Frame is a request for 3. Error Frame indicates bus errors
bytes. The amount of bytes is data from other nodes, either are detected. Figure 7 illustrates
defined in the DLC of the Control Standard or Extended Remote the structure of an Error Frame.
Field. Frames. Figure 6 illustrates the
structure of a Remote Frame. There are five error types defined
The CRC Field consists of a 15-bit in the CAN specifications:
CRC and a 1-bit delimiter that is In order to achieve a Remote a. Acknowledge Error
used for checking errors which Transmit Request (RTR), a Remote b. CRC Error
occur during transmission. Frame as shown in Figure 6 is c. Form Error
sent with the identifier of the d. Stuff Error
The Acknowledge Field consists required Data Frame. The RTR bit e. Bit Error
of a 1-bit ACK bit and a 1-bit in the arbitration field determines
delimiter. Regardless of whether whether the frame is a Remote 4. Overload Frame is generated by
the nodes process or discard Frame or Data Frame. If the RTR nodes that require more time to
the data, once the messages are bit is Recessive (logic 0 bit), then process received messages.
received correctly, Dominant the message is a Remote Frame,
bits will be put on the bus in the and vice versa.
ACK bit.
5
Control Area Network (CAN) Transceiver
The Control Area Network (CAN)
transceivers fall under the Physical
Medium Attachment category
specified by the ISO-11898-2 stan-
dard. CAN protocol defines the logi-
cal states as Dominant (logic 0) bit
and Recessive (logic 1) bit, whereas
the ISO-11898 defines a differential
voltage to represent Dominant and
Recessive states. Figure 8 illustrates
the differential bus of the CAN
transceiver. Figure 8. CAN Transceiver Bus Differential.
6
The propagation delay is calculated System Design Considerations
as a roundtrip signal from the trans- The Microchip PIC18F258 with built-
mitter to receiver and back to the in CAN controller is used to enable
transmitter. Equation 1 explains the the CAN interface for the AEAS‑7000
propagation delay mathematically. module, together with Microchip
MCP2551 CAN transceiver, to ensure
tprop = 2 • (tbus + tcmp + tdrv) Eq. 1
the ISO-11898 is met. Figure 10
where tbus is physical bus timing, illustrates the system block diagram
tcmp is input comparator delay, and of AEAS‑7000 with CAN interface.
tdrv is output driver delay.
CAN BUS
nize to the transmitter data stream
to insure messages are properly
decoded. There are two methods
used for achieving and maintaining
synchronization:
1. Hard Synchronization occurs on
the first recessive-to-dominant
falling edge during bus idle con-
dition that indicates a Start-of-
Frame (SOF) condition. It causes
the bit-timing counter to be reset Figure 10. AEAS-7000 with CAN Interface System Block Diagram.
to the SyncSeg that causes the
edge to fall within the SyncSeg.
At this point, all the receivers are
synchronized to the transmitter.
2. Resynchronization is
implemented to maintain
synchronization between the
transmitter and receiver that was
established by the Hard Synchro-
nization. Without the Resynchro-
nization, the receiver could get
out of synchronization due to
oscillator drift between nodes.
Resynchronization is achieved by
implementing the Digital Phase
Lock Loop (DPLL) function that
compares the actual position
to the expected position and
adjusts the bit time as necessary.
7
Program Flow Chart
Figure 11 illustrates the flow chart of
the AEAS-7000 with CAN interface.
8
Application Usage
Acquiring AEAS-7000 Absolute Position via
CAN Bus
The user is required to send a CAN
message in Remote Frame format to
the AEAS-7000.
9
Appendix I
AEAS-7000 Schematic with CAN Bus Interface
10
Appendix II
AEAS-7000 with CAN Bus Interface Software Example
//*******************************************************************
// Title: CAN Bus For AEAS-7000 Absolute Encoder *
// Author: Teng Kong Leong, Senior Application Engineer *
// Date: February 23rd, 2005 *
// Description: Use of PIC18F258 and MCP2515 Can Bus Tranceiver *
// to enable CAN communication for AEAS-7000. *
// *
// Revision: 0.0 Initial Code *
// Use PIC18F458 for initial code. *
//*******************************************************************
void Delay_100(void) ;
char Temp_ASCII[10] ;
union
{
unsigned char Bytes[2] ;
unsigned int Word ;
} AD_ALL ;
11
// *** SPI Communication Setup ***
SSPSTAT = 0b01000000 ; // CKE = 1, SMP @ Middle
SSPCON1 = 0b00110000 ; // CKP = 1, CLK @ 10MHz
CANInitialize( 2,8,3,3,1, CAN_CONFIG_LINE_FILTER_OFF &
CAN_CONFIG_SAMPLE_ONCE &
CAN_CONFIG_VALID_STD_MSG &
CAN_CONFIG_PHSEG2_PRG_ON &
CAN_CONFIG_ALL_MSG) ; //Initialize CAN Module
CANSetOperationMode(CAN_OP_MODE_NORMAL) ;
while (1)
{
Delay_100() ;
void Delay_100(void)
{
int X1 ;
12
References
1. “AEAS-7000 Plug and Play Ultra-Precision Absolute Encoder 16-bit Gray
Code Datasheet,” Avago Technologies
2. “Microchip PIC18F258 8-bit Micro-controller Datasheet,”
Microchip Inc.
3. “Microchip MCP2551 CAN Transceiver,” Microchip Inc.
4. “AN713 Controller Area Network (CAN) Basics,” Microchip Inc.
5. “AN228 A CAN Physical Layer Discussion,” Microchip Inc.
6. “AN754 Understanding CAN Module Bit Timing,” Microchip Inc.
7. “Ease into Flexible CANbus Network,” Analog Design Note
For product information and a complete list of distributors, please go to our web site: www.avagotech.com
Avago, Avago Technologies, and the A logo are trademarks of Avago Technologies, Limited in the United States and other countries.
Data subject to change. Copyright © 2007-2010 Avago Technologies Limited. All rights reserved.
5989-2857EN - May 14, 2010