DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ...
DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ...
DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>DESIGN</strong> <strong>OF</strong> A <strong>CUSTOM</strong> <strong>ASIC</strong> <strong>INCORPORATING</strong> CAN <strong>AND</strong> 1-WIRE®<br />
COMMUNICATION PROTOCOLS<br />
by<br />
MICHAEL ALAN McNEES<br />
KENNETH G. RICKS, COMMITTEE CHAIR<br />
DAVID JEFF JACKSON<br />
JOSEPH NEGGERS<br />
WILLIAM A. STAPLETON<br />
LARRY T. WURTZ<br />
A DISSERTATION<br />
Submitted in partial fulfillment of the requirements for the<br />
degree of Doctor of Philosophy in the Department<br />
of Electrical and Computer Engineering<br />
in the Graduate School of<br />
The University of Alabama<br />
TUSCALOOSA, ALABAMA<br />
2012
Copyright Michael Alan McNees 2012<br />
ALL RIGHTS RESERVED
ABSTRACT<br />
The vast majority of today’s digital designs utilize custom <strong>ASIC</strong>s (Application-Specific<br />
Integrated Circuits) or gate arrays. In general, <strong>ASIC</strong>s offer the lowest possible device power<br />
consumption for implementing a given function. Each year the number of custom <strong>ASIC</strong>s<br />
designed increases, while the number of parts required for each design decreases. This is due in<br />
part to the increasing use of FPGAs (Field Programmable Gate Arrays) and their ability to<br />
provide a lower cost <strong>ASIC</strong>-based alternative for limited production designs.<br />
This paper presents a VLSI (Very Large Scale Integration) design and simulation of a<br />
custom <strong>ASIC</strong> incorporating two serial bus communication protocols, CAN (Controller Area<br />
Network) and 1 – Wire®, and is targeted towards wearable medical technology and devices as<br />
well as advanced vehicular technologies. In designing a custom communications interface<br />
module, a number of technical and potentially challenging problems had to be addressed and<br />
overcome. These include but are not limited to: combining a multimaster and a single-master<br />
protocol, event-triggered and time-triggered control paradigms, differential communication<br />
speeds, and messages by addressing and messages by IDs. By combining the low-cost and ease<br />
of CAN-enabling almost any device with the variety of 1 – Wire® devices currently in-<br />
production, the combinations of sensor networks is only limited by the creativity of the system<br />
designer. Given the limited FPGA resources utilized by the design presented in this manuscript,<br />
a low-cost <strong>ASIC</strong> could handle the data demands and provide the communications interface of<br />
most any application for either market.<br />
ii
DEDICATION<br />
This work is dedicated to my wife, DeVonna, son, Joseph Darrell, and parents, Barbara<br />
and Joe. Without their continuing love and support, returning to graduate school would have<br />
only been a dream, and none of this work would have been possible. I would also like to thank<br />
the rest of my friends and family, whose names I have not mentioned here, for their support, as<br />
each has played an important role in my continuing success not only as a graduate student but as<br />
a professional in my chosen career.<br />
iii
LIST <strong>OF</strong> ABBREVIATIONS <strong>AND</strong> SYMBOLS<br />
AA DS1996 Authorization Accepted Flag<br />
ACK Acknowledge<br />
ACR Acceptance Code Register<br />
ADC Analog-to-Digital Converter<br />
AMP Arbitration on Message Priority<br />
AMR Acceptance Mask Register<br />
<strong>AND</strong> Automatic Node Discovery<br />
<strong>ASIC</strong> Application-Specific Integrated Circuits<br />
B m<br />
Longest delay time of a message from a lower priority message<br />
BRP Baud Rate Prescaler<br />
BSP Bit Stream Processor<br />
C m<br />
Longest time to send a CAN message<br />
CAN Controller Area Network<br />
CiA CAN in Automation<br />
CIL Controller Interface Logic<br />
CMOS Complementary Metal-Oxide Semiconductor<br />
CRC Cyclic Redundancy Check<br />
CSMA/CD Carrier Sense Multiple Access/Collision Detection<br />
iv
D m<br />
Deadline for a given CAN message<br />
DLC Data Length Code<br />
EEPROM Electrically Erasable Programmable Read-Only Memory<br />
EML Error Management Logic<br />
E<strong>OF</strong> End Of Frame<br />
EPROM Erasable Programmable Read Only Memory<br />
ERBF Enable Receive Buffer Full Interrupt<br />
ESD Electrostatic Discharge Protection<br />
f NBT<br />
Nominal Bit Time Frequency<br />
FIFO First-In-First-Out<br />
FOW Force One Wire<br />
FPGA Field Programmable Gate Array<br />
GPIO General Purpose Input/Output<br />
HLP Higher Layer Protocol<br />
I/O Input/Output<br />
I 2 C Inter-Integrated Circuit<br />
IC Integrated Circuit<br />
ID Identification<br />
IDE Identifier Extension<br />
IEC International Electrotechnical Organization<br />
IP Intellectual Property<br />
IR Infrared<br />
v
ISO International Organization for Standardization<br />
ISR Interrupt Service Routine<br />
J m<br />
Queuing jitter of CAN message<br />
JTAG Joint Test Action Group<br />
LED Light Emitting Diode<br />
LIN Local Interconnect Network<br />
LLC Logical Link Control<br />
LSS Layer Setting Services<br />
MAC Medium Access Control<br />
MCAN Motorola CAN Module<br />
MCU Microcontroller<br />
MDI Medium Dependent Interface<br />
NBT Nominal Bit Time (tNBT)<br />
NRZ Non-Return To Zero<br />
NVSRAM Non-Volatile Static Random Access Memory<br />
OEM Original Equipment Manufacturer<br />
<strong>OF</strong> DS1996 Overflow Flag<br />
OSI Open Systems Interconnection<br />
OTP One-Time Programmable<br />
PCB Printed Circuit Board<br />
PD 1 – Wire® Presence Detect<br />
PF DS1996 Partial-byte Flag<br />
vi
PIC® Programmable Interrupt Controller<br />
PLS Physical Signaling<br />
PMA Physical Medium Attachment<br />
PHASE_SEG Phase Buffer Segment (tPHASE_SEG1/tPHASE_SEG2)<br />
POR Power-On Reset<br />
PROP_SEG Propagation Time Segment (tPROP_SEG)<br />
R m<br />
Worst-case response time of CAN message<br />
R&D Research and Development<br />
RBF Receive Buffer Flag<br />
REC Receive Error Counter<br />
RF Radio Frequency<br />
RJW Resynchronization Jump Width<br />
ROM Read-Only-Memory<br />
RPUP Pull-up Resistor<br />
RTL Register Transfer Level<br />
RTR Remote Transmission Request<br />
RTS Request To Send<br />
RXD Receive Exchange Data<br />
s m<br />
Bounded size of a CAN message in bytes<br />
SAE Society of Automotive Engineers<br />
SFN Single line of contacts, Flat, No leads<br />
SHA Secure Hash Algorithm<br />
vii
SI Serial In<br />
SO Serial Out<br />
S<strong>OF</strong> Start Of Frame<br />
SOIC Small Outline Integrated Circuit<br />
SOT23 Small Outline Transistor, Style 23<br />
SRA Search ROM Accelerator<br />
SRR Substitute Remote Request<br />
SPI Serial Peripheral Interface<br />
SYNC_SEG Synchronization Segment (tSYNC_SEG)<br />
bit<br />
Bit time of the CAN bus<br />
T m<br />
Period of a given CAN message<br />
tPDH 1 – Wire® Presence-detect high time<br />
tPDL 1 – Wire® Presence-detect low time<br />
tREC 1 – Wire® bus recovery time<br />
tRSTH 1 – Wire® Reset high time<br />
tRSTL 1 – Wire® Reset low time<br />
tSCL System Clock time<br />
tSLOT Time to communicate one bit excluding recovery time<br />
ttxclk Transmit Clock<br />
tW1L 1 – Wire® Write-one low time<br />
Tax DS1996 Target Address number<br />
TBE Transmit Buffer Empty<br />
viii
TCL Transceive Logic<br />
TCP/IP Transmission Control Protocol/Internet Protocol<br />
TEC Transmit Error Counter<br />
TEDS Transducer Electronic Data Sheet<br />
TEMT Transmit Shift Register Empty<br />
TO – 92 Transistor Outline Package, Case Style 92<br />
t Q<br />
Time Quantum<br />
TSOC Thin Small Outline C-lead<br />
TTA Time-Triggered Architectures<br />
TTCAN Time-Triggered CAN<br />
TTL Transistor-Transistor Logic<br />
TTP Time-Triggered Protocols<br />
TXD Transmit Exchange Data<br />
UCSP Ultra Chip Scale Package<br />
VCC Common-collector voltage supply<br />
VDD Supply voltage<br />
VPROH High-level of the Power-on Reset comparator<br />
VPUP 1 – Wire® Pull-up Voltage<br />
VHDL VHSIC Hardware Description Language<br />
VHSIC Very-High-Speed Integrated Circuit<br />
w m<br />
Worst-case queuing delay of a CAN message<br />
ix
ACKNOWLEDGEMENTS<br />
I would like to express my sincere gratitude and thanks to Dr. Kenneth G. Ricks for all of<br />
his guidance, support, and supervision of this research project. His countless reviews and<br />
seemingly endless revisions were instrumental in finalizing this work. I would also like to<br />
express my appreciation to all members of my committee: Dr. Jeff Jackson, Dr. Joseph Neggers,<br />
Dr. Kenneth G. Ricks, Dr. William Stapleton, and Dr. Larry Wurtz. Thanks to all for their<br />
continued belief and support to help make this work possible.<br />
x
CONTENTS<br />
ABSTRACT .................................................................................................................................... ii<br />
DEDICATION ............................................................................................................................... iii<br />
LIST <strong>OF</strong> ABBREVIATIONS <strong>AND</strong> SYMBOLS .......................................................................... iv<br />
ACKNOWLEDGEMENTS .............................................................................................................x<br />
LIST <strong>OF</strong> TABLES ...................................................................................................................... xvii<br />
LIST <strong>OF</strong> FIGURES .......................................................................................................................xx<br />
1 INTRODUCTION ........................................................................................................................1<br />
2 1 – WIRE® COMMUNICATION PROTOCOL .........................................................................5<br />
2.1 History of 1 – Wire® ...........................................................................................................5<br />
2.2 1 – Wire® Overview ............................................................................................................6<br />
2.3 1 – Wire® Communication ..................................................................................................9<br />
2.3.1 Microprocessor Port-Pin Attachments ......................................................................11<br />
2.3.2 Microprocessor with Built-In 1 – Wire® Master......................................................13<br />
2.3.3 Synthesizable 1 – Wire® Bus Master .......................................................................14<br />
2.3.4 Serial Interface Protocol Conversions ......................................................................15<br />
2.3.5 Timing/Transaction Sequence on the 1 – Wire® Bus ..............................................19<br />
2.3.6 1 – Wire® Search Algorithm ....................................................................................22<br />
2.3.7 1 – Wire® CRC Check .............................................................................................25<br />
2.3.8 1 – Wire® Commands ..............................................................................................27<br />
xi
2.4 Types of Devices................................................................................................................29<br />
2.4.1 1 – Wire® Device Packaging ...................................................................................29<br />
2.4.2 Device Functions and Typical Applications .............................................................30<br />
2.4.3 Unique Address and Device Customization .............................................................33<br />
2.5 Network Types and Precedents ..........................................................................................34<br />
2.5.1 Slave Device Weight.................................................................................................35<br />
2.5.2 1 – Wire® Network Topologies ...............................................................................36<br />
2.5.3 1 – Wire® Network Limitations ...............................................................................38<br />
2.5.4 Parasitic Power..........................................................................................................39<br />
2.5.5 Making Reliable 1 – Wire® Networks .....................................................................39<br />
3 CONTROLLER AREA NETWORK (CAN) PROTOCOL ...................................................41<br />
3.1 History of CAN ..............................................................................................................41<br />
3.2 Overview of CAN ..........................................................................................................42<br />
3.3 CAN-Message-Based Communication ..........................................................................46<br />
3.3.1 Data Frames ..............................................................................................................47<br />
3.3.2 Remote Frames .........................................................................................................53<br />
3.3.3 Error Frames .............................................................................................................54<br />
3.3.4 Overload Frame ........................................................................................................56<br />
3.3.5 Interframe Space .......................................................................................................57<br />
3.4 Error Detection and Handling ............................................................................................58<br />
3.4.1 Output Timing of an Error Frame .............................................................................61<br />
3.5 Fault Confinement and Error States ...................................................................................62<br />
xii
3.5.1 Error-Active ..............................................................................................................63<br />
3.5.2 Error-Passive .............................................................................................................64<br />
3.5.3 Bus-Off .....................................................................................................................64<br />
3.6 CAN Bit Timing Requirements .....................................................................................65<br />
3.6.1 CAN Bit Structure .................................................................................................65<br />
3.6.2 Synchronization Segment .........................................................................................67<br />
3.6.3 Propagation Segment ................................................................................................69<br />
3.6.4 Synchronization ........................................................................................................70<br />
3.6.5 Re-Synchronization...................................................................................................71<br />
3.7 Oscillator Tolerance ...........................................................................................................72<br />
3.8 Propagation Delay ..............................................................................................................72<br />
3.9 Selection of Bit Timing Values..........................................................................................73<br />
3.9.1 Step-by-Step Calculation of Bit Timing Parameters .............................................74<br />
4 THE CHALLENGES <strong>OF</strong> INTERFACING CAN <strong>AND</strong> 1 – WIRE® COMMUNICATION<br />
PROTOCOLS ................................................................................................................................76<br />
4.1 The Need for the Interface .................................................................................................76<br />
4.2 Applications .......................................................................................................................78<br />
4.3 Challenging Problems ........................................................................................................80<br />
4.3.1 Multi-Master to Single Master ..................................................................................81<br />
4.3.2 Message IDs vs. Addresses .......................................................................................86<br />
4.3.3 Event-Triggered vs. Time-Triggered Control Paradigms .........................................93<br />
4.3.4 Timing Performance .................................................................................................97<br />
xiii
4.3.5 Communication Speed Differential ........................................................................112<br />
5 THE INTERFACE <strong>OF</strong> CAN <strong>AND</strong> 1 – WIRE® COMMUNICATION PROTOCOLS ......113<br />
5.1 Interface Overview...........................................................................................................113<br />
5.2 1 – Wire® FPGA Implementation ...................................................................................113<br />
5.2.1 1 – Wire® Master Overview ...................................................................................114<br />
5.2.2 Command Register..................................................................................................118<br />
5.2.3 Search ROM Accelerator Description ....................................................................119<br />
5.2.4 Transmit/Receive Buffer Register ..........................................................................122<br />
5.2.5 Interrupt & Interrupt Enable Registers ...................................................................123<br />
5.2.6 Clock Divisor Register ............................................................................................127<br />
5.2.7 Control Register ......................................................................................................128<br />
5.2.8 Verification of 1 – Wire® Module .........................................................................130<br />
5.2.8.1 Single Search ROM (single_search_rom) Test..............................................134<br />
5.2.8.2 Multiple One-Wire Network (multi_ow_network) Test ................................135<br />
5.2.8.3 Scratchpad Memory (scratchpad_integrity) Test ...........................................136<br />
5.2.8.4 Command Recognition (cmd_recognition) Test ............................................138<br />
5.3 CAN (Controller Area Network) FPGA Implementation ............................................139<br />
5.3.1 Register Map and Address Allocation ....................................................................143<br />
5.3.2 CAN Module Control Registers Overview .........................................................144<br />
5.3.3 CAN Module Control Register (CCNTRL) ........................................................145<br />
5.3.4 CAN Module Command Register (CCOM) .......................................................147<br />
5.3.5 CAN Module Status Register (CSTAT) .............................................................149<br />
xiv
5.3.6 CAN Module Interrupt Register (CINT) ............................................................152<br />
5.3.7 CAN Module Acceptance Code Register (CACC) .............................................153<br />
5.3.8 CAN Module Acceptance Mask Register (CACM) ...........................................154<br />
5.3.9 CAN Module Bus Timing Register 0 (CBT0) ....................................................155<br />
5.3.10 CAN Module Bus Timing Register 1 (CBT1) ..................................................157<br />
5.3.11 CAN Module Output Control Register (COCNTRL) .......................................159<br />
5.3.12 CAN Module Transmit Buffer Registers Overview .........................................161<br />
5.3.13 CAN Module Transmit Buffer Identifier Register (TBI)..................................162<br />
5.3.14 CAN Module Remote Transmission Request/Data Length Code Register<br />
(TRTDL) ..........................................................................................................................162<br />
5.3.15 CAN Module Transmit Data Segment Registers (TDS) 1 – 8 ..........................163<br />
5.3.16 CAN Module Receive Buffer Registers Overview ...........................................164<br />
5.3.17 CAN Module Receive Buffer Identifier Register (RBI) ...................................165<br />
5.3.18 CAN Module Remote Transmission Request/Data Length Code Register<br />
(RRTDL) ..........................................................................................................................165<br />
5.3.19 CAN Module Receive Data Segment Registers (RDS) 1 – 8 ...........................165<br />
5.3.20 CAN Node Overview ........................................................................................166<br />
5.3.20.1 Firmware Description ..................................................................................171<br />
5.3.20.2 PIC® MCU Initialization .............................................................................173<br />
5.3.20.3 MCP2515 Initialization ................................................................................175<br />
5.3.20.4 Interrupt Service Routine .............................................................................175<br />
5.3.21 Verification of CAN Module ............................................................................181<br />
xv
5.3.21.1 Synchronization Test (test_synchronization) ...............................................182<br />
5.3.21.2 Bus-Off Test (bus_off_test) .........................................................................183<br />
5.3.21.3 Error Test (error_test) ..................................................................................185<br />
5.3.21.4 Send Basic Frame Test (send_frame_basic) ................................................190<br />
5.3.21.5 Send Extended Frame Test (send_frame_extended) ....................................191<br />
6 1 – WIRE® <strong>AND</strong> CAN COMBINED SYSTEM PROTOTYPE IMPLEMENTATION ....193<br />
6.1 Overview of Integrated System .......................................................................................193<br />
6.2 Verification of Combined Prototype System ...................................................................195<br />
6.2.1 Test Verification and Overview ..............................................................................196<br />
6.2.1.1 DS1996 Addressing and Memory Layout .....................................................197<br />
6.2.1.2 Test Results – Transferring CAN data bytes to 1 – Wire® devices ..........199<br />
6.2.1.3 Test Results – 1 – Wire® Master requests data from CAN nodes ............201<br />
7 CONCLUSIONS <strong>AND</strong> FUTURE WORK ...............................................................................206<br />
REFERENCES ............................................................................................................................218<br />
xvi
LIST <strong>OF</strong> TABLES<br />
2.1 Port Adapters for 1 – Wire® Devices ..........................................................................................18<br />
2.2 1 – Wire® Bus Operations ...........................................................................................................20<br />
2.3 1 – Wire® Bit Search Information ...............................................................................................23<br />
2.4 1 – Wire® Master and Slave Search Sequence............................................................................24<br />
2.5 1 – Wire® Search Path Direction ................................................................................................25<br />
3.1 Frame Types and Roles of Each Frame .......................................................................................47<br />
3.2 Data Length Code Field ...............................................................................................................49<br />
3.3 Types of Errors ............................................................................................................................61<br />
3.4 Error Flag Output Timing ............................................................................................................62<br />
3.5 Types of Segments and Their Roles ............................................................................................68<br />
4.1 Address claim status and reserved bits ........................................................................................90<br />
4.2 Time-Triggered vs. Event-Triggered ...........................................................................................94<br />
4.3 Categorization of Real-Time Systems .........................................................................................96<br />
4.4 Time Savings for a Read ROM Function ....................................................................................103<br />
4.5 Parameters of Impact ...................................................................................................................107<br />
4.6 Results Matrix ..............................................................................................................................108<br />
4.7 Example results with N 20 .......................................................................................................110<br />
5.1 1 – Wire® Register Addresses .....................................................................................................116<br />
5.2 Clock Divisor Register Settings for Input Clock Rates ...............................................................128<br />
xvii
5.3 Resource Utilization.....................................................................................................................131<br />
5.4 Single Search ROM (single_search_rom) Test Results ...............................................................134<br />
5.5 Multiple One-Wire Network (multi_ow_network) Test Results .................................................135<br />
5.6 Scratchpad Memory (scratchpad_integrity) Test Results ............................................................137<br />
5.7 Command Recognition (cmd_recognition) Test Results .............................................................138<br />
5.8 Control Registers .........................................................................................................................145<br />
5.9 Synchronization Jump Width (SJW) ...........................................................................................156<br />
5.10 Baud Rate Prescaler ...................................................................................................................156<br />
5.11 Time Segment Values ................................................................................................................158<br />
5.12 Output Control Modes ...............................................................................................................159<br />
5.13 Output Control Bits ....................................................................................................................161<br />
5.14 CAN driver output levels .......................................................................................................161<br />
5.15 Transmit Buffer Registers ..........................................................................................................161<br />
5.16 Data Length Code Bits ...............................................................................................................163<br />
5.17 Receive Buffer Registers ...........................................................................................................164<br />
5.18 CAN Node Message Identifiers .............................................................................................169<br />
5.19 Resource Utilization...................................................................................................................182<br />
5.20 Bus-Off Test (bus_off_test) Results ..........................................................................................185<br />
5.21 Send Basic Frame (send_frame_basic) Test Results .................................................................190<br />
5.22 Send Extended Frame (send_frame_extended) Test Results .....................................................191<br />
6.1 Resource Utilization.....................................................................................................................194<br />
6.2 Test Results ..................................................................................................................................200<br />
xviii
6.3 FILHITx Bit Definitions ..............................................................................................................203<br />
6.4 Test Results ..................................................................................................................................204<br />
7.1 FIFO Buffer Memory Pin Names and Descriptions ....................................................................215<br />
xix
LIST <strong>OF</strong> FIGURES<br />
2.1 1 – Wire® Network .....................................................................................................................5<br />
2.2 Typical 1 – Wire® Communication Flow ...................................................................................10<br />
2.3 Bidirectional port pin with optional circuit for strong pullup (dashed lines) ..............................12<br />
2.4 Unidirectional port pins with optional circuit for strong pullup (dashed lines) ...........................12<br />
2.5 µC with Built-In 1 – Wire® Master & optional strong pullup circuit (dashed lines) ..................13<br />
2.6 <strong>ASIC</strong>/FPGA with optional circuit for strong pullup (dashed lines) ............................................14<br />
2.7 UART/RS232 Serial Port Interface .............................................................................................16<br />
2.8 I 2 C interface with optional circuit for extra strong pullup (dashed lines)....................................17<br />
2.9 1 – Wire® Master for a USB interface ........................................................................................17<br />
2.10 Reset/Presence Detect Sequence ................................................................................................20<br />
2.11 Write Zero Time Slot .................................................................................................................21<br />
2.12 Write One/Read One Time Slot .................................................................................................21<br />
2.13 Read Zero Time Slot ..................................................................................................................22<br />
2.14 64 – Bit Unique ROM ‘Registration’ Number ..........................................................................23<br />
2.15 1 – Wire® 8 – bit CRC ..............................................................................................................26<br />
2.16 Linear Network Topology..........................................................................................................36<br />
2.17 Stubbed Network Topology .......................................................................................................36<br />
2.18 Star Network Topology..............................................................................................................37<br />
3.1 Typical CAN Bus Network ......................................................................................................43<br />
xx
3.2 ISO/OSI Reference Model ...........................................................................................................44<br />
3.3 Standard CAN Data Frame Format ..........................................................................................48<br />
3.4 Extended CAN Data Frame Format .........................................................................................51<br />
3.5 Standard and Extended Remote Frame Structures.......................................................................54<br />
3.6 Structure of the Error Frame ........................................................................................................55<br />
3.7 Structure of the Overload Frame..................................................................................................57<br />
3.8 Structure of the Interframe Space (non error-passive nodes) ......................................................57<br />
3.9 Structure of the Interframe Space (error-passive nodes) .............................................................58<br />
3.10 CAN Bus Error States ............................................................................................................63<br />
3.11CAN Bit Segments ..................................................................................................................66<br />
3.12 Propagation Delay Between Nodes ...........................................................................................68<br />
4.1 Centralized arbiter in a daisy-chain scheme ................................................................................82<br />
4.2 Centralized arbiter with independent request and grant lines ......................................................83<br />
4.3 Centralized arbiter with two priority levels (four devices) ..........................................................84<br />
4.4 Decentralized bus arbitration .......................................................................................................84<br />
4.5 CAN node components simplified block diagram ...................................................................88<br />
4.6 CAN Node Message Acceptance Filtering ..............................................................................89<br />
4.7 Address Claim Unit......................................................................................................................90<br />
4.8 Message Queuing Jitter ................................................................................................................98<br />
4.9 Initialization Procedure: Reset and Presence Pulse .....................................................................105<br />
4.10 Write-One Time Slot..................................................................................................................106<br />
4.11 Write-Zero Time Slot .................................................................................................................106<br />
xxi
4.12 Read-Data Time Slot..................................................................................................................107<br />
5.1 one_wm Synthesizable 1 – Wire® Bus Master Block Diagram ..................................................115<br />
5.2 Command Register Bits ...............................................................................................................118<br />
5.3 Search ROM Accelerator Mode Send Bytes ...............................................................................120<br />
5.4 Search ROM Accelerator Mode Response Bytes ........................................................................121<br />
5.5 Transmit/Receive Buffer Register ...............................................................................................122<br />
5.6 Interrupt Register .........................................................................................................................124<br />
5.7 Interrupt Enable Register .............................................................................................................126<br />
5.8 Clock Divisor Register .................................................................................................................127<br />
5.9 Control Register ...........................................................................................................................129<br />
5.10 Single Search ROM Test Setup .................................................................................................134<br />
5.11 Multiple One-Wire Network Test Setup ....................................................................................135<br />
5.12 Scratchpad Memory Test Setup .................................................................................................137<br />
5.13 CAN Controller Block Diagram ............................................................................................140<br />
5.14 Controller Interface Logic Unit (CIL) .......................................................................................143<br />
5.15 CAN Module memory map....................................................................................................144<br />
5.16 CAN Control Register ............................................................................................................145<br />
5.17 CAN Command Register .......................................................................................................147<br />
5.18 CAN Status Register ..............................................................................................................150<br />
5.19 CAN Interrupt Register ..........................................................................................................152<br />
5.20 CAN Acceptance Code Register ............................................................................................154<br />
5.21 CAN Acceptance Mask Register ...........................................................................................155<br />
xxii
5.22 CAN Bus Timing Register 0 ..................................................................................................155<br />
5.23 CAN Module Oscillator Block Diagram ...............................................................................157<br />
5.24 CAN Bus Timing Register 1 ..................................................................................................157<br />
5.25 CAN Output Control Register ...............................................................................................159<br />
5.26 CAN Transmit Buffer Identifier Register ..............................................................................162<br />
5.27 CAN Remote Transmission Request/Data Length Code Register ........................................162<br />
5.28 CAN Transmit Data Segment Registers ................................................................................164<br />
5.29 CAN Receive Buffer Identifier Register ................................................................................165<br />
5.30 CAN Remote Transmission Request/Data Length Code Register ........................................165<br />
5.31 CAN Receive Data Segment Registers ..................................................................................165<br />
5.32 CAN Node Block Diagram ....................................................................................................167<br />
5.33 CAN Node Operation Flowchart ...........................................................................................172<br />
5.34 PIC12CE674 Pin Names ............................................................................................................173<br />
5.35 CAN Node Interrupt Service Routine Flowchart ...................................................................176<br />
5.36 Timer0 Interrupt Service Routine Flowchart .............................................................................177<br />
5.37 CAN Node Message Received Flowchart .............................................................................178<br />
5.38 Error Handler Routine Flowchart ..............................................................................................179<br />
5.39 Bus-Off Test Setup ....................................................................................................................184<br />
5.40 Error Test Setup .........................................................................................................................188<br />
6.1 Combined CAN & 1 – Wire® Prototype System ....................................................................193<br />
6.2 1 – Wire® & CAN Combined Prototype System ....................................................................195<br />
6.3 DS1996 iButton Memory Map ................................................................................................197<br />
xxiii
6.4 DS1996 Address Registers ..........................................................................................................198<br />
6.5 RXB1CTRL – Receive Buffer 1 Control Register Bit Definitions .............................................202<br />
7.1 FIFO Buffer Memory ...................................................................................................................213<br />
xxiv
CHAPTER 1<br />
INTRODUCTION<br />
An <strong>ASIC</strong> (Application-Specific Integrated Circuit) is a collection of memory and logic<br />
circuits on an individual silicon die. <strong>ASIC</strong>s are custom designed by end-customers to perform a<br />
specific function and thereby meet the specific needs of their application. The use of <strong>ASIC</strong>s<br />
improves performance over general-purpose CPUs, because <strong>ASIC</strong>s are “hardwired” to do a<br />
specific job and do not incur the overhead of fetching and interpreting stored instructions.<br />
Customers implement their designs in a single silicon die by mapping their functions to a set of<br />
predesigned, preverified logic circuits typically provided by the <strong>ASIC</strong> vendor. <strong>ASIC</strong>s are used in<br />
an assortment of products ranging from everyday consumer products such as personal<br />
computers, automobiles, digital cameras and video games, to high-end technology products such<br />
as workstations and supercomputers [1].<br />
<strong>ASIC</strong>s are usually classified into one of three categories: full custom, semi-custom, and<br />
structured or platform <strong>ASIC</strong>s. Full-custom <strong>ASIC</strong>s are those that are entirely tailor-fitted to a<br />
particular application from the very start and are the most costly. This means that a full custom<br />
<strong>ASIC</strong> cannot be modified to suit different applications, and is generally produced as a single,<br />
specific product for a particular application only. Semi-custom <strong>ASIC</strong>s can be partly customized<br />
to serve different functions within its general area of application. Unlike full-custom <strong>ASIC</strong>s,<br />
semi-custom <strong>ASIC</strong>s are designed to allow a certain degree of modification during the<br />
1
manufacturing process. Structured or platform <strong>ASIC</strong>s, which belong to a relatively new <strong>ASIC</strong><br />
classification, are those which have been designed and produced from a tightly defined set of:<br />
design methodologies; intellectual properties (IP’s); and well-characterized silicon, aimed at<br />
shortening the design cycle and minimizing the development costs of the <strong>ASIC</strong> [2].<br />
A new application emerging recently in the medical field, wearable sensor technology<br />
can be widely used in clinical care, home health care, special people monitoring, elderly care and<br />
assistance, psychological evaluation, physical training and many other different medical areas.<br />
Wearable technology may provide an integral part of the solution for providing healthcare to a<br />
growing world population that will be strained by a ballooning aging population. By providing a<br />
means to conduct telemedicine – the monitoring, recording, and transmission of physiological<br />
signals from outside of the hospital – wearable technology solutions could ease the burden on<br />
health-care personnel and use hospital space for more emergent or responsive care. In addition,<br />
employing wearable technology in professions where workers are exposed to dangers or hazards<br />
could help save their lives and protect health-care personnel [3].<br />
Another application is in the rapid introduction of green technology in the form of hybrid<br />
and electric vehicles. This will strongly increase the use of electronics as the electrical features<br />
and increased powertrain complexity will rely on sophisticated electronic control to achieve<br />
maximum efficiency, performance, and reliability. The replacement of mechanical components<br />
by electronics, such as relay replacement by electronic switches, is a means by which electronics<br />
can address several needs of the automobile industry. This would not only reduce the weight of<br />
wire harnesses but would also increase reliability. The wire harness forms the backbone of the<br />
2
entire electrical system of automotive vehicles. The correct implementation of the wire harness<br />
represents one of the most expensive and technically challenging aspects of vehicle design.<br />
This paper presents the design and simulation of a full custom <strong>ASIC</strong> conjoining two<br />
robust, serial protocols, 1 – Wire® and CAN, that can provide a rugged, reliable<br />
communications backbone for wearable medical technology devices as well as advanced<br />
vehicular technologies. There are numerous devices that use either CAN or 1 – Wire® for<br />
communication. By conjoining these two serial bus protocols this will allow data exchange<br />
between an almost unlimited number of devices.<br />
There are many benefits to the use of serial communication for wearable medical<br />
technology and advanced vehicular communications. First, serial communication allows the<br />
transfer of data between two computers, two master devices, a master and a slave device, etc.<br />
Therefore, it is very flexible. Serial communication also allows one to interface with a PC either<br />
during development and/or in the field. Another major benefit of serial protocols is the low pin<br />
count; communication can be established with just one I/O pin, compared to eight or more for<br />
parallel communications. Finally, most physiological characteristics are monitored at relatively<br />
slow rates allowing for lower speed communication protocols to be effective. This makes serial<br />
communications ideal for wearable medical devices.<br />
The remainder of this dissertation is organized as follows: Chapter 2 describes the 1 –<br />
Wire® communication protocol, Chapter 3 describes the CAN communication protocol,<br />
Chapter discusses the challenges of interfacing CAN and 1 – Wire® communication protocols,<br />
Chapter 5 describes the interface of CAN and 1 – Wire® communication protocols, Chapter 6<br />
3
describes the 1 – Wire® and CAN combined system prototype implementation, and Chapter 7<br />
discusses the conclusions reached from this research and future directions of this work.<br />
4
2.1 History of 1 – Wire®<br />
CHAPTER 2<br />
1 – WIRE® COMMUNICATION PROTOCOL<br />
The Dallas 1 – Wire® bus architecture has been around for more than a decade.<br />
Historically, the 1 – Wire® network was envisioned as a single twisted pair (data line and ground<br />
reference) routed throughout the area of interest with 1 – Wire® slaves connected as shown in<br />
Figure 2.1. It was originally designed to facilitate communication with nearby devices on a short<br />
connection. 1 – Wire® was also a way to add auxiliary memory on a single microprocessor port<br />
pin. As the use of 1 – Wire® devices increased, methods were developed to extend the protocol<br />
to network applications well beyond the size of a printed circuit board [4]. The 1 – Wire®<br />
system is sometimes also referred to as MicroLAN or iButton. Figure 2.1 shows a simple 1<br />
– Wire® network topology.<br />
Figure 2.1 1 – Wire® Network.<br />
5
2.2 1 – Wire® Overview<br />
The basis of 1 – Wire® technology is a serial protocol using a single data line plus<br />
ground reference for communication. Note that by convention the ground or reference wire is<br />
not normally counted [5]. The 1 – Wire® bus uses a simple signaling scheme that performs two-<br />
way communications with peripheral devices over a single electrical connection. This scheme<br />
provides the end user with a low-cost bus driven by a PC or microcontroller (master)<br />
communicating digitally over twisted-pair cable with 1 – Wire® components. The network is<br />
defined with an open-drain master/slave multidrop architecture that uses a resistor pull-up to a<br />
nominal 5V supply at the master. The 1 – Wire® protocol uses conventional CMOS/TTL<br />
(Complementary Metal-Oxide Semiconductor/Transistor-Transistor Logic) logic levels<br />
(maximum 0.8V for logic “zero” and a minimum 2.2V for a logic “one”) with operation<br />
specified over a supply voltage range of 2.8V to 6V [6]. Data transfers are half-duplex and bit<br />
sequential over a single wire, from which the slaves steal power by means of an internal diode<br />
half-wave rectifier and capacitor. Most 1 – Wire® devices support two data rates. The lower<br />
(standard) data rate is approximately 14 kbps and the higher (overdrive) data rate is<br />
approximately 140 kbps. However, an even higher data rate of 1Mbps is currently in<br />
development [7]. Since the protocol is self-clocking and tolerant to long inter-bit delays, this<br />
makes for easy operation in input/output (I/O) intensive environments.<br />
There are several terms often used to describe the operation and components of a 1 –<br />
Wire® network. These are not limited to but include the following: Host Interface, Strong<br />
Pullup, 1 – Wire® Timing, Overdrive Support, and Active Pullup.<br />
6
Host InterfaceIn section 2.3.1 through 2.3.4, all of the circuits discussed are 1 – Wire®<br />
masters; they all communicate with 1 – Wire® slave devices. These 1 – Wire® masters,<br />
however, cannot function as stand-alone entities; they need a host (computer) that tells<br />
them what to do on the 1 – Wire® side. The term “host interface” refers to the type of<br />
connection between the 1 – Wire® Master and the host.<br />
Strong PullupThis term refers to a means for providing extra power to the 1 – Wire®<br />
network between time slots. Extra power is needed for several functions: by EEPROM<br />
(Electrically Erasable Programmable Read-Only Memory) devices, when copying data<br />
from a buffer to EEPROM cells; with secure memories, when the SHA – 1 engine is<br />
running; or with 1 – Wire® temperature sensors during a temperature conversion. When<br />
such 1 – Wire® devices are used in a 3V environment, strong pullup is necessary; in a 5V<br />
environment with the same 1 – Wire® slave devices, strong pullup may be optional.<br />
1 – Wire TimingThis is a general expression for the shape of the 1 – Wire® time slots<br />
and the reset/presence detect sequence, and the means to generate these waveforms.<br />
Special chips with their own timing generator can be used or waveforms can be generated<br />
through software. Sometimes it may be necessary for the low-level functions to generate<br />
time slots and for the reset/presence detect sequence to be written in assembly language,<br />
so that individual instructions and the number of clock cycles to execute them can be<br />
calculated.<br />
Overdrive SupportMost 1 – Wire® slaves can communicate at two speeds: standard<br />
speed and overdrive speed. In overdrive, the timing is approximately eight times faster<br />
than at standard speed. All 1 – Wire® slave devices can communicate at standard speed.<br />
7
All 1 – Wire® masters described in sections 2.3.2 through 2.3.4 support overdrive speed.<br />
In section 2.3.1, the overdrive speed support depends on the capabilities of the<br />
microcontroller (i.e. clock rate and number of clock cycles per instruction cycle).<br />
Active PullupThe 1 – Wire® bus or network is an open-drain environment, with 0V<br />
(logic 0) being the active state. When the bus is idle, it is pulled high to the pullup<br />
voltage through a resistor (RPUP). Falling edges, consequently, are sharp; rising edges,<br />
due to the resistor and the parasitic supply, can be quite slow. Active pullup refers to a<br />
method that tests rising edges, and, if a specific threshold has been crossed, bypasses the<br />
pullup resistor for a limited time with a low-impedance path. Active pullup is generally<br />
not needed in short networks or with a single slave device. If available, active pullup<br />
recharges the 1 – Wire® line faster than resistive pullup and, therefore, supports multiple<br />
1 – Wire® slaves in the network without having to extend the recovery time between<br />
time slots. The 1 – Wire® masters covered in section 2.3.4 differ in the strength<br />
(impedance) of the bypass and the method that controls the duration of the active pullup<br />
[8].<br />
A typical 1 – Wire® net-based system consists of three main elements: a bus master with<br />
controlling software or 1 – Wire® interface, the electrical connection between master and slaves,<br />
and the 1 – Wire® devices, i.e. slaves. The primary job of the 1 – Wire® Master is to initiate<br />
and control the communication with one or more 1 – Wire® slave devices on the bus. Each<br />
slave device has a unique, unalterable, factory-programmed 64-bit identification number, which<br />
8
serves as a device address on the bus. The 8-bit family code, a subset of the 64-bit ID, identifies<br />
the device type and functionality.<br />
What makes the 1 – Wire® protocol unique is that it is the only voltage-based digital<br />
system that works with two contacts, data and ground, for half-duplex bidirectional<br />
communication. In contrast to other serial communication systems such as I 2 C [9] or SPI, 1 –<br />
Wire® devices are designed for use in a contact environment. Either disconnecting from the 1 –<br />
Wire® bus or a loss of contact puts the 1 – Wire® slaves into a defined reset state. When the<br />
voltage returns, the slaves wake up and signal their presence. With only one contact to protect,<br />
the built-in ESD protection of 1 – Wire® devices is extremely high. With two contacts, 1 –<br />
Wire® devices are the most economical way to add electronic functionality to nonelectronic<br />
objects for identification, read/write memories, authentication, addressable switches, digital<br />
temperature sensors, and delivery of calibration data or manufacturing information [10].<br />
2.3 1 – Wire® Communication<br />
To take advantage of 1 – Wire® technology, a 1 – Wire® Master that can generate the<br />
waveforms to identify the devices on the bus and to communicate with them is required. There<br />
are numerous ways to construct a 1 – Wire® Master. The differences depend on whether the 1 –<br />
Wire® Master is for a short network (e.g. those that do not extend beyond a radius of 1 meter<br />
and have no more than three to five slaves) or for a larger network (e.g. those that can extend the<br />
radius beyond 1 meter to over 500 meters and can have hundreds of slaves). In general, 1 –<br />
Wire® Master implementations can be grouped into four categories: microprocessor port-pin<br />
9
attachments, microcontroller with built-in 1 – Wire® Master, synthesizable 1 – Wire® Bus<br />
Master, and serial interface protocol conversions [8].<br />
Since data on any 1 – Wire® network is transferred by time slots, a system clock is not<br />
required, as each 1 – Wire® device is self-clocked by its own internal oscillator synchronized to<br />
the falling edge of the master. The first part of communication on any 1 – Wire® network<br />
involves the selection of a 1 – Wire® slave device for communications. This can be<br />
accomplished by selecting all slave devices (i.e. broadcast), selecting a specific slave device<br />
(using the serial number of the device), or discovering the next slave on the bus using a binary<br />
search algorithm. Not to be confusing, all slave devices can be selected, but the 1 – Wire®<br />
Master can only communicate with one slave at a time. Once a slave has been selected, all other<br />
slaves drop out and ignore subsequent communications until the next reset is issued. At this<br />
point, the bus master can issue device-specific commands to the selected slave, send data to it, or<br />
read data from it.<br />
In a typical 1 – Wire® network there will be more than one slave and also different types<br />
of slave devices. Because each slave type (see section 2.4) performs different functions and<br />
serves a different purpose, each has a unique communication sequence once it has been selected<br />
[11]. Even though each slave type may have a different communication sequence and features,<br />
they all have the same selection process and follow the command flow shown in Figure 2.2.<br />
Figure 2.2 Typical 1 – Wire® Communication Flow [11].<br />
10
2.3.1 Microprocessor Port-Pin Attachments<br />
As the only prerequisite, this configuration requires a microprocessor with a spare<br />
bidirectional port pin and some spare space in the program memory. Figure 2.3 shows the most<br />
basic implementation of this 1 – Wire® Master. The upside of this implementation is its low,<br />
additional hardware cost, since it requires just a pullup resistor. On the downside, the 1 – Wire®<br />
timing, to communicate with slave devices, is generated through software, which can increase<br />
the initial software development time and cost. Depending on the number of 1 – Wire® slaves<br />
on the bus and the 1 – Wire® pullup voltage, an additional port pin may be required to<br />
implement a strong pullup. With more than one slave device on the 1 – Wire® bus, the value of<br />
RPUP needs to be lowered. If communicating with 1 – Wire® slaves at overdrive speed, a<br />
microcontroller with a high clock frequency and/or a low number of clock cycles per instruction<br />
is required.<br />
A variation of the implementation shown in Figure 2.3 is shown in Figure 2.4. As a<br />
prerequisite, this new implementation requires two spare unidirectional port pins, a pulldown<br />
transistor, and some spare space in the program memory. The upside of this design is that it does<br />
not need a bidirectional port pin, but on the downside, the 1 – Wire® timing is generated through<br />
software, which can increase the initial software development time and cost. Depending on the<br />
number of 1 – Wire® slaves on the bus and the 1 – Wire® pullup voltage, an additional port pin<br />
may be required to implement a strong pullup. With more than one slave device on the 1 –<br />
Wire® bus, the value of RPUP needs to be lowered. If communicating with 1 – Wire® slaves at<br />
overdrive speed, a microcontroller with a high clock frequency and/or a low number of clock<br />
cycles per instruction is required.<br />
11
Figure 2.3 Bidirectional port pin with optional circuit for strong pullup (dashed lines) [8].<br />
Figure 2.4 Unidirectional port pins with optional circuit for strong pullup (dashed lines) [8].<br />
12
2.3.2 Microprocessor with Built-In 1 – Wire® Master<br />
The implementation in Figure 2.5 is very similar to that in Figure 2.3. The difference is<br />
in the type of microcontroller. The main prerequisites for this implementation include a<br />
microcontroller with a built-in 1 – Wire® Master (e.g., the DS80C400, DS80C410, or<br />
DS80C411) and some spare space in the program memory. The upside is that the 1 – Wire®<br />
timing is generated by hardware, which can reduce the initial software development time and<br />
cost. Consequently, the entire application software can be written in a high-level language. On<br />
the downside, only high-end microcontrollers have a built-in 1 – Wire® Master. Depending on<br />
the number of 1 – Wire® slaves on the bus and the 1 – Wire® pullup voltage, an additional port<br />
pin may be required to implement a strong pullup. With more than one slave device on the 1 –<br />
Wire® bus, the value of RPUP needs to be lowered.<br />
Figure 2.5 µC with Built-In 1 – Wire® Master & optional strong pullup circuit (dashed lines) [8].<br />
13
2.3.3 Synthesizable 1 – Wire® Bus Master<br />
The circuit in Figure 2.6 is very similar to the circuit in Figure 2.5. The difference is that<br />
the microcontroller and 1 – Wire® port are embedded in an <strong>ASIC</strong> or FPGA (Field Programmable<br />
Gate Array). This circuit requires an <strong>ASIC</strong> or FPGA with microcontroller capability, at least one<br />
spare bidirectional port pin, unused logic gates, and some spare space in the program memory.<br />
The upside of this circuit is that the 1 – Wire® timing is generated by hardware, which can<br />
reduce the initial software development time and cost. Consequently, the entire application<br />
software can be written in a high-level language. On the downside, not all <strong>ASIC</strong>s or FPGAs<br />
have 5V – tolerant ports. The 1 – Wire® operating voltage is limited by the port characteristics<br />
of the <strong>ASIC</strong>/FPGA. Depending on the number of 1 – Wire® slaves on the bus and the 1 –<br />
Wire® pullup voltage, an additional port pin may be required to implement a strong pullup.<br />
With more than one slave device on the 1 – Wire® bus, the value of RPUP needs to be lowered.<br />
Figure 2.6 <strong>ASIC</strong>/FPGA with optional circuit for strong pullup (dashed lines) [8].<br />
14
2.3.4 Serial Interface Protocol Conversions<br />
The final category of 1 – Wire® Master implementation is created using an interface<br />
between some type of controller and an off-the-shelf 1 – Wire® Master. As shown in Figure 2.7,<br />
one way to accomplish this is to interface the controller to the 1 – Wire® Master via a serial<br />
interface. This implementation requires a way to control a UART, such as a microcontroller,<br />
FPGA, or PC serial port, and some spare space in the program memory. The upside of this<br />
design is that the 1 – Wire® timing is generated by hardware leading to the benefits mentioned<br />
above. Through control registers, the 1 – Wire® timing can be fine-tuned.<br />
The DS2480B is a serial port to 1 – Wire® interface chip that supports both standard and<br />
overdrive speeds [12]. It directly interfaces UARTs and 5V RS232 systems with its lines TXD<br />
(transmit) and RXD (receive) to a 1 – Wire® bus. In addition, the device performs a speed<br />
conversion allowing the data rate at the communication port to be different from the 1 – Wire®<br />
data rate. The DS2480B supports a strong pullup and active pullup. It is also the strongest (i.e.<br />
capable of delivering the most power) single-chip 1 – Wire® Master available and is good for<br />
communicating with a large number of slave devices. On the downside, the DS2480B is more<br />
costly than the discrete components shown in Figures 2.3 through 2.6.<br />
15
Figure 2.7 UART/RS232 Serial Port Interface [8].<br />
For those applications that already use an I 2 C [9] bus, the implementation in Figure 2.8 is<br />
most convenient to establish a 1 – Wire® Master. This design makes use of an existing I 2 C bus<br />
controller, such as a microcontroller, or <strong>ASIC</strong>/FPGA, and some spare space in the program<br />
memory. The advantages to this implementation are its relatively low cost for the features<br />
provided, and the fact that the 1 – Wire® timing is generated by hardware. The DS2482<br />
supports a strong pullup as well as an active pullup. On the downside, the DS2482 cannot drive<br />
as many 1 – Wire® slave devices as the DS2490 or DS2480B. The single-channel version, the<br />
DS2482-100 as shown in Figure 2.8, has a control output for an additional strong pullup (Q1)<br />
circuit as shown in Figures 2.3 through 2.6 [13 – 15].<br />
16
Figure 2.8 I 2 C interface with optional circuit for extra strong pullup (dashed lines) [8].<br />
Figure 2.9 1 – Wire® Master for a USB interface [8].<br />
A 1 – Wire® Master application circuit can also be created using a USB port, as shown in<br />
Figure 2.9. The upside of this implementation is that the 1 – Wire® timing is generated by<br />
17
hardware. Through control registers, the 1 – Wire® timing can be fine-tuned. The DS2490, like<br />
the DS2482 and DS2480B, supports a strong pullup and an active pullup. On the downside, the<br />
DS2490 is more costly than the other implementations presented here and also the DS2490<br />
pullup is not as strong as the DS2480B.<br />
In addition to the interface circuits described previously, 1 – Wire® can also be<br />
connected to a PC using a bus converter. The primary function of the bus converter is to<br />
generate the appropriate 1 – Wire® communication signals and perform level conversion<br />
depending on the type of port device used. USB, RS232 serial, and parallel port adapters are<br />
available to connect 1 – Wire® devices to a host PC. Table 2.1 lists the different types of PC<br />
adapters available. Since the PC-ready adapters do not require any software development by the<br />
user, PC attachments that function as a 1 – Wire® Master are very convenient for evaluating 1 –<br />
Wire® devices and for prototyping.<br />
Table 2.1 Port Adapters for 1 – Wire® Devices.<br />
Port Type Converter<br />
1 – Wire®<br />
Port<br />
Part Number Notes<br />
USB DS2490<br />
iButton<br />
RJ – 11<br />
DS9490B<br />
DS9490R<br />
Built-in ID chip is hardwired to 1 –<br />
Wire® bus<br />
iButton<br />
DS1411-009<br />
Built-in ID chip is hardwired to 1 –<br />
Wire® bus<br />
DS1411-S09 No ID chip<br />
RS232 DS2480B<br />
DS9097U-009<br />
Built-in IC chip is hardwired to 1 –<br />
Wire® bus<br />
RJ – 11<br />
DS9097U-S09 No ID chip<br />
No ID chip; w/ external 12V supply,<br />
DS9097U-E25 this adapter can program 1 – Wire®<br />
EPROMs<br />
Parallel DS1481 iButton DS1410E-001<br />
Built-in ID chip is hardwired to 1 –<br />
Wire® bus<br />
18
2.3.5 Timing/Transaction Sequence on the 1 – Wire® Bus<br />
In any 1 – Wire® network, there are four basic signaling operations that comprise all<br />
device communications: Reset, Write ‘0’ bit, Write ‘1’ bit, and Read bit. Referring back to<br />
Figure 2.2, these four signaling operations are an integral part of each step in the typical 1 –<br />
Wire® communication flow. The 1 – Wire® bus requires strict signaling protocol to ensure data<br />
integrity. A typical 1 – Wire® transaction sequence consists of four steps: Initialization, ROM<br />
(read-only-memory) Function Command, Memory Function Command, if applicable (not all 1 –<br />
Wire® devices support these commands, i.e. identification (ID) only devices), and<br />
Transaction/Data.<br />
An initialization sequence begins when the bus master drives a defined length “Reset”<br />
pulse that synchronizes the entire bus. Every slave then responds to the “Reset” pulse with a<br />
logic low “Presence” pulse. To write data, the master first initiates a time slot by driving the 1 –<br />
Wire® line low, and then, either holds the line low (wide pulse) to transmit a logic ‘0’ or releases<br />
the line (short pulse) to allow the bus to return to the logic ‘1’ state. To read data, the master<br />
again initiates a time slot by driving the line with a narrow low pulse. A slave can then either<br />
return a logic ‘0’ by turning on its open-drain output and holding the line low to extend the pulse,<br />
or return a logic ‘1’ by leaving the open-drain output off to allow the line to recover. Table 2.2<br />
provides a list of operations and implementation steps for standard speed communications<br />
(overdrive speeds are shown in parentheses) on a typical 1 – Wire® bus network. Figures 2.10<br />
through 2.13 show scope traces of the 1 – Wire® operations described in Table 2.2.<br />
19
Table 2.2 1 – Wire® Bus Operations.<br />
Operation Description Implementation<br />
Reset<br />
Write ‘0’ Bit<br />
Write ‘1’ Bit<br />
Read Bit<br />
Reset all of the 1 – Wire® bus slave<br />
devices and get them ready for a<br />
command.<br />
Send ‘0’ bit to all of the 1 – Wire®<br />
slaves (Write ‘0’ slot time).<br />
Send ‘1’ bit to all of the 1 – Wire®<br />
slaves (Write ‘1’ slot time).<br />
Read a bit from the 1 - Wire® slaves<br />
(Read time slot).<br />
20<br />
Delay 0µs. (2.5µs)<br />
Drive the bus low, delay 480µs. (70µs)<br />
Release the bus, delay 70µs. (8.5µs)<br />
Sample the bus: ‘0’ = device(s) present,<br />
‘1’ = no device present.<br />
Delay 410µs. (40µs)<br />
Drive the bus low, delay for 60µs. (7.5µs)<br />
Release the bus, delay for 10µs. (2.5µs)<br />
Drive the bus low, delay for 6µs. (1.0µs)<br />
Release the bus, delay for 64µs. (7.5µs)<br />
Drive the bus low, delay for 6µs. (1.0µs)<br />
Release the bus, delay for 9µs. (1.0µs)<br />
Sample the bus to read from slave(s), delay for<br />
55µs. (7µs)<br />
Figure 2.10 Reset/Presence Detect Sequence.
Figure 2.11 Write Zero Time Slot.<br />
Figure 2.12 Write One/Read One Time Slot.<br />
21
2.3.6 1 – Wire® Search Algorithm<br />
Figure 2.13 Read Zero Time Slot.<br />
As stated previously, all 1 – Wire® slaves each have a 64 – bit unique registration<br />
number in ROM that is used to address them individually by a 1 – Wire® Master. If the ROM<br />
numbers of the slave devices on the 1 – Wire® network are not known, then they can be<br />
discovered by using a search algorithm. This is a binary tree search where branches are followed<br />
until a device ROM number, or leaf, is found. Subsequent searches then take the other branch<br />
paths until all of the leaves present are discovered.<br />
The search algorithm begins with the devices on the 1 – Wire® being reset using the reset<br />
and presence pulse sequence. If this is successful then the 1 – byte search command is sent. The<br />
search command readies the 1 – Wire® devices to begin the search. There are two types of<br />
search commands. The normal search command (0xF0) will perform a search with all devices<br />
22
participating. The alarm or conditional search command (0xEC) will perform a search with only<br />
the devices that are in some sort of alarm state. This reduces the search pool to quickly respond<br />
to devices that need attention.<br />
Figure 2.14 64 – Bit Unique ROM ‘Registration’ Number.<br />
Following the search command, the actual search begins with all of the participating<br />
devices simultaneously sending the first bit (least significant) in their ROM number as shown in<br />
Figure 2.14. As with all 1 – Wire® communication, the 1 – Wire® Master initiates every bit<br />
whether it is data to be read or written to the slave devices. Due to the characteristics of the 1 –<br />
Wire® bus, when all devices respond at the same time, the result will be a logical <strong>AND</strong> of the<br />
bits sent. After the devices send the first bit of the ROM number, the master initiates the next bit<br />
and the devices then send the complement of the first bit. From these two bits, information can<br />
be derived about the first bit in the ROM numbers of the participating devices. This information<br />
is summarized in Table 2.3.<br />
Table 2.3 1 – Wire® Bit Search Information.<br />
Bit (true) Bit (complement) Information Known<br />
0 0<br />
There are both 0s and 1s in the current bit position of the<br />
participating ROM numbers. This is a discrepancy.<br />
0 1 There are only 0s in the bit of the participating ROM numbers.<br />
1 0 There are only 1s in the bit of the participating ROM numbers.<br />
1 1 No devices participating in search.<br />
Next, according to the search algorithm, the 1 – Wire® Master must then send a bit back<br />
to the participating devices. If a participating device has that bit value, it continues participating.<br />
If it does not have the bit value, it goes into a wait state until the next 1 – Wire® reset is<br />
23
detected. This ‘read two bits’ and ‘write one bit’ pattern, from the perspective of the Master, is<br />
then repeated for the remaining 63 bits of the ROM number (see Table 2.4). In this way the<br />
search algorithm forces all but one device to go into this wait state. At the end of one pass, the<br />
ROM number of this last participating device is known. On subsequent passes of the search, a<br />
different path is taken to find the other device ROM numbers.<br />
Table 2.4 1 – Wire® Master and Slave Search Sequence.<br />
Master Slave<br />
1 – Wire® reset stimulus Produce presence pulse.<br />
Write search command (normal or alarm) Each slave readies for search<br />
Read ‘<strong>AND</strong>’ of bit 1 Each slave sends bit 1 of its ROM number.<br />
Read ‘<strong>AND</strong>’ of complement of bit 1 Each slave sends complement of bit 1 of its ROM number.<br />
Each participating slave receives the bit written by master, if bit<br />
Write bit 1 direction (according to algorithm) read is not the same as bit 1 of its ROM number then go into a<br />
wait state.<br />
Read ‘<strong>AND</strong>’ of bit 64 Each slave sends bit 64 of its ROM number.<br />
Read ‘<strong>AND</strong>’ of complement of bit 64 Each slave sends complement bit 64 of its ROM number.<br />
Write bit 64 direction (according to algorithm)<br />
Each participating slave receives the bit written by master, if bit<br />
read is not the same as bit 64 of its ROM number then go into a<br />
wait state.<br />
On examination of Table 2.3, it is obvious that if all of the participating devices have the<br />
same value in a bit position then there is only one choice for the branch path to be taken. The<br />
condition where no devices are participating is an atypical situation that may arise if the device<br />
being discovered is removed from the 1 – Wire® bus during the search. If this situation arises<br />
then the search should be terminated and a new search started with a 1 – Wire® reset. The<br />
condition where there are both 0s and 1s in the current bit position is called a discrepancy and is<br />
the key to finding devices in the subsequent searches. The search algorithm specifies that on the<br />
first pass, when there is a discrepancy (bit/complement = 0/0), the ‘0’ path is taken. The bit<br />
position for the last discrepancy is recorded for use in the next search [16]. Table 2.5 describes<br />
the paths taken on subsequent searches when a discrepancy occurs.<br />
24
Table 2.5 1 – Wire® Search Path Direction.<br />
Search Bit Position vs. Last Discrepancy Path Taken<br />
= Take the ‘1’ path.<br />
< Take the same path as last time (from the last ROM number found).<br />
> Take the ‘0’ path.<br />
The search algorithm also keeps track of the last discrepancy that occurs within the first<br />
eight bits of the algorithm. The first eight bits of the 64 – bit registration number is a family<br />
code. As a result, the devices discovered during the search are grouped into family types. The<br />
last discrepancy within that family code can be used to selectively skip whole groups of 1 –<br />
Wire® devices. The 64 – bit ROM number also contains an 8 – bit cyclic-redundancy-check<br />
(CRC). This CRC value is verified to ensure that only correct ROM numbers are discovered.<br />
2.3.7 1 – Wire® CRC Check<br />
Serial data can be checked for errors in a variety of ways. One common way is to include<br />
an additional bit in each packet being checked that will indicate if an error has occurred. The<br />
error detection scheme most effective at locating errors in a serial data stream with a minimal<br />
amount of hardware is the Cyclic Redundancy Check. The most significant byte in the ROM<br />
code of each 1 – Wire® device contains a CRC value based on the previous seven bytes of data<br />
for that part. When the host system begins communication with a device, the 8 – byte ROM is<br />
read, least significant bit first. If the CRC that is calculated by the host agrees with the CRC<br />
contained in byte 7 of the ROM data actually read, the communication is considered valid. If<br />
this is not the case, an error has occurred and the ROM code should be read again.<br />
The CRC can be most easily understood by considering the function as it would actually<br />
be built in hardware, usually represented as a shift register arrangement with feedback as shown<br />
25
in Figure 2.15. Alternatively, the CRC is sometimes referred to as a polynomial expression in a<br />
dummy variable X, with binary coefficients for each of the terms. The coefficients correspond<br />
directly to the feedback paths shown in the shift register implementations.<br />
Figure 2.15 1 – Wire® 8 – bit CRC.<br />
The 1 – Wire® CRC magnitude is 8 bits, which is used for checking the 64 – bit ROM<br />
code written into each 1 – Wire® product. This ROM code consists of an 8 – bit family code<br />
written into the least significant byte, a unique 48 – bit serial number written into the next six<br />
bytes, and a CRC value that is computed based on the preceding 56 bits of ROM and then<br />
written into the most significant byte. The location of the feedback paths represented by the<br />
exclusive-or gates in Figure 2.15, or presence of coefficients in the polynomial expression,<br />
determine the properties of the CRC and the ability of the algorithm to locate certain types of<br />
errors in the data. The types of errors that are detectable are:<br />
Any odd number of errors anywhere within the 64 – bit number.<br />
All double-bit errors anywhere within the 64 – bit number.<br />
Any cluster of errors that can be contained within an 8 – bit ‘window’ (1 – 8 bits<br />
incorrect).<br />
Most larger clusters of errors.<br />
26
From Figure 2.15, the input data gets exclusive-or’d with the output of the eighth stage of the<br />
shift register. The shift register can be considered mathematically as a dividing circuit. The<br />
input data is the dividend, and the shift register with feedback acts as a divisor. The resulting<br />
quotient is discarded, and the remainder is the CRC value for that particular stream of input data,<br />
which resides in the shift register after the last data bit has been shifted in. The final result (CRC<br />
value) is dependent on the past history of the bits presented. Therefore, it would take an<br />
extremely rare combination of errors to escape detection by this method [17].<br />
2.3.8 1 – Wire® Commands<br />
After initialization has been completed and the bus master has detected a presence pulse<br />
on the bus, it can issue one of the following ROM function commands:<br />
READ ROM [33h] – This command allows the bus master to read a device’s 8 – bit<br />
family code, unique 48 – bit serial number, and 8 – bit CRC code. This command can<br />
only be used if there is a single slave device on the bus. If more than one slave (See<br />
Figure 2.1) is present on the bus, a data collision will occur when all slaves try to transmit<br />
at the same time (open drain will produce a wired – <strong>AND</strong> result). The resultant family<br />
code and 48 – bit serial number will result in a mismatch of the CRC.<br />
SEARCH ROM [F0h] – When a system is initialized, the bus master might not know the<br />
number of devices on the 1 – Wire® bus or their registration numbers. The SEARCH<br />
ROM command allows the bus master to use a process of elimination to identify the 64 –<br />
bit ROM codes of all slave devices on the bus. The process is the repetition of a simple 3<br />
– step routine on each bit of the ROM by the bus master: read a bit, read the complement<br />
27
of the bit, then write the desired value of that bit. After one complete pass, the bus<br />
master knows the contents of the ROM in one device. The remaining number of devices<br />
and their ROM codes can be identified by additional passes.<br />
MATCH ROM [55h] – This command followed by a 64 – bit ROM sequence, allows the<br />
bus master to address a specific slave device on a bus topology having one or more<br />
slaves. Only the device that exactly matches the 64 – bit ROM sequence will respond to<br />
the following memory function command. All slaves that do not match the 64 – bit ROM<br />
sequence wait for a reset pulse.<br />
SKIP ROM [CCh] – This command can save time in a single slave network by allowing<br />
the bus master to access the memory functions without providing the 64 – bit ROM code.<br />
If more than one slave is present on the bus and, for example, a read command is issued<br />
following the SKIP ROM command, data collision will occur on the bus as multiple<br />
slaves transmit simultaneously (open-drain pulldowns produce a wired – <strong>AND</strong> result).<br />
All iButtons and 1 – Wire® devices support at least some basic set of ROM function<br />
commands such as those previously mentioned. The number of supported ROM functions<br />
depends on the device itself but most importantly, these ROM functions (there are a total of 9)<br />
have the same command number regardless of the iButton or 1 – Wire® device being used.<br />
After a ROM function command has been successfully executed, the bus master may then<br />
provide any one of the memory function commands specific to the device being addressed. (See<br />
device documentation for specific number and type of memory functions as these can be<br />
different for each device and also not all devices support these commands.) This allows further<br />
data and other transactions to take place between the bus master and slave devices.<br />
28
2.4 Types of Devices<br />
Dependent on their function, 1 – Wire® devices are available in a variety of packages<br />
such as single components in an integrated circuit (IC) package and in some cases a portable<br />
form called an iButton that resembles a watch battery. Manufacturers also produce products<br />
that are more complex than a single component, and use the 1 – Wire® bus to communicate. A 1<br />
– Wire® device may be just one of many components on a circuit board within a product, but are<br />
also found in isolation within devices or attached to a device being monitored.<br />
2.4.1 1 – Wire® Device Packaging<br />
Most 1 – Wire® devices are available in durable, stainless steel containers about the size<br />
of four stacked dimes called iButtons. 1 – Wire® devices are also offered in conventional<br />
transistor (TO – 92) and IC packages (TSOC, SOIC, SOT23). Designed for contact applications<br />
and easy attachment, the 2 – contact SFN (Single line of contacts, Flat, No leads) package<br />
accommodates parasitically powered 1 – Wire® devices. The 16mm-diameter stainless steel<br />
iButton package protects 1 – Wire® devices from harsh environments, making them suitable<br />
for indoor and outdoor use [10]. Many devices are also available in flip chip and UCSP (Ultra<br />
Chip Scale Package) versions. In addition to the various device package types for 1 – Wire®<br />
devices, 1 – Wire® peripherals also come in a wide variety including various serial- and parallel-<br />
port adaptors for PCs, probes, fob and holders, and a wide array of iButton attachments. A 1 –<br />
Wire® peripheral can be thought of as an auxiliary device that connects to a 1 – Wire® network<br />
and allows communication between 1 – Wire® devices and a host computer or 1 – Wire®<br />
devices and 1 – Wire® networks.<br />
29
2.4.2 Device Functions and Typical Applications<br />
At this time, there are approximately 40 1 – Wire® devices, including some close to the<br />
end of their lifetime. iButton 1 – Wire® devices can be categorized into one of seven<br />
categories: ID only, NV SRAM, EPROM, EEPROM, Real-Time Clocks, Secure, and Data<br />
Loggers. Remaining 1 – Wire® devices fall into one of eight categories: EPROM; EEPROM;<br />
Memory with GPIO; Temperature Sensors and Switches; 1 – Wire® Interface Products; four<br />
Channel A-to-D Converter; Timekeeping and Real-Time Clocks; and Battery Protectors,<br />
Selectors, and Monitors.<br />
Although the original concept behind the development of the 1 – Wire® protocol was to<br />
provide simplified communications on a single PCB, the main applications of 1 – Wire® devices<br />
today are primarily but not limited to the following:<br />
Print Cartridge ID – using unique SFN packaging, 1 – Wire® devices can easily be<br />
attached to nonelectronic peripherals like printer consumables. The SFN package can be<br />
mounted with snap-fit or adhesive into a recessed area. This allows 1 – Wire®<br />
authentication and monitoring features with a single, dedicated connector contact, which<br />
reduces connector complexity and cost. The 1 – Wire® devices typically used include<br />
the DS1990A/DS1990R, DS1982, and DS1985.<br />
Medical Consumable ID – SFN packaging allows easy attachment to nonelectronic<br />
peripherals like medical sensors (ID and calibration), blood glucose strips (calibration<br />
and authentication), and reagent bottles (ID). The 1 – Wire® devices typically used<br />
include the DS2401, DS2413, DS2502, DS2506, DS2431, DS28EC20, DS2433, DS2432,<br />
and DS28E01.<br />
30
Rack Card Calibration and Control – the controller in a module-based rack or chassis<br />
system often needs to identify what cards are installed, monitor key metrics like<br />
temperature, and track hot-swapped units. The 1 – Wire® memory, I/O, and<br />
temperature-sensor products solve this problem by providing a unique identity for every<br />
module in the system. The 1 – Wire® devices typically used include the DS2413,<br />
DS28EA00, DS2502, DS2505, DS2431, DS28EC20, DS2433, DS28E04, and DS28E01.<br />
PCB identification and authentication – factory-administered 64-bit serialization with<br />
embedded memory provides PCB/product labeling and storage of product information.<br />
Programmable features like OTP (One-Time Programmable) mode and write protection<br />
combine with SHA-1 based secure authentication to ensure that critical data cannot be<br />
altered once it is programmed. Storage of product characteristics, PCB<br />
hardware/software revision, maintenance records, and calibration constants are examples<br />
of typical usage. The 1 – Wire® devices typically used include the DS2401, DS2411,<br />
DS1963S, DS1992L, DS2502-E48, DS2502-E64, DS1982, DS1985, DS2431,<br />
DS28EC20, DS2433, DS28E01, and DS1961S.<br />
Accessory/Peripheral Identification and Control – typical applications include battery-<br />
pack and power-adapter identification, LED control, TEDS (Transducer Electronic Data<br />
Sheet) sensor identification/control, and consumable identification/control. The 1 –<br />
Wire® devices typically used include the DS2401, DS2411, DS2413, DS2502, DS2505,<br />
DS2431, DS28EC20, DS2433, and DS28E01.<br />
IP Protection, Secure Feature Control Clone Prevention – authentication solutions help<br />
OEMs (Original Equipment Manufacturers) protect product development and research<br />
31
and development (R&D) investments by preventing low-quality knockoffs from entering<br />
the marketplace. Authentication solution options range from customization of the unique<br />
serial number factory-lasered into each device (providing controlled procurement access)<br />
to secure crypto-strong ISO/IEC 10118-3 SHA-1 based challenge and response for bi-<br />
directional authentication. The 1 – Wire® devices typically used include the DS2401,<br />
DS2411, DS1963S, DS1993L, DS1995L, DS1996L, DS2431, DS28EC20, DS28E01, and<br />
DS1961S.<br />
Consumer electronics – the types of 1 – Wire® devices used in consumer electronics<br />
include those of identification only (DS2401 and DS2411), identification plus control<br />
(DS2450), identification plus time (DS2417 and DS1904L), identification plus EEPROM<br />
(DS28EC20 and DS2431), and identification plus SHA – 1 secure EEPROM (DS28E01).<br />
Access control – the types of 1 – Wire® devices used for access control include those of<br />
identification only (DS1990A/DS1990R), identification plus NV SRAM (DS1992L,<br />
DS1993L, DS1995L, DS1996L), and identification plus EEPROM (DS1971, DS1972,<br />
DS1973).<br />
Electronic cash – the type of 1 – Wire® devices used for electronic cash tokens include<br />
those of identification plus NV SRAM (DS1963S) and identification plus SHA – 1<br />
Secure EEPROM (DS1961S).<br />
Gaming devices – the type of 1 – Wire® devices used for the gaming industry include<br />
those of identification plus EEPROM (DS1977) due to high capacity (32KB) and<br />
password protection.<br />
32
2.4.3 Unique Address and Device Customization<br />
Within each 1 – Wire® slave device is stored a lasered ROM section with its own<br />
guaranteed unique, 64-bit serial number that acts as its node address. This globally unique<br />
address is composed of eight bytes divided into three main sections: the first byte stores the 8 –<br />
bit family code identifying the device type, the next six bytes store a customizable 48 – bit<br />
individual address, and the last byte contains the CRC data based on the data contained in the<br />
first seven bytes. With a 2 48 address pool, conflicting or duplicate node addresses on the bus are<br />
almost never a problem.<br />
Because 1 – Wire® devices can be formatted with a file directory like a floppy disk, files<br />
can be randomly accessed and changed without disturbing other records. Information is read or<br />
written when the master addresses a slave device connected to the bus, or an iButton is<br />
touched to a probe somewhere along the 1 – Wire® network. The inclusion of up to 64k of<br />
memory in 1 – Wire® devices allows a great deal of information to be stored within the device<br />
[6].<br />
Additionally, 1 – Wire® devices are afforded several types of device customization.<br />
Custom ROM is perhaps the most popular with identification-only devices, but is applicable to<br />
all devices with a 64 – bit ID number. With custom ROM, a pool of 68.7 x 10 9 numbers<br />
(equivalent to 36 bits) is committed to the sole use of a single customer. This type of<br />
customization occurs before packaging, which leads to a fairly long lead-time. For OTP<br />
EPROMs, an alternate customization, called UniqueWare, takes place after packaging. Instead<br />
of modifying the ID number, customer-specified serialization is programmed into EPROM and<br />
then write protected [10].<br />
33
2.5 Network Types and Precedents<br />
As the use and popularity of 1 – Wire® devices has increased over the past two decades,<br />
so to have the methods to extend the 1 – Wire® protocol to networked applications well beyond<br />
the size of a circuit board. There have been many application notes, tech briefs, and other<br />
documents published over the years from a variety of sources, authorized and unauthorized alike,<br />
regarding 1 – Wire® implementations. As the world of 1 – Wire® devices and systems has<br />
grown and evolved, some of the information in these documents has been augmented, modified,<br />
or sometimes even proven incorrect. This has lead to the creation of some misinformation before<br />
a complete analysis of large 1 – Wire® networks was completed, and some was perhaps based<br />
on anecdotal information. As the scope of 1 – Wire® networks has grown, much has been<br />
learned about those characteristics that make a large network reliable, and the devices themselves<br />
have undergone a process of evolution that continues in earnest today.<br />
As is the case with most other communication protocols and buses, a proper match<br />
among network components (i.e., master, network cabling, and 1 – Wire® slave devices) is the<br />
precondition for reliable 1 – Wire® operation. When bus masters are improperly designed or<br />
implemented, or when masters intended for short-line use are pressed into service with greatly<br />
extended communication lines, then satisfactory performance cannot always be expected [4].<br />
Since 1 – Wire® networks are often quite “free form” in structure, this leads to numerous<br />
combinations of wire types and topologies that can be used with 1 – Wire® devices. Due to<br />
space limitations here, only the most general and typical applications associated with 1 – Wire®<br />
networks are considered.<br />
34
Often to describe measurements that are critical to 1 – Wire® network performance, two<br />
simple terms are used: radius and weight. The radius of a network is the wire distance from the<br />
1 – Wire® Master to the most distant slave and is measured in meters. The weight of a network<br />
is the total amount of connected wire in the network, and it too is measured in meters. In<br />
general, the weight of the network limits the rise time on the cable, while the radius establishes<br />
the timing of the slowest signal reflections [4].<br />
2.5.1 Slave Device Weight<br />
The weight that can be supported in a 1 – Wire® network is limited and depends on the<br />
driver (1 – Wire® Master interface). In simple terms, the weight can consist of many slaves on<br />
very little cable, or very few slaves on a lot of cable. Slave devices add equivalent weight to a<br />
network. Each device adds weight similar to that of a small length of wire, so devices can be<br />
rated in terms of their equivalent wire weight. Consequently, when a network is designed, the<br />
weight of the devices is an important consideration. A slave in iButton form usually<br />
contributes more weight than a slave packaged as a soldered-in component. iButtons add a<br />
weight of approximately 1m, and non-iButton slaves add a weight of approximately 0.5m [4].<br />
In addition to the weight added by the slave devices, circuit-board traces, connectors and ESD<br />
protection devices also contribute to the weight of a 1 – Wire® network. Although weight is<br />
influenced by many factors, capacitance is clearly the largest single contributor. As a general<br />
rule, the weight contribution of ESD circuits and PC-board traces can be related to their<br />
capacitance by a factor of approximately 24pF/m [4].<br />
35
2.5.2 1 – Wire® Network Topologies<br />
Although there are countless configurations of 1 – Wire® networks, they usually fit into<br />
a few general categories including linear, stubbed, and star topologies. 1 – Wire® network<br />
topologies are based on the distribution of the 1 – Wire® slaves and the organization of the<br />
interconnecting wires.<br />
Linear topology: The 1 – Wire® bus is a single pair, starting from the master and extending to<br />
the farthest slave device. Other slaves are attached to the 1 – Wire® bus with (
Star Topology: The 1 – Wire® bus is split at or near the master end and extends in multiple<br />
branches of varying lengths. There are slave devices along, or at the ends of, the branches.<br />
Figure 2.18 shows an example of a star topology 1 – Wire® network.<br />
Figure 2.18 Star Network Topology.<br />
When different topologies are intermixed, it becomes much more difficult to determine<br />
the effective limitations for the 1 – Wire® network. As a rule, the designer should apply the<br />
most conservative of the criteria in these cases. Unswitched star topologies (i.e. those with<br />
several branches diverging at the master) are the most difficult to make reliable. The junction of<br />
the various branches presents highly mismatched impedances; reflections from the end of one<br />
branch can travel distances equal to nearly the weight of the network and cause data errors.<br />
37
2.5.3 1 – Wire® Network Limitations<br />
Several factors determine the maximum radius and weight of a network. Some of these<br />
factors can be controlled and some cannot. The master-end interface greatly influences the<br />
allowable size of a 1 – Wire® network. This interface must provide sufficient drive current to<br />
overcome the weight of the cable and slaves. The master-end interface must also generate the 1<br />
– Wire® waveform with timing that is within specification and optimized for the charge and<br />
discharge times of the network. Finally, the interface must provide a suitable impedance match<br />
to the network, so that signals are not reflected back down the line to interfere with other<br />
network slaves.<br />
When the network is very small, very simple master-end interfaces are acceptable.<br />
Capacitance is low, reflected energies arrive too soon to pose a problem, and cable losses are<br />
minimal. A simple active FET pulldown and passive resistor pullup are sufficient. However,<br />
when cable lines lengthen and more slave devices are connected, complex signal interactions<br />
come into play. This requires the master-end interface to be properly designed to handle these<br />
complex signal characteristics.<br />
The network radius is limited by several factors: the timing of waveform reflections, the<br />
time delay produced by the cable, the resistance of the cable, and the degradation of signal<br />
levels. Network weight is limited by the ability of the cable to be charged and discharged<br />
quickly enough to satisfy the 1 – Wire® protocol. A simple pullup resistor has a weight<br />
limitation of about 200m. Sophisticated 1 – Wire® Master designs have overcome this<br />
limitation by using active pullups, that provide higher currents under logic control and have<br />
extended the maximum supportable weight to over 500m.<br />
38
2.5.4 Parasitic Power<br />
The 1 – Wire® waveform must not only be sufficient for communication, but also<br />
provide operating power for the slaves. Each slave “steals” power from the bus when the voltage<br />
on the bus is greater than the voltage on its internal energy storage capacitor. When the weight<br />
of the network becomes excessive, the current delivered by the master may not be sufficient to<br />
maintain operating voltage in the slaves.<br />
The worst-case scenario for parasitic power is a very long sequence of zero bits issued by<br />
the master. When this occurs, the bus data line spends most of its time in the low state, and there<br />
is very little opportunity to recharge the slaves. If the bus reaches a sufficient voltage during the<br />
recovery time between bits and if the recovery time is long enough, there is no problem. As the<br />
internal operating voltage in each slave drops, the slave’s ability to drive the bus to make zero<br />
bits is reduced, and the timing of the slave changes. Eventually, when the parasitic voltage drops<br />
below a critical level, the slave enters a reset state and stops responding. Then, when the slave<br />
again receives sufficient operating voltage, it will issue a presence pulse and may corrupt other<br />
bus activity in doing so. When a network has insufficient energy to maintain operating power in<br />
the slaves, failures will be data-dependent and intermittent.<br />
2.5.5 Making Reliable 1 – Wire® Networks<br />
Of all the activity that occurs on a 1 – Wire® bus, device searches are the most complex<br />
and the most difficult to perform in the presence of bus problems. Searches are the only time<br />
(with the exception of presence pulses) when all slaves may drive the bus low at the same time.<br />
This means that bus conditions during searches are much different from normal communications<br />
39
with a single selected slave. If any of the many slaves misses an edge or fails to discriminate a<br />
pulse, then it will become unsynchronized with the search algorithm and will cause errors in<br />
subsequent bits of the search. This means that the search will fail if: a bus problem causes a<br />
glitch on the rising edge of the waveform; the waveform fails to reach a valid low level; or any<br />
device is starved for power during the search. Most search algorithms handle a search failure by<br />
terminating the search algorithm and starting over, at which point yet undiscovered slaves will<br />
seem to drop from the search.<br />
Searching algorithms typically assume that devices may be missed due to noise. In<br />
networks with touch-contact iButtons, the arrival of new iButtons to the network can<br />
introduce momentary short circuits in the form of a presence pulse from the newly arrived<br />
device. Depending on the timing of these events, those presence pulses will interfere with search<br />
activity. The search algorithms manage such problems by removing slaves from their list of<br />
discovered slaves only after the devices have been observed missing for a “debounce” period of<br />
time [4].<br />
The causes of search failures vary widely. Among the most common are starvation of<br />
parasitic power with large radius, heavyweight networks; reflections on waveform edges with<br />
small- and medium-radius, lightweight networks; and false triggering of the active pullup<br />
master-end interface due to ringing in the waveform’s falling edges. Consequently, it is critical<br />
that designers adhere to published specifications and guidelines to assure reliable networks with<br />
good safety margins and tolerance of variations in cable, distance, and connections. In summary,<br />
a network that reliably and consistently performs searches can generally perform other 1 –<br />
Wire® functions reliably.<br />
40
3.1 History of CAN<br />
CHAPTER 3<br />
CONTROLLER AREA NETWORK (CAN) PROTOCOL<br />
Robert Bosch introduced the CAN serial bus system at the Society of Automotive<br />
Engineers (SAE) congress in Detroit in 1986. It was called the “Automotive Serial Controller<br />
Area Network” because CAN systems were developed first for the automotive industry. It<br />
quickly became obvious, however, that the protocol would work extremely well in a wide variety<br />
of embedded systems applications. In 1990 CAN technology was introduced for weaving<br />
machines, and today the textile industry makes heavy use of CAN systems. CAN chips are<br />
found in elevator systems in large buildings, ships of all kinds, trains, aircraft, X-Ray machines,<br />
and other medical equipment, logging equipment, tractors and combines, coffee makers, and<br />
major appliances. Today almost every new car built in Europe has at least one CAN system,<br />
and CAN has become the industry standard for communications systems in vehicles.<br />
Intel delivered the first CAN chip in 1987, and Phillips Semiconductors responded<br />
with a CAN chip of their own shortly after that. Motorola and NEC followed; today some 15<br />
different semiconductor vendors build CAN chips. The International Standards Organization<br />
(ISO), based in Geneva, Switzerland, is a network of standards institutes from 147 countries that<br />
defines standards for international cooperation in technology. ISO published standard 11898 in<br />
November of 1993 to define CAN for general industry use. The CAN in Automation (CiA)<br />
41
user group was founded in March of 1992. Now in its 25 th year, the CAN protocol is still<br />
being enhanced. Early in 2000 an ISO task force defined a protocol for scheduled transmission<br />
of CAN messages called Time-Triggered CAN (TTCAN). The CAN user’s group<br />
estimates that the TTCAN extension will allow Controller Area Network to continue its rapid<br />
growth for another ten to fifteen years into a variety of other embedded systems applications. In<br />
years to come, CAN systems may be working in just about every type of machine or process.<br />
3.2 Overview of CAN<br />
CAN is a network protocol that allows multiple nodes in a system to communicate<br />
efficiently with each other. CAN makes it possible for all of the separate nodes in a system to<br />
send and receive messages without relying on some form of central control. This makes for<br />
much more efficient control of message traffic, and it reduces the need for internal computer<br />
wiring by as much as 90 percent in some cases. Also, CAN systems are flexible and easy to<br />
maintain.<br />
A CAN system sends messages using a serial bus network, with the individual nodes in<br />
the network linked together with a twisted pair of wires as shown in Figure 3.1. Every node in<br />
the network is equal to every other node in that any node can send a message to any other node,<br />
and if any node fails, the other nodes in the system will continue to work properly and<br />
communicate with each other uninterrupted. Any node on the network that wants to transmit a<br />
message waits until the bus is free. Every message has an identifier, and every message is<br />
available to every other node in the network. The nodes select those messages that are relevant<br />
and ignore the rest.<br />
42
The CAN protocol was designed for short messages, no more than eight bytes long.<br />
The protocol never interrupts an ongoing transmission, but it assigns priorities to messages to<br />
prevent conflicts and to make sure that urgent messages are delivered first, and includes error<br />
checking to make the communications highly reliable.<br />
Figure 3.1 Typical CAN Bus Network.<br />
Most network applications follow a layered approach to system implementation, which<br />
enables interoperability between products from different manufacturers. A standard was created<br />
by the ISO as a template to follow for this layered approach. It is called the ISO Open Systems<br />
Interconnection (OSI) Network Layering Reference Model and is shown in Figure 3.2 for<br />
reference.<br />
The CAN protocol itself implements most of the lower two layers of this reference<br />
model. The communication medium portion of the model was purposely left out of the Bosch<br />
CAN specification to enable system designers to adapt and optimize the communication<br />
43
protocol on multiple media for maximum flexibility (twisted pair, single wire, optically isolated,<br />
RF, IR, etc.). With this flexibility, however, comes the possibility of interoperability concerns.<br />
Figure 3.2 ISO/OSI Reference Model.<br />
To ease some of these concerns, the ISO and Society of Automotive Engineers (SAE)<br />
have defined some protocols based on CAN that include the Media Dependent Interface<br />
definition such that all of the lower two layers are specified. ISO11898 is a standard for high-<br />
speed applications. ISO11519 is a standard for low-speed applications, and J1939 is targeted for<br />
truck and bus applications. All three of these protocols specify a 5V differential electrical bus as<br />
the physical interface.<br />
The rest of the layers of the ISO/OSI protocol stack are left to be implemented by the<br />
system software developer. Higher Layer Protocols (HLPs) are generally used to implement the<br />
upper five layers of the OSI Reference Model. HLPs are used to: standardize startup procedures<br />
44
including bit rates used, distribute addresses among participating nodes or types of messages,<br />
determine the structure of the messages, and provide system-level error handling routines.<br />
The CAN communication protocol is a CSMA/CD protocol. The CSMA stands for<br />
Carrier Sense Multiple Access, which means that every node on the network must monitor the<br />
bus for a period of no activity before trying to send a message on the bus (Carrier Sense). Also,<br />
once this period of no activity occurs, every node on the bus has an equal opportunity to transmit<br />
a message (Multiple Access). The CD stands for Collision Detection, which means if two nodes<br />
on the network start transmitting at the same time, the nodes will detect the ‘collision’ and take<br />
the appropriate action. In CAN protocol, a non-destructive bitwise arbitration method is<br />
utilized. This means that messages remain intact after arbitration is completed even if collisions<br />
are detected. All of this arbitration takes place without corruption or delay of the higher priority<br />
messages.<br />
There are a couple of things that are required to support non-destructive bitwise<br />
arbitration. First, logic states need to be defined as dominant or recessive, and second, the<br />
transmitting node must monitor the state of the bus to see if the logic state it is trying to send<br />
actually appears on the bus. CAN defines a logic bit ‘0’ as a dominant bit and a logic bit ‘1’<br />
as a recessive bit.<br />
A dominant bit state will always win arbitration over a recessive bit state, therefore the<br />
lower the value in the Message Identifier (the field used in the message arbitration process), the<br />
higher the priority of the message. As an example, suppose two nodes are trying to transmit a<br />
message at the same time. Each node will monitor the bus to make sure the bit that it is trying to<br />
send actually appears on the bus. The lower priority message will at some point try to send a<br />
45
ecessive bit and the monitored state on the bus will be a dominant. At that point this node loses<br />
arbitration and immediately stops transmitting. The higher priority message will continue until<br />
completion and the node that lost arbitration will wait for the next period of inactivity on the bus<br />
and try to transmit its message again.<br />
3.3 CAN - Message-Based Communication<br />
CAN is a message-based protocol, not an address-based protocol, which means that<br />
messages are not transmitted from one node to another node based on addresses. Embedded in<br />
the CAN message itself are the priority (Message Identifier) and the contents of the data being<br />
transmitted. All nodes in the system receive every message transmitted on the bus and will<br />
acknowledge if the message was properly received. It is up to each node in the system to decide<br />
whether the message received should be immediately discarded or kept to be processed. A single<br />
message can be destined for one particular node or many nodes to receive based on the way the<br />
network and system are designed.<br />
Another useful feature built into the CAN protocol is the ability for a node to request<br />
information from other nodes. This is called a Remote Transmission Request (RTR), which<br />
means that instead of waiting for information to be sent by a particular node, any receiver node<br />
may request data to be sent to it from one source node. A Remote Frame is consequently<br />
followed by a Data Frame containing the requested data.<br />
One additional benefit of this message-based protocol is that additional nodes can be<br />
added to the system without the necessity to reprogram all other nodes to recognize this addition.<br />
46
This new node will start receiving messages from the network and, based on the message ID,<br />
decide whether to process or discard the received information.<br />
The CAN protocol defines five different types of messages or frames to perform<br />
communication: Data Frame, Remote Frame, Error Frame, Overload Frame, and Interframe<br />
space. Of these frames, the data and the remote frames need to be set by the user each time data<br />
is transmitted on the bus. The other frames are set by the hardware part of CAN. The data<br />
and the remote frames come in two frame formats: standard and extended. The standard format<br />
has an 11-bit Message ID (Identifier), and the extended format has a 29-bit Message ID. The<br />
roles of each frame type are summarized and listed in Table 3.1.<br />
Table 3.1 Frame Types and Roles of Each Frame.<br />
Frame Roles of Frame<br />
Data Frame<br />
Remote Frame<br />
Error Frame<br />
Overload Frame<br />
Interframe<br />
Space<br />
3.3.1 Data Frames<br />
This frame is used by the transmit unit to send a<br />
message to the receive unit.<br />
This frame is used by the receive unit to request<br />
transmission of a message that has the same ID from the<br />
transmit unit.<br />
When an error is detected, this frame is used to notify<br />
other units of the detected error.<br />
This frame is used by the receive unit to notify that it<br />
has not been prepared to receive frames yet.<br />
This frame is used to separate a data or remote frame<br />
from a preceding frame.<br />
47<br />
User<br />
Settings<br />
Necessary<br />
Necessary<br />
Unnecessary<br />
Unnecessary<br />
Unnecessary<br />
The Data Frame is the most common type of frame and is used when a node transmits<br />
information to any or all other nodes in the system. Data Frames consist of seven different bit<br />
fields that provide additional information about the message as defined by the CAN
specification: Start-Of-Frame, Arbitration Field, Control Field, Data Field, CRC Field, ACK<br />
Field, and End-Of-Frame. Figure 3.3 shows the format for a Standard CAN Data Frame. The<br />
bit fields are defined as follows:<br />
1 bit<br />
Start-Of-Frame<br />
Start-Of-FrameA single dominant bit marks the beginning of the Data Frame. The<br />
CAN bus is in an idle (recessive) state prior to the transmission of this bit.<br />
11 bits<br />
Message Identifier<br />
Arbitration<br />
Field<br />
1 bit<br />
Remote Transmission Request<br />
1 bit<br />
1 bit<br />
Identifier Extension<br />
r0<br />
Control<br />
Field<br />
4 bits<br />
Data Length Code<br />
0 – 8 bytes<br />
Data Field<br />
48<br />
15 bits<br />
CRC Sequence<br />
CRC Field<br />
1 bit<br />
1 bit<br />
Delimiter<br />
Acknowledgement Slot<br />
Figure 3.3 Standard CAN Data Frame Format [18].<br />
1 bit<br />
Delimiter<br />
Ack<br />
Field<br />
Arbitration FieldThe Arbitration Field contains the Message Identifier Field and the<br />
RTR bit. The Arbitration Field serves a dual purpose. It is used to determine which node<br />
has access to the bus and to identify the type of data the message contains. The Message<br />
Identifier is 11 bits long (for standard format) meaning that 2048 (2 11 ) unique messages<br />
are possible. The lower the value of this field, the higher the priority of the message.<br />
7 bits<br />
End-Of-Frame<br />
3 bits<br />
Interframe Space
The RTR bit indicates whether the frame is a Data Frame or a Remote Frame and must be<br />
dominant for a Data Frame.<br />
Control FieldThe Control Field contains the Identifier Extension (IDE) bit (in an<br />
Extended Data Frame the IDE bit resides in the Arbitration Field), a reserved bit (r0), and<br />
the Data Length Code (DLC) bits. If the IDE bit is dominant, then the frame is a<br />
Standard Format Data Frame, otherwise it is an Extended Format Data Frame. The<br />
reserved bit, r0, is not used and should always be dominant. The number of bytes is<br />
stored in the Data Length Code Field. This field typically holds values from zero to<br />
eight. Since the field is four bits long, values greater than eight can be indicated. If the<br />
value of the Data Length Code is greater than eight then it is assumed that the frame<br />
contains eight bytes. Table 3.2 shows the Data Length Code and the number of data<br />
bytes.<br />
Table 3.2 Data Length Code Field<br />
Number<br />
Data Length Code (D=Dominant level, R=Recessive level)<br />
of data bytes DLC3 DLC2 DLC1 DLC0<br />
0 D D D D<br />
1 D D D R<br />
2 D D R D<br />
3 D D R R<br />
4 D R D D<br />
5 D R D R<br />
6 D R R D<br />
7 D R R R<br />
8 R D or R D or R D or R<br />
Data FieldThe Data Field is the payload of the Data Frame. It contains from 0 to 8<br />
bytes and is transmitted most significant bit first. It is the only field in the Data Frame<br />
that does not have a fixed length.<br />
49
Cyclic Redundancy Check (CRC) FieldThe CRC Field is 16 bits long. It consists of a<br />
CRC Sequence (15 bits) followed by a CRC delimiter (1 bit). The receiver uses the value<br />
in the CRC Sequence field to check if the data bit sequence in the frame was corrupted<br />
during delivery. The CRC delimiter is always a recessive bit.<br />
Acknowledgement FieldThe Acknowledgement Field is two bits long. It contains the<br />
Acknowledgement Slot bit and the Acknowledgement Delimiter Bit. The node that<br />
transmits the Data Frame sends these two bits recessively. The transmitter expects at<br />
least one receiver to acknowledge receipt of the transmitted message. Any node that<br />
receives the message without error will overwrite the Acknowledgement Slot bit with a<br />
dominant bit. The Acknowledge Delimiter bit always remains recessive to distinguish a<br />
positive acknowledgement from the start of an Error Frame. If no receiver acknowledges<br />
a message, the transmitter will continue to try to send the message until the sending node<br />
turns itself off.<br />
End-Of-Frame and Interframe SpaceEvery Data Frame ends with a seven-bit End-Of-<br />
Frame Field and a three-bit Interframe Space. The End-Of-Frame Field must be<br />
transmitted recessively to mark a completely error-free transmitted frame. If the<br />
Acknowledgement Delimiter bit or any of the End-Of-Frame bits are transmitted<br />
dominantly then this marks the beginning of an Error or Overload Frame. The Interframe<br />
Space represents the minimum amount of spacing between adjacent Data or Remote<br />
Frames. All three bits must be transmitted recessively. The bus may continue to remain<br />
idle after this, or a new frame will be indicated with the dominant Start-Of-Frame bit. If<br />
50
one of the first two bits of this field is dominant then it is assumed an Overload Frame<br />
has begun.<br />
The Extended Format Data Frame is nearly identical to the Standard Format Data Frame<br />
(Figure 3.3). The only differences between these two formats are found in the IDE bit in the<br />
Arbitration Field for an Extended Data Frame (in a Standard Data Frame the IDE bit resides in<br />
the Control Field), and the size and arrangement of the Arbitration Field. Both the Standard Data<br />
Frame Format and the Extended Data Frame Format can coexist in the same CAN system.<br />
The rule is that Standard Data Frames always have priority over the Extended Data Frames.<br />
Figure 3.4 shows the format for an Extended CAN Data Frame. The following is a description<br />
of the Arbitration and Control Fields:<br />
1 bit<br />
Start-Of-Frame<br />
11 bits<br />
Standard Message Identifier<br />
1 bit<br />
Substitute Remote Request<br />
Arbitration Field<br />
1 bit<br />
Identifier Extension<br />
18 bits<br />
Extended Message Identifier<br />
1 bit<br />
Remote Transmission Request<br />
1 bit<br />
r1<br />
1 bit<br />
r0<br />
Control<br />
Field<br />
4 bits<br />
Data Length Code<br />
51<br />
0 – 8 bytes<br />
Data Field<br />
15 bits<br />
CRC Sequence<br />
CRC Field<br />
1 bit<br />
Delimiter<br />
Acknowledgement Slot<br />
Figure 3.4 Extended CAN Data Frame Format [18].<br />
1 bit<br />
1 bit<br />
Delimiter<br />
ACK<br />
Field<br />
7 bits<br />
End-Of-Frame<br />
3 bits<br />
Interframe Space
Arbitration FieldThe Arbitration Field in the Extended Format Data Frame is longer to<br />
accommodate the 29-bit Message Identifier. Over 536 million (2 29 ) unique messages are<br />
possible using the Extended Format. The Standard Message Identifier is identical to the<br />
Message Identifier Field in the Standard Data Frame Format. It is 11 bits long and<br />
contains the most significant bits of the 29-bit identifier. The Substitute Remote Request<br />
Field (SRR) bit replaces the RTR bit in the Standard Data Frame. Its sole purpose is to<br />
be a placeholder so that the Identifier Extension bit remains in the same location as it is in<br />
the Standard Data Frame Format. This bit is always transmitted recessively. The RTR<br />
bit for the Extended Data Frame Format has been moved to the end of the Arbitration<br />
Field. If the IDE bit is recessive, then the frame is an Extended Data Frame Format<br />
otherwise the frame is a Standard Data Frame Format. The Extended Message Identifier<br />
Field adds another 18 bits on to the Standard Message Identifier. This brings the total<br />
number of identifier bits to 29. The RTR bit in an Extended Data Frame Format is<br />
identical to the RTR bit in the Standard Data Frame Format. It indicates whether the<br />
frame is a Data Frame or a Remote Frame. This bit value will be a dominant (‘0’) bit for<br />
a Data Frame and a recessive (‘1’) bit for a Remote Frame.<br />
Control FieldThe Control Field in the Extended Data Frame Format contains two<br />
reserved bits and the DLC bits. The reserved bits, r1 and r0, are unused and must be<br />
transmitted dominantly. The DLC bits in an Extended Data Frame are identical to those<br />
used in a Standard Data Frame.<br />
52
3.3.2 Remote Frames<br />
Remote Frames are used for receivers to request information from another node. Remote<br />
Frames are often sent out on a regular schedule to request updates from sensors. The Remote<br />
Frame is the same as a Data Frame with two exceptions: in a Remote Frame there is no Data<br />
Field, and contrary to a Data Frame where the RTR bit is always transmitted dominantly (RTR =<br />
‘0’), the RTR bit of a Remote Frame is recessive (RTR = ‘1’). The RTR bit is considered part of<br />
the bitwise arbitration, so a Data Frame will always win arbitration in the unlikely event that<br />
both a Data Frame and a Remote Frame with the same Message Identifier are being transmitted<br />
at the same time. This is due to the dominant RTR bit following the Message Identifier. This is<br />
reasonable since a request for data should not take precedence over the data being requested.<br />
Figure 3.5 shows the structure of the Remote Frame for both Standard Data Frames and<br />
Extended Data Frames.<br />
53
S<strong>OF</strong><br />
S<strong>OF</strong><br />
Bit 28<br />
Bit 27<br />
Arbitration field Control field CRC field<br />
(Standard) ID<br />
DLC Sequence<br />
…<br />
Bit 19<br />
Bit 18<br />
RTR<br />
IDE<br />
r0<br />
Bit 3<br />
MSB (first bit transmitted) LSB<br />
(Standard) ID<br />
Bit 28<br />
Bit 27<br />
…<br />
Bit 19<br />
Bit 18<br />
SRR<br />
54<br />
Bit 2<br />
Bit 1<br />
Arbitration field Control field CRC field<br />
IDE<br />
(Extended) ID<br />
Bit 17<br />
Bit 16<br />
…<br />
Bit 1<br />
Bit 0<br />
RTR<br />
r1<br />
r0<br />
Bit 0<br />
Bit 14<br />
Bit 13<br />
…<br />
DLC Sequence<br />
Bit 3<br />
Bit 2<br />
Bit 1<br />
Bit 0<br />
Bit 14<br />
Bit 13<br />
MSB (first bit transmitted)<br />
Figure 3.5 Standard and Extended Remote Frame Structures.<br />
3.3.3 Error Frames<br />
…<br />
Bit 1<br />
Bit 0<br />
Bit 1<br />
Bit 0<br />
Delimiter<br />
Receivers send out Error Frames whenever they detect that a frame contains an error.<br />
The Error Frame (transmitted by the hardware part of CAN) can be sent during any point of a<br />
transmission and is always sent before a Data Frame or Remote Frame has completed<br />
successfully. The transmitter constantly monitors the bus while it is transmitting. When the<br />
transmitter detects the Error Frame, it aborts the current frame and prepares to resend once the<br />
bus becomes idle again. Figure 3.6 shows the structure of the Error Frame.<br />
Delimiter<br />
LSB
Figure 3.6 Structure of the Error Frame [19].<br />
From Figure 3.6, the Error Frame contains the following fields: Error Flag and Error<br />
Delimiter Field. The Error Frame deliberately violates the bit stuffing rule (See Section 3.4<br />
Error Detection and Handling – Stuff Error) by sending either six recessive bits or six dominant<br />
bits in the Error Flag Field. The determination of whether the Error Flag is recessive or<br />
dominant depends on the Error State of the node. There are two types of error flags: Active-error<br />
and Passive-error flags. The Active-error flag consists of six consecutive ‘dominant’ bits and is<br />
output by a node in an error-active state that detected an error. The Passive-error flag consists of<br />
six consecutive ‘recessive’ bits unless it is overwritten by ‘dominant’ bits from other nodes. This<br />
error flag is output by a node in an error-passive state when it detects an error. Depending on the<br />
timing at which an error is detected by each node connected to the bus, error flags may overlap<br />
one on top of another, up to 12 bits in total length. The Error Delimiter field is a sequence of<br />
eight ‘recessive’ bits and indicates the end of the frame. After transmission of an Error Flag,<br />
each node sends ‘recessive’ bits and monitors the bus until it detects a ‘recessive’ bit.<br />
55
Afterwards it starts transmitting seven more ‘recessive’ bits. The bus will then enter an idle state<br />
or a new Data Frame or Remote Frame will start.<br />
3.3.4 Overload Frame<br />
The Overload Frame can be considered a special form of the Error Frame. It is used to<br />
ask a transmitter to delay further frames or to signal problems with the Interframe Space. The<br />
Overload Frame has the same format as the Error Frame, but unlike the Error Frame it does not<br />
cause the retransmission of the previous frame. If the Overload Frame is being used to delay<br />
further transmissions on the bus, then no more than two Overload Frames can be generated<br />
successively. Figure 3.7 shows the structure of the Overload Frame.<br />
An Overload Frame includes a Flag Field that contains a sequence of six ‘dominant’ bits<br />
followed by a Delimiter Field, a series of eight ‘recessive’ bits. Depending on timing of the<br />
Error Flag, Overload Flags may overlap one on top of another up to 12 bits in total length. When<br />
one node sends out an Overload Flag, all of the nodes on the network detect it and send out their<br />
own Overload Flags, effectively stopping all message traffic on the CAN bus. Then, all of the<br />
nodes listen for the sequence of eight ‘recessive’ bits. The maximum amount of time needed to<br />
recover in a CAN network after an Overload Frame is 31 bit times (Overload Flag (6 bit times)<br />
+ Overlapping of Overload Flag (6 bit times) + Overload Delimiter (8 bit times) + Intermission<br />
(3 bit times) + Suspend Transmission (8 bit times) = 31 bit times max).<br />
56
3.3.5 Interframe Space<br />
Figure 3.7 Structure of the Overload Frame [19].<br />
This frame is used to separate the Data and Remote Frames. The Data and the Remote<br />
Frames, whichever frame (Data, Remote, Error, or Overload Frame) may have been transmitted<br />
prior to them, are separated from the preceding frame by an inserted Interframe Space.<br />
However, no Interframe Spaces are inserted preceding Overload and Error Frames. Figure 3.8<br />
shows the structure of the Interframe Space for nodes that are not ‘error-passive’ or have been<br />
the receiver of the previous message. For ‘error-passive’ nodes which have been the transmitter<br />
of the previous message, there is an extra bit field called Suspend Transmission. This structure is<br />
shown in Figure 3.9.<br />
Figure 3.8 Structure of the Interframe Space (non error-passive nodes) [19].<br />
57
Figure 3.9 Structure of the Interframe Space (error-passive nodes) [19].<br />
The Intermission bit field consists of 3 ‘recessive’ bits. If a dominant level is detected<br />
during an Intermission, an Overload Frame must be transmitted. However, if the third bit of an<br />
Intermission is of a ‘dominant’ level, the Intermission is recognized as the Start-Of-Frame. The<br />
Bus Idle bit field may be of arbitrary length. The bus is recognized to be free and any node<br />
having something to transmit can access the bus and start sending a message. Similar to the<br />
Intermission bit field, the detection of a ‘dominant’ bit on the bus is interpreted as a Start-Of-<br />
Frame. For error-passive nodes which have been the transmitter of the previous message, there<br />
is an extra bit field called Suspend Transmission. This field consists of eight ‘recessive’ bits<br />
following the Intermission bit field [20]. This bit field is included in only an Interframe Space if<br />
the immediately preceding message transmitting node was in an error-passive state.<br />
3.4 Error Detection and Handling<br />
Error detection and error handling are important for the performance of CAN. Because<br />
of complementary error detection mechanisms, the probability of having an undetected error is<br />
small. The Data Link Layer in CAN systems is very efficient in detecting errors. Every frame<br />
is simultaneously accepted by every node in the network or rejected by every node. If a node<br />
detects an error it transmits an error flag to every other node in the network and destroys the<br />
transmitted frame. The CAN protocol supports five defined error conditions: Bit Error, Form<br />
58
Error, CRC Error, Acknowledge Error, and Stuff Error. A summary of these error checking<br />
methods is provided in Table 3.3.<br />
Bit ErrorEvery transmitting node monitors its own messages as it transmits them<br />
across the bus, checking the bits in each frame for errors. A transmitting node always<br />
reads back the message as it is sending [21 – 22]. The node will detect a Bit Error if it<br />
sends out a dominant bit when it was supposed to transmit a recessive bit, or a recessive<br />
bit when the message called for a dominant bit. Also, if the bit is not part of the<br />
Arbitration Field or Acknowledge Slot, a Bit Error has been detected. At this point, an<br />
Error Frame is generated and the original message is then resent after a proper<br />
intermission time.<br />
Form ErrorThe first bit in every frame must always be a dominant bit. If any node in<br />
the network detects a dominant bit in one of the following four segments of the message:<br />
End-Of-Frame, Interframe Space, Acknowledge Delimiter, or CRC Delimiter, a Form<br />
Error has occurred. An Error Frame is then generated and the original message is then<br />
resent later after a proper intermission time.<br />
CRC ErrorCyclic redundancy checking is a very effective method of looking for errors<br />
in a network by applying a polynomial equation to a block of transmitted data. The<br />
transmitting node calculates a 15-bit CRC value according to the polynomial Gxin Equation 3.1. The CAN bus applies a CRC-15 with a hamming distance of D 6 for<br />
8 byte information data packets. All nodes on the network receive this message, calculate<br />
their own CRC and verify that the CRC values match. If the values do not match, a CRC<br />
59
error occurs, an Error Frame is generated by the receiving node, and the message is then<br />
resent later after a proper intermission time.<br />
15 14 10 8 7 4 3<br />
G x x x x x x x x 1<br />
(3.1)<br />
Acknowledge ErrorIn the ACK bit field of a message, the transmitting node checks if<br />
the ACK bit slot, which is sent as a ‘recessive’ bit, contains a ‘dominant’ bit. A<br />
‘dominant’ bit implies at least one node correctly received the message. A ‘recessive’ bit<br />
means no node received the message and an ACK Error occurs. An Error Frame is<br />
generated by the original transmitting node, and the original message is then resent later<br />
after a proper intermission time.<br />
Stuff ErrorReceiving nodes check for a violation of the bit stuffing rule. The final<br />
method of error detection uses the bit stuffing rule where after five consecutive bits of the<br />
same logic level, if the next bit is not a complement, an error is generated. Bit stuffing by<br />
the transmitter ensures that rising edges are available for on-going synchronization of the<br />
network. Bit stuffing also ensures that a stream of bits is not mistaken for an error frame<br />
or the seven-bit interframe space that signifies the end of a message. Stuffed bits are<br />
removed by a receiving node’s controller before the data is forwarded to the application.<br />
If there are more than five bits of the same polarity in a row, a bit of the opposite polarity<br />
is automatically stuffed into the data stream. This will be used by the receiving nodes for<br />
synchronization, but ignored for data purposes. If between the Start-Of-Frame and the<br />
CRC Delimiter, six consecutive bits with the same polarity are detected, a Stuff Error has<br />
occurred. An Error Frame is then generated by the receiving node, and the original<br />
message is then resent later after a proper intermission time.<br />
60
Table 3.3 Types of Errors [19].<br />
Type of Error Content of Error Target Frame (field) in which errors detected Unit by which<br />
errors<br />
Bit Error This error is detected when<br />
the output level and the data<br />
level on the bus do not match<br />
when they are compared.<br />
Form Error This error is detected when an<br />
illegal format is found in any<br />
fixed-format bit field.<br />
CRC Error This error is detected if the<br />
CRC calculated from the<br />
received message and the<br />
value of the received CRC<br />
sequence do not match.<br />
ACK Error This error is detected if the<br />
ACK slot of the transmit unit<br />
is found recessive (i.e., the<br />
error that is detected when<br />
ACK is not returned from the<br />
Stuffing<br />
Error<br />
receive unit).<br />
This error is detected when<br />
the same level of data is<br />
detected for 6 consecutive<br />
bits in any field that should<br />
have been bit-stuffed.<br />
3.4.1 Output Timing of an Error Frame<br />
Data Frame (S<strong>OF</strong> to E<strong>OF</strong>)<br />
Remote Frame (S<strong>OF</strong> to E<strong>OF</strong>)<br />
Error Frame<br />
Overload Frame<br />
Data Frame (CRC Delimiter, ACK Delimiter,<br />
E<strong>OF</strong>)<br />
Remote Frame (CRC Delimiter, ACK<br />
Delimiter, E<strong>OF</strong>)<br />
Error Delimiter<br />
Overload Delimiter<br />
Data Frame (CRC sequence)<br />
Remote Frame (CRC sequence)<br />
Data Frame (ACK slot)<br />
Remote Frame (ACK slot)<br />
Data Frame (S<strong>OF</strong> to CRC sequence)<br />
Remote Frame (S<strong>OF</strong> to CRC Sequence)<br />
61<br />
detected<br />
Transmit unit<br />
Transmit unit<br />
Receive unit<br />
Receive unit<br />
Transmit unit<br />
Receive unit<br />
The node that detected an error condition outputs an Error Flag to notify other nodes of<br />
the error. The Error Flag output at this time is either an Active-Error Flag or a Passive-Error<br />
Flag depending on the node’s error status. The transmitting node resends the Data or Remote<br />
Frame after it outputs an Error Frame. Table 3.4 shows the timing with which an Error Flag is<br />
output.
Table 3.4 Error Flag Output Timing [19].<br />
Type of Error Output Timing<br />
Bit Error The Error Flag is output beginning with the bit that immediately follows the<br />
Stuffing Error one in which an error was detected<br />
Form Error<br />
ACK Error<br />
CRC Error The Error Flag is output beginning with the bit immediately following the<br />
CRC field (ACK slot bit).<br />
3.5 Fault Confinement and Error States<br />
A major risk with any serial bus system is that a single defective node can shut down the<br />
entire network. To deal with this, the CAN protocol is designed to automatically detect a<br />
faulty node and disconnect it from the network. CAN requires two error counters for every<br />
node, one to keep track of transmit errors and the other to keep track of receive errors. When a<br />
transmission or reception error occurs, the respective counter is increased by a weighted value<br />
depending upon the type of error and which node caused the error. For every successful<br />
transmission or reception, the respective counter is decremented by one. Generally, if a node<br />
recognizes that it is the source of the error then the counter is incremented by nine for receive<br />
errors and eight for transmission errors. Otherwise, each counter is increased by one [18].<br />
Detected errors are made public to all other nodes via Error Frames or Error Flags. The<br />
transmission of an erroneous message is aborted and the frame is repeated as soon as the<br />
message can again win arbitration on the network. Also, each node is in one of three error states,<br />
Error-Active, Error-Passive or Bus-Off. Figure 3.10 shows a graphical representation of these<br />
three error states.<br />
62
3.5.1 Error-Active<br />
Figure 3.10 CAN Bus Error States<br />
An Error-Active node can actively take part in bus communication, including sending an<br />
active-error flag, which consists of six consecutive dominant bits. The Error Flag actively<br />
violates the bit stuffing rule and causes all other nodes to send an Error Flag, called the Error<br />
Echo Flag, in response. An Active-Error Flag, and the subsequent Error Echo Flag may cause as<br />
many as twelve consecutive dominant bits on the bus; six from the Active Error Flag, and zero<br />
up to six more from the Error Echo Flag depending upon when each node detects an error on the<br />
bus. A node is Error-Active when both the TEC and the REC are below 127. Error-Active is the<br />
normal operational mode, allowing the node to transmit and receive without restrictions.<br />
63
3.5.2 Error-Passive<br />
A node becomes Error-Passive when either the TEC or REC is equal to or greater than<br />
127. Error-Passive nodes are not permitted to transmit Active-Error Flags on the bus, but<br />
instead, transmit Passive-Error Flags which consist of six recessive bits. If the Error-Passive<br />
node is currently the only transmitter on the bus, then the passive error flag will violate the bit<br />
stuffing rule and the receiving node(s) will respond with Error Flags of their own (either active<br />
or passive depending upon their own error state). If the Error-Passive node in question is not the<br />
only transmitter (i.e. during arbitration) or is a receiver, then the Passive-Error Flag will have no<br />
effect on the bus due to the recessive nature of the error flag. When an Error-Passive node<br />
transmits a Passive-Error Flag and detects a dominant bit, it must see the bus as being idle for<br />
eight additional bit times after an intermission before recognizing the bus as available. After this<br />
time, it will attempt to retransmit. These measures restrict nodes that have a higher than average<br />
error rate so that they can’t interfere with communication across the bus.<br />
3.5.3 Bus-Off<br />
A node goes into the Bus-Off state when the TEC is greater than 255 (receive errors<br />
cannot cause a node to go Bus-Off). This means that a faulty node will be turned off if it<br />
transmits 32 consecutive messages with errors. In this mode, the node cannot send or receive<br />
messages, acknowledge messages, or transmit Error Frames of any kind. This is how Fault<br />
Confinement is achieved. There is a bus recovery sequence that is defined by the CAN<br />
protocol that allows a node in a Bus-Off state to recover, return to Error-Active, and begin<br />
64
transmitting again if the fault condition is removed [21]. The rest of the network will continue to<br />
work even if a node is set to Bus-Off.<br />
3.6 CAN Bit Timing Requirements<br />
One beneficial feature of the CAN protocol is that the bit rate, bit sample point and<br />
number of samples per bit are completely programmable by the system designer. This provides<br />
the opportunity to optimize the performance of the network for a given application. Even if<br />
minor errors in the configuration of the CAN bit timing do not result in immediate failure, the<br />
performance of a CAN network can be reduced significantly if not properly tuned.<br />
In many cases, the CAN bit synchronization will amend a faulty configuration of the<br />
CAN bit timing to such a degree that only occasionally an Error Frame is generated. In the<br />
case of arbitration however, when two or more CAN nodes simultaneously try to transmit a<br />
frame, a misplaced sample point may cause one of the transmitters to become Error-Passive.<br />
The analysis of such sporadic errors requires a detailed knowledge of the CAN bit<br />
synchronization inside a CAN node and of the CAN nodes’ interaction on the CAN bus<br />
[19].<br />
3.6.1 CAN Bit Structure<br />
The Nominal Bit Rate of any CAN network is uniform throughout and is given by:<br />
f<br />
NBT<br />
65<br />
1<br />
(3.2)<br />
t<br />
NBT
where tNBT is the Nominal Bit Time (NBT). A bit is divided into four separate non-overlapping<br />
time segments called SYNC_SEG, PROP_SEG, PHASE_SEG1, and PHASE_SEG2. These are<br />
illustrated in Figure 3.11.<br />
Figure 3.11 CAN Bit Segments [20] [23].<br />
The sample point indicated in Figure 3.11 is the position of the actual sample point if a<br />
single point per bit is selected. However, some CAN Controllers can also sample each bit<br />
three times. In this case, the bit will be sampled three quanta in a row, with the last sample being<br />
taken at the sample point indicated in Figure 3.11. The period of the NBT is the sum of the<br />
segment durations:<br />
t t t t t<br />
(3.3)<br />
NBT SYNC _ SEG PROP _ SEG PHASE _ SEG1 PHASE _ SEG2<br />
Each of these segments is an integer multiple of a unit of time called a time quantum, t Q . The<br />
duration of a time quantum is equal to the period of the CAN system clock, which is derived<br />
from the microcontroller (MCU) system clock or oscillator by way of a programmable prescaler,<br />
called the Baud Rate Prescaler (BRP).<br />
The duration of the synchronization segment, SYNC_SEG, is not programmable and is<br />
fixed at one time quantum. The duration of the other segments are programmable, either<br />
individually or with two values, tSEG1 and SEG2<br />
t where:<br />
66
t t t<br />
(3.4)<br />
SEG1 PROP _ SEG PHASE _ SEG1<br />
t t<br />
(3.5)<br />
SEG2 PHASE _ SEG2<br />
The duration of the propagation time segment PROP_SEG may be between 1 and 8 time<br />
quanta. The duration of the segment PHASE_SEG1 may be between 1 and 8 time quanta if one<br />
sample per bit is selected and may be between 2 and 8 time quanta if three samples per bit are<br />
selected. If three samples per bit are chosen, the most frequently sampled value is taken as the<br />
bit value. The duration of segment PHASE_SEG2 must be equal to PHASE_SEG1, unless<br />
PHASE_SEG1 is less than the Information Processing Time (IPT), in which case PHASE_SEG2<br />
must be equal to the IPT. Table 3.5 summarizes the roles of each segment and the number of tQ<br />
’s.<br />
3.6.2 Synchronization Segment<br />
For each CAN node, the nominal start of each bit is the beginning of the SYNC_SEG<br />
segment. For nodes that are transmitting, the new bit value is transmitted from the beginning of<br />
the SYNC_SEG segment. For receiving nodes, the start of the received bit is expected to occur<br />
during the SYNC_SEG segment. Due to the propagation delay of the transmitted signal through<br />
the physical interface to the bus and along the bus itself, the SYNC_SEG segment of receiving<br />
nodes will be delayed with respect to the SYNC_SEG segment of the transmitting node(s). This<br />
is illustrated in Figure 3.12. The actual delay will vary depending on the distance between the<br />
transmitting and receiving nodes being considered.<br />
67
Figure 3.12 Propagation Delay Between Nodes [23].<br />
Segment Name<br />
Table 3.5 Types of Segments and Their Roles [19].<br />
Roles of Segment Number of t Q ’s<br />
Synchronization Segment<br />
(SYNC_SEG)<br />
Propagation Time Segment<br />
(PROP_SEG)<br />
Phase Buffer Segment1<br />
(PHASE_SEG1)<br />
Phase Buffer Segment2<br />
(PHASE_SEG2)<br />
Resynchronization Jump<br />
Width (RJW) (See Section<br />
3.6.5)<br />
Multiple units connected to the bus are timed<br />
to be coincident during the interval of this<br />
segment as they send or receive a frame. A<br />
recessive to dominant or a dominant to<br />
recessive transition edge is expected to exist in<br />
this segment.<br />
This segment absorbs physical delays on the<br />
network, which include an output delay of the<br />
transmit unit, a propagation delay of signal on<br />
the bus, and an input delay of the receive unit.<br />
The duration of this segment is twice the sum<br />
of each delay time.<br />
This segment is used to correct for errors when<br />
signal edges do occur within SYNC_SEG.<br />
This segment is used to correct for errors when<br />
signal edges do occur within SYNC_SEG.<br />
Since each unit is operating with their own<br />
clock, even a minute clock error in each node<br />
will accumulate. This segment absorbs such<br />
an error. To absorb a clock error, add or<br />
subtract within the Resynchronization Jump<br />
Width (RJW) setup range for PHASE_SEG1<br />
and PHASE_SEG2. The larger the values of<br />
PHASE_SEG1 and PHASE_SEG2, the greater<br />
the tolerance, but the communication speed<br />
slows down.<br />
Some units may get out of sync for reasons of<br />
a drift in clock frequency or a delay in<br />
transmission path. RJW is the maximum<br />
width for which this out-of-sync is corrected.<br />
68<br />
1<br />
1 – 8<br />
1 – 8<br />
PHASE_SEG1 or<br />
IPT, whichever is<br />
larger.<br />
1 – 4 and<br />
≤PHASE_SEG1<br />
8-25 t Q ’s
3.6.3 Propagation Segment<br />
The existence of the propagation delay segment, PROP_SEG, is due to the fact that the<br />
CAN protocol allows for non-destructive arbitration between nodes contending for access to<br />
the bus, and the requirement for in-frame acknowledgement. In the case of non-destructive<br />
arbitration, more than one node may be transmitting during the arbitration field. Each<br />
transmitting node samples data from the bus in order to determine whether it has won the<br />
arbitration, and also to receive the arbitration field in case it loses arbitration. When each node<br />
samples each bit, the value sampled must be the logical superposition of the bit values<br />
transmitted by each of the nodes arbitrating for bus access. In the case of the Acknowledge<br />
Field, the transmitting node transmits a recessive bit but expects to receive a dominant bit (i.e., a<br />
dominant value must be sampled at the sample point(s)). The propagation delay segment,<br />
PROP_SEG, exists to delay the earliest possible sample of the bit by a node until the transmitted<br />
bit values from all the transmitting nodes have reached all of the nodes.<br />
Figure 3.10 shows the propagation delay between two nodes, and shows that the bit value<br />
transmitted by Node A is received by Node B after a time t Prop(A,B) , and the bit value transmitted<br />
by Node B is received by Node A after a time t Prop(B,A) , before the end of Node A’s propagation<br />
segment. This ensures that Node A will correctly sample the bit value. Node B will also<br />
correctly sample the bit value, even although Node B’s sample point lies beyond the end of Node<br />
A’s bit time, because of the propagation delay between Node A and Node B. Time t Prop(A,B)<br />
consists of the sum of the propagation delay through Node A’s bus driver plus the propagation<br />
delay along the bus from Node A to Node B plus the propagation delay through Node B’s bus<br />
receiver:<br />
69
3.6.4 Synchronization<br />
t t t t<br />
(3.6)<br />
<br />
Prop A,B Tx A Bus A,B Rx B<br />
All CAN nodes on a network must be synchronized while receiving a transmission<br />
(i.e., the beginning of each received bit must occur during each nodes SYNC_SEG segment).<br />
This is achieved by means of synchronization. Synchronization is required due to phase errors<br />
between nodes which may arise due to nodes having slightly different oscillator frequencies or<br />
due to changes in propagation delay when a different node starts transmitting. Two types of<br />
synchronization are defined, hard synchronization and re-synchronization. Hard synchronization<br />
is performed only at the beginning of a message frame, when every CAN node aligns the<br />
SYNC_SEG of its current bit time to the recessive to dominant edge of the transmitted Start-Of-<br />
Frame bit. Re-synchronization is subsequently performed during the remainder of the message<br />
frame, whenever a change of bit value from recessive to dominant occurs outside of the expected<br />
SYNC_SEG segment.<br />
For CAN nodes which are transmitting, the value of a bit is transmitted on the CAN<br />
bus at the start of the transmitting nodes SYNC_SEG segment, and the bit value is transmitted<br />
until the end of the PHASE_SEG2 segment. All nodes which are active receive the data on the<br />
bus (including transmitting nodes) and any changes in bit value are expected to occur during the<br />
SYNC_SEG segment. If a recessive to dominant bit value transition is detected outside of a<br />
receiving nodes SYNC_SEG segment, then that node will re-synchronize to the edge. If a<br />
recessive to dominant bit value transition is detected after the SYNC_SEG segment, but before<br />
the sample point, then this is interpreted as a late edge. The node will attempt to re-synchronize<br />
70
to the bit stream by increasing the duration of its PHASE_SEG1 segment of the current bit by the<br />
number of time quanta by which the edge was late, up to the re-synchronization jump width<br />
limit. The effect of this is that the next sample point is delayed until it is the programmed<br />
number of time quanta after the actual edge (if the required delay does not exceed the re-<br />
synchronization jump width limit). Conversely, if a recessive to dominant bit value transition is<br />
detected after the sample point but before the SYNC_SEG segment of the next bit, then this is<br />
interpreted as an early bit. The node will now attempt to re-synchronize to the bit stream by<br />
decreasing the duration of its PHASE_SEG2 segment of the current bit by the number of time<br />
quanta by which the edge was early, by up to the re-synchronization jump width limit.<br />
Effectively, the SYNC_SEG segment of the next bit begins immediately (if the edge is early by<br />
no more than the re-synchronization jump width limit).<br />
3.6.5 Re-Synchronization<br />
The number of time quanta by which a bit period may be extended or shortened due to re-<br />
synchronization is limited by a programmable value called the re-synchronization jump width<br />
(RJW). The RJW must be programmed to a valid value. The RJW cannot exceed four time<br />
quanta and it also must not exceed the number of time quanta in the PHASE_SEG1 segment.<br />
The minimum value for the RJW is one time quantum.<br />
In order to minimize the maximum time between recessive to dominant edges, and<br />
maximize the number of opportunities for re-synchronization, the CAN protocol uses bit<br />
stuffing. After every occurrence of five consecutive bits of equal value, an extra stuff bit of<br />
71
opposite value is inserted into the bit stream. Bit stuffing is implemented in Data Frames and<br />
Remote Frames, from the Start-Of-Frame bit to the end of the CRC field.<br />
3.7 Oscillator Tolerance<br />
Typically, the CAN system clock for each CAN node will be derived from a<br />
different oscillator. The actual CAN system clock frequency for each node, and hence the<br />
actual bit time, will be subject to a tolerance. Ageing and variations in ambient temperature will<br />
also affect the initial tolerance. The CAN system clock tolerance is defined as a relative<br />
tolerance:<br />
f f<br />
where f is the actual frequency and f N is the nominal frequency.<br />
N<br />
f (3.7)<br />
f<br />
N<br />
To ensure effective communication, the minimum requirement for a CAN network is<br />
that two nodes, each at opposite ends of the network with the largest propagation delay between<br />
them, and each having a CAN system clock frequency at the opposite limits of the specified<br />
frequency tolerance, must be able to correctly receive and decode every message transmitted on<br />
the network. This requires that all nodes sample the correct value for each bit.<br />
3.8 Propagation Delay<br />
The minimum time for the propagation delay segment to ensure correct sampling of bit<br />
values is given by:<br />
tPROP_SEG tProp(A,B) tProp(B,A)<br />
(3.8)<br />
72
where nodes A and B are at opposite ends of the network (i.e. the propagation delay is a<br />
maximum between nodes A and B). From Equation 3.6, this gives:<br />
<br />
t 2 t t t<br />
(3.9)<br />
PROP_SEG Bus Tx Rx<br />
where tBus is the propagation delay of the signal along the longest length of the bus between two<br />
nodes, t Tx is the propagation delay of the transmitter part of the physical interface and tRx is the<br />
propagation delay of the receiver part of the physical interface. If the propagation delay of the<br />
transmitters and receivers on a network is not uniform, the maximum delay values should be<br />
used in Equation 3.9.<br />
The minimum number of time quantum that must be allocated to the PROP_SEG<br />
segment is therefore:<br />
PROP_SEG<br />
PROP_SEG=ROUND_UP t <br />
<br />
<br />
<br />
t <br />
73<br />
Q <br />
(3.10)<br />
where the function ROUND_UP() returns the argument rounded up to the next integer value [24<br />
– 26].<br />
3.9 Selection of Bit Timing Values<br />
The selection of bit timing values involves consideration of various fundamental system<br />
parameters. The requirement of the PROP_SEG value imposes a trade-off between the<br />
maximum achievable bit rate and the maximum propagation delay, due to the bus length and the<br />
characteristics of the bus driver circuit. The maximum achievable bit rate is also influenced by<br />
the tolerance of the CAN clock source. The highest bit rate can only be achieved with a short<br />
bus length, a fast bus driver circuit and a high frequency tolerance CAN clock source. In
many systems, the bus length will be the least variable system parameter which will impose the<br />
fundamental limit on bit rate. However, the actual bit rate chosen may involve a trade-off with<br />
other system constraints, such as cost [23].<br />
3.9.1 Step-by-Step Calculation of Bit Timing Parameters<br />
The following steps provide a method for determining the optimum bit timing parameters<br />
which satisfy the requirements for proper bit sampling.<br />
Step 1: Determine the minimum permissible time for the PROP_SEG segment. Obtain the<br />
maximum propagation delay of the physical interface for both the transmitter and the<br />
receiver from the manufacturer’s data sheet. Calculate the propagation delay of the bus<br />
by multiplying the maximum length of the bus by the signal propagation delay of the<br />
bus cable. Use these values to calculate t PROP_SEG using Equation 3.9.<br />
Step 2: Choose the CAN System Clock Frequency. As the CAN system clock is derived<br />
from the MCU system clock or oscillator, the possible CAN system clock<br />
frequencies will be limited to whole fractions of the MCU system clock or oscillator by<br />
the prescaler. The CAN system clock is chosen so that the desired CAN bus NBT<br />
is an integer number of time quanta (CAN system clock periods) from 8 - 25.<br />
Step 3: Calculate the PROP_SEG duration. From equation 3.10, the number of time quanta<br />
required for the PROP_SEG segment is calculated. If the result is greater than eight, go<br />
back to Step 2 and choose a lower CAN system clock frequency.<br />
Step 4: Determine the Phase-Buffer-Segment quantities PHASE_SEG1 and PHASE_SEG2.<br />
From the number of time quanta per bit obtained in Step 2, subtract the PROP_SEG<br />
74
value calculated in Step 3 and subtract one tQ for SYNC_SEG. If the remaining<br />
number is less than three then go back to Step 2 and select a higher CAN system<br />
clock frequency. If the remaining number is an odd number greater than three then add<br />
one to the PROP_SEG value and recalculate. If the remaining number is equal to three<br />
then PHASE_SEG1 = 1 and PHASE_SEG2 = 2 and only one sample per bit may be<br />
chosen. Otherwise divide the remaining number by two and assign the result to<br />
PHASE_SEG1 and PHASE_SEG2.<br />
Step 5: Determine the value of RJW. RJW is chosen as the smaller of four and PHASE_SEG1.<br />
Step 6: Calculate the required oscillator tolerance from Equations 3.11 and 3.12.<br />
2 f 10 tNBT tRJW<br />
(3.11)<br />
2 f 13 tNBT tPHASE_SEG2 MIN tPHASE_SEG1, tPHASE_SEG2<br />
<br />
(3.12)<br />
In the case of PHASE_SEG1 > 4 t Q , it is recommended to repeat Steps 2 through 6 with<br />
a larger value for the prescaler (i.e. smaller tQ period, as this may result in a reduced<br />
oscillator tolerance requirement). Conversely, if PHASE_SEG1 < 4 t Q , it is<br />
recommended to repeat Steps 2 through 6 with a smaller value for the prescaler, as long<br />
as PROP_SEG < 8, as this may result in a reduced oscillator tolerance requirement. If<br />
the prescaler is already equal to one and a reduced oscillator tolerance is required, the<br />
only option is to consider using a higher frequency for the prescaler clock source [27 –<br />
29].<br />
75
CHAPTER 4<br />
THE CHALLENGES <strong>OF</strong> INTERFACING CAN <strong>AND</strong> 1 – WIRE® COMMUNICATION<br />
4.1 The Need for the Interface<br />
PROTOCOLS<br />
With each passing year, an increasing number of electronic devices need to be<br />
interconnected with an end goal of providing better system accuracy and added functionality<br />
such as remote management and remote diagnostic and maintenance capabilities. At the<br />
backbone of these automated and interconnected systems, there needs to be robust and reliable<br />
communications. Both CAN and 1 – Wire® are serial bus protocols allowing the transfer of<br />
data between master and slave devices. Having a transparent interface between the two<br />
protocols would allow a system designer to take full advantage of the robustness and flexibility<br />
of both technologies. Additionally, by combining the simplicity and cost of CAN-enabling a<br />
device with the multitude of 1 – Wire® devices commercially available, the savings to a system<br />
designer becomes two-fold: reduced complexity of wiring harnesses and increased features and<br />
functionality of the overall system.<br />
Just as CAN is emerging for use in medical equipment, 1 – Wire® devices are also<br />
being used for medical consumable IDs such as medical sensors (ID and calibration), blood<br />
glucose strips (calibration and authentication), and reagent bottles (ID). 1 – Wire® devices are<br />
also ideally suited for use in test equipment and mobile machines. Examples include: PCB<br />
76
Identification and Authentication and Accessory/Peripheral Identification and Control (See<br />
Section 2.4.2 for more details). Again, combining CAN and 1 – Wire® would increase the<br />
features and functionality of the overall system.<br />
Although CAN is the dominant serial communication protocol preferred in the<br />
automotive industry, 1 – Wire® devices are gaining popularity, especially with the emergence of<br />
hybrid and all-electric vehicles and technologies. As the result of new developments on<br />
experimental battery-powered electric vehicles, the need for fast information related to different<br />
components and equipment emerges, especially data related to battery life and knowledge about<br />
the overall system efficiency [30]. Battery monitoring systems for electric vehicles is one of the<br />
biggest uses of 1 – Wire® devices in the automotive industry. Most applications use the<br />
DS2436, a battery ID and monitor chip, to allow voltage and temperature monitoring of all<br />
batteries. This allows early detection of problems or failures in individual batteries. Another<br />
application of iButtons in the automotive industry is the vehicle black box. Like that found in<br />
commercial airliners, the Road Safety On-Board Computer System is a new car device that<br />
monitors speed, braking, turns, and just about everything else. It is designed to show you just<br />
what kind of driver you are. Before the engine will start, you have to log on with an iButton<br />
that tells the car who you are and from that point on, every move you make is strictly on the<br />
record. Combining the simplicity of CAN-enabling a device and application-specific 1 –<br />
Wire® devices such as the DS2436 and other function-specific 1 – Wire® devices, a system<br />
designer will be able to design a reliable, rugged, and functionally diverse network for almost<br />
any application.<br />
77
In June 2004, Maxim Integrated Products introduced the DS2482-X00 I 2 C-to-1 – Wire®<br />
interface devices, bridging a multi-master communication protocol with a single master<br />
communication protocol. The DS2482-X00 is an I 2 C-to-1 – Wire® line driver with one<br />
(DS2482-100) or eight (DS2482-800) channels of independently operated 1 – Wire® I/O ports.<br />
The DS2482 is an I 2 C-to-1 – Wire® bridge device that interfaces directly to standard (100 kHz<br />
max) or fast (400 kHz max) I 2 C masters to perform bidirectional protocol conversion between<br />
the I 2 C master and any downstream 1 – Wire® slave devices. Relative to any attached 1 –<br />
Wire® slave device, the DS2482 is a 1 – Wire® Master. I 2 C is appropriate for peripherals where<br />
simplicity and low manufacturing cost are more important than speed. Some common<br />
applications include: reading hardware monitors and diagnostic sensors, like a CPU thermostat<br />
and fan speed; reading real-time clocks; and turning on and turning off the power supply of<br />
system components. Peripherals can also be added or removed from the I 2 C bus while the<br />
system is running, just like 1 – Wire® devices, which makes it ideal for applications that require<br />
hot swapping of components [13 – 15]. Combining the diverse functionality of 1 – Wire®<br />
devices with the simplicity and low manufacturing cost of I 2 C, reduces the wiring complexity of<br />
any system down to just two wires and gives the system designer greater application diversity.<br />
4.2 Applications<br />
Of the many commercial markets that could potentially benefit from the interfacing of<br />
CAN and 1 – Wire® technologies, two of the most rapidly emerging markets, wearable sensor<br />
technology and automotive electronics and sensors would benefit the most. Other applications<br />
and markets that could benefit include hybrid mining and construction equipment, mobile and<br />
78
stationary agricultural equipment, nautical machinery, textile machines, and other special-<br />
purpose machinery such as production lines and machine tools.<br />
Paralleling the growth in automobile electronics is the increasing number of electronic<br />
control systems being used in vehicles with each new production year. This growth is partly due<br />
to the customer’s wish for better safety and greater comfort and also partly due to the<br />
government’s requirements for improved emission control and reduced fuel consumption. The<br />
complexity of the functions implemented in these systems necessitates an exchange of data<br />
between them. With conventional systems, data is exchanged by means of dedicated signal<br />
lines, but this is becoming increasingly difficult and expensive as control functions become ever<br />
more complex, and the use of dedicated connections does not scale as the number of electronic<br />
control systems in each vehicle continues to increase. In the case of complex control systems<br />
(such as Motronic) in particular, the number of connections cannot be increased much further.<br />
To consider future developments aimed at overall vehicle optimization, it becomes<br />
necessary to overcome the limitations of conventional control device linkage. This can only be<br />
done by networking the system components using a serial data bus system. In the near future,<br />
serial communication will also be used in mobile communication in order to link components<br />
such as car radios, car telephones, navigation aids etc. to a central, ergonomically designed<br />
control panel. The functions defined in the Prometheus project [31], such as vehicle-to-vehicle<br />
and vehicle-to-infrastructure communication will depend largely on serial communication.<br />
Whereas some of these devices and functions can only be implemented via CAN, the vast<br />
majority can be accomplished with the use of both CAN and 1 – Wire® inter-communications.<br />
79
Wearable sensor technology is a new application emerging recently in the medical field<br />
that would benefit from a merger of CAN and 1 – Wire® protocols. Wearable devices can be<br />
widely used in clinical care, home health care, hospice, special people monitoring, elderly care<br />
and assistance, psychological evaluation, physical training and many other medical areas.<br />
Wearable technology may provide an integral part of the solution for providing healthcare to a<br />
growing world population that will be strained by a ballooning ageing population. By providing<br />
a means to conduct telemedicine – the monitoring, recording, and transmission of physiological<br />
signals from outside of the hospital – wearable technology solutions could ease the burden on<br />
health-care personnel and use hospital space for more emergent or responsive care. In addition,<br />
employing wearable technology in professions where workers are exposed to dangers or hazards<br />
could help save their lives and protect health-care personnel [32]. In addition to providing a<br />
rugged, reliable communications backbone, combining the ability and ease of CAN-enabling<br />
an electrical device or component with the variety of 1 – Wire® devices used for medical<br />
consumable IDs would provide an almost unlimited type and number of body measurements,<br />
movements, and functions that could be monitored by wearable sensor technology and medical<br />
devices.<br />
4.3 Challenging Problems<br />
In designing a custom interface merging two communication protocols, a number of<br />
potentially challenging, technical problems had to be addressed such as combining a multi-<br />
master and a single-master protocol, messages by IDs and messages by addressing, event-<br />
80
triggered and time-triggered control paradigms, timing performance in relation to potential<br />
latencies, and possible communication speed differences.<br />
4.3.1 Multi-Master to Single Master<br />
Bridging a multi-master and a single-master communication protocol might seem a bit<br />
daunting at first to a systems design engineer. However, communication protocols supporting<br />
more than one master have an arbitration scheme in place that is either controlled in hardware or<br />
by software. Examples of communication protocols that contain provisions for multiple masters<br />
include: I 2 C, SPI [33 – 35], and CAN. Communication protocols such as Local<br />
Interconnect Network (LIN), 1 – Wire®, and Joint Test Action Group (JTAG) support only a<br />
single master and therefore need no arbitrator or bus arbitration scheme to help with<br />
communication conflicts.<br />
Bus arbitration provides a method for resolving bus control conflicts and assigning<br />
priorities to the requests for control of the bus. It is needed to resolve conflicts when two or<br />
more devices want to become the bus master at the same time. In short, arbitration is the process<br />
of selecting the next bus master from among multiple candidates. Traditionally, a single<br />
arbitrator schedules communication between one or more bus masters and bus slaves. If multiple<br />
masters attempt to access the bus, the arbitrator allocates bus resources to a single master based<br />
on a fixed set of arbitration rules [36]. Although there are many different types of arbitration<br />
schemes employed in both hardware and software, conflicts can be resolved based on fairness or<br />
priority in centralized or distributed mechanisms.<br />
81
In traditional bus architectures, one or more bus masters and bus slaves connect to a<br />
shared bus, and when multiple masters attempt to access the bus at the same time, the arbiter<br />
allocates the bus resources to a single master, forcing all other masters to wait. One shortcoming<br />
of this method is that access to the shared system bus becomes the bottleneck for data<br />
throughput. Since only one master has access to the bus at a time, this means that other masters<br />
are forced to wait and only one slave can transfer data at a time [37].<br />
In centralized arbitration schemes, a single arbiter is used to select the next master. A<br />
simple form of centralized arbitration uses a bus request line, a bus grant line, and a bus busy<br />
line. Each of these lines is shared by potential masters, which are daisy-chained in a cascade as<br />
shown in Figure 4.1 [38].<br />
Figure 4.1 Centralized arbiter in a daisy-chain scheme [38].<br />
In Figure 4.1, each of the potential masters can submit a bus request at any time. A fixed<br />
priority is set among the masters from left to right. When a bus request is received at the central<br />
bus arbiter, it issues a bus grant by asserting the bus grant line. When the potential master that is<br />
closest to the arbiter (Potential Master 1) sees the bus grant signal, it checks to see if it had made<br />
a bus request. If yes, it takes over the bus and stops propagation of the bus grant signal any<br />
further [38]. If it has not made a request, it will simply pass the bus grant signal to the next<br />
82
master to the right (Potential Master 2), and so on. When the transaction is complete, the busy<br />
line is deasserted.<br />
Instead of using shared request and grant lines, multiple bus request and bus grant lines<br />
can be used. In one scheme, each master will have its own independent request and grant line as<br />
shown in Figure 4.2. The central arbiter can employ any priority-based or fairness-based<br />
tiebreaker. Another scheme allows the masters to have multiple priority levels. For each priority<br />
level, there is a bus request and a bus grant line. In this scheme, each device is attached to the<br />
daisy chain of one priority level. If the arbiter receives multiple bus requests from different<br />
levels, it grants the bus to the level with the highest priority. Daisy chaining is used among the<br />
devices of that level. Figure 4.3 shows an example of four devices included in two priority<br />
levels. Potential Master 1 and Potential Master 3 are daisy-chained in level 1 and Potential<br />
Master 2 and Potential Master 4 are daisy-chained in level 2.<br />
Figure 4.2 Centralized arbiter with independent request and grant lines [38].<br />
83
Figure 4.3 Centralized arbiter with two priority levels (four devices) [38].<br />
In decentralized arbitration schemes, priority-based arbitration is usually used in a<br />
distributed fashion without the need of a central arbiter as shown in Figure 4.4. Each potential<br />
master has a unique arbitration number, which is used in resolving conflicts when multiple<br />
requests are submitted [38]. A device that wants to become a bus master first asserts the bus<br />
Request Level line, and then it checks if the bus is busy. If the Bus Busy line is not asserted,<br />
then the device sends a “0” to the next higher numbered device on the daisy chain, asserts the<br />
Bus Busy line, and de-asserts the Request Level line. If the bus is busy, or if a device does not<br />
want the bus, then it simply propagates the bus grant to the next device.<br />
Figure 4.4 Decentralized bus arbitration [38].<br />
84
CAN is a serial bus protocol with multi-master capabilities allowing all nodes to<br />
transmit data and multiple nodes to request access to the bus simultaneously. Arbitration is<br />
required if more than one node is accessing the bus. The bus arbitration method used in CAN<br />
is called Carrier Sense Multiple Access with Collision Detection and Arbitration on Message<br />
Priority (CSMA/CD + AMP), and works as follows. While the bus is idle, a “hard<br />
synchronization” on the Start-Of-Frame (S<strong>OF</strong>) bits transmitted by those nodes attempting to<br />
write to the bus occurs, after which each of these nodes sends the bits of its message identifier<br />
and monitors the bus level. Per definition, bits with a dominant value (zero) overwrite those with<br />
a recessive value (one). If, at some point, node i sends a recessive bit but reads back a dominant<br />
bit, then the message identifier of some other transmitting node has a lower binary value and<br />
therefore a higher priority than node i’s message. Node i therefore loses the arbitration and<br />
switches to listening-only mode. At the conclusion of this process, the node with the highest-<br />
priority message wins the arbitration and this message has been broadcast to the other nodes<br />
[39].<br />
Slave-side arbitration moves the arbitration logic close to the slave, such that the<br />
algorithm determines which master gains access to a specific slave in the event that multiple<br />
masters attempt to access the same slave at the same time. Some of the benefits associated with<br />
this arbitration scheme include: eliminating the need to create arbitration hardware manually,<br />
allowing multiple masters to transfer data simultaneously to different slaves, and providing<br />
configurable arbitration settings thus allowing arbitration for each slave to be specified<br />
independently.<br />
85
For the initial prototype design presented here, the CAN bus arbitration method will be<br />
used to resolve multi-master conflicts on the bus and also provide bidirectional protocol<br />
conversion between CAN and 1 – Wire® devices. For a larger system, having more CAN<br />
nodes and 1 – Wire® devices, other arbitration schemes such as slave-side arbitration would<br />
merit further exploration. This would especially be true for systems where safety-critical and<br />
real-time data throughput is a requirement and also when large amounts of data needs to be<br />
transferred among many CAN nodes and 1 – Wire® devices.<br />
4.3.2 Message IDs vs. Addresses<br />
In bridging two different communication protocols such as CAN and 1 – Wire®, how<br />
to handle converting between message IDs (CAN) and message addresses (1 – Wire®) is a<br />
problem that must be addressed. In a system based upon message IDs, masters broadcast<br />
messages with IDs. All slaves are required to decode the message ID to determine if it is the<br />
intended recipient. For an address-based system, each slave has a unique address, and every<br />
transfer includes the specific address of a slave. Generally, the address is decoded by all slaves<br />
and the intended slave accepts the message and all others reject the message.<br />
One possible way to bridge these two types of systems would be the addition of a simple<br />
PIC® microcontroller to each CAN node. Another way of addressing this problem would be<br />
to use message acceptance filters and masks (typically built-in on CAN Controllers) on each<br />
individual CAN node. A third possible solution would be to use the reserved bits of the<br />
CAN extended identifier field (r0 and r1) as part of an initial address assignment process [40].<br />
86
A final proposed method is based upon an automatic node discovery process to identify<br />
nonconfigured CAN nodes directly in a CANopen® system [41].<br />
Every CAN node in the prototype system described in this dissertation consists of the<br />
following components: Microchip PIC12CE674 [42] microcontroller, Microchip MCP2515<br />
stand-alone CAN Controller [43 – 44], and a Microchip MCP2551 high-speed CAN<br />
transceiver [45]. A simplified block diagram of the CAN components on each node is shown<br />
in Figure 4.5. The use of the PIC® microcontroller allows each node to have a unique address,<br />
stored in EEPROM, so a number of different devices can coexist on the same network. This<br />
would allow communication from a 1 – Wire® device (message by address) to a specific CAN<br />
node which would have a unique address on the CAN network. By storing the node address in<br />
EEPROM, this allows the node to not only be re-addressed if the addition of more nodes on the<br />
CAN bus is required, but also ensures that the node address value is retained in the event of<br />
power loss.<br />
Message IDs must be unique on a single CAN bus, otherwise two nodes would<br />
continue transmission beyond the end of their arbitration field (ID) causing an error (see Figures<br />
3.3 and 3.4). The choice of IDs for messages is often done simply on the basis of identifying the<br />
type of data and the sending node; however, as the message ID is also used as the message<br />
priority, this can lead to poor real-time performance. For example, consider an 11-bit ID CAN<br />
network, with two nodes with IDs of 31 (binary representation, 00000011111) and 32 (binary<br />
representation, 00000100000). If these two nodes transmit at the same time, each will transmit<br />
the first five zeros of their ID with no arbitration decision being made. When the sixth bit is<br />
transmitted, the node with the ID of 32 transmits a ‘1’ (recessive) for its ID, and the node with<br />
87
the ID of 31 transmits a ‘0’ (dominant) for its ID. When this happens, the node with the ID of 32<br />
will realize that it lost its arbitration, and allow the node with ID of 31 to continue its<br />
transmission. This ensures that the node with the lower bit value will always win the arbitration.<br />
So to summarize, with properly configured message acceptance filters and masks, messages sent<br />
from the 1 – Wire® Master will be properly directed to the appropriate CAN node.<br />
Figure 4.5 CAN node components simplified block diagram [45 – 47].<br />
By configuring hardware acceptance filters in the CAN Controller on each node, this<br />
reduces the probability of data overrun conditions on any one CAN node. The number of<br />
acceptance filters varies with different CAN Controllers and manufacturers. If properly<br />
configured for each CAN node, the acceptance filters could be used as a method of allowing<br />
only certain types of messages to be accepted by each individual CAN node. While receiving<br />
a CAN message, the identifier (and sometimes even the data) can be compared to a configured<br />
filter. Only if the incoming message matches the filter does the message get stored into a receive<br />
buffer on that particular CAN node. Thus it is possible to reduce the processing load of the<br />
host controller. Typically on a CAN Controller the message acceptance filter is controlled by<br />
two 8 – bit wide registers: usually named Acceptance Code Register (ACR) and Acceptance<br />
Mask Register (AMR). The eight most significant bits of the identifier of the CAN message<br />
88
are compared to the values contained in these registers; see example below and also Figure 4.6.<br />
Thus always groups of eight identifiers can be defined to be accepted for any node.<br />
Example: MSB LSB<br />
The Acceptance Code Register (ACR) contains: 0 1 1 1 0 0 1 0<br />
The Acceptance Mask Register (AMR) contains: 0 0 1 1 1 0 0 0<br />
Messages with the following 11 – bit identifiers are accepted 0 1 x x x 0 1 0 x x x<br />
(x = don’t care) ID.10 ID.0<br />
Figure 4.6 CAN Node Message Acceptance Filtering [48].<br />
At the bit positions containing a “1” in the AMR, any value is allowed in the composition<br />
of the identifier. The AMR defines the bit positions, which are relevant for the comparison (0 =<br />
relevant, 1 = not relevant). The same is valid for the three least significant bits. Thus 64<br />
different identifiers are accepted in this example. The other bit positions must be equal to the<br />
values in the ACR. For accepting a message all relevant received bits have to match the<br />
respective bits in the ACR. Although using acceptance filters and acceptance masks does not<br />
provide a CAN node with a physical address, it does however provide a means to limit what<br />
types of messages and how many will be received into an individual CAN node’s receive<br />
buffers.<br />
89
Recently, a technique has been proposed to use two reserved bits of the CAN extended<br />
data frame identifier field as part of an initial address assignment process [40]. The CAN<br />
protocol has two reserved bits in the Control Field for future expansion and/or modifications to<br />
the existing protocol. CAN 2.0B specification requires a transmitting node to transmit these<br />
reserved bits as zeros (dominant state). However, when a receiving unit receives the message, it<br />
will ignore the state of these two bits. The method proposed in [40] is to use these reserved bits<br />
to represent the address claim status of a CAN node as shown in Table 4.1.<br />
Table 4.1 Address claim status and reserved bits [40].<br />
Reserved bits Meaning<br />
00 Address Acquired (Normal Tx)<br />
01 Address Assignment Pending<br />
10 Address Claim Override<br />
11 Reserved<br />
Additionally, the CAN Controller for each node should be modified as shown in Figure<br />
4.7 to include an additional unit for address claim. This unit should include special registers<br />
which will contain the highest priority of the message that will be transmitted from the node and<br />
node address. A timing control unit is also required for monitoring the address claim timeout<br />
and a priority resolving unit will resolve address claim contentions.<br />
Figure 4.7 Address Claim Unit [40].<br />
90
Whenever a new CAN node is added to the network and powered up, it should wait for<br />
a random amount of time and transmit a message with an address assignment pending status<br />
(Reserved bits = 01). The CAN Controller should start claiming addresses from zero and the<br />
message transmitted should have the highest priority CAN message ID which is stored in the<br />
Highest Priority ID register.<br />
The Address Claim Unit should monitor the CAN bus for the successful transmission<br />
of an address claim message. If there is a bus error which prevents this message from being<br />
successfully transmitted then the node should wait for a random amount of time before<br />
attempting retransmission (i.e., automatic retransmission disabled). After a successful<br />
transmission of an address claim message, the CAN node should monitor the bus for the<br />
response from other CAN nodes possibly having the same source address. If the CAN node<br />
does not receive a response within a specified amount of time, it can assume that it has<br />
successfully claimed the address. If it receives a message from another CAN node with the<br />
same source address, then the address status bits are checked. If the status bits indicate an<br />
address claim override and the newly received CAN ID has an equal or higher priority than the<br />
new CAN node, then the new node will try to claim the next available valid address. If the<br />
override/normal Tx message comes from a lower priority CAN ID, then the address claim<br />
message is retransmitted with override information so the other CAN node will release its<br />
address. The CAN node should continuously monitor the data bus to check for address claim<br />
messages and if any CAN node has the same address as its own, take appropriate action.<br />
The above procedure will result in a sequential address assignment to networked CAN<br />
nodes. For example, if there are 25 CAN nodes at the start of the first address claim<br />
91
procedure, then the address claim process will result in addresses being assigned from zero to 24.<br />
If a new higher priority node is added to the CAN bus at a later time, all of the existing 25<br />
CAN nodes will be bumped off to a lower priority address resulting in a complete<br />
reassignment of CAN node addresses. This problem can be avoided by reserving some<br />
addresses at regular intervals. These addresses can be claimed by the CAN nodes only if they<br />
are being bumped out of a valid address claimed status and cannot be claimed during the initial<br />
configuration [40]. The reader is referred to [40] for a complete state machine diagram of the<br />
address claim process.<br />
The last proposed method to solve the issue of bridging message ID-based and address-<br />
based protocols such as CAN and 1 – Wire® would require that the PIC® microcontroller and<br />
CAN Controller used in the prototype system be CANopen® compliant. One of the biggest<br />
challenges in developing the hardware for a CANopen® compliant node can be selecting the<br />
right part, as some 20 chip manufacturers produce microcontrollers with CANopen® compliant<br />
CAN interfaces.<br />
CANopen® is a CAN - based higher layer application protocol conceived for process<br />
control and automated manufacturing environments that, at present, is knowing widespread<br />
diffusion all over the world and, in particular, in the European countries. CANopen® requires<br />
that each device in the network be assigned a unique node address (Node – ID) before the normal<br />
operations are started. To this extent, the CANopen® specifications provide a means to remotely<br />
configure the addresses of the slave devices attached to the CAN bus. This technique,<br />
however, requires that each device has to be connected separately to a configuration tool.<br />
CANopen®, in fact, does not have a mechanism to identify, in an efficient and reliable way, the<br />
92
nodes that do not have an associated address when they have already been connected to the<br />
network [41].<br />
The Automatic Node Discovery (<strong>AND</strong>) protocol [41] introduces a technique that enables<br />
nodes in a CANopen® network to be dynamically identified, so that their addresses can be<br />
assigned correctly. The overall configuration mechanism consists of two separate phases: node<br />
identification and address assignment. In the node identification phase the Layer Setting<br />
Services (LSS) master, one of two protocols included with CANopen®, discovers the different<br />
nodes in the network. Once this task is finished, the address assignment phase is started. Since<br />
the address assignment scheme for the slaves affects the precedence of the messages they<br />
transmit, the timing requirements of the different data exchanges have to be somehow known in<br />
this phase. This aspect is covered in more detail in [49] and [50].<br />
The <strong>AND</strong> algorithm enables slave devices to be discovered quickly when they are<br />
already connected to the final system. This is achieved by adding some communication services<br />
to the basic LSS protocol, so that the nonconfigured nodes can be identified. In [41] two<br />
versions of the discovery algorithm are described, that are nonrecursive and recursive,<br />
respectively. The former facilitates implementations, while the latter runs faster. The <strong>AND</strong><br />
protocol is efficient and requires few changes to the firmware of the slave devices and provides a<br />
good degree of compatibility with the devices currently available off the shelf [41].<br />
4.3.3 Event-Triggered vs. Time-Triggered Control Paradigms<br />
One of the elementary requirements of all real-time systems is the ability to react to an<br />
asynchronous event within a predefined period of time. At present, two different control<br />
93
paradigms are prevalent in the design of real-time architectures, and it has been recognized that<br />
communication protocols fall into two general categories with corresponding strengths and<br />
deficiencies: event-triggered and time-triggered control [51 – 53]. Event-triggered protocols<br />
(e.g., TCP/IP, CAN, Ethernet, 1 – Wire®, ARINC629) offer flexibility and resource<br />
efficiency. Time-triggered protocols (e.g., TTP, SafeBus, FlexRay [54], Spider) excel with<br />
respect to temporal predictability, composability, error detection and error containment.<br />
In event-triggered architectures, the system activities, such as sending a message or<br />
starting computational activities, are triggered by the occurrence of events in the environment or<br />
the computer system. In time-triggered architectures (e.g., Time – Triggered Architecture (TTA)<br />
[55], FlexRay [54]), activities are triggered by the progression of global time. The major<br />
contrast between event-triggered and time-triggered approaches lies in the location of control.<br />
Time-triggered systems exhibit autonomous control and interact with the environment according<br />
to an internal predefined schedule, whereas event-triggered systems are under the control of the<br />
environment and must respond to stimuli as they occur [51]. Table 4.2 summarizes the<br />
comparisons between event-triggered and time-triggered systems.<br />
Table 4.2 Time-Triggered vs. Event-Triggered.<br />
Time-Triggered Event-Triggered<br />
Periodic Messages Yes<br />
Sporadic Messages Yes<br />
Predictability Yes<br />
Flexibility Yes<br />
The time-triggered approach is generally preferred for safety-critical systems [51 – 53].<br />
For example, in the automotive industry a time-triggered architecture will provide the ability to<br />
handle the communication needs of by-wire cars [56]. In addition to hard real-time performance,<br />
94
time-triggered architectures help in managing the complexity of fault-tolerance and<br />
corresponding formal dependability models, as required for the establishment of ultra-high<br />
reliability (failure rates in the order of 10 -9 failures/hour) [51]. The predetermined points in time<br />
of periodic message transmissions allow error detection and redundancy to be integrated<br />
transparently into applications without any modification of the function and timing of the system.<br />
A time-triggered system also supports replica determinism, which is essential for establishing<br />
fault-tolerance through active redundancy. The communication controller in a time-triggered<br />
system decides autonomously when a message is transmitted.<br />
One drawback, however, of time-triggered bus concepts is the lack of flexibility and the<br />
restrictive design process. All processes and their time specifications must be known in advance.<br />
Otherwise, an efficient implementation is not possible. Furthermore, the communication and the<br />
task scheduling on the control units have to be synchronized during operation in order to ensure<br />
the strict timing specifications of the system design [57].<br />
In non safety-critical (soft real-time) applications, however, the event-triggered control<br />
paradigm may be preferred due to higher flexibility and resource efficiency. Event-triggered<br />
architectures support dynamic resource allocation strategies and resource sharing. In event-<br />
triggered systems, the provision of resources can be biased towards average demands, thus<br />
allowing timing failures to occur during worst-case scenarios in favor of more cost-effective<br />
solutions [58]. The main advantage of event-triggered systems is their ability to quickly react to<br />
asynchronous external events which are not known in advance [59]. Thus, they show a better<br />
real-time performance in comparison with time-triggered systems. In addition, event-triggered<br />
95
systems possess a higher flexibility and allow, in many cases, the adaptation to the actual<br />
demand without a redesign of the complete system [57].<br />
Both CAN and 1 – Wire® are event-triggered (asynchronous) in the sense that all<br />
activities are carried out in response to relevant events external to the system. In terms of real-<br />
time, a system is said to be real-time if the total correctness of an operation depends not only<br />
upon its logical correctness, but also upon the time in which it is performed [60]. Real-time<br />
systems, as well as their deadlines, are classified by the consequence of missing a deadline (See<br />
Table 4.3).<br />
Table 4.3 Categorization of Real-Time Systems [60].<br />
Category Definition<br />
Hard Missing a deadline is a total system failure.<br />
Firm<br />
Infrequent deadline misses are tolerable, but may degrade the system’s quality of service. The<br />
usefulness of a result is zero after its deadline.<br />
Soft<br />
The usefulness of a result degrades after its deadline, thereby degrading the system’s quality of<br />
service.<br />
In terms of real-time, neither protocol, by definition, can be classified as such. Without<br />
adding a higher layer protocol on top of the data layer (i.e., TTCAN [61 – 62]), neither protocol<br />
can guarantee a response within strict time constraints. However, both serial protocols can be<br />
sub-classified as soft real-time protocols. By definition, a soft real-time system is one, which<br />
tolerates lateness and may respond with decreased service quality.<br />
Overall, the CAN protocol is going to be more responsive to external demands. This is<br />
due to a number of factors including: a non-destructive bus arbitration scheme in place to handle<br />
message collisions; multiple data rates that include some slower and many much faster than the<br />
communication speeds at which 1 – Wire® can operate; CAN also has a number of fault<br />
tolerance mechanisms (the inclusion of a 2 – bit acknowledgement field and when the bus speed<br />
96
is kept below 125 kbps, the bus can function if one of the two data wires is cut), whereas 1 –<br />
Wire® has only a 16 – bit CRC; with CAN information being carried on the bus as a voltage<br />
difference, this also gives the CAN bus a high immunity to electromagnetic interference,<br />
whereas 1 – Wire® has data and power residing on the same line;<br />
4.3.4 Timing Performance<br />
One of the key elements related to the performance of any embedded system is message<br />
latency. By definition, message latency is the time needed for an electronic message to travel<br />
across a communications system and for the remote system to respond [63]. Message latency in<br />
a packet-switched network is measured either one-way (the time from the source sending a<br />
packet to the destination receiving it), or round-trip (the one-way message latency from source to<br />
destination plus the one-way latency from the destination back to the source). Round-trip<br />
message latency is more often quoted, because it can be measured from a single point. Where<br />
precision is important, one-way message latency can be more strictly defined as the time from<br />
the start of packet transmission to the start of packet reception [64]. This section presents an<br />
analysis of the message latencies attributed with both communication protocols and possible<br />
ways to minimize them.<br />
Under CAN, a given message is assumed to be invoked by some event, and is then<br />
given a bounded time for queueing of this message [65 – 66]. Because this time is bounded<br />
instead of fixed, there is some variability, or jitter, between subsequent queuings of the message.<br />
This is known as queuing jitter. It is assumed for the sake of analysis that there is a minimum<br />
time between invocations of a given message (i.e. period). Since a given message is assigned a<br />
97
fixed identifier and hence a fixed priority, it can be assumed that each given message must<br />
contain a bounded number of bytes. Given a bounded size, and a bounded rate at which the<br />
message is sent, this effectively bounds the peak load on the bus. This allows scheduling<br />
analysis to be applied to obtain a latency bound for each message on the bus [67].<br />
The queuing of a hard real-time message can occur with jitter (variability in queuing<br />
times) as shown in Figure 4.8. The shaded boxes in Figure 4.8 represent the ‘windows’ in which<br />
a node can queue a message. Jitter is important because to ignore it would lead to insufficient<br />
analysis. For example, ignoring jitter would lead to the assumption that message m could be<br />
queued at most once in an interval of duration (b – a). In fact, during the interval (a … b] the<br />
message could be queued twice: once at a (as late as possible in the first queuing window), and<br />
once at b (as early as possible in the next queuing window). Queuing jitter can be defined as the<br />
difference between the earliest and latest possible times a given message can be queued [67].<br />
Figure 4.8 Message Queuing Jitter [67].<br />
98
The analysis to bind the worst-case latency of a given hard real-time message is an<br />
almost direct application of processor scheduling theory [68 – 70]. However, there are some<br />
assumptions made by this analysis: first, the deadline of a given message m (denoted Dm) must<br />
not be more than the period of the message (denoted Tm), and second, the bus controller must not<br />
release the bus to lower priority messages if there are higher priority messages pending (i.e. the<br />
controller cannot release the bus between sending one message and entering any pending<br />
message into the arbitration phase).<br />
The worst-case response time of a given message m is denoted by Rm, and is defined as<br />
the longest time between the start of a node queuing m and the latest time that the message<br />
arrives at the destination nodes. From this, the worst-case response time of a given hard real-<br />
time message m can be bound by equation 4.1.<br />
Rm Jm wm Cm<br />
(4.1)<br />
The term Jm is the queuing jitter of message m, and gives the latest queuing time of the message,<br />
relative to the start of the transmitting node. The term wm represents the worst-case queuing<br />
delay of message m (due to both higher priority messages pre-empting message m, and a lower<br />
priority message that has already obtained the bus). The term Cm represents the longest time<br />
taken to physically send message m on the bus. This time includes the time taken by the frame<br />
overheads, the data contents, and extra stuff bits (the CAN protocol specifies that the message<br />
contents and 34 bits of the overhead are subject to bit stuffing with a stuff width of 4 – worst<br />
case of 1 stuff bit for every 4 message bits). The stuff bit counts as the first bit in a new stuffing<br />
sequence. For an 11-bit identifier (slightly different formula below for 29-bit header), only 34 of<br />
the overhead bits are subject to stuffing; others aren’t subject to stuffing. Equation 4.2 gives Cm:<br />
99
348sm <br />
Cm 47 8 smbit<br />
11-bit header<br />
4 <br />
<br />
100<br />
<br />
548sm <br />
Cm 67 8 smbit<br />
29-bit header<br />
4 <br />
<br />
<br />
The term sm denotes the bounded size of message m in bytes. The term bit is the bit time of the<br />
bus (on a bus running at 1 Mbps this is 1µs). The 34 (11-bit) term in the numerator comes from<br />
the sum of the S<strong>OF</strong>, Arbitration, ACK, CRC, and Interframe Space bit fields whose values are 1,<br />
12, 2, 16, and 3 respectively. For a 29-bit header, this value is 54 (sum of 1, 32, 2, 16, and 3).<br />
The value of 47 (11-bit) in Equation 4.2 comes from the previous sum of 34 and the Control and<br />
E<strong>OF</strong> bit fields whose values are 6 and 7 respectively. For a 29-bit header, the value is 67 (the<br />
sum of 54 and the Control and E<strong>OF</strong> bit fields).<br />
Equation 4.3 represents the queuing delay and is given by:<br />
(4.2)<br />
wm J j <br />
bit<br />
wm Bm Cj<br />
(4.3)<br />
j hpm Tj<br />
<br />
The set hp(m) is the set of messages in the system of higher priority than m. Tj is the period of a<br />
given message j, and Jj is the queuing jitter of the message. Bm is the longest time that the given<br />
message m can be delayed by lower priority messages (this is equal to the time taken to transmit<br />
the largest lower priority message), and can be defined by:<br />
<br />
<br />
max B C<br />
(4.4)<br />
m k<br />
k lp m<br />
where lp(m) is the set of lower priority messages.<br />
In Equation 4.3, the term wm appears on both sides of the equation, thus the equation<br />
cannot be rewritten in terms of wm. A simple solution is possible by forming a recurrence<br />
relationship:
n w 1<br />
m J n<br />
j <br />
<br />
bit<br />
wm Bm Cj<br />
(4.5)<br />
j hpm Tj<br />
<br />
A value of zero for w can be used. The iteration process proceeds until convergence (i.e.<br />
n 1 n<br />
m m<br />
0<br />
m<br />
<br />
w w ). Equations 4.1 through 4.5 do not assume anything about how identifiers and hence<br />
priorities are chosen [67].<br />
From analysis of Equations 4.1 through 4.5, the minimal latency time occurs when the<br />
CAN bus is running at its maximum speed of 1 Mbps and when a frame consisting of zero<br />
data bytes is transmitted (i.e. sm 0 and bit 1μs ). Solving Equation 4.2 for a value of Cm<br />
yields:<br />
C<br />
C<br />
m<br />
m<br />
34 <br />
47 8.5 47 55.5 μsec 11-bit header<br />
4 <br />
<br />
101<br />
<br />
54 <br />
67 13.5 67 80.5 μsec 29-bit header<br />
4 <br />
<br />
<br />
The maximum latency time occurs when the bus is running at its slowest speed of 10 kbps and<br />
when a frame consisting of eight data bytes is transmitted (i.e. sm 8and<br />
bit 100μs ).<br />
Resolving Equation 4.2 for Cm yields:<br />
C<br />
C<br />
m<br />
m<br />
(4.6)<br />
34 88 98 <br />
47 8 8 10μs 111 10μs 1.355msec=1355μsec (11-bit)<br />
4 <br />
<br />
<br />
4 <br />
(4.7)<br />
54 88 118 <br />
67 88 10μs 13110μs1.605msec=1605μsec (29-bit)<br />
4 <br />
4 <br />
From this analysis, the worst-case latency value comes from the bus operating at the<br />
slowest speed of 10 kbps when each message contains the maximum amount of data at eight<br />
bytes and the values for the queuing jitter (Jm) and worst-case queuing delay (wm) are zero. The
est-case latency occurs when the bus is operated at it maximum speed of 1 Mbps and each data<br />
frame contains no data. Again for this case it is assumed that the values for queuing jitter (Jm)<br />
and worst-case queuing delay (wm) are zero. Therefore operating the bus at the highest speed<br />
possible and keeping the amount of data in each data frame as small as possible would allow<br />
minimal latency times on the CAN bus.<br />
In many iButton and 1 – Wire® applications, cable length and loading often preclude<br />
the use of the overdrive mode. Cable length and loading are the two biggest factors that<br />
contribute to message latency on 1 – Wire® networks. In those applications where the<br />
embedded electronics are in close proximity to the slave devices, the high-speed overdrive<br />
communication mode can greatly reduce transaction times [71]. Table 4.4 shows a comparison<br />
of typical 1 – Wire® command transactions using both standard and overdrive speeds.<br />
There are two ways to get an overdrive-capable slave device into overdrive mode. One<br />
way uses the Overdrive Skip command, which puts all devices on the bus into overdrive. The<br />
other way uses the Overdrive Match command, which only puts the device with the matching<br />
identification number into overdrive. The device remains in overdrive mode until it gets a 1 –<br />
Wire® reset at standard speed, or it is disconnected from the bus. Any 1 – Wire® device that is<br />
either hot swapped (plug-and-play) or is already on the bus at power always starts at standard<br />
speed [71].<br />
The example in Table 4.4 shows that despite the extra command and reset cycle of<br />
getting to overdrive speed, using overdrive obtains the device identification number in 2152µs<br />
compared to 5640µs at standard speed. The more communication that occurs at overdrive, the<br />
more substantial is the time savings. The downside to using overdrive speed is the additional<br />
102
caution required after a short or loss of electrical contact or when hot-swapping slave devices.<br />
Electrical shorts typically occur when an iButton is placed on an iButton probe and the data<br />
contact of the iButton bridges the probe’s DATA and GND contacts. The duration of such a<br />
short can vary from a few milliseconds up to a second or even more. Although a short does not<br />
damage 1 – Wire® devices on the bus, it causes a communication bus reset which, in turn, resets<br />
the 1 – Wire® data rate to standard speed. If the bus master were using overdrive speed and was<br />
unaware of the short, subsequent communication attempts at overdrive speed would fail. From<br />
an iButton’s perspective, loss of contact is equivalent to a short; in either case there is no<br />
voltage between DATA and GND. Consequently, the reset to standard speed also occurs if the<br />
connection between the iButton and probe is lost [71].<br />
Table 4.4 Time Savings for a Read ROM Function [71].<br />
Step Time Slots STD Speed Time OD Speed Time<br />
1 – Wire® Reset/Presence Detect Cycle at<br />
Standard Speed<br />
N/A 960µs 960µs<br />
Command Overdrive Skip ROM 8 N/A 8 x 65µs<br />
1 – Wire® Reset/Presence Detect Cycle at<br />
N/A N/A 96µs<br />
Overdrive Speed<br />
Command Read ROM 8 8 x 65µs 8 x 8µs<br />
Read Device Identification Number 64 64 x 65µs 64 x 8µs<br />
Total Time 5640µs 2152µs<br />
From the above discussion with overdrive and standard speeds it is easy to see that there<br />
is a savings factor greater than 2.5 when using overdrive speed. The main disadvantages are:<br />
loss of bus power forcing a reset and loss of device contact. Although not really a disadvantage,<br />
using overdrive speed on a 1 – Wire® network does require additional programming to be done<br />
for the 1 – Wire® Master if both standard and overdrive capable devices reside on the same<br />
branch of a network. Ideally, if both speeds are desired on the same network, it is recommended<br />
103
to break the 1 – Wire® network into separate branches or trunks having only overdrive capable<br />
devices on one branch and only standard speed capable devices on the other.<br />
Another key parameter affecting message latency times on the 1 – Wire® bus, other than<br />
cable length and loading, is the recovery time, tREC. The majority of 1 – Wire® devices is<br />
parasitically powered, meaning that the 1 – Wire® line serves as power line and bidirectional<br />
data line. The 1 – Wire® protocol is designed to have idle times without communication,<br />
precisely so power can be transmitted to the 1 – Wire® slave devices on the line. The critical<br />
parameter that limits the amount of power available for the 1 – Wire® slaves is the recovery<br />
time, tREC. The tREC value specified in product data sheets and read/write waveforms is valid for<br />
only 1 – Wire® networks of a single slave. An analysis is presented here to identify the power-<br />
critical events and provide an algorithm to calculate the necessary recovery time for varying<br />
number of 1 – Wire® slaves, different operating voltage, and temperature. The algorithm<br />
presented here explains how to set tREC in Write-Zero Time Slots, and, as a derived value, tSLOT<br />
(time to communicate one bit excluding recovery time), to ensure adequate power supply in 1 –<br />
Wire® networks with multiple slaves. The resulting tSLOT, if also applied to Read-Data and<br />
Write-One Time Slots, defines the maximum data rate for reliable communication in a given 1 –<br />
Wire® network.<br />
Figure 4.9 shows the reset/presence detect cycle for a DS2411 (Silicon Serial Number<br />
with VCC Input) 1 – Wire® device. The recovery time begins after the presence pulse and ends<br />
with the falling edge of the next time slot. Typically, tRSTL (Reset low time) and tRSTH (Reset<br />
high time) are chosen to have the same duration. At standard speed, tRSTL is 480µs. Under<br />
worst-case conditions, tPDH (Presence-detect high time) + tPDL (Presence-detect low time) are<br />
104
300µs, leaving 180µs for tREC. At overdrive speed, these numbers are ten times shorter, reducing<br />
tREC to 18µs. Compared to the minimum data sheet specification of tREC, plenty of time remains<br />
for the parasitic power supply (a capacitor inside the slave) to recharge. Therefore, the<br />
reset/presence detect cycle is not critical for power considerations, as long as tRSTL does not<br />
exceed the data sheet’s maximum limit and the parasitic power supply is sufficiently charged<br />
before tRSTL begins. At overdrive speed an extended recovery time of 2.5 times the minimum<br />
value prior to a reset pulse provides this extra charge. At standard speed the extended recovery<br />
time prior to a reset pulse is optional.<br />
Figure 4.9 Initialization Procedure: Reset and Presence Pulse [72 – 73].<br />
The read/write timing diagram below consists of three waveforms: Write-One Time Slot-<br />
to write a logical ‘1’ (Figure 4.10); Write Zero Time Slot-to write a logical ‘0’ (Figure 4.11); and<br />
Read Data Time Slot-to read a bit from a 1 – Wire® slave (Figure 4.12). As can easily be seen<br />
from Figure 4.10, a Write-One Time Slot is not critical for power delivery. The window for<br />
power delivery, tSLOT – tW1L (Write-one low time), is at least 50µs at standard speed and 6µs at<br />
overdrive speed. The 6µs at overdrive speed, however, are barely more than the minimum<br />
specification of tREC. The Write-Zero Time Slot, especially when there are multiple zeros in a<br />
105
ow, is most critical for power delivery due to the long low-time compared to the recovery time.<br />
It is important to understand that the tREC specification in the product data sheets for 1 – Wire®<br />
devices applies for a single slave on a 1 – Wire® line with a 2.2kΩ pullup resistor to 2.8V. A<br />
Read-Data Time Slot, when reading a zero, is also critical for power delivery. It is, however,<br />
more benign since a slave typically pulls the 1 – Wire® line low for less than the permissible<br />
60µs (standard speed) or 6µs (overdrive speed).<br />
Figure 4.10 Write-One Time Slot [72 – 73].<br />
Figure 4.11 Write-Zero Time Slot [72 – 73].<br />
106
Figure 4.12 Read-Data Time Slot [72 – 73].<br />
When analyzing the recovery time with respect to power delivery, several primary and<br />
secondary parameters are considered. These parameters are defined and described in Table 4.5.<br />
Table 4.5 Parameters of Impact [72].<br />
Primary<br />
Number of Slaves The demand for power increases with the number of consumers.<br />
Pullup Voltage The higher the voltage, the more energy can be delivered.<br />
Communication Speed At overdrive speed, the duty cycle of a Write-Zero Time Slot is higher.<br />
Type of 1 – Wire® Driver An ‘intelligent’ driver can pump more energy.<br />
Secondary<br />
Operating Temperature A cold 1 – Wire® device needs more energy.<br />
Cable Length The capacitance of the cable needs to be charged too.<br />
1 – Wire® Device Type Some devices need slightly more or less energy than others.<br />
In the first example, only typical data sheet conditions are used: a driver consisting of a<br />
2.2kΩ pullup resistor to 2.8V, the worst-case temperature, a single 1 – Wire® slave on the bus,<br />
and negligible cable capacitance. This example uses the number of 1 – Wire® slaves as the main<br />
parameter and provides answers for varying operating voltage, speed, and temperature. If the<br />
cable between 1 – Wire® driver and slaves becomes significant, it can be represented in the<br />
calculation as an additional slave for every 15 meters of length. The results shown in Table 4.6<br />
apply for typical 1 – Wire® slaves for ROM function commands, general memory read functions<br />
and SRAM write functions. Writing to EEPROMS, temperature conversion and SHA – 1<br />
107
computations have device-specific power delivery requirements, such as a strong pullup, which<br />
do not affect the validity of the method presented here. As far as ROM functions and memory<br />
are concerned, 1 – Wire® EPROM devices can also be considered as typical; for programming<br />
purposes, only a single EPROM device is permitted on the network.<br />
Table 4.6 Results Matrix [72].<br />
Operating Voltage (V) Temperature (°C) Standard Speed (µs) Overdrive Speed (µs)<br />
-40 tREC = 2.12 x N +1.0 tREC = 1.43 x N +0.5<br />
4.5 and higher<br />
-5<br />
+25<br />
tREC = 1.99 x N +1.0<br />
tREC = 1.83 x N +1.0<br />
tREC = 1.37 x N +0.5<br />
tREC = 1.30 x N +0.5<br />
+85 tREC = 1.54 x N +1.0 tREC = 1.18 x N +0.5<br />
-40 tREC = 3.52 x N +1.0 tREC = 1.82 x N +0.5<br />
2.8 (minimum)<br />
-5<br />
+25<br />
tREC = 3.30 x N +1.0<br />
tREC = 3.17 x N +1.0<br />
tREC = 1.80 x N +0.5<br />
tREC = 1.74 x N +0.5<br />
+85 tREC = 2.70 x N +1.0 tREC = 1.63 x N +0.5<br />
The recovery time can be calculated using a linear equation as shown in equation 4.8.<br />
t REC<br />
a N b<br />
(4.8)<br />
N is the number of parasitically powered slave devices on the network, assuming that all slaves<br />
are connected in parallel from the 1 – Wire® line to the ground reference. 1 – Wire® devices<br />
that get their power through a VCC pin do not significantly load the 1 – Wire® line; they should<br />
be counted as one-tenth of a device. The slope ‘ a ’ varies with temperature, operating (pullup)<br />
voltage, and 1 – Wire® speed. For this analysis, it is sufficient to let the offset ‘ b ’ vary with<br />
speed only. Table 4.6 shows the equation with slope and offset inserted. The numerical values<br />
are obtained through manual curve fitting; the results closely match those obtained through an<br />
iterative process based on scientific models. For N 1,<br />
the results matrix does not generate<br />
exactly the same number as published in most device data sheets. This different value is a side<br />
effect of the curve fitting, and should not be regarded as in conflict with the specification.<br />
108
The recovery time is longest for low operating voltage and low temperature. If the<br />
application requires operation at very low temperatures, the -40°C entry should be used. For<br />
room-temperature environments, it is acceptable to use the +25°C entry, which also allows safe<br />
operation at higher temperatures. The +85°C entry yields a result that only applies at that<br />
temperature; it should be regarded as a reference, not as a design value for other temperatures.<br />
The recovery is shortest for high operating voltages. The 4.5V entries apply for pullup<br />
voltages of 4.5V or higher. A recovery time based on 2.8V entries also works for higher<br />
voltages, but unnecessarily slows the data rate. For an operating voltage, say Vx, between 2.8V<br />
and 4.5V, a new slope value can be obtained through linear interpolation using equation 4.9 [72].<br />
<br />
Slope@2.8V Vx 2.8V<br />
Slope@Vx Slope@2.8V Slope@4.5V<br />
<br />
(4.9)<br />
1.7V<br />
As a second example, assume that an application requires a network of twenty 1 – Wire®<br />
devices N 20<br />
, with tW0L = 60µs at standard speed and 6µs at overdrive (from DS2411 data<br />
sheet). The network is supposed to operate from 0°C to 70°C. The operating voltage is not<br />
unknown. The applicable entry for this temperature range is that of -5°C, because it is the<br />
nearest value below the minimum operating temperature. Since the slope for higher<br />
temperatures is lower than that of the -5°C entry, the result is valid for all temperatures above -<br />
5°C. Table 4.7 shows the tREC results for this example and the maximum data rate with this<br />
recovery time.<br />
109
Table 4.7 Example results with N 20 .<br />
Operating Voltage (V) Standard Speed Overdrive Speed<br />
t 1.99 N 1.0<br />
s<br />
t 1.37 N 0.5 s<br />
4.5 and higher<br />
2.8 (minimum)<br />
REC<br />
data rate <br />
REC<br />
<br />
1.99 20 1.0<br />
<br />
40.8s<br />
<br />
<br />
data rate <br />
1<br />
t t <br />
W 0L<br />
REC<br />
1<br />
60s40.8s 9.92 kbps<br />
3.30 1.0<br />
3.30 20 1.0<br />
1<br />
t t <br />
W 0L<br />
REC<br />
1<br />
60s67s 7.87 kbps<br />
110<br />
s<br />
t N s<br />
<br />
67s<br />
<br />
<br />
s<br />
REC<br />
data rate <br />
REC<br />
<br />
1.37 20 0.5<br />
<br />
27.9s<br />
<br />
<br />
data rate <br />
1<br />
t t <br />
W 0L<br />
REC<br />
1<br />
6s27.9s 29.5 kbps<br />
1.80 0.5<br />
1.80 20 0.5<br />
1<br />
t t <br />
W 0L<br />
REC<br />
1<br />
6s36.5s 23.5 kbps<br />
s<br />
t N s<br />
<br />
36.5s<br />
At standard speed, the data rate is reduced to approximately 65% of the 15.3 kbps for an<br />
operating voltage of 4.5V and is reduced to approximately 51% when the minimum 2.8V<br />
operating voltage is used. At overdrive speed, the data rate is less than 25% of the 125 kbps<br />
reference for operating voltages of 4.5V and higher. When operating at the minimum operating<br />
voltage of 2.8V, the data rate is less than 20% of the 125 kbps reference. If any of the data rates<br />
in Table 4.7 is acceptable for the application, the choice of operating voltage is not critical.<br />
However, if an operating voltage of approximately 5V is available, it should be preferred<br />
because of better noise immunity.<br />
<br />
<br />
s
If the recovery time resulting from Table 4.7 is not acceptable, there are several ways to<br />
increase the data rate:<br />
Reduce the pullup resistor from 2.2kΩ to e.g., 1kΩ. The lower resistor doubles the<br />
recharge current for the 1 – Wire® network, which in turn reduces the recovery time by<br />
50%. With this approach, it is important to verify whether each of the slave devices can<br />
handle the increased current, VPUP/RPUP (1 – Wire® pullup voltage/Pullup resistor), when<br />
pulling the 1 – Wire® line low during a Read-Data Time Slot.<br />
Change the network topology. Instead of one network, use two or more smaller networks<br />
or use the DS2409 1 – Wire® coupler to disconnect some slave devices from the active<br />
part of the network.<br />
Consider using an active 1 – Wire® driver. An active driver uses transistors to<br />
temporarily bypass the pullup resistor. This allows a faster recharge of the 1 – Wire®<br />
network and, in turn, reduces the necessary recovery time [72].<br />
The most flexibility, in particular for driving a physically large 1 – Wire® network, is<br />
achieved with a microcontroller that operates as an intelligent 1 – Wire® driver. Depending on<br />
the characteristics of the microcontroller, such a driver can also operate at 3.3V or 5V.<br />
Calculating the necessary recovery time of 1 – Wire® applications with multiple slaves is a<br />
simple and straightforward process. A 5V environment is generally the preferred choice for any<br />
1 – Wire® network. For most applications, a 1 – Wire® driver with a resistive pullup is<br />
sufficient. For larger networks, a driver with active pullup capabilities may be required.<br />
111
4.3.5 Communication Speed Differential<br />
Since the communication speeds supported under the CAN protocol specification are<br />
well above and below those supported by the 1 – Wire® protocol, an additional buffer is needed<br />
to handle any underflow or overflow of messages from one bus to the other. For CAN, the bit<br />
rates are inversely proportional to the bus lengths and can range from 10 kbps up to 1000 kbps.<br />
As stated in section 2.2, most 1 – Wire devices support two data rates. The lower (standard) data<br />
rate is about 14 kbps and the higher (overdrive) data rate is about 140 kbps. Best suited to solve<br />
any communication speed differential, would be the use of either a First-In-First-Out (FIFO) or a<br />
prioritized FIFO buffer.<br />
112
CHAPTER 5<br />
THE INTERFACE <strong>OF</strong> CAN <strong>AND</strong> 1 – WIRE® COMMUNICATION PROTOCOLS<br />
5.1 Interface Overview<br />
In many situations, especially those involving cutting-edge technology, new designs have<br />
unanticipated problems that are difficult to predict by modeling or simulations. When the<br />
performance of a new device is uncertain, an early development of a prototype can be useful for<br />
testing the key features of the design, exploring design alternatives, testing theories, and<br />
confirming performance prior to starting production [74]. Since prototyping is an iterative<br />
process, a series of products will be designed, constructed, and tested to refine the final design.<br />
The prototype design presented here consists of a 1 – Wire® Bus Master and a CAN<br />
Transceiver. Both components in the prototype system have been designed in Verilog®, so they<br />
can be targeted to different implementation technologies. To implement all of the prototype<br />
design components, the DE2 Development and Education Board, equipped with a Cyclone II<br />
(2C35) FPGA, manufactured by Altera was used for all design synthesis and simulations.<br />
5.2 1 – Wire® FPGA Implementation<br />
As more 1 – Wire® devices become available, more and more users have to deal with the<br />
demands of generating 1 – Wire® signals to communicate to them. This usually requires “bit-<br />
113
anging” a port pin on a microprocessor, and having the microprocessor perform the timing<br />
functions required for the 1 – Wire® protocol. Even though 1 – Wire® transmissions can be<br />
interrupted mid-byte, they cannot be interrupted during the “low” time of a bit time slot; this<br />
means that a CPU will be idle for up to 60 microseconds for each bit sent and at least 480<br />
microseconds when performing a 1 – Wire® reset [75].<br />
5.2.1 1 – Wire® Master Overview<br />
The synthesizable 1 – Wire® Master implemented here, termed one_wm, was created to<br />
facilitate host CPU communication with devices over a 1 – Wire® bus without concern for bit<br />
timing and without tying up valuable CPU cycles. Some of the features incorporated into the<br />
design include:<br />
Support for long line conditions.<br />
Support for single bit transmissions.<br />
Memory maps into any standard byte-wide data bus.<br />
Search ROM accelerator relieves the CPU from any single bit operations on the 1 –<br />
Wire® bus.<br />
Generates interrupts to provide for more efficient programming.<br />
Eliminates CPU “bit-banging” by internally generating all 1 – Wire® timing and control<br />
signals.<br />
Supports standard and overdrive communication speeds.<br />
Capable of running off any system clock from 4 MHz up to 128 MHz.<br />
Supports strong pull-up specifications as defined by the 1 – Wire® protocol standards.<br />
114
Applications include any circuit containing a 1 – Wire® communication bus.<br />
The synthesizable 1 – Wire® Bus Master as shown in Figure 5.1 is designed to be<br />
memory-mapped into any system and provides complete control of the 1 – Wire® bus through<br />
single-bit or 8-bit commands. The host CPU loads commands, reads and writes data, and sets<br />
interrupt control through seven individual registers. All of the timing and control of the 1 –<br />
Wire® bus are generated within. The host merely needs to load a command or data and then<br />
may go on about other business. When bus activity has generated a response that the CPU needs<br />
to receive, the 1 – Wire® Master sets a status bit and, if enabled, generates an interrupt to the<br />
CPU. In addition to read and write simplification, the 1 – Wire® Master also provides a Search<br />
ROM Accelerator function relieving the CPU from having to perform the complex single-bit<br />
operations on the 1 – Wire® bus.<br />
Figure 5.1 one_wm Synthesizable 1 – Wire® Bus Master Block Diagram.<br />
115
From Figure 5.1, the block I/O pins are defined as follows with ‘0’ representing a logic<br />
level “low” and ‘1’ representing a logic level “high”:<br />
A0, A1, A2Register Select: Address signals connected to these three inputs select a<br />
register for the CPU to read from or write to during data transfer. A table of registers and<br />
their addresses is shown below in Table 5.1.<br />
Table 5.1. 1 – Wire® Register Addresses.<br />
Register Addresses<br />
A2 A1 A0 Register<br />
0 0 0 Command Register (read/write)<br />
0 0 1 Transmit Buffer (write), Receive Buffer (read)<br />
0 1 0 Interrupt Register (read)<br />
0 1 1 Interrupt Enable Register (read/write)<br />
1 0 0 Clock Divisor Register (read/write)<br />
1 0 1 Control Register (read/write)<br />
ADS Address Strobe: The positive edge of an active Address Strobe ( ADS ) signal<br />
latches the Register Select (A0, A1, A2) into an internal latch. Provided that setup and<br />
hold timings are observed, ADS may be tied low making the latch transparent.<br />
CLKClock Input: This is a (preferably) 50% duty cycle clock that can range from 4<br />
MHz to 128 MHz. This clock provides the timing for the 1 – Wire® bus.<br />
D0 – D7Data Bus: This bus comprises eight input/output lines. The bus provides bi-<br />
directional communications between the 1 – Wire® Master and the CPU. Data, control<br />
words, and status information are transferred via this D0 – D7 Data Bus.<br />
DQ1 – Wire® Data Line: This open-drain line is the 1 – Wire® bi-directional data bus.<br />
1 – Wire® slave devices are connected to this pin. This pin must be pulled high by an<br />
external resistor, nominally 5kΩ.<br />
116
EN Enable: When EN is low, the 1 – Wire® Master is enabled; this signal acts as<br />
the device chip enable. This enables communication between the 1 – Wire® Master and<br />
the CPU.<br />
INTR Interrupt: This line goes to its active state whenever any one of the interrupt<br />
types has an active high condition and is enabled via the Interrupt Enable Register. The<br />
INTR signal is reset to an inactive state when the Interrupt Register is read.<br />
MRMaster Reset: When this input is high, it clears all the registers and the control<br />
logic of the 1 – Wire® Master, and sets INTR to its default inactive state, which is HIGH.<br />
RD Read: This pin drives the bus during a read cycle. When the circuit is enabled,<br />
the CPU can read status information or data from the selected register by driving RD<br />
low. RD and WR should never be low simultaneously; if they are WR takes<br />
precedence.<br />
STPZ Strong Pull-up Enable: This pin drives the gate of the p-channel transistor that<br />
bypasses the weak pull-up resistor in order to provide the slave device with a strong<br />
power supply for high current applications.<br />
WR Write: This pin drives the bus during a write cycle. When WR is low while<br />
the circuit is enabled, the CPU can write control words or data into the selected register.<br />
RD and WR should never be low simultaneously; if they are WR takes<br />
precedence.<br />
117
5.2.2 Command Register<br />
In addition to reading and writing the 1 – Wire® Master can generate two special<br />
commands on the bus. The first is a 1 – Wire® reset, which must precede any command given<br />
on the 1 – Wire® bus. Secondly, the 1 – Wire® Master can be placed into Search ROM<br />
Accelerator mode to prevent the host from having to perform single bit manipulations of the bus<br />
during a Search ROM operation (command 0xF0h). For more details on the Reset or Search<br />
ROM command, the reader is referred to [75]. In addition to these two functions, the Command<br />
Register contains two bits to bypass the 1 – Wire® Master features and control the 1 – Wire®<br />
bus directly (See Figure 5.2).<br />
Figure 5.2 Command Register Bits.<br />
Bit 3 – OW_IN: OW Input. This bit always reflects the current state of the 1 – Wire®<br />
line.<br />
Bit 2 – FOW: Force One Wire. This bit can be used to bypass 1 – Wire® Master<br />
operations and drive the bus directly if needed. Setting this bit high will drive the bus<br />
low until it is cleared or a bus reset occurs. While the 1 – Wire® bus is held low, no<br />
other 1 – Wire® Master operations will function. By controlling the length of time this<br />
bit is set and the point when the line is sampled, any 1 – Wire® communication can be<br />
generated by the host controller. To prevent accidental writes to the bus, the EN bit in<br />
the CONTROL register must be set to a 1 before the FOW bit will function. The FOW<br />
bit is cleared to a 0 on a power-up or master reset.<br />
118
Bit 1 – SRA: Search ROM Accelerator. When this bit is set, the 1 – Wire® Master will<br />
switch to Search ROM Accelerator mode. When this bit is set to 0, the master will<br />
function in its normal mode. The SRA bit is cleared to 0 on a power-up or master reset.<br />
Bit 0 – 1WR: 1 – Wire® Reset. If this bit is set, a reset will be generated on the 1 –<br />
Wire® bus. Setting this bit automatically clears the SRA bit. The 1WR bit will be<br />
automatically cleared as soon as the 1 – Wire® reset completes. The 1 – Wire® Master<br />
will set the Presence Detect interrupt flag (PD) when the reset is complete and sufficient<br />
time for a presence detect to occur has passed. The result of the presence detect will be<br />
placed in the interrupt register bit PDR. If a presence detect pulse was received, PDR<br />
will be cleared, otherwise it will be set.<br />
5.2.3 Search ROM Accelerator Description<br />
The search ROM Accelerator Mode presupposes that a Reset followed by the Search<br />
ROM command (0xF0h) has already been issued on the 1 – Wire® bus. For details on how the<br />
Search ROM is actually done in a 1 – Wire® system, the reader is referred to [7]. The algorithm<br />
specifies that the bus master reads two bits (a bit and its complement), then writes a bit to specify<br />
which devices should remain on the bus for further processing.<br />
After the 1 – Wire® Master is placed in Search ROM Accelerator Mode, the CPU must<br />
send 16 bytes to complete a single Search ROM pass on the 1 – Wire® bus. These bytes are<br />
constructed as shown in Figure 5.3. In this scheme, the index (values from 0 to 63, “n”)<br />
designates the position of the bit in the ROM ID of a 1 – Wire® device. The character “x” marks<br />
bits that act as a filler and do not require a specific value (i.e., don’t care bits). The character “r”<br />
119
specifies the selected bit value to write at that particular bit in case of a conflict during the<br />
execution of the ROM search.<br />
Figure 5.3 Search ROM Accelerator Mode Send Bytes.<br />
For each bit position n (values from 0 to 63), the 1 – Wire® Master will generate three<br />
time slots on the 1 – Wire® bus. These are referenced as follows:<br />
b0for the first time slot (read data)<br />
b1for the second time slot (read data) and<br />
b2for the third time slot (write data).<br />
The 1 – Wire® Master determines the type of time slot b2 (write 1 or write 0) as follows:<br />
b2 = rn if conflict (as chosen by the host)<br />
= b0 if no conflict (there is no alternative)<br />
= 1 if error (there is no response)<br />
The response bytes that will be in the data register for the CPU to read during a complete pass<br />
through a Search ROM function using the Search ROM Accelerator consists of 16 bytes as<br />
shown in Figure 5.4.<br />
120
Figure 5.4 Search ROM Accelerator Mode Response Bytes.<br />
As before, the index designates the position of the bit in the ROM ID of a 1 – Wire®<br />
device. The character “d” marks the discrepancy flag in that particular bit position. The<br />
discrepancy flag will be “1” if there is a conflict or no response in that particular bit position and<br />
“0” otherwise. The character “r” marks the actual chosen path at that particular bit position. The<br />
chosen path is identical to b2 for the particular bit position of the ROM ID.<br />
To perform a Search ROM sequence, one starts with all bits rn being zero. In the case of<br />
a bus error, all subsequent response bits r’n are 1’s until the Search Accelerator is deactivated by<br />
writing 0 to bit 1 (SRA bit) of the Command register. Thus, if r’63 and d63 are both 1, an error<br />
has occurred during the search procedure and the last sequence has to be repeated. Otherwise, r’n<br />
(n=0…63) is the ROM code of the device that has been found and addressed. When the Search<br />
ROM process is complete, the SRA bit should be cleared in order to release the 1 – Wire®<br />
Master from Search ROM Accelerator Mode.<br />
For the next Search ROM sequence, one reuses the previous set rn (n=0…63) but sets rm<br />
to 1 with “m” being the index number of the highest discrepancy flag that is 1 and sets all ri to 0<br />
121
with i > m. This process is repeated until the highest discrepancy occurs in the same bit position<br />
for two consecutive passes.<br />
5.2.4 Transmit/Receive Buffer Register<br />
Data sent and received from the 1 – Wire® Master passes through the transmit/receive<br />
buffer location (See Figure 5.5). The 1 – Wire® Master is actually double buffered with separate<br />
transmit and receive buffers. Writing to this location connects the Transmit Buffer to the data<br />
bus, while reading connects the Receive Buffer to the data bus.<br />
Figure 5.5 Transmit/Receive Buffer Register.<br />
To send a byte on the 1 – Wire® bus, the user writes the desired data to the Transmit<br />
Buffer. The data is then moved to the Transmit Shift Register where it is shifted serially onto the<br />
bus LSB first. A new byte of data can then be written to the Transmit Buffer. As soon as the<br />
Transmit Shift Register is empty, the data will be transferred from the Transmit Buffer and the<br />
process repeats. Each of these registers has a flag that may be used as an interrupt source. The<br />
Transmit Buffer Empty (TBE) flag is set when the Transmit Buffer is empty and ready to accept<br />
a new byte. As soon as a byte is written into the Transmit Buffer, TBE is cleared. The Transmit<br />
Shift Register Empty (TEMT) flag is set when the shift register has no data in it and is ready to<br />
accept a new byte. As soon as a byte of data is transferred from the Transmit Buffer, TEMT is<br />
cleared and TBE is set.<br />
122
To read data from a slave device, the device must first be ready to transmit data<br />
depending on commands already received from the CPU. Data is retrieved from the bus in a<br />
similar fashion to a write operation. The host initiates a read by writing to the Transmit Buffer.<br />
The data that is then shifted into the Receive Shift Register is the wired-<strong>AND</strong> of the written data<br />
and the data from the slave device. Therefore, in order to read a byte from a slave device, the<br />
host must write 0xFFh. When the Receive Shift Register is full, the data is transferred to the<br />
Receive Buffer where it can be accessed by the host. Additional bytes can now be read by<br />
sending 0xFFh again. If the slave device is not ready to transmit, the data received will be<br />
identical to that which was transmitted. The Receive Buffer Register can also generate<br />
interrupts. The Receive Buffer flag (RBF) is set when data is transferred from the Receive Shift<br />
Register and cleared when the host reads the register. If RBF is set, no further transmissions<br />
should be made on the 1 – Wire® bus or else data may be lost, as the byte in the Receive Buffer<br />
will be overwritten by the next received byte.<br />
5.2.5 Interrupt & Interrupt Enable Registers<br />
Flags from current status, transmit, receive, and 1 – Wire® reset operations are located in<br />
the Interrupt Register (See Figure 5.6). The Presence Detect flag (PD), OW_LOW, and<br />
OW_SHORT are cleared when the Interrupt Register is read. The other flags are cleared<br />
automatically when the Transmit and Receive Buffers are written or read. All of these flags can<br />
generate an interrupt on the INTR pin if the corresponding enable bit is set in the Interrupt<br />
Enable Register. To clear the INTR signal, the Interrupt Register must be read. Reading the<br />
Interrupt Register always sets the INTR pin inactive even if all flags are not cleared.<br />
123
Figure 5.6 Interrupt Register.<br />
OW_LOW – One Wire Low. This flag will be set to ‘1’ when the 1 – Wire® line is low<br />
while the master is in idle signaling that a slave device has issued a presence pulse on the<br />
1 – Wire® (DQ) line. A read to the Interrupt Register will clear this bit.<br />
OW_SHORT – One Wire Short. This flag will be set to a ‘1’ when the 1 – Wire® line<br />
was low before the master was able to send out the beginning of a reset or a time slot.<br />
When this flag is ‘0’, it indicates that the 1 – Wire® line was high as expected prior to all<br />
resets and time slots. Reading the Interrupt Register will clear this bit.<br />
RSRF – Receive Shift Register Full. This flag will be set to ‘1’ when there is a byte of<br />
data waiting in the Receive Shift Register. When this bit is ‘0’, it indicates that the<br />
Receive Shift Register is either empty or currently receiving data. This bit will be cleared<br />
by the hardware when data in the Receive Shift Register is transferred to the Receive<br />
Buffer. Reading the Interrupt Register will have no effect on this bit.<br />
RBF – Receive Buffer Full. This flag will be set to ‘1’ when there is a byte of data<br />
waiting to be read in the Receive Buffer. When this bit is ‘0’, it indicates that the<br />
Receive Buffer has no new data to be read. This bit will be cleared when the byte is read<br />
from the Receive Buffer. Reading the Interrupt Flag Register will have no effect on this<br />
bit. However, following a read of the Interrupt Register, while the Enable Receive Buffer<br />
Full Interrupt (ERBF) bit is set to ‘1’, if the ERBF is not cleared and the value is not read<br />
from the Receive Buffer, another instance of this interrupt will occur.<br />
124
TEMT – Transmit Shift Register Empty. This flag will be set to ‘1’ when there is<br />
nothing in the Transmit Shift Register and it is ready to receive the next byte of data to be<br />
transmitted from the Transmit Buffer. When this bit is ‘0’, it indicates that the Transmit<br />
Shift Register is busy transferring data. This bit is cleared when data is transferred from<br />
the Transmit Buffer to the Transmit Shift Register. Read the Interrupt Register will have<br />
no effect on this bit.<br />
TBE – Transmit Buffer Empty. This flag will be set to ‘1’ when there is nothing in the<br />
Transmit Buffer and it is ready to receive the next byte of data. When it is ‘0’, the<br />
Transmit Buffer is waiting for the Transmit Shift Register to finish sending its current<br />
data. This bit is cleared when data is written to the Transmit Buffer. Read the Interrupt<br />
Register will have no effect on this bit.<br />
PDR – Presence Detect Result. When a Presence Detect interrupt occurs, this bit will<br />
reflect the result of the presence detect read – it will be ‘0’ if a slave was found, or ‘1’ if<br />
no device was found. Reading the Interrupt Register will have no effect on this bit.<br />
PD – Presence Detect. After a 1 – Wire® Reset has been issued, this flag will be set to<br />
‘1’ after the appropriate amount of time has expired for a presence detect pulse to occur.<br />
This flag will be ‘0’ when the master has not issued a 1 – Wire® Reset since the previous<br />
read of the Interrupt Register. This bit is cleared when the Interrupt Register is read.<br />
The Interrupt Enable Register (See Figure 5.7) allows the system programmer to specify<br />
the source of interrupts which will cause the INTR pin to be active, and to define the active state<br />
for the INTR pin. When a Master Reset is received all bits in this register are cleared to ‘0’<br />
disabling all interrupt sources and setting the active state of the INTR pin to LOW. This means<br />
125
the INTR pin will be pulled high since all interrupts are disabled. The INTR pin is reset to an<br />
inactive state by reading the Interrupt Register.<br />
Figure 5.7 Interrupt Enable Register.<br />
EOWL – Enable One Wire Low Interrupt. Setting this bit to a ‘1’ enables the One Wire<br />
Low Interrupt. If set, INTR will be asserted when the OW_LOW flag is set. Clearing<br />
this bit disables OW_LOW as an active interrupt source.<br />
EOWSH – Enable One Wire Short Interrupt. Setting this bit to a ‘1’ enables the One<br />
Wire Short Interrupt. If set, INTR will be asserted when the OW_SHORT flag is set.<br />
Clearing this bit disables OW_SHORT as an active interrupt source.<br />
ERSF – Enable Receive Shift Register Full Interrupt. Setting this bit to a ‘1’ enables the<br />
Receive Shift Register Full Interrupt. If set, INTR will be asserted when the RSRF flag is<br />
set. Clearing this bit disables RSRF as an active interrupt source.<br />
ERBF – Enable Receive Buffer Full Interrupt. Setting this bit to a ‘1’ enables the<br />
Receive Buffer Full Interrupt. If set, INTR will be asserted when the RBF flag is set.<br />
Clearing this bit disables RBF as an active interrupt source.<br />
ETMT – Enable Transmit Shift Register Empty Interrupt. Setting this bit to a ‘1’ enables<br />
the Transmit Shift Register Empty Interrupt. If set, INTR will be asserted when the<br />
TEMT flag is set. Clearing this bit disables TEMT as an active interrupt source.<br />
126
ETBE – Enable Transmit Buffer Empty Interrupt. Setting this bit to a ‘1’ enables the<br />
Transmit Buffer Empty Interrupt. If set, INTR will be asserted when the TBE flag is set.<br />
Clearing this bit disables TBE as an active interrupt source.<br />
IAS – INTR Active State. This bit determines the active state for the INTR pin. If this<br />
bit is a ‘1’, the INTR pin is active high; if it is a ‘0’, the INTR pin is active low.<br />
EPD – Enable Presence Detect Interrupt. Setting this bit to a ‘1’ enables the Presence<br />
Detect Interrupt. If set, INTR will be asserted when the PD flag is set. Clearing this bit<br />
disables PD as an active interrupt source.<br />
5.2.6 Clock Divisor Register<br />
All 1 – Wire® timing patterns are generated using a base clock of 1.0 MHz. The 1 –<br />
Wire® Master will generate this clock frequency internally given an external reference on the<br />
CLK pin. The external clock must have a frequency from 4 to 128 MHz and a 50% duty cycle is<br />
preferred. The Clock Divisor Register controls the internal clock divider and provides the<br />
desired reference frequency. This is done in two stages: first, a prescaler divides by 1, 3, 5, or 7,<br />
and then the remaining circuitry divides by 2, 4, 8, 16, 32, 64, or 128. Figure 5.8 shows the<br />
Clock Divisor Register.<br />
Figure 5.8 Clock Divisor Register.<br />
The clock divisor must be configured before any communication on the 1 – Wire® bus<br />
can take place as well as setting the CLK_EN bit to a 1. This register is set to 0x00h when a<br />
127
master reset occurs. Table 5.2 shows how to find the proper register value based on the CLK<br />
reference frequency (i.e., if using a 40 MHz CLK reference frequency, write a value of 0x8Eh to<br />
this location).<br />
Table 5.2. Clock Divisor Register Settings for Input Clock Rates.<br />
Min CLK<br />
Frequency<br />
(MHz)<br />
5.2.7 Control Register<br />
Max CLK<br />
Frequency<br />
(MHz)<br />
Divider<br />
Ratio<br />
DIV2<br />
128<br />
DIV1<br />
DIV0<br />
PRE1<br />
PRE0<br />
4.0 < 5.0 4 0 1 0 0 0<br />
5.0 < 6.0 5 0 0 0 1 0<br />
6.0 < 7.0 6 0 0 1 0 1<br />
7.0 < 8.0 7 0 0 0 1 1<br />
8.0 < 10.0 8 0 1 1 0 0<br />
10.0 < 12.0 10 0 0 1 1 0<br />
12.0 < 14.0 12 0 1 0 0 1<br />
14.0 < 16.0 14 0 0 1 1 1<br />
16.0 < 20.0 16 1 0 0 0 0<br />
20.0 < 24.0 20 0 1 0 1 0<br />
24.0 < 28.0 24 0 1 1 0 1<br />
28.0 < 32.0 28 0 1 0 1 1<br />
32.0 < 40.0 32 1 0 1 0 0<br />
40.0 < 48.0 40 0 1 1 1 0<br />
48.0 < 56.0 48 1 0 0 0 1<br />
56.0 < 64.0 56 0 1 1 1 1<br />
64.0 < 80.0 64 1 1 0 0 0<br />
80.0 < 96.0 80 1 0 0 1 0<br />
96.0 < 112.0 96 1 0 1 0 1<br />
112.0 < 128.0 112 1 0 0 1 1<br />
Various 1 – Wire® devices utilize different communication protocols in order to properly<br />
function and report back to the master in an efficient manner. The Control Register, shown in<br />
Figure 5.9, adds the robustness needed to handle all of the major conditions expected from each<br />
iButton and 1 – Wire® chip family device.
Figure 5.9 Control Register.<br />
OD: Overdrive. Setting this bit to a ‘1’ will place the master into Overdrive mode that<br />
effectively changes the master’s 1 – Wire® timings to match those outlined for Overdrive<br />
in [75]. Clearing this bit to a ‘0’ leaves the master operating in standard mode speed.<br />
BIT_CTL: Bit Control. Setting this bit to a ‘1’ will place the master into its “Bit<br />
Banging” mode of operation. In this mode, only the least significant bit of the<br />
Transmit/Receive register will be sent or received before enabling the interrupt flags that<br />
signal the end of the transmission. Clearing this bit to ‘0’ leaves the master operating<br />
using full byte boundaries.<br />
STP_SPLY: Strong Pull-up Supply. Setting this bit to a ‘1’ while STPEN is also set to a<br />
‘1’ will enable the STPZ output while the master is in an IDLE state. This will provide a<br />
stiff supply to devices requiring high current during operations. Clearing this bit to a ‘0’<br />
disables the STPZ output while the master is in an IDLE state. The STP_SPLY bit is a<br />
don’t care bit if STPEN is set to a ‘0’.<br />
STPEN: Strong Pull-up Enable. Setting this bit to a ‘1’ enables the strong pull-up output<br />
enable (STPZ) pin’s functionality which allows this output pin to enable an external<br />
strong pull-up any time the master is not pulling the line low or waiting to read a value<br />
from a slave device. This functionality is used for meeting the recovery time requirement<br />
in Overdrive mode and long-line standard communications. Clearing this bit to a ‘0’ will<br />
disable the STPZ output pin.<br />
129
EN_FOW: Enable Force One Wire. Setting this bit to a ‘1’ will enable the functionality<br />
of the Force One Wire (FOW) register bit in the Command Register. Clearing this bit<br />
will disable the functionality of the FOW bit.<br />
PPM: Presence Pulse Masking Mode. Setting this bit to a ‘1’ will enable Presence Pulse<br />
Masking Mode. This mode causes the master to initiate the falling edge of a presence<br />
pulse during a 1 – Wire® Reset before the fastest slave would initiate one. This enables<br />
the master to prevent the larger amount of ringing caused by the slave devices when<br />
initiating a low on the DQ line. If the PPM bit is set, the PDR result bit in the Interrupt<br />
Register will always be set to a ‘0’ showing that a slave device was on the line even if<br />
there were none. Clearing this bit to a ‘0’ disables the Presence Pulse Masking Mode.<br />
LLM: Long Line Mode. Setting this bit to a ‘1’ will enable Long Line Mode timings on<br />
the 1 – Wire® line during standard mode communications. This mode effectively moves<br />
the write one release, the data sampling, and the time slot recovery times out to roughly<br />
8µs, 22µs, and 14µs respectively. This provides a less strict environment for long line<br />
transmissions. Clearing this bit to a ‘0’ leaves the write one release, the data sampling,<br />
and the time slot recovery times at roughly 5µs, 15µs, and 7µs respectively [76].<br />
5.2.8 Verification of 1 – Wire® Module<br />
To verify proper operation of the synthesizable 1 – Wire® Master, four test cases were<br />
executed: Single One-Wire Network (single_search_rom), Multiple One-Wire Network<br />
(multi_ow_network), Scratchpad Memory (scratchpad_integrity), and a Command Recognition<br />
test (cmd_recognition). All tests were compiled and simulated using Altera Quartus II 9.1 (32-<br />
130
it) and ModelSim Altera Starter Edition 6.6c software on a PC executing Windows XP Service<br />
Pack 3. All tests performed were performed extensively while trying to cover all possible<br />
combinations of inputs and outputs for the 1 – Wire® Master. No failures were observed for any<br />
of the four tests described below. The source code for all modules, testbench code, and<br />
simulation results are located on the DVD included with this work. Table 5.3 shows FPGA<br />
resource utilization for the Altera DE2 Development and Education board.<br />
Table 5.3 Resource Utilization.<br />
Revision Name one_wm<br />
Family Cyclone II<br />
Device EP2C35F672C6<br />
Timing Models Final<br />
Met timing requirements Yes<br />
Total logic elements 435 / 33,216 ( 1 % )<br />
Total combinational functions 425 / 33,216 ( 1 % )<br />
Dedicated logic registers 145 / 33,216 ( < 1 % )<br />
Total registers 145<br />
Total pins 20 / 475 ( 4 % )<br />
Total virtual pins 0<br />
Total memory bits 0 / 483,840 ( 0 % )<br />
Embedded Multiplier 9-bit element 0 / 70 ( 0 % )<br />
Total PLLs 0 / 4 ( 0 % )<br />
Each one_wm transaction consists of the following instruction sequence: 1 – Wire®<br />
Reset, a device addressing instruction, and a data access instruction. A 1 – Wire® Reset consists<br />
of generating a 1 – Wire® Reset/Presence Detect pulse on the 1 – Wire® bus. The state of the 1<br />
– Wire® bus is then sampled and a value of ‘1’ is returned if no Presence Detect pulse was found<br />
and a value of ‘0’ is returned otherwise (i.e. slave device(s) found).<br />
A device addressing instruction may be one of the following: READ_ROM (0x33),<br />
MATCH_ROM (0x55), SKIP_ROM (0xCC), OD_SKIP_ROM (0x3C), or OD_MATCH_ROM<br />
(0x69).<br />
131
READ_ROM – Used to read the 64-bit ROM ID directly. It can only be used on a 1 –<br />
Wire® network where there is only one device attached. If there are several slave<br />
devices connected to the bus, the result of this command will be the <strong>AND</strong> result of all<br />
slave device identifiers. Assuming that communication is flawless, the presence of<br />
several slaves is indicated by a failed CRC.<br />
MATCH_ROM – Used to address individual slave devices on the bus. After this<br />
command is issued, the complete 64-bit identifier is transmitted on the bus. When this is<br />
done, only the device with exactly this identifier is allowed to answer until the next reset<br />
pulse is received.<br />
SKIP_ROM – Used when no specific slave is targeted. On a one-slave bus, this<br />
command is sufficient for addressing. On a multiple-slave bus, this command can be<br />
used to address all devices at once. This is only useful when sending commands to slave<br />
devices, e.g. to start temperature conversions on several temperature sensors at once. It is<br />
not possible to use the SKIP_ROM command when reading from slave devices on a<br />
multiple-slave bus.<br />
OD_SKIP_ROM – This command is similar to the SKIP_ROM command but it not only<br />
selects devices, it also sets those devices to the Overdrive communication rate. This is<br />
most often used to set all capable 1 – Wire® slave devices to Overdrive speed. After the<br />
devices are communicating in Overdrive, the ROM IDs can be discovered using the<br />
conventional Search Rom sequence.<br />
OD_MATCH_ROM – This command is identical to the MATCH_ROM command but it<br />
also switches the device to the Overdrive communication speed.<br />
132
A data access instruction may be one of the following: WRITE_SP (0x0F), READ_SP<br />
(0xAA), COPY_SP (0x55), and READ_MEM (0xF0).<br />
WRITE_SP – The Write Scratchpad command applies to the data memory and the<br />
writeable addresses in the register page of 1 – Wire® slave devices. After issuing the<br />
Write Scratchpad command, the bus master must provide a 2-byte target address<br />
followed by the data to be written to the scratchpad.<br />
READ_SP – The Read Scratchpad command allows the 1 – Wire® Master to read the<br />
contents of the scratchpad. The data transfer starts with the least significant bit of byte 0<br />
and continues through the scratchpad until the ninth byte (byte 8 – CRC) is read. The 1 –<br />
Wire® Master may issue a reset to terminate at any time if only part of the scratchpad<br />
data is needed.<br />
COPY_SP – The Copy Scratchpad command is used to copy data from the scratchpad of<br />
the slave device to the memory of the slave device. After issuing the copy scratchpad<br />
command, the master must provide a 3-byte authorization pattern which is obtained by<br />
reading the scratchpad for verification.<br />
READ_MEM – The Read Memory command is used to read data from 1 – Wire® slave<br />
devices that support EEPROM. The bus master follows the command byte with a two<br />
byte address that indicates a starting byte location within the EEPROM data field. With<br />
every subsequent read data time slot, the bus master receives data starting at the initial<br />
address and continuing until the end of the EEPROM data field is reached or until a Reset<br />
Pulse is issued.<br />
133
5.2.8.1 Single Search ROM (single_search_rom) Test<br />
This test checks the Search ROM Accelerator algorithm described in section 2.3.6 and<br />
also proper operation of the device addressing instruction READ_ROM (0x33). For this test<br />
configuration there is a single 1 – Wire® slave device on the network with an Altera DE2<br />
Development and Education board serving as the 1 – Wire® Master. Figure 5.10 shows the<br />
setup configuration used to conduct this test. Any configurable FPGA I/O pin on the DE2 board<br />
can serve as the 1 – Wire® Master I/O pin. Multiple iButton Probe Cables were used to test<br />
connectivity of a variety of 1 – Wire® slave devices (both single and multi-function), including<br />
parasitically and non-parasitically powered slaves. Additionally, while conducting the test, the 1<br />
– Wire® devices listed in Table 5.4 were hot swapped to ensure reliability and integrity in the<br />
design of the 1 – Wire® network. The test results, summarized in Table 5.4, verified that the<br />
correct single ROM_ID was found by the Search ROM Accelerator algorithm.<br />
Figure 5.10 Single Search ROM Test Setup.<br />
Table 5.4 Single Search ROM (single_search_rom) Test Results.<br />
1 – Wire® Device Type 1 – Wire Probe Cables Length of test Hot Swapped Failures<br />
DS1990A[77]/DS1990R[78] DS9092L[79], DS1402-<br />
Yes None<br />
DS1994[82] BR8+[80] with DS1401-4[81],<br />
Yes None<br />
DS1996[83] DS1402D-DR8+[80],<br />
30 min<br />
Yes None<br />
DS1904[84] DS1402-RP8+[80], DS1402-<br />
Yes None<br />
DS1972[85] RP3+[80]<br />
Yes None<br />
DS1822-PAR 1 [86]/ DS2431 1 [87] See Note 1 30 min Yes None<br />
1<br />
This device is a 3-pin TO-92 Package and was interfaced utilizing a breadboard.<br />
134
5.2.8.2 Multiple One-Wire Network (multi_ow_network) Test<br />
The multi_ow_network test is an extension of the single_search_rom test conducted in<br />
section 5.2.8.1. To perform this test, three 1 – Wire® slave devices, each from a different family<br />
code, were connected in the test configuration shown in Figure 5.11. Again for this test<br />
configuration, the Altera DE2 Development and Education board serves as the 1 – Wire®<br />
Master. Any configurable I/O pin on the DE2 board can serve as the 1 – Wire® Master I/O pin.<br />
The three slave devices were connected to the 1 – Wire Master using a DS1402-BR8+ 1 –<br />
Wire® network cable [80] in conjunction with a DS1401-4 front panel iButton holder [81].<br />
While conducting the test, the 1 – Wire® devices listed in Table 5.5 were hot swapped (one, two,<br />
and three at a time) to ensure proper operation of the 1 – Wire® network and that no additional<br />
pull-up or drive circuitry was needed. The test results, summarized in Table 5.5, verified that the<br />
correct ROM_IDs were found by the Search ROM Accelerator algorithm.<br />
Figure 5.11 Multiple One-Wire Network Test Setup.<br />
Table 5.5 Multiple One-Wire Network (multi_ow_network) Test Results.<br />
1 – Wire® Device Type 1 – Wire Probe Cables Length of test Hot Swapped Failures<br />
DS1990A[77]/DS1990R[78]<br />
Yes None<br />
DS1994[82]<br />
DS1996[83]<br />
DS1904[84]<br />
DS1402-BR8+[80] with<br />
DS1401-4[81]<br />
60 min<br />
Yes<br />
Yes<br />
Yes<br />
None<br />
None<br />
None<br />
DS1972[85] Yes None<br />
135
5.2.8.3 Scratchpad Memory (scratchpad_integrity) Test<br />
The scratchpad memory in a 1 – Wire® slave device is written to and read from using the<br />
WRITE_SP (0x0Fh) and READ_SP (0xAAh) commands. The eight bytes of data being written<br />
are random and are stored at the bus functional model (i.e. Verilog® code software) while also<br />
being written to the one_wm block and sent across to the 1 – Wire® slave device. The data<br />
written to the slave device is then read back and compared to the previously stored value in the<br />
bus functional model. This test also verifies proper operation of the device addressing<br />
instruction SKIP_ROM (0xCC).<br />
For the eight bytes of random data the Verilog® statistical function $random() was used.<br />
The $random() function returns a new 32-bit random number each time it is called. The return<br />
type is a signed integer. An optional seed_expression can be used to control the random number<br />
generation and must be a signed integer value, a register, or a time variable. Additionally the<br />
modulus operator % can be used to restrict the return value (i.e. for b > 0,<br />
$random(seed_expression) %b will restrict the random number returned to (-b + 1) : (b – 1) [88].<br />
For this test only a single 1 – Wire® slave exists on the 1 – Wire® network. Figure 5.12<br />
shows the setup configuration used to conduct this test. Just like the previous test cases, any<br />
configurable FPGA I/O pin on the Altera DE2 Development and Education board can serve as<br />
the 1 – Wire Master I/O pin. Only 1 – Wire® devices having an internal scratchpad area in<br />
memory were used to conduct this test (See Table 5.6). As was done in the previous tests, the 1<br />
– Wire® devices listed in Table 5.6 were hot swapped during execution of the test to check for<br />
data integrity and failures in the design of the 1 – Wire® network. The test results, summarized<br />
in Table 5.6, verified that the correct single ROM_ID was found by the Search ROM Accelerator<br />
136
algorithm. In addition to this, correct operation was also tested for the WRITE_SP (0x0Fh),<br />
READ_SP (0xAAh), and SKIP_ROM (0xCC) commands.<br />
Figure 5.12 Scratchpad Memory Test Setup.<br />
Table 5.6 Scratchpad Memory (scratchpad_integrity) Test Results.<br />
1 – Wire® Device Type 1 – Wire Probe Cables Length of test Hot Swapped Failures<br />
DS1963S[89]<br />
Yes No<br />
DS1994[82] Yes No<br />
DS1996[83] DS1402-RP8+[80] 60 min<br />
Yes No<br />
DS1995[90] Yes No<br />
DS1972[85] Yes No<br />
Not to be misleading, the absence of failures in Table 5.6 is only due to the fact that a<br />
single 1 – Wire® device exists and the SKIP_ROM (0xCC) command was used instead of the<br />
READ_ROM (0x33) command. The SKIP_ROM (0xCC) command can save time in a single<br />
slave system by allowing the 1 – Wire® Master to access the memory functions without<br />
providing the 64-bit ROM_ID code. So in this case hot swapping would be successful since the<br />
1 – Wire® Master would not care about the 1 – Wire® slave device ROM_ID code it was<br />
addressing. If more than a single 1 – Wire® slave device had been present on the 1 – Wire®<br />
network, it is possible that failures could have occurred. Since the SKIP_ROM (0xCC)<br />
command is typically used to select all devices regardless of their ROM_ID, more testing under<br />
circumstances with multiple 1 – Wire® slave devices is needed for conclusive evidence on<br />
failure rates in this case.<br />
137
5.2.8.4 Command Recognition (cmd_recognition) Test<br />
This test checks all of the basic commands shared by almost every family of 1 – Wire®<br />
devices available on the commercial market today. These commands include: READ_ROM<br />
(0x33), SKIP_ROM (0xCC), MATCH_ROM (0x55), SEARCH_ROM (0xF0), WRITE_SP<br />
(0x0F), READ_SP (0xAA), OD_SKIP_ROM (0x3C), OD_MATCH_ROM (0x69), COPY_SP<br />
(0x55), and READ_MEM (0xF0). The command recognition test also checks 1 – Wire® reset,<br />
overdrive reset, strong pullup enable, active high and low interrupts and some of the divisor<br />
clock frequencies from 4 MHz up to 112 MHz (see Table 5.2).<br />
Due to the amount of time required to run a complete test with all commands and full<br />
range of clock frequencies, there is only a single 1 – Wire® slave device on the network. Only 1<br />
– Wire® devices capable of supporting overdrive speeds and having an internal scratchpad area<br />
in memory were used to conduct this test (See Table 5.7). The setup configuration, shown in<br />
Figure 5.12, uses any configurable I/O pin on the Altera DE2 Development and Education board<br />
to serve as the 1 – Wire® Master. Unlike the other tests run in sections 5.2.8.1 – 5.2.8.3, hot<br />
swapping of 1 – Wire® slave devices was not performed while running this test. The main goals<br />
of this test were to check the functionality and reliability of the different 1 – Wire® commands,<br />
as listed above, and the commands required to have a reliable 1 – Wire® Master capable of<br />
driving long 1 – Wire® networks. The test results, summarized in Table 5.7, verified correct<br />
operation.<br />
Table 5.7 Command Recognition (cmd_recognition) Test Results.<br />
1 – Wire® Device Type 1 – Wire Probe Cables Length of test Hot Swapped Failures<br />
DS1963L[91]<br />
~120 min No No<br />
DS1921G[92] ~120 min No No<br />
DS1996[83]<br />
DS1995[90]<br />
DS1402-RP8+[80]<br />
~120 min<br />
~120 min<br />
No<br />
No<br />
No<br />
No<br />
DS1977[93] ~120 min No No<br />
DS1922L[94] ~120 min No No<br />
138
5.3 CAN (Controller Area Network) FPGA Implementation<br />
For the FPGA implementation of the CAN Controller, the Bosch VHDL Reference System<br />
was used as a guide and verification test tool. Some of the features incorporated into the design<br />
are:<br />
Implementation of the Basic CAN specification.<br />
Receiving and transmitting of 11 and 29-bit identifiers.<br />
Programmable baud rate prescaler (up to 1/256).<br />
Up to 1 Mbit/sec speeds of operation.<br />
Message based filtering and addressing.<br />
Non-Destructive bitwise arbitration (CSMA/CA).<br />
Readable Error Counters.<br />
Maskable Error and Status Interrupts.<br />
Figure 5.13 contains a block diagram of a CAN Controller showing only the major<br />
blocks. It is designed to be memory-mapped into any system and is based on the Motorola<br />
CAN (MCAN) Module [95 – 97]. All hardware modules necessary to implement the CAN<br />
Transfer Layer (Bit Stream Processor and Bit Timing Logic) are included, representing the<br />
kernel of the CAN bus protocol as defined by Bosch GmbH, the originators of the CAN<br />
specification. From Figure 5.13, the hardware modules are defined as follows:<br />
IML – The Interface Management Logic unit interprets the commands from the CPU,<br />
controls allocation of both transmit and receive buffers, and supplies interrupts and status<br />
information to the CPU via the Controller Interface Logic (CIL) Unit (See Figure 5.14).<br />
139
TBF – The Transmit Buffer provides an interface between the CPU and the Bit Stream<br />
Processor (BSP) and is able to store a complete message. The buffer is written by the<br />
Figure 5.13 CAN Controller Block Diagram [98].<br />
CPU and read by the BSP. The TBF is 10 bytes long and holds the identifier (1 byte), the<br />
Control Field (1 byte) and the Data Field (maximum length of 8 bytes) (i.e., a complete<br />
message and identifier).<br />
RBF – The Receive Buffer is an interface between the BSP and the CPU and stores a<br />
message received from the CAN bus line. Once filled by the BSP and allocated to the<br />
CPU by the IML, the Receive Buffer cannot be used to store subsequent received<br />
messages until the CPU has acknowledged the reading of the buffer’s contents. Thus,<br />
unless the CPU releases an RBF within a protocol-defined time frame, future messages to<br />
140
e received may be lost. To reduce the requirements on the CPU, two receive buffers<br />
(RBF0 and RBF1) are implemented. While one receive buffer is allocated to the CPU,<br />
the BSP may write to the other buffer. RBF0 and RBF1 are each 10 bytes long and hold<br />
the Identifier (1 byte), the Control Field (1 byte) and the Data Field (maximum length of<br />
8 bytes). The BSP only writes into a receive buffer when the message being received or<br />
transmitted has an Identifier which passes the Acceptance Filter.<br />
BSP – This is a sequencer controlling the data stream between the Transmit and Receive<br />
Buffers (parallel data) and the CAN (serial data). The BSP also controls the<br />
Transceive Logic (TCL) and the Error Management Logic (EML) such that the processes<br />
of reception, arbitration, transmission and error signaling are performed according to the<br />
protocol and the bus rules. The BSP also provides signals to the IML indicating when a<br />
Receive Buffer contains a valid message and when the Transmit Buffer is no longer<br />
required after a successful transmission. The automatic retransmission of messages,<br />
which have been corrupted by noise or other external conditions on the bus line, is<br />
effectively handled by the BSP.<br />
BTL – The Bit Timing Logic block monitors the CAN bus line using an input<br />
comparator and handles the CAN bus line related bit timing. The BTL synchronizes<br />
on a recessive-to-dominant bus line transition at the Start of Frame (hard<br />
synchronization), and resynchronizes on further transitions during reception of a frame<br />
(soft synchronization). A programmable control bit in the CPU determines which edges<br />
are used for resynchronization. The BTL also provides programmable time segments to<br />
141
compensate for the propagation delay times and phase shifts and to define the sampling<br />
time and the number of samples (1 or 3) within the bus time slot.<br />
TCL – The Transceive Logic unit is a generic term for a group of logic elements<br />
consisting of a programmable output driver, bit stuff logic, CRC logic and the transmit<br />
shift register. The coordination of these components is controlled by the BSP.<br />
EML – The Error Management Logic unit is responsible for the error confinement of the<br />
CAN module. It receives notification of errors from the BSP and then informs the<br />
BSP, TCL, and IML about error statistics [98].<br />
Up to the message level, the CAN module presented here is totally compatible with<br />
CAN Specification 2.0 Part A. The functional differences are related to the object layer only.<br />
Whereas a full CAN Controller provides dedicated hardware for handling a set of messages,<br />
the implementation presented here is restricted to receiving and/or transmitting messages on a<br />
message by message basis. Also, the controller presented here will never initiate an Overload<br />
Frame. If the module starts to receive a valid message (i.e., one that passes the Acceptance<br />
Filter) and there is no receive buffer available for it, then the Overrun Flag in the CPU Status<br />
Register will be set. The module, will however, respond to Overload Frames generated by other<br />
CAN nodes, as required by the CAN protocol specifications.<br />
To be able to function as a serial communication interface, the CAN Controller<br />
Module, shown in Figure 5.13, itself has to be supplemented by an additional module, the<br />
Controller Interface Logic Unit (CIL). The CIL is an integral part of any CAN system or<br />
stand-alone CAN Controller. The CIL, shown in Figure 5.14, links the CAN Module to the<br />
142
CPU or external microcontroller and connects the CPU busses to the CAN busses. It also<br />
generates internal control signals from internal CPU signals.<br />
Figure 5.14 Controller Interface Logic Unit (CIL) [95 – 96].<br />
The control lines are comprised of a reset input line and an interrupt line. In addition to<br />
the control lines are the 8-bit multiplexed address/data bus lines. Together these lines, which are<br />
tied back to the IML Unit of the CAN Controller Module, aid in the interpretation of<br />
commands from the CPU, help control the allocation of the message buffers (both Tx and Rx),<br />
and supply interrupt and status information to the CPU via the CIL.<br />
5.3.1 Register Map and Address Allocation<br />
The CAN Controller Module memory map is shown in Figure 5.15. There are three<br />
main register blocks discussed here: control registers (10 bytes), transmit buffer (10 bytes), and<br />
receive buffer (10 bytes). The individual registers in each of these blocks will be described in<br />
the sections to follow.<br />
143
Figure 5.15 CAN Module memory map [95 – 96].<br />
5.3.2 CAN Module Control Registers Overview<br />
The interchange of commands, status and control signals between the microprocessor and<br />
the CAN Module takes place via the control registers. The layout of these registers is shown<br />
in Table 5.8.<br />
144
Table 5.8 Control Registers [95 – 96].<br />
Register Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />
Control (CCNTRL) 10h X SPD X OIE EIE TIE RIE RR<br />
Command (CCOM) 11h RX0 RX1 COMP-SEL SLEEP COS RRB AT TR<br />
Status (CSTAT) 12h BS ES TS RS TCS TBA DO RBS<br />
Interrupt (CINT) 13h X X X WIF OIF EIF TIF RIF<br />
Acceptance code (CACC) 14h AC7 AC6 AC5 AC4 AC3 AC2 AC1 AC0<br />
Acceptance mask (CACM) 15h AM7 AM6 AM5 AM4 AM3 AM2 AM1 AM0<br />
Bus timing 0 (CBT0) 16h SJW1 SJW0 BRP5 BRP4 BRP3 BRP2 BRP1 BRP0<br />
Bus timing 1 (CBT1) 17h SAMP TSEG-22 TSEG-21 TSEG-20 TSEG-13 TSEG-12 TSEG-11 TSEG-10<br />
Output Control (COCNTRL) 18h OCT-P1 OCT-N1 OCPOL1 OCT-P0 OCT-N0 OCPL0 OCM1 OCM0<br />
Test Register 19h X X X X X X X X<br />
Note: The acceptance code register, acceptance mask register, bus timing register 0, bus timing<br />
register 1 and the output control register are only accessible when the RESET REQUEST<br />
(RR) bit in the CAN control register (CCNTRL) is set. It is not foreseen that these<br />
registers will be referenced again after the initial reset sequence [95].<br />
5.3.3 CAN Module Control Register (CCNTRL)<br />
The Control Register, shown in Figure 5.16, provides the local mask bits for the CAN<br />
Module interrupts. In addition, it contains the Reset Request (RR) bit, which is set to disable the<br />
CAN Module operation and allow access to the message filtering, bus timing and output<br />
control registers [96]. This register may be read or written by the microprocessor; only the RR<br />
bit is affected by the CAN Module.<br />
Figure 5.16 CAN Control Register.<br />
SPD: Speed Mode. When this bit is set to ‘1’, slow speed mode will be used for<br />
resynchronization. Bus line transitions from both recessive to dominant and from<br />
dominant to recessive will be used for resynchronization. When this bit is cleared, set to<br />
145
‘0’, fast speed mode will be used for resynchronization. Only transitions from recessive<br />
to dominant will be used for resynchronization.<br />
OIE: Overrun Interrupt Enable. Setting this bit to a ‘1’ enables the CPU to get an<br />
interrupt request whenever the Overrun Status bit gets set. Setting this bit to a ‘0’ will<br />
prevent the CPU from getting an overrun interrupt request.<br />
EIE: Error Interrupt Enable. Setting this bit to a ‘1’ enables the CPU to get an interrupt<br />
request whenever the error status or bus status bits in the CSTAT register change. Setting<br />
this bit to a ‘0’ disables the CPU from receiving error interrupt requests.<br />
TIE: Transmit Interrupt Enable. If enabled (set to a ‘1’), the CPU will get an interrupt<br />
request whenever a message has been successfully transmitted, or when the transmit<br />
buffer is accessible again following an ABORT command. If disabled (set to a ‘0’), the<br />
CPU will not get a transmit interrupt request.<br />
RIE: Receive Interrupt Enable. Setting this bit to a ‘1’ will enable the CPU to get an<br />
interrupt request whenever a message has been received free of errors. If set to a ‘0’, the<br />
CPU will not get a receive interrupt request.<br />
RR: Reset Request. If the RR bit is set, the CAN Module aborts the current<br />
transmission or reception of a message and enters the reset state. A reset request may be<br />
generated by an external reset, by the CPU, or by the CAN Module itself. The RR bit<br />
can only be cleared by the CPU. After the RR bit has been cleared, the CAN Module<br />
will begin normal operation in one of two ways. If RR was generated by an external reset<br />
or by the CPU, then the CAN Module starts normal operation after the first occurrence<br />
of 11 recessive bits. If, however, the RR was generated by the CAN Module due to the<br />
146
BS (CAN Status Register (CSTAT) Bus Status bit) bit being set, the CAN Module<br />
waits for 128 occurrences of 11 recessive bits before starting normal operation.<br />
5.3.4 CAN Module Command Register (CCOM)<br />
The Command Register, shown in Figure 5.17, is a write only register which contains the<br />
Release Receive Buffer (RRB) and Transmit Request (TR) bits. Bits RX0, RX1, and COMP-<br />
SEL are used to control the input comparator configuration, allowing it to operate correctly for<br />
single-wire (not implemented yet) and differential modes of operation [96]. A read of this<br />
register location will always return a value of $FF. This register may be written only when the<br />
RR bit in CCNTRL is clear.<br />
Figure 5.17 CAN Command Register.<br />
RX0: Receive Pin 0. When this bit is set to a ‘1’, VDD/2 will be connected to the input<br />
comparator. The RX0 pin is disconnected. When this bit is set to a ‘0’, the RX0 pin will<br />
be connected to the input comparator. VDD/2 is then disconnected.<br />
RX1: Receive Pin 1. Setting this bit to a ‘1’ will connect VDD/2 to the input comparator<br />
and disconnect the RX1 pin. Setting this bit to a ‘0’ will connect the RX1 pin to the input<br />
comparator and disconnect VDD/2. If, however, both RX0 and RX1 are set, or both are<br />
clear, then neither of the RX pins will be disconnected.<br />
147
COMP-SEL: Comparator Select. When this bit is set to a ‘1’, RX0 and RX1 will be<br />
compared with VDD/2 during sleep mode. Setting this bit to a ‘0’ will cause RX0 to be<br />
compared with RX1 during sleep mode.<br />
SLEEP: Sleep Mode. Setting this bit to a ‘1’ will cause the CAN Module to enter<br />
sleep mode, as long as there are no interrupts pending and there is no activity on the bus.<br />
Otherwise, the CAN Module will issue a wake-up interrupt. Setting this bit to a ‘0’<br />
will cause the CAN Module to function normally. If the SLEEP bit is cleared by the<br />
CPU, then the CAN Module will wake up, but will not issue a wake-up interrupt. If<br />
the SLEEP bit gets set during the reception or transmission of a message, the CAN<br />
Module will generate an immediate wake-up interrupt. This will have no effect on the<br />
transfer layer (i.e., no message will be lost or get corrupted). Any node that was sleeping<br />
and has been awakened by bus activity will not be able to receive any messages until its<br />
oscillator has started and it has found a valid end of frame sequence (11 recessive bits).<br />
COS: Clear Overrun Status. Setting this bit to a ‘1’ clears the read-only overrun status<br />
bit in the CSTAT (CAN Status Register) register. It may be written at the same time as<br />
the Release Receive Buffer (RRB) bit. Setting this bit to a ‘0’ causes no action to be<br />
performed.<br />
RRB: Release Receive Buffer. When set to a ‘1’, this bit releases the receive buffer<br />
attached to the CPU, allowing the buffer to be reused by the CAN Module. This may<br />
result in another message being received, which could cause another receive interrupt<br />
request (if RIE is set). This bit is cleared automatically when a message is received, i.e.<br />
148
when the RS bit (see CSTAT register – Section 5.3.5) becomes set. Setting this bit to a<br />
‘0’ causes no action to be performed.<br />
AT: Abort Transmission. When this bit is set to a ‘1’, a pending message transmission<br />
will be cancelled if it is not already in progress. This allows the transmit buffer to be<br />
loaded with a new, higher priority message when the buffer is released. If the CPU tries<br />
to write to the buffer when it is locked, the information will be lost without being<br />
signaled. The status register can be checked to see if transmission was aborted or is still<br />
in progress. Setting this bit to a ‘0’ has no effect.<br />
TR: Transmission Request. When this bit is set to a ‘1’, a data frame or a remote frame<br />
will be transmitted depending on the transmission buffer’s contents. Setting this bit to a<br />
‘0’ has no effect. It will not cancel a previously requested transmission; the abort<br />
transmission request bit must be used to do this.<br />
5.3.5 CAN Module Status Register (CSTAT)<br />
The Status Register, shown in Figure 5.18, provides information on a number of<br />
conditions which can occur in the CAN Module. This includes information on the status of<br />
the last requested transmission, incoming messages and the availability of the Transmit Buffer<br />
for acceptance of new messages for transmission. It also provides a flag to indicate the module<br />
‘off bus’ state and provides limited information on the status of the error counters [96]. This<br />
register is a read only register and only the CAN Module can change its contents.<br />
149
Figure 5.18 CAN Status Register.<br />
BS: Bus Status. This bit is set to a ‘1’ (off-bus) by the CAN Module when the transmit<br />
error counter reaches 256. The CAN Module will then set the RR bit (CCNTRL<br />
Register) and will remain off-bus until the CPU clears RR again. At this point the<br />
CAN Module will wait for 128 successive occurrences of a sequence of 11 recessive<br />
bits before clearing the BS bit and resetting the read and write error counters. While in<br />
the off-bus state, the CAN Module does not take part in bus activities. A value of ‘0’<br />
means the CAN Module is operating normally.<br />
ES: Error Status. This bit is set automatically to a ‘1’ when either the read or the write<br />
error counter has reached the predefined CPU warning limit of 127. A value of ‘0’<br />
indicates that neither of the error counters has reached the predefined warning limit.<br />
TS: Transmit Status. The CAN Module will set this bit to a ‘1’ when it has started to<br />
transmit a message. If, in addition to this bit having a value of ‘0’, the Receive Status bit<br />
(RS) is also clear, then the CAN Module is idle; otherwise it is in receive mode.<br />
RS: Receive Status. This bit is set to a ‘1’ when the CAN Module has entered the<br />
receive mode from idle, or by losing arbitration during message transmission. If the<br />
Transmit Status bit (TS) is also clear, then the CAN Module is idle; otherwise it is in<br />
transmit mode.<br />
TCS: Transmit Complete Status. This bit is cleared by the CAN Module when the TR<br />
bit is set (bit 0 CCOM register). When TCS is set to a ‘1’, it indicates that the last<br />
150
equested transmission was successfully completed. If, after TCS is cleared, but before<br />
transmission begins, an abort transmission command is issued then the transmit buffer<br />
will be released and TCS will remain clear. TCS will then only be set after a further<br />
transmission is both requested and successfully completed.<br />
TBA: Transmit Buffer Access. When clear, the transmit buffer is locked and cannot be<br />
accessed by the CPU. This indicates that either a message is being transmitted or is<br />
awaiting transmission. If the CPU writes to the transmit buffer while it is locked, then<br />
the data will be lost without this being signaled. While set to a ‘1’, the transmit buffer<br />
may be written to by the CPU.<br />
DO: Data Overrun. While clear, this bit indicates normal operation. This bit is set when<br />
both receive buffers are full and there is a further message to be stored. In this case the<br />
new message is dropped, but the internal logic maintains the correct protocol. The<br />
CAN Module does not receive the message, but no warning is sent to the transmitting<br />
node. The CAN Module clears the DO bit when the CPU sets the COS bit in the<br />
CCOM register. Data overrun can also be caused by a transmission, since the CAN<br />
Module will temporarily store an outgoing frame in a receive buffer in case arbitration is<br />
lost during transmission.<br />
RBS: Receive Buffer Status. This bit is set to a ‘1’ by the CAN Module when a new<br />
message is available. When clear this indicates that no message has become available<br />
since the last RRB (bit 2 of the CCOM register) command. The bit is cleared when RRB<br />
is set. However, if the second receive buffer already contains a message, then control of<br />
151
that buffer is given to the CPU and RBS is immediately set again. The first receive<br />
buffer is then available for the next incoming message from the CAN Module.<br />
5.3.6 CAN Module Interrupt Register (CINT)<br />
The CAN Module has only one interrupt vector assigned to it. The Interrupt Register,<br />
shown in Figure 5.19, can be read to determine the source of a CAN interrupt. The five<br />
interrupt sources include: Wake Up, Data Overrun (a third message being received before either<br />
of the Receive Buffers have been released), Error (either read or write error counter reaching a<br />
pre-determined level), Transmission Complete, and Receive Interrupt [96]. All bits of this<br />
register are read only; all are cleared by a read of this register. However, this register must be<br />
read in the interrupt handling routine in order to enable further interrupts.<br />
Figure 5.19 CAN Interrupt Register.<br />
WIF: Wake-Up Interrupt Flag. If the CAN module detects bus activity while it is in<br />
the SLEEP state, it clears the SLEEP in the CCOM register; the WIF bit will then be set.<br />
WIF is cleared by reading the CAN Interrupt Register (CINT), or by an external reset.<br />
OIF: Overrun Interrupt Flag. When OIE (bit 4 of CCNTRL register) is set this bit will<br />
be set when a data overrun condition is detected. Like all the bits in this register, OIF is<br />
cleared by reading the register, or when an external reset request is set.<br />
EIF: Error Interrupt Flag. When EIE (bit 3 of CCNTRL register) is set then this bit will<br />
be set by a change in the error or bus status bits in the CAN module status register.<br />
152
Like all the bits in this register, EIF is cleared by reading the register, or by an external<br />
reset.<br />
TIF: Transmit Interrupt Flag. The TIF bit is set at the end of a transmission whenever<br />
both the TBA (bit 2 of CSTAT register) and TIE (bit 2 of CCNTRL register) bits are set.<br />
Like all the bits in this register, TIF is cleared by reading the register, or when reset<br />
request is set.<br />
RIF: Receive Interrupt Flag. The RIF bit is set by the CAN Module when a new<br />
message is available in the receive buffer, and the RIE bit in CCNTRL is set. At the<br />
same time the RBS bit in the CSTAT register also gets set, indicating a new message is<br />
available. Like all the bits in this register, RIF is cleared by reading the register, or when<br />
reset request is set.<br />
5.3.7 CAN Module Acceptance Code Register (CACC)<br />
The Acceptance Code and Acceptance Mask Registers are used to provide limited<br />
message filtering on the eight most significant bits of the identifier. The Acceptance Mask<br />
Register defines which bits of the Acceptance Code Register are compared with the identifier of<br />
the incoming message. If the CAN Module receives a message with an identifier which does<br />
not meet its acceptance criterion, then it will respond by transmitting a dominant bit in the<br />
correct position of the ACK field, but will not transfer the message to the receive buffers or<br />
indicate to the CPU that a new message has been received [96].<br />
On reception each message is written into the current receive buffer. The CPU is only<br />
signaled to read the message however, if it passes the criteria in the Acceptance Code and<br />
153
Acceptance Mask Registers (accepted); otherwise, the message will be overwritten by the next<br />
message (dropped). Shown in Figure 5.20, this register can only be accessed when the RR bit in<br />
the CCNTRL register is set.<br />
Figure 5.20 CAN Acceptance Code Register.<br />
AC7 – AC0: Acceptance Code Bits. These bits comprise a user defined sequence of bits<br />
with which the 8 most significant bits of the message identifier (ID10 – ID3) are<br />
compared. The result of this comparison is then masked with the Acceptance Mask<br />
Register. Once a message has passed the acceptance criterion the respective identifier,<br />
data length code and data are sequentially stored in a receive buffer, providing there is<br />
one free. If there is no free buffer, the data overrun condition will be signaled. On<br />
acceptance the receive buffer status bit is set to full and the receive interrupt bit is set<br />
(provided RIE=enabled).<br />
5.3.8 CAN Module Acceptance Mask Register (CACM)<br />
The Acceptance Mask Register, shown in Figure 5.21, specifies which of the<br />
corresponding bits in the Acceptance Code Register are relevant for acceptance filtering. This<br />
register can only be accessed when the RR bit in the CCNTRL register is set. When a particular<br />
bit in this register is clear, this indicates that the corresponding bit in the Acceptance Code<br />
Register must be the same as its corresponding identifier bit, before a match will be detected.<br />
The message will be accepted if all such bits match. When a bit is set, it indicates that the state<br />
154
of the corresponding bit in the Acceptance Code Register will not affect whether or not the<br />
message is accepted.<br />
Figure 5.21 CAN Acceptance Mask Register.<br />
5.3.9 CAN Module Bus Timing Register 0 (CBT0)<br />
The CAN Bus Timing Registers are used to select a suitable baud rate prescaler value<br />
to provide an appropriate system clock cycle time (tSCL) value, which is then used to derive the<br />
bit time and position of the sample point within the bit. Figure 3.11 (See Section 3.6.1) shows<br />
the components of the CAN Bit Time Segments. The Bus Timing Registers allow the two<br />
values, TSEG1 and TSEG2, to be defined. TSEG1 is the sum of PHASE_SEG1 and the<br />
PROP_SEG (See Equation 3.4). TSEG2 is equal to PHASE_SEG2 (See Equation 3.5). The Bus<br />
Timing Registers also define the size of the RESYNCHRONIZATION JUMP WIDTH (See<br />
Section 3.6.5). This is the amount by which a bit can be lengthened or shortened during the<br />
resynchronization process.<br />
register is set.<br />
Shown in Figure 5.22, this register can only be accessed when the RR bit in the CCNTRL<br />
Figure 5.22 CAN Bus Timing Register 0.<br />
155
SJW1, SJW0: Synchronization Jump Width Bits. The synchronization jump width<br />
defines the maximum number of system clock cycles (tSCL) by which a bit may be<br />
shortened, or lengthened, to achieve resynchronization on data transitions on the bus (See<br />
Table 5.9).<br />
Table 5.9 Synchronization Jump Width (SJW) [95].<br />
SJW1 SJW0 Synchronization Jump Width<br />
0 0 1 tSCL cycle<br />
0 1 2 tSCL cycles<br />
1 0 3 tSCL cycles<br />
1 1 4 tSCL cycles<br />
BRP5 – BRP0: Baud Rate Prescaler Bits. These bits determine the CAN system clock<br />
cycle time (tSCL), which is used to build up the individual bit timing. This is shown in<br />
Table 5.10 and Figure 5.23.<br />
Table 5.10 Baud Rate Prescaler.<br />
BRP5 BRP4 BRP3 BRP2 BRP1 BRP0 Prescaler Value (P)<br />
0 0 0 0 0 0 1<br />
0 0 0 0 0 1 2<br />
0 0 0 0 1 0 3<br />
0 0 0 0 1 1 4<br />
: : : : : : :<br />
: : : : : : :<br />
1 1 1 1 1 1 64<br />
156
Figure 5.23 CAN Module Oscillator Block Diagram [95].<br />
5.3.10 CAN Module Bus Timing Register 1 (CBT1)<br />
This register, shown in Figure 5.24, can only be accessed when the RR bit in the<br />
CCNTRL register is set.<br />
Figure 5.24 CAN Bus Timing Register 1.<br />
SAMP: Sampling. This bit determines the number of samples of the bus to be taken per<br />
bit time. When set to a ‘1’, three samples per bit are taken. This sample rate gives better<br />
rejection of noise on the bus, but introduces a one bit delay to the bus sampling. For<br />
higher bit rates SAMP should be cleared, which means that only one sample will be taken<br />
per bit.<br />
157
TSEG22 – TSEG10: Time Segment Bits. Time segments within the bit time fix the<br />
number of clock cycles per bit time and the location of the sample point. Time Segment<br />
TSEG1 and Time Segment TSEG2 are programmable as shown in Table 5.11.<br />
Table 5.11 Time Segment Values.<br />
TSEG13 TSEG12 TSEG11 TSEG10 Time Segment 1 TSEG22 TSEG21 TSEG20 Time Segment 2<br />
0 0 0 1 2 tSCL cycles 0 0 1 2 tSCL cycles<br />
0 0 1 0 3 tSCL cycles : : :<br />
0 0 1 1 4 tSCL cycles : : :<br />
: : : : : 1 1 1 8 tSCL cycles<br />
: : : : :<br />
1 1 1 1 16 tSCL cycles<br />
The bit time is determined by the oscillator frequency, the baud rate prescaler, and the<br />
number of bus clock cycles (tSCL) per bit. From Section 3.6.1, the bit time is calculated as shown<br />
in Equation 5.1:<br />
BIT _TIME SYNC _ SEG TSEG1 TSEG2<br />
(5.1)<br />
TSEG2 must be at least 2*tSCL, i.e. the configuration bits must not be 000. (If three samples per<br />
bit mode is selected then TSEG2 must be at least 3*tSCL.) TSEG1 must be at least as long as<br />
TSEG2. The Synchronization Jump Width (SJW) may not exceed TSEG2, and must be at least<br />
tSCL shorter than TSEG1 to allow for physical propagation delays.<br />
i.e. in terms of tSCL:<br />
SYNC _SEG1 TSEG1SJW1 TSEG1TSEG2 TSEG2 SJW<br />
<br />
<br />
and TSEG2 2 SAMP 0<br />
or TSEG2 3 SAMP 1<br />
These boundary conditions result in minimum bit times of 5*tSCL, for one sample per bit, and<br />
7*tSCL, for three samples per bit.<br />
158
5.3.11 CAN Module Output Control Register (COCNTRL)<br />
The Output Control Register (COCNTRL), shown in Figure 5.25, is used to determine<br />
the configuration of the output drivers on the CAN transmit pins. The Output Control Mode<br />
bits allow normal differential operation, bi-phase operation, or a special test mode to be selected<br />
(not fully implemented yet). The output drivers can be selected for pull up, pull down, or push-<br />
pull operation by selectively enabling or disabling P type and N type transistors in the output<br />
driver circuits via the OCTN0/1 and OCTP0/1 bits. The COCNTRL register also allows the data<br />
output to be inverted if required. Normal configuration is for complementary levels to be<br />
transmitted on the TX0 and TX1 pins (two-wire differential operation). The bus termination<br />
network should ensure that the bus reverts to its recessive state when the driver transistors are<br />
switched off [96].<br />
Figure 5.25 CAN Output Control Register.<br />
OCM1 – OCM0: Output Control Mode Bits. The values of these two bits determine the<br />
output mode, as shown in Table 5.12.<br />
Table 5.12 Output Control Modes.<br />
OCM1 OCM0 Function<br />
0 0 Bi-phase operation mode<br />
0 1 Test mode (not fully implemented)<br />
1 0<br />
Normal mode 1<br />
1 1<br />
Bit stream transmitted on both TX0 and TX1<br />
Normal mode 2<br />
TX0 – bit sequence<br />
TX1 – bus clock (ttxclk)<br />
159
The transmit clock (ttxclk) is used to indicate the end of the bit time and will be high<br />
during SYNC_SEG. For all the following modes of operation, a dominant bit is<br />
internally coded as a zero, a recessive as a one. The other output control bits are used to<br />
determine the actual voltage levels transmitted to the CAN bus for dominant and<br />
recessive bits.<br />
Bi-phase mode: If the CAN Module is isolated from the bus lines by a transformer<br />
then the bit stream has to be coded so that there is no resulting dc component. There is a<br />
flip-flop (Toggle) within the CAN Module that keeps the last dominant configuration;<br />
its direct output goes to TX0 and its complement to TX1. The flip-flop is toggled for<br />
each dominant bit; dominant bits are thus sent alternately on TX0 and TX1 (i.e. the first<br />
dominant bit is sent on TX0, the second on TX1, the third on TX0, and so on). During<br />
recessive bits, all output drivers are deactivated (i.e. high impedance).<br />
Normal Mode 1: In contrast to bi-phase mode, the bit representation is time invariant and<br />
not toggled.<br />
Normal Mode 2: For the TX0 pin this is the same as Normal Mode 1, however, the data<br />
stream to TX1 is replaced by the transmit clock. The rising edge of the transmit clock<br />
marks the beginning of a bit time. The clock pulse will be tSCL long [95].<br />
Other Output Control Bits: The other six bits in this register, shown in Table 5.13,<br />
control the output driver configurations, to determine the format of the output signal for a<br />
given data value.<br />
160
Table 5.13 Output Control Bits.<br />
Bit Name Description<br />
OCTP0/1 These two bits control whether the P-type output control transistors are enabled.<br />
OCTN0/1 These two bits control whether the N-type output control transistors are enabled.<br />
OCPOL0/1 These two bits determine the driver output polarity for each of the CAN bus lines (TX0, TX1).<br />
TP0/1 These are the resulting states of the output transistors.<br />
TD<br />
This is the internal value of the data bit to be transferred across the CAN bus.<br />
(A zero corresponds to a dominant bit, a one to a recessive.)<br />
The actions of these bits in the Output Control Register are summarized in Table 5.14.<br />
Table 5.14 CAN driver output levels [95].<br />
Mode TD OCPOLi OCTPi OCTNi TPi TNi TXi Output Level<br />
Float<br />
Pull-down<br />
Pull-up<br />
Push-pull<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
1<br />
0<br />
0<br />
1<br />
1<br />
0<br />
0<br />
1<br />
1<br />
0<br />
0<br />
1<br />
1<br />
0<br />
0<br />
1<br />
1<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
1<br />
1<br />
1<br />
1<br />
1<br />
1<br />
1<br />
1<br />
161<br />
0<br />
0<br />
0<br />
0<br />
1<br />
1<br />
1<br />
1<br />
0<br />
0<br />
0<br />
0<br />
1<br />
1<br />
1<br />
1<br />
Off<br />
Off<br />
Off<br />
Off<br />
Off<br />
Off<br />
Off<br />
Off<br />
Off<br />
On<br />
On<br />
Off<br />
Off<br />
On<br />
On<br />
Off<br />
5.3.12 CAN Module Transmit Buffer Registers Overview<br />
Off<br />
Off<br />
Off<br />
Off<br />
On<br />
Off<br />
Off<br />
On<br />
Off<br />
Off<br />
Off<br />
Off<br />
On<br />
Off<br />
Off<br />
On<br />
Float<br />
Float<br />
Float<br />
Float<br />
Low<br />
Float<br />
Float<br />
Low<br />
Float<br />
High<br />
High<br />
Float<br />
Low<br />
High<br />
High<br />
Low<br />
The Transmit Buffer acts as interface between the CPU and the Bit Stream Processor<br />
(BSP). It is ten bytes long and is capable of storing a complete message plus message identifier.<br />
The layout of these registers is shown in Table 5.15.<br />
Table 5.15 Transmit Buffer Registers.<br />
Register Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />
Identifier (TBI) 20h ID10 ID9 ID8 ID7 ID6 ID5 ID4 ID3<br />
RTR/DLC (TRTDL) 21h ID2 ID1 ID0 RTR DLC3 DLC2 DLC1 DLC0<br />
DSB1 (TDS1) 22h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB2 (TDS2) 23h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB3 (TDS3) 24h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB4 (TDS4) 25h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB5 (TDS5) 26h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB6 (TDS6) 27h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB7 (TDS7) 28h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB8 (TDS8) 29h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
5.3.13 CAN Module Transmit Buffer Identifier Register (TBI)<br />
The message ID’s must be unique on a CAN bus, otherwise two nodes would continue<br />
transmission beyond the end of the arbitration field (ID), causing an error. Figure 5.26 shows the<br />
CAN Transmit Buffer Identifier Register (TBI).<br />
Figure 5.26 CAN Transmit Buffer Identifier Register.<br />
ID10 – ID3: Identifier Bits. The identifier consists of 11 bits (ID10 – ID0). ID10 is the<br />
most significant bit and is transmitted first on the bus during the arbitration procedure.<br />
The priority of an identifier is defined to be highest for the smallest binary number. The<br />
three least significant bits are contained in the TRTDL register (See Section 5.3.14). The<br />
seven most significant bits must not all be recessive.<br />
5.3.14 CAN Module Remote Transmission Request/Data Length Code Register (TRTDL)<br />
The Remote Transmission Request and Data Length Code Register, shown in Figure<br />
5.27, contains the bits responsible for setting the number of bytes or data byte count of the<br />
respective CAN message and dictating to the CAN bus whether a remote frame or a data<br />
frame will be transmitted.<br />
Figure 5.27 CAN Remote Transmission Request/Data Length Code Register.<br />
162
ID2 – ID0: Identifier Bits. These bits contain the three least significant bits of the<br />
Transmit Buffer Identifier (TBI).<br />
RTR: Remote Transmission Request. When set to a ‘1’, a remote frame will be<br />
transmitted. When set to a ‘0’, a data frame will be transmitted.<br />
DLC3 – DLC0: Data Length Code Bits. The Data Length Code contains the number of<br />
bytes (data byte count) of the respective message. Upon transmission of a remote frame,<br />
the Data Length Code is ignored, forcing the number of bytes to be zero. The data byte<br />
count ranges from 0 – 8 for a data frame. Table 5.16 shows the effect of setting the DLC<br />
bits.<br />
Table 5.16 Data Length Code Bits.<br />
Data Length Code Bits Data Byte<br />
DLC3 DLC2 DLC1 DLC0 Count<br />
0 0 0 0 0<br />
0 0 0 1 1<br />
0 0 1 0 2<br />
0 0 1 1 3<br />
0 1 0 0 4<br />
0 1 0 1 5<br />
0 1 1 0 6<br />
0 1 1 1 7<br />
1 0 0 0 8<br />
5.3.15 CAN Module Transmit Data Segment Registers (TDS) 1 – 8<br />
Depending upon the Data Length Code there may be up to eight data bytes transmitted as<br />
part of a data frame. Figure 5.28 shows the register bit definitions for the Transmit Data<br />
Segment Registers (TDS).<br />
163
Figure 5.28 CAN Transmit Data Segment Registers.<br />
DB7 – DB0: Data Bits. These data bits in the eight data segment registers make up the<br />
bytes of data to be transmitted. The number of bytes to be transmitted is determined by<br />
the Data Length Code bits (bits 3 – 0) as defined in the TRTDL Register (See Section<br />
5.3.14).<br />
5.3.16 CAN Module Receive Buffer Registers Overview<br />
There are two full Receive Buffers (each ten bytes in length) used to handle all incoming<br />
messages being passed from the BSP to the CPU. Each Receive Buffer is capable of storing an<br />
entire message and has a layout identical to that of the Transmit Buffer. They are arranged in a<br />
double buffered configuration, with each buffer occupying the same area of the memory map.<br />
When the first buffer is filled it can be read by the CPU as a second incoming message is being<br />
transferred by the BSP into the second buffer. After the CPU has read a message from the<br />
Receive Buffer it can release that buffer, making it available for storing the next incoming<br />
message and allowing the second buffer to be read once it contains a complete message. The<br />
layout of these registers is shown in Table 5.17.<br />
Table 5.17 Receive Buffer Registers.<br />
Register Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />
Identifier (RBI) 30h ID10 ID9 ID8 ID7 ID6 ID5 ID4 ID3<br />
RTR/DLC (RRTDL) 31h ID2 ID1 ID0 RTR DLC3 DLC2 DLC1 DLC0<br />
DSB1 (RDS1) 32h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB2 (RDS2) 33h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB3 (RDS3) 34h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB4 (RDS4) 35h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB5 (RDS5) 36h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB6 (RDS6) 37h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB7 (RDS7) 38h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
DSB8 (RDS8) 39h DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0<br />
164
5.3.17 CAN Module Receive Buffer Identifier Register (RBI)<br />
The layout and bit definitions for the Receive Buffer Identifier Register, shown in Figure<br />
5.29, are identical to the TBI register (See Section 5.3.13).<br />
Figure 5.29 CAN Receive Buffer Identifier Register.<br />
5.3.18 CAN Module Remote Transmission Request/Data Length Code Register<br />
(RRTDL)<br />
The layout of this register, shown in Figure 5.30, along with the bit names and meanings<br />
are identical to the TRTDL register as discussed in Section 5.3.14.<br />
Figure 5.30 CAN Remote Transmission Request/Data Length Code Register.<br />
5.3.19 CAN Module Receive Data Segment Registers (RDS) 1 – 8<br />
The layout and bit definitions of these registers, shown in Figure 5.31, are identical to the<br />
TDSx registers discussed in Section 5.3.15.<br />
Figure 5.31 CAN Receive Data Segment Registers.<br />
165
5.3.20 CAN Node Overview<br />
As stated in Section 4.3.2, each individual CAN node is comprised of an 8-pin<br />
Microchip PIC12CE674 microcontroller [42], an 18-pin Microchip MCP2515 Stand-Alone<br />
CAN Controller [46], and an 8-pin Microchip MCP2551 High-Speed CAN transceiver [45].<br />
Together these create a fully autonomous CAN node, which supports both “time-based” (in<br />
the sense that messages are automatically transmitted from each CAN node every 500 ms) and<br />
“event-driven” message transmission. Each individual node is interrupt driven and capable of<br />
monitoring five external inputs (two analog and three digital) and automatically generating<br />
messages based upon their value. The node also controls two digital outputs, responding to<br />
message requests via the CAN network and generating a repeating, time-based message. Each<br />
node is configured for a maximum CAN bus speed of 125 kbps, which is closest to the<br />
overdrive speed of 1 – Wire® devices, and is capable of handling standard or extended frames.<br />
Figure 5.32 shows the block diagram of one CAN node. There are two function<br />
blocks. The first is the Control Logic block. This function is performed by the PIC12CE674<br />
microcontroller. The PIC12CE674 was chosen because of the low pin count and powerful<br />
feature set, including an internal oscillator; on-board, multi-channel, 8-bit analog-to-digital<br />
converter (ADC); multiple interrupt sources; and low-power sleep mode. The second is the<br />
CAN Interface block. This block is comprised of the MCP2515 CAN Controller and the<br />
MCP2551 transceiver. The MCP2515 provides a full CAN 2.0 implementation with message<br />
filtering, which relieves the host microcontroller from having to perform any CAN bus related<br />
overhead. This is a key feature given the limited available code space of the PIC12CE674.<br />
166
Figure 5.32 CAN Node Block Diagram.<br />
Communication between the Control Logic block and the CAN Interface block makes<br />
use of the MCP2515 device’s built-in support for the SPI protocol. The PIC12CE674 does not<br />
have a hardware SPI interface, so the necessary functions are implemented in firmware.<br />
Two external analog signals are tied directly to the analog input pins of the PIC12CE674.<br />
An analog-to-digital (A/D) conversion is performed automatically for the Analog Channel 0<br />
(AN0) based upon the internal timer setup, and the value is automatically transmitted over the<br />
CAN bus when the conversion is completed.<br />
The nodes also utilize the MCP2515 device’s multiple filters to respond to six additional<br />
CAN Message Identifiers received via the CAN bus. The masks and filters are set to accept<br />
messages into Receive Buffer 1 only. The identifiers are interpreted as one of the following,<br />
depending upon which filter is matched:<br />
Read Analog Channel 1Perform A/D conversion for Analog Channel 1 (AN1) and<br />
initiate transmission of the value (ADRES) back to the requesting node.<br />
167
Read Digital InputsRead the value of the MCP2515 input pins and transmit the value<br />
back to the requesting node.<br />
Update Digital Output 1Write the received value to the MCP2515 Digital Output 1.<br />
Update Digital Output 2Write the received value to the MCP2515 Digital Output 2.<br />
Check I/O StatusChange a CAN node unit’s address.<br />
Change Unit AddressTurns off Digital Outputs 1 and 2. This can be done in case of an<br />
emergency.<br />
Since only Receive Buffer 1 is to be used, in order to take advantage of the greater number of<br />
filters associated with that receive buffer, the Mask registers for Receive Buffer 0 must all be set<br />
to a ‘1’. The filter bits must then be set to match an unused message identifier (typically all ‘0’<br />
or all ‘1’).<br />
As presented, the system requires that the messages intended for any of the CAN nodes<br />
on the CAN bus have a standard identifier, which has a value of 0x3F0 – 0x3F5, with each of<br />
the six filters configured to accept one of these messages. For the messages that the node<br />
transmits back, it uses the same identifier as the received message, with the exception that the<br />
ID3 bit is set to a ‘1’. Therefore, for example, when the ‘Read Analog Channel 1’ message is<br />
received (ID = 0x3F0), the node transmits the data back using a message ID of 0x3F8. The time-<br />
based message for the value of Analog Channel 0 is transmitted with an identifier of 0x3FE,<br />
every 500 ms. In the event of a system error being detected, the system error message uses the<br />
identifier, 0x3FF. Table 5.18 summarizes the various transmit and receive message identifiers<br />
used. All transmitted messages use data byte 1 of the CAN message to hold the data to be<br />
sent.<br />
168
Table 5.18 CAN Node Message Identifiers.<br />
ID Tx/Rx Description<br />
3F0 Rx Read Analog Channel 1<br />
3F1 Rx Read Digital Inputs<br />
3F2 Rx Change Digital Output 1<br />
3F3 Rx Change Digital Output 2<br />
3F4 Rx Change Unit Address<br />
3F5 Rx Turn Off Outputs<br />
3F8 Tx Analog Channel 1 Value<br />
3F9 Tx Current Values of Digital Inputs<br />
3FA Tx 3F2 Command Acknowledgement<br />
3FB Tx 3F3 Command Acknowledgement<br />
3FC Tx 3F4 Command Acknowledgement<br />
3FD Tx 3F5 Command Acknowledgement<br />
3FE Tx Analog Channel 0 Value<br />
3FF Tx System Error<br />
The PIC12CE674 only has six available I/O pins, and all of these are used, two for analog<br />
inputs and four (three SPIs and one INT ) to interface to the MCP2515. This requires the<br />
system to take advantage of the internal RC oscillator of the PIC12CE674. The internal RC<br />
oscillator provides a 4 MHz system clock to the microcontroller, which translates to a 1 µs<br />
instruction cycle. The instruction cycle time directly affects the achievable speed of the SPI bus.<br />
This, in turn, determines the interrupt latency time as the SPI communication makes up the<br />
majority of the time required for the Interrupt Service Routine (ISR).<br />
The standard SPI interface has been modified in this application to use a common signal<br />
line for both Serial In (SI) and Serial Out (SO) lines, isolated from each other via a resistor. This<br />
method requires only three I/O pins to implement the SPI interface, instead of the usual four.<br />
Using this configuration does not support the Full-Duplex mode of SPI communications, which<br />
is not an issue in this application. The system achieves an overall SPI bus rate of slightly more<br />
than 80 kbps. The raw SPI clock rate averages 95 kbps. The clock low time is a fixed 5 µs, and<br />
169
the clock high time is either 5 µs or 6 µs, depending upon whether a ‘0’ or a ‘1’ is being<br />
sent/received, which gives a worst case (sending the value 0xFF) raw clock rate of 90.0 kbps<br />
[47]. The overall effective speed achieved includes the additional software overhead of ‘bit-<br />
banging’ the SPI protocol.<br />
There are two interrupt sources in this CAN node system. The first is the PIC12CE674<br />
Timer0 interrupt. This interrupt occurs approximately every 500 ms. The second interrupt<br />
source is the INT pin of the PIC12CE674. This pin is connected to the INT output of the<br />
MCP2515. This interrupt occurs any time a valid message is received or if the MCP2515 detects<br />
a CAN bus related error. This external interrupt is completely asynchronous with respect to<br />
the rest of the system.<br />
It is necessary to carefully consider the interrupt latency requirements during the system<br />
design/development phase. This CAN node system has two interrupt sources: the internal<br />
timer interrupt, which occurs approximately every 500 ms, and the external INT pin interrupt,<br />
which is generated by the MCP2515 CAN Controller and may occur at any time. The latency<br />
time for the timer ISR is essentially fixed. This parameter is a function of the time it takes for<br />
the ADC to perform a conversion on both channels, write the values to the transmit buffer, and<br />
issue a Request To Send (RTS) command to the MCP2515, via the SPI interface. This takes<br />
approximately 428 µs to complete.<br />
The MCP2515 has three pins that are configured as general purpose inputs and two pins<br />
that are configured as digital outputs. The inputs for each CAN node system are connected to<br />
switch contacts and the outputs are connected to LED indicators. The MCP2515 inputs have<br />
internal pull-up resistors and will read high when the attached switch is open and low when it is<br />
170
closed. The MCP2515 also has two I/O pins ( RX0BF and RX1BF ) that can be configured as<br />
general purpose outputs. These pins are configured as outputs, and are connected to LEDs to<br />
function as indicator lights that are controlled via the CAN bus.<br />
The CAN bus is configured to run at two distinct speeds; 10 kbps and 125 kbps. These<br />
two speeds were chosen since they most closely mimic the speeds capable of 1 – Wire®<br />
networks. The clock source for the MCP2515 is a standard, 8 MHz crystal connected to the<br />
OSC1 and OSC2 inputs. The CAN physical layer is implemented using an industry standard<br />
transceiver chip (e.g., Microchip MCP2551 [45]). This device supports CAN bus rates of up<br />
to 1 Mbps and is more than adequate for the CAN node system presented here.<br />
5.3.20.1 Firmware Description<br />
The firmware is written in PIC® Microcontroller (MCU) assembly code. The relative<br />
simplicity and small size of the CAN node system makes assembly language more than a<br />
suitable choice. Figure 5.33 shows the top level flowchart for the overall CAN node system<br />
operation. The PIC® MCU after going through self-initialization and initializing the MCP2515<br />
goes to sleep and waits for an interrupt to occur. The following sections provide a more detailed<br />
discussion of the operation of each of the major blocks in the firmware.<br />
171
Yes<br />
Perform A/D<br />
Conversion on AN0<br />
Write A/D Value to<br />
MCP2515 Transmit<br />
Buffer<br />
Send Request to<br />
Send Command to<br />
MCP2515<br />
Clear Interrupt Flags<br />
in PIC12CE674<br />
System POR<br />
Initialize PIC MCU<br />
and MCP2515<br />
Sleep<br />
Interrupt<br />
Occurred?<br />
Yes<br />
Timer0<br />
Interrupt?<br />
172<br />
No<br />
Read MCP2515<br />
Interrupt Flags<br />
Error Interrupt?<br />
No<br />
Read MCP2515 Rx<br />
Filters<br />
Filter Match?<br />
Yes<br />
Process Request<br />
Clear Interrupt Flags<br />
in PIC12CE674 and<br />
MCP2515<br />
Figure 5.33 CAN Node Operation Flowchart [47].<br />
No<br />
Yes<br />
No<br />
Error Handler<br />
Routine<br />
System Error<br />
(InvMsg)
5.3.20.2 PIC® MCU Initialization<br />
Initialization of the PIC12CE674 is straightforward. There are three major functions that<br />
need to be properly configured within the PIC12CE674:<br />
General Purpose I/O (GPIO) pins<br />
Timer0 module<br />
A/D Converter module<br />
Figure 5.34 shows the pin diagram and names for the PIC12CE674.<br />
Figure 5.34 PIC12CE674 Pin Names [42].<br />
The GPIO pins are the six I/O pins that are used to interface the PIC12CE674 to the<br />
MCP2515 and sample the analog signals. The PIC® MCU OPTION, TRIS and INTCON<br />
registers are used to control the setup of the GPIO pins. For the CAN nodes used in the<br />
prototype system, the OPTION register is programmed to disable the internal pull-up resistors on<br />
GP0/GP1/GP3. It also configures GP2 to generate an interrupt on the negative edge (to match<br />
the MCP2515 device’s active low INT output). The TRIS register, which controls whether<br />
each I/O pin is configured as an input or an output, is configured to set GP0/GP1/GP3 as inputs,<br />
173
and GP2 and GP5 as outputs. With the exception of GP4, all of the GPIO pins remain in their<br />
initially configured state. GP4 is changed between Input and Output mode, depending upon<br />
whether an SPI read or write operation is being performed by the PIC12CE674. The final step of<br />
configuring the port pins is to program the INTCON register to enable the interrupt-on-change<br />
feature for GP2. This allows the MCP2515 to generate an interrupt to the PIC12CE674.<br />
The Timer0 module operation is controlled by the OPTION register and the TMR0<br />
register. The OPTION register contains the control bits for the Timer0 prescaler. The TMR0<br />
register is the counting register for Timer0 and generates an interrupt when it rolls over from<br />
0xFF to 0x00. This register must be reloaded as part of the ISR in order to correctly control the<br />
time period between Timer0 interrupts. Initially for each CAN node the timer is set to rollover<br />
every 62 ms. This is further expanded to every 500 ms by using a counter. This will reduce the<br />
amount of traffic on the CAN bus, but on the down side will reduce the response time to a<br />
change in the input.<br />
The A/D conversion takes approximately 19 µs for the SPI communication to write the<br />
A/D result to the MCP2515 transmit buffer. Then, the conversion sends the RTS command,<br />
which requires approximately 409 µs to complete for a total of approximately 428 µs for the ISR<br />
to execute. The Timer0 module is configured to use the FOSC/8 option for the conversion clock,<br />
which gives a TAD value of 2 µs and an overall conversion time of 19 µs (TAD * 9.5). This is<br />
more than fast enough compared to the amount of time spent on SPI communications during the<br />
ISR.<br />
174
5.3.20.3 MCP2515 Initialization<br />
Before the system can communicate on the CAN bus, the MCP2515 must be properly<br />
configured. The configuration of the MCP2515 is accomplished by loading the various control<br />
registers with the desired values. The firmware is written to take advantage of the table read<br />
functionality of the PIC® MCU. The values for each register are stored at the top of the PIC®<br />
ROM memory. During the MCP2515 initialization, the values are sequentially read by the table<br />
read function and then written to the MCP2515, via the SPI interface.<br />
The CAN bit rate configuration is controlled by the CNF1, CNF2 and CNF3 registers.<br />
The MCP2515 for each CAN node is configured to operate at a bus rate of 125 kbps using the<br />
following parameters:<br />
8 MHz oscillator<br />
Baud rate prescaler equivalent to divide-by-4<br />
8 TQ per bit time<br />
Sync segment: 1 TQ<br />
Prop segment: 1 TQ<br />
Phase segment 1: 3 TQ<br />
Phase segment 2: 3 TQ<br />
Sync Jump Width: 1 TQ<br />
5.3.20.4 Interrupt Service Routine<br />
When an interrupt occurs, the PIC® MCU begins executing the ISR routine. Figure 5.35<br />
shows the flowchart for the ISR. The ISR first determines the source of the interrupt, Timer0 or<br />
175
external INT pin, and then branches to the appropriate section of code to process the interrupt.<br />
Figures 5.36 and 5.37 show the program flow for the Timer0 and CAN message received<br />
through interrupts, respectively.<br />
Read MCP2515<br />
CANINTF Register<br />
___<br />
Msg Rx INT?<br />
No<br />
CAN Bus Error?<br />
No<br />
Yes<br />
System Error ___ (Invalid<br />
INT)<br />
Yes<br />
Yes<br />
ISR<br />
___<br />
INT Pin<br />
Interrupt<br />
Occurred?<br />
CAN Msg Received<br />
System Error (CANErr)<br />
No<br />
176<br />
Timer0<br />
Interrupt?<br />
Yes<br />
Timer0 Time-out<br />
No<br />
System Error ___ (Invalid<br />
INT)<br />
Figure 5.35 CAN Node Interrupt Service Routine Flowchart [47].<br />
When the Timer0 interrupt occurs, as shown in Figure 5.3, the PIC® MCU initiates an<br />
A/D conversion on AN0 constantly polling the ADDONE bit until the conversion process is<br />
complete. Once the conversion is complete, the ADRES value is loaded into the MCP2515<br />
Transmit Buffer 0, Data Byte 0, and an RTS command is issued for Buffer 0. The TMR0<br />
register is then reloaded and the interrupt flag is cleared. The interrupts are then re-enabled by<br />
the execution of the RETIE command at the end of the Timer0 ISR (See Figure 5.36).
When an interrupt is generated by the MCP2515, the PIC12CE674 reads the CANINTF<br />
register of the MCP2515 to determine the source of the interrupt. If a valid message has been<br />
received, then the MsgRcvd subroutine is executed (See Figure 5.37), and if an error has<br />
occurred, the error handling subroutine is executed (See Figure 5.38).<br />
Timer0 Time-out<br />
Start Conversion on<br />
AN0<br />
Interrupt<br />
Occurred?<br />
Yes<br />
Store AN0 Value into<br />
RAM Variable<br />
Load AN0 Value into<br />
MCP2515 TxMsg<br />
Buffer<br />
Send RTS Command<br />
to MCP2515<br />
Clear Interrupt Flag<br />
Reload Timer0<br />
Re-enable Interrupts<br />
(RETIE Command)<br />
Exit ISR<br />
Figure 5.36 Timer0 Interrupt Service Routine Flowchart [47].<br />
177<br />
No
Read MCP2515 Rx<br />
Buffer for Digital<br />
Output 1 Data<br />
Update MCP2515<br />
Digital Output<br />
Control Register<br />
Yes<br />
Read MCP2515 Rx<br />
Buffer for Digital<br />
Output 2 Data<br />
Store New Unit<br />
Address in EEDATA<br />
Register and Write<br />
to EEPROM<br />
Turn off Digital<br />
Outputs 1 and 2<br />
Yes<br />
Yes<br />
___<br />
INT Pin<br />
(CAN Msg Rx)<br />
Read MCP2515 Rx<br />
Filter<br />
Filter Match = 1?<br />
No<br />
Filter Match = 2?<br />
No<br />
Filter Match = 3?<br />
No<br />
Filter Match = 4?<br />
No<br />
Filter Match = 5?<br />
No<br />
Filter Match = 6?<br />
No<br />
System Error<br />
(InvMsg)<br />
Clear Interrupt Flags<br />
in PIC12CE674 and<br />
MCP2515<br />
Exit ISR<br />
178<br />
Yes<br />
Yes<br />
Read Value of Three<br />
MCP2515 Digital<br />
Inputs<br />
Send RTS Command<br />
to MCP2515<br />
Figure 5.37 CAN Node Message Received Flowchart [47].<br />
Perform A/D<br />
Conversion on AN1<br />
Write A/D Value to<br />
MCP2515 Transmit<br />
Buffer<br />
Send RTS Command<br />
to MCP2515
Error Handler<br />
Read ERRIF Register<br />
RxB1 Overflow?<br />
No<br />
Error Warning<br />
Flag Set?<br />
No<br />
Rx Error<br />
Passive Flag<br />
Set?<br />
No<br />
Tx Error<br />
Passive Flag<br />
Set?<br />
No<br />
Bus-Off Flag<br />
Set?<br />
No<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x13<br />
Done<br />
Yes<br />
Yes<br />
Yes<br />
Yes<br />
Yes<br />
Yes<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x11<br />
Rx Warning<br />
Flag Set?<br />
Yes<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x01<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x03<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x04<br />
1 st Bus-Off<br />
Occurrence?<br />
Yes<br />
Set Bus-Off Flag and<br />
Re-Initialize<br />
MCP2515<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x12<br />
Message<br />
Transmitted<br />
Successfully<br />
Send Error Message<br />
0x3FF, Error Code =<br />
0x02<br />
Figure 5.38 Error Handler Routine Flowchart [47].<br />
179<br />
No<br />
No<br />
No<br />
Enter Idle State;<br />
MCU must Reset<br />
System Node
When a valid message is received, the FILHIT bits of the RXB1CTRL register are<br />
read to determine which message has been received. Depending on the filter match number, they<br />
are described as follows:<br />
Filter 1The PIC® MCU initiates an A/D conversion on AN1, waits for the conversion<br />
to complete, loads the ADRES register value into the MCP2515 Transmit Buffer 0 and<br />
Data Byte 0, and sends the RTS command.<br />
Filter 2The PIC® MCU reads the TXRTSCTRL register for the value of the three<br />
input pins, loads this value into the MCP2515 transmit buffer and sends the RTS<br />
command.<br />
Filter 3 or 4The PIC® MCU reads the first byte of the received message and writes it<br />
to the appropriate output pin via the MCP2515 BFPCTRL register.<br />
Filter 5The PIC® MCU reads the first byte of the received message and stores the new<br />
units address into the EEDATA register and write the new unit address into the<br />
EEPROM.<br />
Filter 6The PIC® MCU turns off Digital Outputs 1 and 2.<br />
The system also provides for error detection for a number of different types of errors that<br />
may occur, including CAN bus errors detected by the MCP2515, as well as invalid system<br />
state errors (See Figure 5.38). When any of these errors are detected, the system transmits a<br />
message with the ID of 0x3FF. This message contains one data byte which is a code used to<br />
represent the type of error that occurred. The one exception to this is the Bus-Off condition that<br />
the MCP2515 may enter if a large number of transmit errors are detected. If the Bus-Off<br />
180
condition is detected, the PIC® MCU performs a re-initialization of the MCP2515 and then<br />
attempts to transmit the error message (ID = 0x3FF) with an error code of 0x12. After initiating<br />
a request to send for the error message, the PIC® MCU checks to ensure that the message was<br />
transmitted successfully. If it was successfully transmitted, the PIC® MCU sets an internal flag<br />
to indicate that a Bus-Off condition occurred and then resumes normal operation. If the error<br />
message fails to transmit correctly, of if the Bus-Off condition is detected a second time, the<br />
PIC® MCU automatically enters an Idle loop and remains there until a system Reset occurs via<br />
power-on.<br />
5.3.21 Verification of CAN Module<br />
To verify the proper operation of the synthesizable CAN Controller, five test cases<br />
were executed: Synchronization (test_synchronization), Bus Off (bus_off_test), Error Test<br />
(error_test), Send Basic Frame Test (send_frame_basic), and Send Extended Frame Test<br />
(send_frame_extended). All tests were compiled and simulated using Altera Quartus II 9.1 (32-<br />
bit) and ModelSim Altera Starter Edition 6.6c software on a PC executing Windows XP Service<br />
Pack 3. All tests were performed extensively while trying to cover all possible combinations of<br />
data and I/O values for the CAN Controller. Only a few failures (most were attributed to the<br />
addition and removal of nodes while tests were being conducted) were observed for any of the<br />
five tests described below. The source code for all modules, testbench code, and simulation<br />
results are located on the DVD included with this work. Table 5.19 shows the FPGA resource<br />
utilization for the Altera DE2 Development and Education Board.<br />
181
Table 5.19 Resource Utilization.<br />
Revision Name CAN_Controller<br />
Family Cyclone II<br />
Device EP2C35F672C6<br />
Timing Models Final<br />
Met timing requirements Yes<br />
Total logic elements 1560 / 33,216 ( 1 % )<br />
Total combinational functions 1462 / 33,216 ( 1 % )<br />
Dedicated logic registers 625 / 33,216 ( < 1 % )<br />
Total registers 625<br />
Total pins 19 / 475 ( 4 % )<br />
Total virtual pins 0<br />
Total memory bits 832 / 483,840 ( 0 % )<br />
Embedded Multiplier 9-bit element 0 / 70 ( 0 % )<br />
Total PLLs 0 / 4 ( 0 % )<br />
5.3.21.1 Synchronization Test (test_synchronization)<br />
All nodes on a CAN bus must have the same NBT. Since the CAN protocol is an<br />
asynchronous serial bus with Non-Return to Zero (NRZ) bit coding; a clock is not encoded into<br />
each message. The receivers must synchronize to the transmitted data stream to insure messages<br />
are properly decoded. There are two methods used for achieving and maintaining<br />
synchronization: hard synchronization and re-synchronization (Sections 3.6.4 – 3.6.5).<br />
When synchronizing, there are five basic rules to follow to synchronize the receivers with<br />
the transmitted data:<br />
Only recessive-to-dominant edges will be used for synchronization.<br />
Only one synchronization within one bit time is allowed.<br />
An edge will be used for synchronization only if the value at the previous sample<br />
point differs from the bus value immediately after the edge.<br />
182
A transmitting node will not resynchronize due to propagation delays of its own<br />
transmitted message. The receivers will synchronize normally.<br />
If the absolute magnitude of the phase error is greater than the SJW, then the<br />
appropriate phase segment will be adjusted by an amount equal to the SJW.<br />
The synchronization test performs a hard synchronization by transitioning the rx line<br />
from recessive to dominant (logic “1” to logic “0”) and then waits for ten bit times before<br />
transitioning from dominant to recessive (logic “0” to logic “1”). Ten more bit times pass before<br />
another transition occurs. This simulates a resynchronization on time. This test also simulates<br />
early (two frames early) and late resynchronization (two frames and one frame late) before<br />
finally performing another resynchronization on time. For this test, no physical CAN nodes<br />
were connected to the Altera DE2 Development and Education Board. This test was performed<br />
and verified using ModelSim to prove validity and integrity of the synthesizable CAN<br />
Controller and Verilog® code modules.<br />
5.3.21.2 Bus-Off Test (bus_off_test)<br />
This test simulates a CAN node being in the Bus-Off state (See Figure 3.10). For this<br />
to happen, a value of 256 is placed in the TEC, since receive errors cannot cause a CAN node<br />
to go Bus-Off. While in this state, the CAN node cannot send or receive messages,<br />
acknowledge messages, or transmit Error Frames of any kind. At the present, the only way for a<br />
CAN node to leave this state is by a software reset.<br />
183
For this test, only one CAN node was utilized. The test setup configuration is shown<br />
in Figure 5.39. The node is comprised of the components discussed in Section 4.3.2. With only<br />
one node on the bus, message filtering is not configured on the CAN node for this test. After<br />
power-up, a value of 256 is written to the TEC for CAN node 1. CAN messages having<br />
either an 11-bit ID or a 29-bit ID are written to CAN node 1 in an attempt to get a response<br />
back from the node. Both ID sizes are used to ensure compliance with the CAN 2.0B<br />
standard in which the CAN Module must be capable of receiving and transmitting extended<br />
message frames, which use a 29-bit message identifier. Only two configurable pins are required<br />
on the Altera DE2 board to perform this test. The test results are summarized in Table 5.20 and<br />
verify proper operation of this test.<br />
Figure 5.39 Bus-Off Test Setup.<br />
184
Table 5.20 Bus-Off Test (bus_off_test) Results.<br />
Speed(kbps) Data Bytes Length of test Messages Sent Messages Rec’d<br />
10<br />
60 min 226,718 0<br />
20 60 min 457,433 0<br />
62.5 60 min 1,413,317 0<br />
125<br />
250<br />
8<br />
60 min<br />
60 min<br />
2,817,783<br />
5,628,518<br />
0<br />
0<br />
500 60 min 11,249,982 0<br />
800 60 min 17,977,528 0<br />
1000 60 min 22,401,991 0<br />
5.3.21.3 Error Test (error_test)<br />
CAN nodes have the ability to determine fault conditions and transition to different<br />
modes based on the severity of problems being encountered. They also have the ability to<br />
differentiate between short disturbances and permanent failures and modify their functionality<br />
accordingly. CAN nodes can transition from functioning like a normal node (being able to<br />
transmit and receive messages normally), to shutting down completely (Bus-Off) based on the<br />
severity of the errors detected. There are five error conditions (Section 3.4) and three error states<br />
(Section 3.5) defined in the CAN protocol that a node can be in, based upon the type and<br />
number of error conditions detected [21 – 22]. The errors simulated in this test are as follows:<br />
CRC Error, Acknowledge Error, Form Error, Bit Error, and Stuff Error. The error states<br />
simulated in this test are as follows: Error-Active, Error-Passive, and Bus-Off.<br />
CRC Error Test – For this test the Altera DE2 board is configured as the transmitting<br />
node while all 30 other nodes act as receivers. A 15-bit CRC value is calculated<br />
according to the following formula: 15 14 10 8 7 4 3 1<br />
X X X X X X X<br />
. All other<br />
nodes on the network receive this message, calculate a CRC and verify that the CRC<br />
values match. For test purposes, bit 8 was complemented in the receiving nodes to cause<br />
185
an Error Frame to be generated. After ten bit time slots, the message is resent with the<br />
proper CRC value to simulate whether all nodes received the message properly.<br />
Acknowledge Error – For this test, the Altera DE2 board checks if the Acknowledge Bit<br />
(which it has sent as a recessive bit) contains a dominant bit. The purpose of this<br />
dominant bit is to acknowledge that at least one node correctly received the message. If<br />
this bit is recessive, then no node received the message properly and an Acknowledge<br />
Error will occur. Both scenarios, recessive and dominant states, are tested to ensure<br />
proper message reception by all CAN nodes. For the recessive state, an Acknowledge<br />
Error occurs and an Error Frame is generated. After ten bit time slots the original<br />
message is resent with a dominant bit in the Acknowledge Field to verify the successful<br />
retransmission of the message.<br />
Form Error – If any node detects a dominant bit in the End of Frame, Interframe Space,<br />
Acknowledge Delimiter or CRC Delimiter, the CAN protocol defines this to be a form<br />
violation and a Form Error is generated. For this test, a dominant bit is placed in each of<br />
the bit positions to cause a Form Error to be generated for each of these conditions. After<br />
waiting for ten bit times, the original message is then resent to all 30 CAN nodes<br />
verifying proper operation.<br />
Bit Error – This situation arises if a transmitter sends a dominant bit and detects a<br />
recessive bit, or if it sends a recessive bit and detects a dominant bit when monitoring the<br />
actual bus level and comparing it to the bit that it has just sent. If a Bit Error is detected,<br />
an Error Frame is generated. To verify this, the actual bit sent is complemented from the<br />
receiver nodes and after ten bit times the bit is sent again in its uncomplemented form.<br />
186
Stuff Error – To verify a Stuff Error, six consecutive bits with the same polarity are<br />
inserted in a CAN message between the Start of Frame and the CRC Delimiter. This<br />
causes a Stuff Error to occur and after ten bit time slots the message is resent with<br />
random dominant and recessive bits between the two delimiters.<br />
Error – Active Error State – Since this is normal operation as long as the Transmit Error<br />
Counter (TEC) and Receive Error Counter (REC) are below 128, no test is necessary to<br />
prove proper operation. If the TEC or REC exceeds 127, the nodes become either Error –<br />
Passive or go in to the Bus – Off state.<br />
Error – Passive Error State – A node becomes Error – Passive when either the TEC or<br />
REC exceeds 127. Error – Passive nodes are not permitted to transmit Active Error Flags<br />
on the bus, but instead, transmit Passive Error Flags, which consist of six recessive bits.<br />
To verify this state, the REC and TEC are set to random values above 127 but less than<br />
255. This forces the nodes to enter the Error-Passive state and transmit a Passive Error<br />
Flag (six recessive bits). At this point a dominant bit is sent on the bus, which is seen by<br />
the Error – Passive nodes, and forces these nodes to see the bus as being idle for eight<br />
additional bit times after an intermission frame before recognizing the bus as available.<br />
After this time, the nodes begin retransmitting normally and return to the Error-Active<br />
state.<br />
Bus – Off – This test is an extension of the test performed in Section 5.3.21.1. To verify<br />
nodes being in the Bus-Off state, a value of 256 is placed in the TEC, since receive errors<br />
cannot cause nodes to go Bus-Off. While in this mode the nodes cannot send or receive<br />
187
messages, acknowledge messages, or transmit Error Frames of any kind. The only way<br />
for nodes to leave this state is by a software reset.<br />
For these tests, 30 CAN are nodes connected to the Altera DE2 board. The test setup<br />
configuration is shown in Figure 5.40. Only two configurable pins are required on the Altera<br />
DE2 board to perform this test. Eight tests in all are performed, one for each of the five error<br />
types and one for each of the three error states that a CAN node can assume. These tests are<br />
only run at speeds of 10 kbps and 125 kbps, for the reason that these two speeds are closest to the<br />
normal and overdrive speeds of 1 – Wire® networks.<br />
Figure 5.40 Error Test Setup.<br />
188
In addition to being conducted at two different speeds, the tests are also conducted using<br />
both 11-bit and 29-bit message identifier fields. Without hot swapping, no failures are noted<br />
while running any of the tests but a considerable degradation in the performance is noticed in the<br />
bandwidth when using the extended 29-bit message identifiers at the 125 kbps speeds. When<br />
making an attempt to perform hot swapping on any individual node (regardless of any of the<br />
eight tests being conducted or bus speeds), it is noticed that all communications on the CAN<br />
bus come to a halt and the only way to restore communications is to perform a hard reset,<br />
powering down the Altera DE2 board and all CAN nodes.<br />
It is clear that more extensive testing is needed to find a solution for this problem. It is<br />
common that adding additional components to a network most often requires shutting down the<br />
entire network to prevent costly system errors, as was evident in this case. The ability to plug-in<br />
or remove a CAN node from the system would be a valued asset for many CAN<br />
applications.<br />
At this time, it is believed that the transceivers on each CAN node are the root cause of<br />
the failure, since hot swapping CAN nodes requires that the transceiver output remain stable<br />
during the unpowered to power-up transition without disturbing ongoing CAN network<br />
communications. Since many CAN transceivers on the market today have very low output<br />
impedance when unpowered, this causes the device to sink any signal present on the bus and<br />
would effectively shut down all bus communication. Clearly, further research and testing is<br />
needed in this area along with CAN transceivers from different manufacturers being replaced<br />
on individual CAN nodes.<br />
189
5.3.21.4 Send Basic Frame Test (send_frame_basic)<br />
For this test, messages are placed on the CAN bus for reception by all nodes using only<br />
the 11-bit message identifier (CAN 2.0A). The Altera DE2 Development and Education board<br />
is connected with 30 CAN nodes on the network. The test setup is the same as that shown<br />
previously in Figure 5.40. Again only two data rates are tested, 10 kbps and 125 kbps, since<br />
these two data rates are closest to those data rates supported by most 1 – Wire® devices. Table<br />
5.21 shows the results for this test.<br />
Table 5.21 Send Basic Frame (send_frame_basic) Test Results.<br />
Data Rate Messages Sent Data Bytes Length of test Hot Swapped Failures<br />
10 kbps 225,419 8 60 min No None<br />
10 kbps 253 8 60 min Yes Yes<br />
125 kbps 2,748,624 8 60 min No None<br />
125 kbps 119 8 60 min Yes Yes<br />
Again, while attempting to hot swap CAN nodes on the network, communication on<br />
the bus is halted and the only way to restore communications is to perform a hard reset, powering<br />
down the Altera DE2 board and all CAN nodes. This is clearly an issue that merits further<br />
research and exploration to fully understand the nature and root cause of the failure when<br />
attempting to hot swap nodes on the CAN bus. For both data rates, the total messages sent is<br />
representative of the total number of messages sent up to the point that hot swapping of a node is<br />
attempted. When hot swapping of nodes is not attempted, no failures are noted.<br />
For the data rate of 10 kbps and 30 CAN nodes, no significant degradation in<br />
bandwidth or reduction in total messages transferred is realized. However, while conducting this<br />
test at 125 kbps with 30 CAN nodes, a slight degradation in bandwidth is noticed as can be<br />
seen by the lower amount of messages transferred within the same amount of time from the test<br />
conducted here versus the test conducted in Section 5.3.21.2 (compared to data in Table 5.20<br />
190
which is in section 5.3.21.2). While this is only a 2.45% reduction in total messages transferred<br />
in going from one node to thirty nodes, this issue could become critical as more nodes are added<br />
to the system.<br />
5.3.21.5 Send Extended Frame Test (send_frame_extended)<br />
In conducting this test, messages are placed on the CAN bus using the extended 29-bit<br />
message identifier field. The Altera DE2 board is connected with 30 CAN nodes on the<br />
network. The test setup is the same as that shown previously in Figure 5.40. Only two data rates<br />
are used in conducting this test: 10 kbps and 125 kbps. Again, these values were selected<br />
because they most closely match those speeds supported by 1 – Wire® devices. The results for<br />
this test are shown in Table 5.22.<br />
Table 5.22 Send Extended Frame (send_frame_extended) Test Results.<br />
Data Rate Messages Sent Data Bytes Length of test Hot Swapped Failures<br />
10 kbps 208,615 8 60 min No None<br />
10 kbps 1,548 8 60 min Yes Yes<br />
125 kbps 2,531,027 8 60 min No None<br />
125 kbps 5,483 8 60 min Yes Yes<br />
For this test, no failures are noted when hot swapping nodes is not attempted. But when<br />
attempting to hot swap nodes, communication on the bus is again halted and the only way to<br />
restore communications is to perform a hard reset, powering down the Altera DE2 board and all<br />
CAN nodes. For both data rates, the total messages sent is representative of the total number<br />
of messages sent up to the point that hot swapping of a node is attempted. As stated previously,<br />
this is an issue that merits further investigation and research.<br />
While conducting this test with 30 CAN nodes, degradation in bandwidth is realized<br />
even at the slower speed of 10 kbps. While only a 7.98% reduction in total messages transferred,<br />
191
going from one node to 30 nodes (see test results presented in Table 5.20), this is still a<br />
significant reduction. At the higher data rate of 125 kbps, the reduction in total messages<br />
transferred is even more apparent, having a reduction in value of 10.18% for 30 CAN nodes.<br />
This reduction in total messages transferred could become a larger issue as more CAN nodes<br />
are added to the system. Clearly, more research and testing are needed to conclusively identify<br />
the source of this reduction in total messages transferred.<br />
192
CHAPTER 6<br />
1 – WIRE® <strong>AND</strong> CAN COMBINED SYSTEM PROTOTYPE IMPLEMENTATION<br />
6.1 Overview of Integrated System<br />
The fully integrated prototype system presented here consists of the following: a<br />
synthesizable 1 – Wire® Bus Master and a synthesizable CAN Controller implemented on the<br />
Altera DE2 board; multiple CAN nodes using the design specified in Section 5.3.20; and<br />
multiple 1 – Wire® slave devices. The complete prototype system is shown in Figure 6.1. The 1<br />
– Wire® slave devices shown in Figure 6.1 are samples obtained through Maxim<br />
Semiconductor. The CAN nodes shown in Figure 6.1 are based on Microchip application note<br />
AN215 [47]. Table 6.1 shows FPGA resource utilization by the Altera DE2 Development and<br />
Education board for the prototype CAN Controller and 1 – Wire® Master.<br />
Figure 6.1 Combined CAN & 1 – Wire® Prototype System.<br />
193
Table 6.1 Resource Utilization.<br />
Revision Name one_wm_CAN_Controller<br />
Family Cyclone II<br />
Device EP2C35F672C6<br />
Timing Models Final<br />
Met timing requirements Yes<br />
Total logic elements 4248 / 33,216 ( 13 % )<br />
Total combinational functions 3626 / 33,216 ( 11 % )<br />
Dedicated logic registers 1167 / 33,216 ( 3.5 % )<br />
Total registers 1167<br />
Total pins 44 / 475 ( 9 % )<br />
Total virtual pins 0<br />
Total memory bits 3538 / 483,840 (
6.2 Verification of Combined Prototype System<br />
To verify proper operation of the 1 – Wire® and CAN combined prototype system,<br />
several test cases are executed, utilizing both regular and overdrive 1 – Wire® communication<br />
speeds. For all tests, the hardware used, shown in Figure 6.2, includes the following<br />
components: three DS1996 – 64Kb Memory iButtons [83], DS1402-BR8+ 1 – Wire®<br />
Network Cable [80], DS1401-4 Front-Panel iButton Holder [81], and two CAN nodes as<br />
described in Section 5.3.20. The reason for using the DS1996 64Kb Memory iButtons is that<br />
the DS1996 is the largest memory iButton currently in production, and provides 65,536 bits of<br />
read/write nonvolatile memory partitioned into 256-bit pages for packetizing data. The<br />
equivalent EPROM, DS1986 [99], could just as easily have been used as a suitable replacement<br />
except the product is no longer available and therefore is not recommended for new designs.<br />
However, the DS1977 [93] could be used as a substitute, especially if security were an issue and<br />
password protection were required. Both tests are compiled and simulated using Altera Quartus<br />
II 9.1 (32-bit) and ModelSim Altera Starter Edition 6.6c software on a PC executing Windows<br />
XP Service Pack 3. All tests are performed extensively while trying to cover all possible<br />
combinations of inputs and outputs. The source code for all modules, testbench code, and<br />
simulation results are located on the DVD included with this work.<br />
Figure 6.2 1 – Wire® & CAN Combined Prototype System.<br />
195
6.2.1 Test Verification and Overview<br />
For the tests presented here, all 1 – Wire® devices and CAN nodes are tested at regular<br />
speeds (approximately 14 kbps for all 1 – Wire® devices and 10 kbps for all CAN nodes) and<br />
overdrive speeds (approximately 140 kbps for all 1 – Wire® devices and 125 kbps for all<br />
CAN nodes). Also for this test only two CAN nodes and three DS1996 1 – Wire® devices<br />
are used. This was done for easier troubleshooting in case of a catastrophic failure and would<br />
make analysis of the data bytes transferred simpler with fewer CAN nodes and 1 – Wire®<br />
devices on the bus. Since this was the first time testing the combined system, there was some<br />
degree of uncertainty concerning functionality after combining the Verilog® source code of the 1<br />
– Wire® Master and the CAN Module. Combining the source code for the CAN Module<br />
and 1 – Wire® Master required additional lines of code to take into account the additional logic<br />
registers and logic elements required.<br />
For both tests in described Sections 6.2.1.2 and 6.2.1.3, the 1 – Wire Search Algorithm<br />
(see Section 2.3.6) is used to discover the 64-bit identification numbers of the DS1996 1 –<br />
Wire® devices. Once the identification numbers are known and stored in memory on the 1 –<br />
Wire Master, the order in which the numbers are obtained is the order in which the devices are<br />
written to. With the DS1996, the offset data byte is used to determine the next byte of memory<br />
to which data will be written. When the device memory is full, the next available DS1996<br />
discovered by the 1 – Wire® Search Algorithm is used. This process is repeated for all three<br />
DS1996 1 – Wire® devices until the memory of all three devices is full. Then the process is<br />
repeated all over again with the next byte of data being written to the first DS1996 1 – Wire®<br />
device, overwriting old data as necessary.<br />
196
6.2.1.1 DS1996 Addressing and Memory Layout<br />
Properly communicating with the DS1996 [83] 1 – Wire® devices used in these tests<br />
requires an understanding and explanation of how the memory is organized and how to address<br />
individual pages within the memory. The memory map for a DS1996 [83] is shown in Figure<br />
6.3. At the top of the memory map is a 32-byte page, called the scratchpad. The scratchpad is an<br />
additional page that acts as a buffer when writing to memory. Beneath this are the additional 32-<br />
byte pages of memory. The DS1996 contains 256 pages which comprise the 65,536 bits of<br />
read/write nonvolatile memory.<br />
Figure 6.3 DS1996 iButton Memory Map.<br />
Because of the serial data transfer, the DS1996 employs three address registers, called<br />
TA1, TA2, and E/S as shown in Figure 6.4. Registers TA1 and TA2 must be loaded with the<br />
target address to which the data will be written or from which data will be sent to the 1 – Wire®<br />
Master upon a Read command. Register E/S acts like a byte counter and Transfer Status register.<br />
It is used to verify data integrity with Write commands. Therefore, the 1 – Wire® Master only<br />
197
has read access to this register. The lower five bits of the E/S register indicate the address of the<br />
last byte that has been written to the scratchpad. This address is called the Ending Offset bit. Bit<br />
5 of the E/S register, called PF or “partial-byte flag,” is set if the number of data bits sent by the<br />
1 – Wire® Master is not an integer multiple of 8. Bit 6, <strong>OF</strong> or “Overflow,” is set if more bits are<br />
sent by the 1 – Wire® Master than can be stored in the scratchpad area. Note that the lowest five<br />
bits of the target address also determine the address within the scratchpad, where intermediate<br />
storage of data will begin. This address is called the byte offset. For best economy of speed and<br />
efficiency, the target address for writing should point to the beginning of a new page, i.e., the<br />
byte offset will be zero. Thus, the full 32-byte capacity of the scratchpad is available, resulting<br />
also in the ending offset of 0x001F. However, it is possible to write one or several contiguous<br />
bytes somewhere within a page. The ending offset together with the Partial and Overflow Flag is<br />
mainly a means to support the 1 – Wire® Master checking the data integrity after a Write<br />
command. The highest valued bit of the E/S register, called AA or Authorization Accepted, acts<br />
as a flag to indicate that the data stored in the scratchpad area has already been copied to the<br />
target memory address. Writing data to the scratchpad clears this flag.<br />
Figure 6.4 DS1996 Address Registers.<br />
198
To write data to the DS1996, the scratchpad has to be used as an intermediate storage<br />
area. First, the 1 – Wire® Master issues the Write Scratchpad command (0xF0) to specify the<br />
desired target address, followed by the data to be written to the scratchpad. In the next step, the<br />
1 – Wire® Master sends the Read Scratchpad command (0xAA) to read the scratchpad and to<br />
verify data integrity. As preamble to the scratchpad data, the DS1996 sends the requested target<br />
address TA1 and TA2 and the contents of the E/S register. If one of the flags <strong>OF</strong> or PF is set,<br />
data did not arrive correctly in the scratchpad. The master does not need to continue reading; it<br />
can start a new trial to write data to the scratchpad. Similarly, a set AA flag indicates that the<br />
Write command was not recognized by the DS1996. If everything works correctly, all three<br />
flags are cleared and the ending offset indicates the address of the last byte written to the<br />
scratchpad. Now the 1 – Wire® Master can continue verifying every data bit. After the 1 –<br />
Wire® Master has verified the data it has to send the Copy Scratchpad command (0x55). This<br />
command must be followed exactly by the data of the three address registers TA1, TA2, and E/S<br />
as the 1 – Wire® Master has read them verifying the scratchpad contents. As soon as the slave<br />
has received these bytes, it will copy the data to the requested location beginning at the target<br />
address. The communication between the 1 – Wire® Master and the DS1996 takes place either<br />
at regular speed or at overdrive speed. If not explicitly set into the Overdrive Mode, the DS1996<br />
assumes regular speed.<br />
6.2.1.2 Test Results – Transferring CAN data bytes to 1 – Wire® devices<br />
To conduct this test, three DS1996 1 – Wire® slaves are present on the 1 – Wire®<br />
network, providing a total of 196,608 bits (24,576 bytes) of memory. Figure 6.2 shows the<br />
199
system configuration used for this test. In addition two CAN nodes are utilized, whose<br />
addresses are set to 1 and 2, respectively. The custom interface on the FPGA handles all<br />
conversions from CAN messages to 1 – Wire® commands. Each CAN node is<br />
automatically performing an A/D conversion (voltage divider circuit from a potentiometer)<br />
approximately every 500 ms and transmitting this data on the CAN bus to the DS1996 1 –<br />
Wire® devices. In addition to the data byte containing the A/D conversion result, both CAN<br />
nodes are programmed to also send an I/O status byte, which includes the status of both the<br />
Digital Inputs and Digital Outputs. So to summarize, approximately every 500 ms, eight data<br />
bytes are being transmitted on the CAN bus to the DS1996 1 – Wire® devices. Two of these<br />
data bytes represent the transmitting node number and the other two represent the A/D<br />
conversion result and Digital I/O status bytes, respectively (i.e., node number + A/D conversion<br />
result and node number + Digital I/O status). The results of this test are presented in Table 6.2.<br />
Table 6.2 Test Results.<br />
1 – Wire®<br />
Devices<br />
Type #<br />
# of CAN<br />
Nodes<br />
CAN Bus<br />
Speed (kbps)<br />
1 – Wire® Bus<br />
Speed (kbps)<br />
Hot-Swapped<br />
(1 – Wire®)<br />
Length of Test<br />
(min)<br />
Failures<br />
DS1996 3 2 10 14 Yes 60 No<br />
DS1996 3 2 10 140 Yes 18 Yes 1<br />
DS1996 3 2 125 14 Yes 60 No<br />
DS1996 3 2 125 140 Yes 14 Yes 1<br />
1<br />
This failure resulted in loss of messages to 1 – Wire® devices from the CAN bus.<br />
From Table 6.2, lost CAN bus messages are noted when running the 1 – Wire® bus in<br />
overdrive speed. After many hours of repeating these two tests and many lines of debug code, it<br />
was found that if a CAN bus message came in while running the 1 – Wire® bus in overdrive<br />
and the devices were not all operating in overdrive speed yet, the present CAN bus message<br />
was dropped. Although, technically this is not a failure in the sense of a catastrophic event, it is<br />
200
a problem in that important CAN messages can be lost with no indication of a lost message or<br />
need for retransmission.<br />
As discussed in Section 4.3.4, there are two ways to get an overdrive-capable slave<br />
device into overdrive mode: Overdrive Skip command, and Overdrive Match command. Also,<br />
despite the extra command and reset cycle necessary to get 1 – Wire® devices into overdrive<br />
mode, using overdrive obtains the device identification number in less than half the time required<br />
at standard speed.<br />
One possible solution to this problem is to implement either a FIFO or prioritized FIFO<br />
buffer to possibly prevent CAN bus messages from being discarded and retain them until all 1<br />
– Wire® devices are operating at overdrive speed. Another possible solution is to implement<br />
some type of handshaking or acknowledgement when CAN bus messages are transmitted for 1<br />
– Wire® devices.<br />
6.2.1.3 Test Results – 1 – Wire® Master requests data from CAN Nodes<br />
Again for this test, three DS1996 1 – Wire® devices and two CAN nodes are present<br />
on the network. The 1 – Wire® devices and CAN bus nodes are connected as shown in Figure<br />
6.2. The CAN node addresses remain set at 1 and 2 respectively. Unlike the test conducted in<br />
Section 6.2.1.2, the CAN nodes utilized for this test have been modified to prevent the<br />
automatic transmission of the A/D conversion result every 500 ms. Also, the 1 – Wire® Master<br />
was modified to have the capability to send a command to any one particular node or all of the<br />
CAN nodes. Additional Verilog® code in the form of a For loop was added to simulate a<br />
broadcast command being sent from the 1 – Wire® Master. Whether this command is executed<br />
201
or not depends on the number of receiving CAN nodes. The command sent depends on the<br />
data written to the FILHIT bits of the RXB1CTRL register of the MCP2515. The<br />
meaning of these filter bits is described in Section 5.3.20.4 and a program execution flowchart is<br />
shown in Figure 5.37. Figure 6.5 shows the contents of this MCP2515 register.<br />
Figure 6.5 RXB1CTRL – Receive Buffer 1 Control Register Bit Definitions [44].<br />
The $random() function is used to determine which command is going to be sent to the<br />
CAN nodes. Details of the $random() function are covered in Section 5.2.8.3. To generate a<br />
random value to represent the command to send to the CAN node(s), the following block of<br />
code was executed:<br />
integer seed_value, random_value;<br />
random_value = $random(seed_value) % 7;<br />
random_value = abs(random_value);<br />
This block of code returns a value between 0 and 6 which corresponds to the list of commands<br />
summarized in Table 6.3. This random value is then sent out to one or both CAN nodes as a<br />
command setting the appropriate bits in the FILHITx registers on the node(s). The receiving<br />
CAN node(s) then perform the required command and send the resulting data back to the 1 –<br />
Wire® Master which then stores the data contiguously in the DS1996 1 – Wire® slave devices.<br />
The results of this test are presented in Table 6.4.<br />
202
1 – Wire®<br />
Devices<br />
Type #<br />
Table 6.3 FILHITx Bit Definitions.<br />
FILHIT2 FILHIT1 FILHIT0 Description<br />
0 0 0 Perform A/D conversion on AN1.<br />
0 0 1 Read Digital Input pins.<br />
0 1 0 Write Value to Digital Output 1.<br />
0 1 1 Write Value to Digital Output 2.<br />
1 0 0 Change Node Address.<br />
1 0 1 Turn off Digital Outputs 1 and 2.<br />
1 1 1 Not Used<br />
# of<br />
CAN<br />
Nodes<br />
# of<br />
Receiving<br />
CAN<br />
Nodes<br />
Table 6.4 Test Results.<br />
CAN Bus<br />
Speed (kbps)<br />
203<br />
1 – Wire®<br />
Bus Speed<br />
(kbps)<br />
Hot-<br />
Swapped<br />
(1 – Wire®)<br />
Length of<br />
Test<br />
(min)<br />
Failures<br />
DS1996 3 2 1 10 14 Yes 60 No<br />
DS1996 3 2 2 10 14 Yes 60 Yes 2<br />
DS1996 3 2 1 10 140 Yes 18 Yes 1<br />
DS1996 3 2 2 10 140 Yes 11 Yes 1<br />
DS1996 3 2 1 125 14 Yes 60 No<br />
DS1996 3 2 2 125 14 Yes 60 Yes 2<br />
DS1996 3 2 1 125 140 Yes 14 Yes 1<br />
DS1996 3 2 2 125 140 Yes 24 Yes 1<br />
1 This failure resulted in loss of messages to the 1 – Wire® devices from the CAN bus.<br />
2 This failure resulted in loss of messages to the 1 – Wire® devices, but did not require a hard reset.<br />
From Table 6.4, lost CAN bus messages are noted in all cases where running the 1 –<br />
Wire® bus in overdrive speed. As was the case with the test performed in Section 6.2.1.2,<br />
debugging the system found that if a CAN bus message came in while running the 1 – Wire®<br />
bus in overdrive and the 1 – Wire® devices were not all operating in overdrive speed yet, the<br />
present CAN bus message got dropped. Although, technically this is still not a failure in the<br />
sense of a catastrophic failure, it is still a problem in that if this had been a safety-critical system,<br />
any loss of data or messages could be catastrophic.<br />
When sending a 1 – Wire® command to multiple CAN nodes it was sometimes noted<br />
that the data received from the CAN nodes was not the data requested by the 1 – Wire®<br />
Master and stored by the 1 – Wire® slaves. For instance, consider the second test case in Table
6.4. There are two receiving CAN nodes and both the CAN bus and 1 – Wire® bus are<br />
operating at their slower speeds of 10 kbps and 14 kbps, respectively. Only in certain instances<br />
is data lost when it is requested from the CAN nodes. After inserting lines of debug code and<br />
recording the commands sent to the CAN nodes from the 1 – Wire® Master, no correlation is<br />
found between one particular command being sent to the CAN nodes from Table 6.4 and data<br />
loss. It was discovered, however, that in certain cases if both CAN nodes send their data<br />
before it can be fully processed by the 1 – Wire® Bus Master, data loss to the 1 – Wire® slaves<br />
occurs. This results in the first byte of requested data being overwritten by the second byte of<br />
data. The CAN node that transmits its byte of data first determines which byte of data is<br />
actually stored to the 1 – Wire® slaves. It is also discovered that there is no loss of data in the<br />
commands being send from the 1 – Wire® Master to the receiving CAN nodes.<br />
Again, a possible solution to this problem is to implement either a FIFO or a prioritized<br />
FIFO buffer to possibly prevent the data requested from the CAN nodes from being<br />
overwritten. As was mentioned in Section 6.2.1.2, another possible solution is to implement<br />
some type of handshaking or acknowledgement when the data byte requested from the CAN<br />
nodes are actually successfully stored in the memory of the DS1996 1 – Wire® devices. Even<br />
though this would impact the speed of the bus, the reliability gained by preventing data loss<br />
would greatly outweigh the reduction in data throughput.<br />
Finally, no conclusion is reached regarding the loss of data in the test cases (tests 3,4,7,<br />
and 8) where the 1 – Wire® slaves are operating at overdrive speed. It is unknown as to whether<br />
the data loss to the 1 – Wire® slaves is a result of all devices not operating in overdrive speed or<br />
if data loss is a result of both CAN nodes transmitting the requested data before the 1 – Wire®<br />
204
Master could successfully process the requested data. Clearly, further research and testing is<br />
needed to determine the root cause of data loss and to implement a viable solution. One simple<br />
solution might be to place a delay timer when trying to communicate with 1 – Wire® slaves at<br />
overdrive speed. This should give all 1 – Wire® slaves enough time to successfully be ready to<br />
accept data at overdrive speeds.<br />
205
CHAPTER 7<br />
CONCLUSIONS <strong>AND</strong> FUTURE WORK<br />
Many of today’s digital designs are implemented using custom <strong>ASIC</strong>s or gate arrays.<br />
Quite often, entire systems can be implemented with only a few <strong>ASIC</strong>s. The use of FPGAs is<br />
also increasing, providing lower cost <strong>ASIC</strong>-based alternatives to limited production designs. In<br />
general, the proliferation of <strong>ASIC</strong>s and gate arrays in contemporary digital designs is increasing<br />
at a rapid rate. The research encompassed by this work presented a VLSI (Very Large Scale<br />
Integration) design and simulation of a custom <strong>ASIC</strong> incorporating two communication<br />
protocols, CAN (Controller Area Network) and 1 – Wire®, targeting wearable medical<br />
technology and devices and hybrid-electric vehicle technology applications.<br />
The synthesizable 1 – Wire® Master presented in Chapter 5 is based on the 1 – Wire®<br />
communications protocol by Maxim Semiconductor. The design is written in Verilog® and<br />
tested on an Altera DE2 Development and Education Board using the Quartus II software<br />
package. From the four tests executed (single_search_rom, multi_ow_network,<br />
scratchpad_integrity, and cmd_recognition), no failures were observed even during hot-swapping<br />
of both parasitically and non-parasitically powered slave device. With this being the case, more<br />
testing is needed using standard and overdrive speeds as well as parasitically and non-<br />
parasitically powered devices before finalizing the prototype 1 – Wire® Master.<br />
206
As stated in section 5.2.8.3, scratchpad_integrity test, more testing is needed for<br />
conclusive evidence on failure rates. In particular more tests need to be performed using<br />
multiple 1 – Wire® slave devices of different types. If multiple 1 – Wire® slave devices exist on<br />
the 1 – Wire® network and a READ_ROM command (0x33) is issued immediately following<br />
the SKIP_ROM command (0xCC), data collision is inevitable on the bus as multiple slaves will<br />
try and transmit simultaneously. This is a direct result of open-drain pull-downs, as they will<br />
produce a wired-<strong>AND</strong> result. This will more than likely shut the 1 – Wire® network down but<br />
perhaps with testing on just this case, it might be possible to at least minimize the failure rate and<br />
prevent data loss from occurring.<br />
Another area where more testing is needed for all four test cases presented in sections<br />
5.2.8.1 through 5.2.8.4 is the use of both standard and overdrive speed devices coexisting on the<br />
same network. Even though the test conducted in section 5.2.8.4, cmd_recognition, used several<br />
overdrive commands, there was only a single 1 – Wire® slave device on the network.<br />
Additionally hot-swapping was performed and no failures were observed with a single 1 –<br />
Wire® device; the same cannot be automatically assumed in the case for multiple 1 – Wire®<br />
slaves. This is especially true if both standard and overdrive speed capable devices coexist on<br />
the same network. Therefore more testing is needed to ensure reliability and data integrity on the<br />
1 – Wire® network, in the cases of hot-swapping and coexistence of both standard and overdrive<br />
speed devices.<br />
Even though the time savings is nearly 2.5 times greater at overdrive speeds than at<br />
standard speeds, extra care must be taken when hot-swapping slave devices at overdrive speeds.<br />
Since hot-swapping slave devices causes a temporary electrical short between DATA and GND,<br />
207
a communication bus reset will occur. This in turn will reset all slave devices operating at<br />
overdrive speed back to standard speed. For the combined 1 – Wire® and CAN system,<br />
failures will be imminent. More testing and debugging is needed so as to minimized the failure<br />
rate as much as possible and also to try and mitigate data loss and/or corruption of both CAN<br />
and 1 – Wire® data packets.<br />
The synthesizable CAN Controller presented in Chapter 5 is based upon two different<br />
models: the Bosch VHDL Reference System is used mostly for a verification tool and the<br />
Motorola CAN (MCAN) Module [95 – 97] for its functional and memory map layout. The<br />
design is written in Verilog® and tested on an Altera DE2 Development and Education Board<br />
using the Quartus II software package. From the five tests executed (test_synchronization,<br />
bus_off_test, error_test, send_frame_basic, and send_frame_extended), failures were only<br />
noticed when attempting to hot swap a node. Of the three tests where hot-swapping was<br />
attempted (error_testSection 5.3.21.3, send_frame_basicSection 5.3.21.4, and<br />
send_frame_extendedSection 5.3.21.5), all three tests encountered failures and a hard reset had<br />
to be performed for communication to be re-established.<br />
For the test conducted in Section 5.3.21.3, error_test, 30 CAN nodes are utilized.<br />
More testing and debugging is necessary to find, if one exists, a root cause for the failure of the<br />
CAN realized when attempting hot-swapping of CAN nodes. At this time, the only<br />
plausible explanation for the failure is believed to be in the CAN transceiver used on each<br />
CAN node. Although the data sheet for the MCP2551 [45], used on each CAN node, states<br />
that when the device is powered on, CAN_H and CAN_L remain in a high-impedance state until<br />
VDD reaches the voltage-level VPORH, it does not give an exact value for this impedance. It is<br />
208
known that many CAN transceivers on the market today have very low output impedance<br />
when unpowered. This causes the device to sink any signal present on the bus and effectively<br />
shuts down all data transmission. One possible solution might be to perform this exact test again<br />
but with a different CAN transceiver on each node. Texas Instruments has a transceiver,<br />
SN65HVD1050 [100], which according to the data sheet, should work to solve this problem.<br />
According to the data sheet, the HVD1050’s bus pins are biased internally to a high-impedance<br />
recessive state. This provides for a power-up into a known recessive condition without<br />
disturbing ongoing bus communication. It also maintains the integrity of the bus when power or<br />
ground is added to or removed from the circuit [100]. Another possible solution is to add<br />
additional hardware to the entire CAN bus system, in the form of a bus utilization monitor and<br />
data packet logger. Clearly, more time and testing are needed to find a viable solution to this<br />
problem. This is important since the ability to plug directly into a currently operating system<br />
becomes a valued asset in many CAN applications.<br />
For the remaining two tests, send_frame_basic and send_frame_extended, failures are<br />
again noted when hot-swapping of nodes was attempted. As previously discussed, more testing<br />
is needed, plus the possibility of swapping out the CAN transceiver used on each node, to find<br />
a solution and prevent having to perform a hard reset each time hot-swapping is attempted. The<br />
prevention of such failures would be a very beneficial feature to any CAN node system,<br />
especially for safety-critical networks. It might prove worthwhile for future modifications to<br />
consider writing testbench code for tests such as a Reset Mode test and Bus-Off Recovery test.<br />
Such tests might provide some insight to possible hot-swapping failures.<br />
209
For the synthesizable CAN Controller, there was an additional test considered but<br />
never fully implemented: self_reception_request test. In this test, there are two different modes<br />
of operation. First, the CAN module performs an internal loop back (default), which can be<br />
used for self-test operation. In this mode, a dummy Acknowledge bit is provided, thereby<br />
eliminating the need for another node on the bus to provide the Acknowledge bit (i.e. the module<br />
treats its own transmitted message as a message received from a remote node). The rx input pin<br />
is ignored and the tx output pin goes to the recessive state (logic ‘1’). Both transmit and receive<br />
interrupts are generated. Alternatively, if the user desires, the current message can be queued for<br />
transmission without disabling the receiver. It will receive the message only if the Acceptance<br />
Filter recognizes the message ID. This test was originally considered as a part of a plan to also<br />
implement a FIFO or prioritized FIFO buffer in the synthesizable CAN Controller. But after<br />
much time and consideration it was thought that a better approach would be to implement a FIFO<br />
or prioritized FIFO buffer as a separate entity in the design and not integrate it as part of the<br />
CAN Controller. So for this reason development and implementation of this test was dropped.<br />
From the test results of those performed in Chapter 6, the combined 1 – Wire® to CAN<br />
prototype system clearly needs more debugging and testing before becoming a fully-functional<br />
production prototype. This is evident from the failures noted in Tables 6.2 and 6.4 as a result of<br />
the two tests performed. Even though neither of the two tests performed had a failure from a<br />
catastrophic point of view, both tests had failures concerning lost CAN bus messages when<br />
trying to run 1 – Wire® devices in overdrive speed and also when trying to hot-swap 1 – Wire®<br />
devices. As stated previously, this is primarily attributed to the extra steps required to get all 1 –<br />
Wire® devices into overdrive mode. This is still a big problem especially if the system is going<br />
210
to be used in any type of safety-critical application environment. A simple and obvious fix to<br />
this problem is to run similar speeds on both buses without allowing hot-swapping: either the<br />
CAN bus at 10 kbps and the 1 – Wire® bus at 14 kbps or the CAN bus at 125 kbps and the<br />
1 – Wire® bus at 140 kbps. The downside to this option is the reduced flexibility placed on the<br />
combined system which is stated as being one of the big advantages of using 1 – Wire® devices<br />
and technology.<br />
The other type of failure from the tests conducted on the combined prototype system<br />
occurred when sending a 1 – Wire® command to multiple CAN nodes. It was originally<br />
thought that the cause of data loss was from receiving the response data bytes from the CAN<br />
nodes before the 1 – Wire® Master had time to process and write the received data bytes to the<br />
appropriate memory locations on the DS1996 1 – Wire® devices. Another possible scenario for<br />
the source of the data loss was that data was coming in to the 1 – Wire® Master before all of the<br />
1 – Wire® slave devices were operating in overdrive speed. After inserting numerous traps and<br />
inserting lines of debug code, it was determined that when requesting data from multiple CAN<br />
nodes the first byte of received data could be overwritten by the second byte of data if the 1 –<br />
Wire® Master had not been able to successfully process the incoming data byte. However, no<br />
definitive conclusions were reached as to the root cause of data loss. Data loss could have been a<br />
combination of one or both scenarios. Clearly further research and testing is needed to find a<br />
solution to prevent data loss and the idea of inserting a delay timer for the cases when 1 – Wire®<br />
slaves are being operated at overdrive speed certainly merits exploration. No further testing was<br />
performed with additional nodes, since it can be assumed that if failures were seen when<br />
requesting data from two CAN nodes that this problem would only become more apparent as<br />
211
additional CAN nodes were added to the system. It should be noted that no failures were<br />
observed when only requesting data from an individual CAN node.<br />
For the vast majority of failures observed while conducting tests on the combined<br />
prototype system, there is no doubt that the system would greatly benefit from the addition of<br />
either a FIFO or prioritized FIFO buffer. Although not implemented as an integral part of the<br />
final design, considerable research was done on this solution. A proposed FIFO buffer based on<br />
a 74F433 FIFO Buffer Memory IC [101] from Fairchild Semiconductor is presented here. Its<br />
purpose would be to provide seamless, asynchronous communication between the 1 – Wire® and<br />
CAN networks. It might even be a possibility that the addition of a FIFO or prioritized FIFO<br />
buffer and a delay timer would solve all of the failure rates seen in the testing of the combined<br />
system.<br />
The FIFO Buffer Memory is organized as 64 words by 4-bits and may be expanded to<br />
any number of words or any number of bits in multiples of four. This allows data to be entered<br />
or extracted asynchronously in serial form. Figure 7.1 shows a block diagram of the FIFO<br />
Buffer Memory section and Table 7.1 gives a brief description of the pin names. It consists of<br />
three major sections:<br />
An Input Register with serial data inputs, as well as control inputs and outputs for input<br />
handshaking and expansion.<br />
A 4-bit-wide, 64-word-deep fall-through stack with self-contained control logic.<br />
An Output Register with serial data outputs, as well as control inputs and outputs for<br />
output handshaking and expansion.<br />
212
Figure 7.1 FIFO Buffer Memory [101].<br />
These three sections operate asynchronously and are virtually independent of one another:<br />
Input Register (Data Entry) the Input Register receives data in bit-serial form and<br />
stores this data until it is sent to the fall-through stack. It also generates the necessary<br />
status and control signals. Data on the Serial Data line (DS) input is serially entered<br />
into a shift register on each HIGH-TO-LOW transition of the SIC input when the<br />
Serial Input Enable ( SIE ) signal is LOW.<br />
213
Fall-Through Stack A LOW level on the Transfer to Stack ( TTS ) input initiates a<br />
fall-through action; if the top location of the stack is empty, data is loaded into the<br />
stack and the input register is reinitialized. Thus, automatic FIFO action is achieved<br />
by connecting the IRF output to the TTS input. An RS-type flip-flop (the<br />
initialization flip-flop) in the control section records the fact that data has been<br />
transferred to the stack. This prevents multiple entry of the same word into the stack<br />
even though IRF and TTS may still be LOW. Once in the stack, data falls<br />
through automatically, pausing only when it is necessary to wait for an empty next<br />
location.<br />
Output Register The Output Register receives 4-bit data words from the bottom<br />
stack location, stores them, and outputs data on a TRI-STATE serial data bus. The<br />
output section generates and receives the necessary status and control signals. When<br />
the FIFO is empty after a LOW is applied to the MR input, the ORE output is<br />
LOW. After data has been entered into the FIFO and has fallen through to the bottom<br />
stack location, it is transferred into the output register if the TOS input is LOW. As<br />
a result of the data transfer, ORE goes HIGH, indicating that valid data is in the<br />
register.<br />
214
Table 7.1 FIFO Buffer Memory Pin Names and Descriptions.<br />
Pin Name Description<br />
SIC Serial Input Clock<br />
SIE Serial Input Enable<br />
TTS Transfer to Stack Input<br />
MR Master Reset<br />
SOE Serial Output Enable<br />
TOS Transfer Out Serial<br />
SOC Serial Output Clock<br />
DS<br />
QS<br />
Serial Data Input<br />
Serial Data Output<br />
ORE Output Register Empty<br />
IRF Input Register Full<br />
Another option that was considered regarding the FIFO buffer was to integrate it directly<br />
into the synthesizable CAN Controller. Even though the CAN Controller is fully functional<br />
concerning both standard and extended data frames, it is not perfect and by no means capable of<br />
handling hot-swapping of CAN nodes. Perhaps with more testing and debugging, especially<br />
dealing with hot-swapping this idea might be worth returning to and trying to integrate as part of<br />
the CAN Controller.<br />
Although not implemented, considerable thought was also given to the idea of<br />
implementing bi-directional (full-duplex) communication in the prototype system. This would<br />
allow data to be transferred from the CAN network to the 1 – Wire® network and vice versa<br />
simultaneously. This would greatly increase the throughput of the entire system and also system<br />
marketability.<br />
215
In conclusion, the prototype system design presented in this manuscript is comprised of a<br />
fully-functional 1 – Wire® Bus Master and a CAN 2.0B compliant CAN Controller. It has<br />
successfully been shown that data from a 1 – Wire® network can be sent to a CAN bus node<br />
and that data can be requested by a 1 – Wire® Bus Master from a CAN bus node. In fact, data<br />
has been stored on a DS1996 iButton that was received from the result of an A/D conversion<br />
on a CAN bus node.<br />
Minor issues that still need to be addressed are as follows: hot-swapping of CAN<br />
Controller nodes, hot-swapping of 1 – Wire® devices in overdrive mode while receiving data<br />
from the CAN bus, receiving requested data from multiple CAN nodes for 1 – Wire®<br />
devices, and hot-swapping of both 1 – Wire® and CAN nodes. Given time and resources<br />
these issues and many more can be addressed and solved to yield a fully integrated 1 – Wire®<br />
Master/CAN, CAN/1 – Wire® Master.<br />
The prototype system presented in this manuscript would no doubt be of great benefit to<br />
wearable medical technology and devices and hybrid-electric vehicle technology applications.<br />
By utilizing serial communications, the pin count for a robust, reliable communication backbone<br />
is kept to a minimum. This would keep both the wiring cost and complexity to implement such a<br />
system to a minimum. With the low-cost and ease of CAN-enabling almost any device, the<br />
combinations of sensor networks that could be designed for both application markets is infinite<br />
and is only limited by the creativity of the system designer. Combine this with the variety of<br />
both current in-production 1 – Wire® devices and those not currently in production but still<br />
readily available, and almost any application or system can be implemented. Taking all of this<br />
into account and the limited FPGA resources utilized in the design presented in this manuscript,<br />
216
an inexpensive <strong>ASIC</strong> would be capable of handling the interface and data demands of most any<br />
application for either market.<br />
217
REFERENCES<br />
[1] IBM <strong>ASIC</strong> Products Application Note, “<strong>ASIC</strong> Design Methodology Primer,” Initial<br />
Publication 05/98. Website: http://asaha.com/ebook/UODk0Njc-/<strong>ASIC</strong>-Design-<br />
Methodology-Primer.pdf#PDF Ebook (Accessed on November 20, 2011).<br />
[2] Application-Specific Integrated Circuits (<strong>ASIC</strong>’s). Website:<br />
http://www.siliconfareast.com/asic.htm. (Accessed on November 20, 2011).<br />
[3] J. Rutherford, “Wearable Technology,” in IEEE Engineering In Medicine and Biology,<br />
Volume 29, Issue 3, 2010, Page(s): 19 – 24.<br />
[4] Maxim Application Note 148: “Guidelines for Reliable Long Line 1 – Wire® Networks,”<br />
September 22, 2008. Website: http://pdfserv.maxim-ic.com/en/an/AN148.pdf.<br />
(Accessed on November 17, 2011).<br />
[5] D. Awtrey, “Transmitting Data and Power Over a One-Wire Bus,” in Sensors – The<br />
Journal of Applied Sensing Technology, February 1997. Website:<br />
http://archives.sensorsmag.com/articles/0297/onewire/index.htm. (Accessed on<br />
November 17, 2011).<br />
[6] Dallas/Maxim Semiconductor Engineering Journals, “A layman’s overview of 1 – Wire®<br />
technology and its use”, Volume 4, Pages 3 – 8, March 2003. Website:<br />
http://pdfserv.maxim-ic.com/en/ej/DallasEJ4.pdf. (Accessed on November 17, 2011).<br />
[7] Dallas/Maxim Semiconductor Engineering Journals, “Dissecting the Versatile 1 – Wire®<br />
Network,” Volume 1, Pages 21 – 22, September 2001. Website: http://pdfserv.maximic.com/en/ej/DallasEJ1.pdf.<br />
(Accessed on November 17, 2011).<br />
[8] B. Linke, “Maxim Application Note 4206: Choosing the Right 1 – Wire® Master for<br />
Embedded Applications,” March 27, 2008. Website: http://pdfserv.maximic.com/en/an/AN4206.pdf.<br />
(Accessed on November 17, 2011).<br />
[9] Philips Semiconductors, “The I 2 C – Bus Specification,” Version 2.1, January 2000.<br />
Website: http://www.nxp.com/documents/other/39340011.pdf. (Accessed on November<br />
17, 2011).<br />
[10] B. Linke, “Maxim Application Note 1796: Overview of 1 – Wire® Technology and Its<br />
Use,” June 19, 2008. Website: http://pdfserv.maxim-ic.com/en/an/AN1796.pdf.<br />
(Accessed on November 17, 2011).<br />
[11] Maxim Application Note 155: “1 – Wire® Software Resource Guide Device<br />
Description,” July 8, 2008. Website: http://pdfserv.maxim-ic.com/en/an/AN155.pdf.<br />
(Accessed on November 17, 2011).<br />
218
[12] Maxim Semiconductor DS2480B – Serial to 1 – Wire® Line Driver Datasheet, 19-5047,<br />
Revision 3, May 2010. Website: http://datasheets.maxim-ic.com/en/ds/DS2480B.pdf.<br />
(Accessed on November 17, 2011).<br />
[13] Maxim Semiconductor Single-Channel 1 – Wire® Master, DS2482 – 100 Product<br />
Datasheet, 19-4930, Revision 8, November 2009. Website: http://datasheets.maximic.com/en/ds/DS2482-100.pdf.<br />
(Accessed on November 17, 2011).<br />
[14] Maxim Semiconductor Single-Channel 1 – Wire® Master with Sleep Mode, DS2482 –<br />
101 Product Datasheet, 19-4931, Revision 3, November 2010. Website:<br />
http://datasheets.maxim-ic.com/en/ds/DS2482-101.pdf. (Accessed on November 17,<br />
2011).<br />
[15] Maxim Semiconductor Eight-Channel 1 – Wire® Master with Sleep Mode, DS2482 –<br />
800 Product Datasheet, 19-4932, Revision 3, November 2009. Website:<br />
http://datasheets.maxim-ic.com/en/ds/DS2482-800.pdf. (Accessed on November 17,<br />
2011).<br />
[16] Maxim Application Note 187: “1 – Wire® Search Algorithm,” March 28, 2002.<br />
Website: http://pdfserv.maxim-ic.com/en/an/AN187.pdf. (Accessed November 17,<br />
2011).<br />
[17] Maxim Application Note 27: “Understanding and Using Cyclic Redundancy Checks with<br />
Maxim iButton Products,” March 29, 2001. Website: http://pdfserv.maximic.com/en/an/AN27.pdf.<br />
(Accessed on November 17, 2011).<br />
[18] D. Mannisto, M. Dawson (Machine Bus Technology), “An Overview of Controller Area<br />
Network (CAN) Technology,” November 12, 2003. Website:<br />
http://www.parallax.com/dl/docs/prod/comm/cantechovew.pdf. (Accessed on November<br />
17, 2011).<br />
[19] Renesas Electronics Corporation Application Note: “Introduction to CAN.” Website:<br />
http://documentation.renesas.com/eng/products/mpumcu/apn/rej05b0804_m16cap.pdf.<br />
(Accessed on November 17, 2011).<br />
[20] BOSCH CAN Specification Version 2.0. Website:<br />
http://esd.cs.ucr.edu/webres/can20.pdf. (Accessed on November 17, 2011).<br />
[21] K. Pazul (Microchip Technology, Inc.), Microchip Application Note AN713: “Controller<br />
Area Network (CAN) Basics,” September 16, 2005. Website:<br />
http://ww1.microchip.com/downloads/en/AppNotes/00713a.pdf. (Accessed on<br />
November 17, 2011).<br />
219
[22] “CAN – a brief tutorial for Embedded Engineers,” COMSOL – Computer Solutions Ltd.<br />
Website: http://www.computersolutions.co.uk/info/Embedded_tutorials/can_tutorial.htm.<br />
(Accessed on November 17,<br />
2011).<br />
[23] S. Robb (Freescale Semiconductor), Freescale Semiconductor Application Note AN1798:<br />
“CAN Bit Timing Requirement.” Website:<br />
http://www.freescale.com/files/microcontrollers/doc/app_note/AN1798.pdf. (Accessed<br />
on November 17, 2011).<br />
[24] L. M. Pinho, F. Vasques, and E. Tovar, “Integrating Inaccessibility in Response Time<br />
Analysis of CAN Networks,” in Proceeding of the 2000 IEEE International Workshop<br />
on Factory Communication Systems, 2000, Page(s): 77 – 84.<br />
[25] K. Zuberi and K. Shin, “Scheduling Messages on Controller Area Network for Real-Time<br />
CIM Applications,, in IEEE Transactions on Robotics and Automation, Volume 13,<br />
Number 2, Page(s): 310 – 314, 1997.<br />
[26] Rockwell Automation, “DeviceNet Product Overview,” Publication DN – 2.5, Rockwell,<br />
1997. Website:<br />
http://www.pacpro.com/upload/data/Rockwell%20Networks/DeviceNET/hardware/Devic<br />
eNet_ProdustOverview_Dn25.pdf. (Accessed on November 17, 2011).<br />
[27] L.-B. Fredriksson, “CAN for Critical Embedded Automotive Networks,” in IEEE Micro,<br />
Volume 22, Issue 4, 2002, Page(s): 28 – 35.<br />
[28] H. Kopetz, “Real-Time Systems Design Principles for Distributed Embedded<br />
Applications,” Kluwer Academic, Boston, 1997.<br />
[29] R. Obermaisser, “Ordering Messages in Virtual CAN Networks,” in the 12 th IEEE<br />
International Conference on Electronics, Circuits and Systems, 2005. ICECS 2005,<br />
Page(s): 1 – 4.<br />
[30] J. Vial and J. Dixon, “Monitoring Battery System for Electric Vehicle, Based on “One<br />
Wire” Technology,” Website: http://web.ing.puc.cl/~power/paperspdf/dixon/64a.pdf.<br />
(Accessed on November 17, 2011).<br />
[31] Eureka Prometheus Project. Website:<br />
http://en.wikipedia.org/wiki/EUREKA_Prometheus_Project. (Accessed on November<br />
17, 2011).<br />
[32] B. Linke, Maxim Application Note 3967: “Selecting a Serial Bus,”January 30, 2007.<br />
Website: http://pdfserv.maxim-ic.com/en/an/AN3967.pdf. (Accessed on November 17,<br />
2011).<br />
220
[33] Huang, “PIC® Microcontroller: An Introduction to Software and Hardware<br />
Interfacing,” Thomson-Delmar Learning, 2005, pg. 508, ISBN: 1-4018-3967-3.<br />
[34] Huang, “The HCS12/9S12: An Introduction to Software and Hard Interfacing,”<br />
Thomson-Delmar Learning, 2006, pg. 494, ISBN: 1-4018-9812-2.<br />
[35] Xilinx LogiCORE IP XPS Serial Perpiheral Interface (SPI) (v2.02a) Product<br />
Specification DS570, June 22, 2011. Website:<br />
http://www.xilinx.com/support/documentation/ip_documentation/xps_spi.pdf. (Accessed<br />
on November 17, 2011).<br />
[36] Altera Corporation Application Note 184: “Simultaneous Multi-Mastering with the<br />
Avalon Bus,” Version 1.1, April 2002. Website: http://www.altera.ru/Disks/Altera<br />
Documentation Library/literature/an/an184.pdf. (Accessed on November 17, 2011).<br />
[37] Altera Corporation, “SOPC User Builder Guide,” December 2010. Website:<br />
http://www.altera.com/literature/ug/ug_sopc_builder.pdf. (Accessed on November 17,<br />
2011).<br />
[38] M. Abd-El-Barr and H. El-Rewini, “Fundamentals of Computer Organization and<br />
Architecture,” John Wiley and Sons, 2005, pp. 179 – 180, ISBN: 0-471-46741-3.<br />
[39] M. van Osch and S. Smolka, “Finite-State Analysis of the CAN Bus Protocol,” in<br />
Proceedings of the 6 th IEEE International Symposium on High Assurance Systems<br />
Engineering (HASE ’01), 22 – 24 October 2001, Page(s): 42 – 52.<br />
[40] Y. Yellambalase and M. Choi, “Automatic Node Discovery in CAN (Controller Area<br />
Network) Controllers Using Reserved Identifier Bits,” IMTC 2007 – Instrumentation and<br />
Measurement Technology Conference, May 1 – 3, 2007.<br />
[41] G. Cena and A. Valenzano, “A Protocol for Automatic Node Discovery in CANOpen<br />
Networks,” in IEEE Transactions on Industrial Electronics, Volume 50, Number 3, June<br />
2003, Page(s): 419 – 430.<br />
[42] Microchip PIC12C67X – 8 – Pin, 8 – Bit CMOS Microcontroller with A/D Converter<br />
and EEPROM Data Memory Datasheet. Website:<br />
http://ww1.microchip.com/downloads/en/DeviceDoc/30561b.pdf. (Accessed on<br />
November 17, 2011).<br />
[43] O. Pfeiffer, “Selecting a CAN Controller”. Website:<br />
http://www.esacademy.com/en/library/technical-articles-and-documents/can-andcanopen/selecting-a-can-controller.html.<br />
(Accessed on November 17, 2011).<br />
221
[44] Microchip MCP2515 – Stand-Alone CAN Controller With SPI Interface Datasheet.<br />
Website: http://ww1.microchip.com/downloads/en/devicedoc/21801e.pdf. (Accessed on<br />
November 29, 2011).<br />
[45] Microchip MCP 2551 – High-Speed CAN Transceiver Datasheet. Website:<br />
http://ww1.microchip.com/downloads/en/DeviceDoc/21667f.pdf. (Accessed on<br />
November 17, 2011).<br />
[46] Microchip MCP 2515 – Stand-Alone CAN Controller with SPI Interface Datasheet.<br />
Website: http://ww1.microchip.com/downloads/en/DeviceDoc/21801F.pdf. (Accessed<br />
on November 17, 2011).<br />
[47] Microchip Application Note AN215: “A Simple CAN Node using the MCP2515 and<br />
PIC12C67X,” November 8, 2010. Website:<br />
http://ww1.microchip.com/downloads/en/AppNotes/00215c.pdf. (Accessed on<br />
November 17, 2011).<br />
[48] P. Hank and E. Jӧhnk, Philips Semiconductors Application Note AN97067: “SJA 1000<br />
Stand – Alone CAN Controller,” December 15, 1997. Website:<br />
http://www.nxp.com/documents/application_note/AN97076.pdf. (Accessed on<br />
November 17, 2011).<br />
[49] K. W. Tindell, A. Burns, and A. J. Wellings, “Calculating Controller Area Network<br />
(CAN) Messages Response Times,” in Control Engineering Practice, Colume 3,<br />
Number 8, pp. 1163 – 1169, 1995.<br />
[50] K. W. Tindell, H. Hansson, and A. J. Wellings, “Analysing Real-Time Communications:<br />
Controller Area Network (CAN),” in Proceedings Real-Time Systems Symposium,<br />
1994, pp. 259 – 263.<br />
[51] R. Obermaisser and D. Riezler, “HIS/Vector CAN Driver API on Top of a Time-<br />
Triggered Communication Protocol”, 07AE – 290, in SAE International, 2007.<br />
[52] J. Rushby, “Bus Architectures for Safety-Critical Embedded Systems,” in Proceedings of<br />
the 1 st Workshop on Embedded Software, October 2001.<br />
[53] H. Kopetz, “Why Time-Triggered Architectures will Succeed in Large Hard Real-Time<br />
Systems,” in Proceedings of the Fifth IEEE Computer Society Workshop on Future<br />
Trands of Distributed Computing systems, 1995, Page(s): 2 – 9.<br />
[54] FlexRay Consortium. BMW AG, DaimlerChrysler AG, General Motors Corporation,<br />
Freescale GmbH, Philips GmbH, Robert Bosch GmbH, and Volkswagen AG. FlexRay<br />
Requirements Specification Version 2.1, December 2005.<br />
222
[55] H. Kopetz and G. Bauer, “The Time-Triggered Architecture,” in Proceedings of the<br />
IEEE, Volume 91, Issue 1, 2003, Page(s): 112 – 126.<br />
[56] E. A. Bretz, “By – Wire Cars Turn the Corner,” in IEEE Spectrum, Volume 38, Issue 4,<br />
2001, Page(s): 68 – 73.<br />
[57] A. Albert, “Comparison of Event-Triggered and Time-Triggered Concepts with Regard<br />
to Distributed Control systems,” in Embedded World 2004, Nürnberg, February 17 – 19,<br />
2004, Page(s): 235 – 252.<br />
[58] R. Obermaisser, “Event-Triggered and Time-Triggered Control Paradigms,” Springer<br />
Science and Business Media, 2005, ISBN: 0-387-23043-2.<br />
[59] A. Albert and W. Gerth, “Evaluation and Comparison of the Real-Time Performance of<br />
CAN and TTCAN,” 9th international CAN in Automation Conference, iCC, Munich,<br />
pages 05/01–05/08, 2003.<br />
[60] Wikipedia – Defintion of Real-Time Computing. Website:<br />
http://en.wikipedia.org/wiki/Real-time_computing. (Accessed on November 17, 2011).<br />
[61] S. Zug, M. Schulze, and J. Kaiser, “Latency Analysis for the Cooperation of Event and<br />
Time-Triggered Networks,” in IEEE International Workshop on Factory Communication<br />
Systems, WCFS 2008, Page(s): 3 – 9.<br />
[62] T. Führer, B. Müller, W. Dieterle, F. Hartwich, R. Hugel, and M. Walther, “Time-<br />
Triggered Communication on CAN (Time-Triggered CAN – TTCAN).” Website:<br />
http://www.can-cia.de/fileadmin/cia/pdfs/technology/fuehrer.pdf. (Accessed on<br />
November 17, 2011).<br />
[63] Latency Defintion. Website: http://www.linfo.org/latency.html. (Accessed on November<br />
17, 2011).<br />
[64] Wikipedia – Definition of Latency (Engineering). Website:<br />
http://en.wikipedia.org/wiki/Latency_(engineering). (Accessed on November 17, 2011).<br />
[65] Rainbow Layers – Jaco Swart’s website and blog, “Can the CAN bus solve your design<br />
problems?” Website: http://www.rainbowlayers.co.nz/portfolio/CAN-bus. (Accessed on<br />
February 11, 2010).<br />
[66] J.P. Acle, M.S. Reorda, and M. Violante, “Early, Accurate Dependability Analysis of<br />
CAN-Based Networked Systems,” in IEEE Design & Test of Computers, Volume 23,<br />
Issue 1, Jan. – Feb. 2006, Page(s): 38 – 45.<br />
223
[67] K. Tindell and A. Burns, “Guaranteeing Message Latencies on Control Area Network<br />
(CAN),” Department of Computer Science, University of York.<br />
[68] K. Tindell, “Fixed Priority Scheduling of Hard Real-Time Systems,” YCST 94/03, DPhil<br />
Thesis, Department of Computer Science, University of York (1993).<br />
[69] N. Audsley, A. Burns,M. Richardson, K. Tindell, and A. Wellings, “Applying New<br />
Scheduling Theory to Static Priority Pre-emptive Scheduling,” Software Engineering<br />
Journal 8(5) pp. 284-292 (September 1993).<br />
[70] A. Burns, M. Nicholson, K. Tindell, and Zhang, “Allocating and Scheduling Hard Real-<br />
Time Tasks on a Point-to-Point Distributed System,” in Proceedings of the The<br />
Workshop on Parallel and Distributed Real-Time Systems, pp. 11-20, Newport Beach,<br />
California (April 13-15 1993).<br />
[71] Maxim Application Note 159: “Software Methods to Achieve Robust 1 – Wire®<br />
Communication in iButton Applications,” September 22, 2008. Website:<br />
http://pdfserv.maxim-ic.com/en/an/AN159.pdf. (Accessed November 17, 2011).<br />
[72] B. Linke, “Maxim Application Note 3829: Determining the Recovery Time for Multiple<br />
Slave 1 – Wire® Networks,” June 21, 2006. Website: http://pdfserv.maximic.com/en/an/AN3829.pdf.<br />
(Accessed on November 17, 2011).<br />
[73] Maxim Semiconductor DS2411 – Silicon Serial Number with Vcc Input Datasheet,<br />
Revision 2, December 21, 2006. Website: http://datasheets.maximic.com/en/ds/DS2411.pdf.<br />
(Accessed on November 17, 2011).<br />
[74] H. Nguyen and M. Vai, “RAPID Prototyping Technology,” in Lincoln Laboratory<br />
Journal, Volume 18, Number 2, 2010, Pages 17 – 27.<br />
[75] B. Linke, “Dallas – Maxim Semiconductor Application Note 937: Book of iButton<br />
Standards,” January 16, 2002. Website: http://pdfserv.maxim-ic.com/en/an/AN937.pdf.<br />
(Accessed on November 17, 2011).<br />
[76] Maxim Application Note: “DS1WM – Synthesizable 1 – Wire® Bus Master,” Revision 3,<br />
September 17, 2007. Website: http://datasheets.maxim-ic.com/en/ds/DS1WM.pdf.<br />
(Accessed on November 17, 2011).<br />
[77] Maxim Integrated Products Serial Number iButton DS1990A Datasheet, Revision 3,<br />
October 2008. Website: http://datasheets.maxim-ic.com/en/ds/DS1990A.pdf. (Accessed<br />
on November 17, 2011).<br />
224
[78] Maxim Integrated Products Serial Number iButton DS1990R, DS1990R – F3,<br />
DS1990R – F5 Datasheet, 19-4894, Revision 4, August 2010. Website:<br />
http://datasheets.maxim-ic.com/en/ds/DS1990R-DS1990R-F5.pdf. (Accessed on<br />
November 17, 2011).<br />
[79] Maxim Integrated Products DS9092L – iButton Probe with LED Datasheet, 19-4868,<br />
Revision 3, August 2009. Website: http://datasheets.maxim-ic.com/en/ds/DS9092L.pdf.<br />
(Accessed on November 17, 2011).<br />
[80] Maxim Integrated Products DS1402X – 1 – Wire® Network Cables Datasheet, 19-4684,<br />
June 2009. Website: http://datasheets.maxim-ic.com/en/ds/DS1402-BP8-DS1402D-<br />
DR8.pdf. (Accessed on November 17, 2011).<br />
[81] Maxim Integrated Products DS1401, DS1401-4 – Front Panel iButton Holder<br />
Datasheet, 19-4860, Revision 2, August 2009. Website: http://datasheets.maximic.com/en/ds/DS1401-DS1401-4.pdf.<br />
(Accessed on November 17, 2011).<br />
[82] Maxim Integrated Products DS1994 – 4Kb Plus Time Memory iButton Datasheet, 19-<br />
5049, Revision 4, November 2009. Website: http://datasheets.maximic.com/en/ds/DS1994.pdf.<br />
(Access on November 17, 2011).<br />
[83] Maxim Integrated Products DS1996 – 64Kb Memory iButton Datasheet, 19-4896,<br />
Revision 3, August 2009. Website: http://datasheets.maxim-ic.com/en/ds/DS1996.pdf.<br />
(Accessed on November 17, 2011).<br />
[84] Maxim Integrates Products DS1904 – RTC iButton Datasheet, 19-4864, Revision 3,<br />
April 2011. Website: http://datasheets.maxim-ic.com/en/ds/DS1904.pdf. (Accessed on<br />
November 17, 2011).<br />
[85] Maxim Integrated Products DS1972 – 1024-bit EEPROM iButton Datasheet, 19-4888,<br />
Revision 3, April 2010. Website: http://datasheets.maxim-ic.com/en/ds/DS1972.pdf.<br />
(Accessed on November 17, 2011).<br />
[86] Maxim Integrated Products DS1822-PAR – Econo 1 – Wire® Parasite-Power Digital<br />
Thermometer Datasheet, Revision 1. Website: http://datasheets.maximic.com/en/ds/DS1822-PAR.pdf.<br />
(Accessed on November 17, 2011).<br />
[87] Maxim Integrated Products DS2431 – 1024-Bit 1 – Wire® EEPROM Datasheet, 19-<br />
4675, Revision 10, March 2011. Website: http://datasheets.maximic.com/en/ds/DS2431.pdf.<br />
(Accessed on November 17, 2011).<br />
225
[88] “Verilog – A Language Reference Manual (Analog Extensions to Verilog HDL),”<br />
Version 1.0, August 1, 1996, Open Verilog International. Website:<br />
http://www.vhdl.org/verilog-ams/htmlpages/public-docs/lrm/VerilogA/verilog-a-lrm-1-<br />
0.pdf. (Accessed on November 17, 2011).<br />
[89] Maxim Integrated Products DS1963S – SHA iButton Datasheet. Website:<br />
http://www.maxim-ic.com/datasheet/index.mvp/id/2822. (Accessed on November 17,<br />
2011).<br />
[90] Maxim Integrated Products DS1995 – 16Kb Memory iButton Datasheet, 19-4895,<br />
Revision 3, August 2009. Website: http://datasheets.maxim-ic.com/en/ds/DS1995.pdf.<br />
(Accessed on November 17, 2011).<br />
[91] Maxim Integrated Products DS1963L – 4Kb Monetary iButton Datasheet, Revision 2.<br />
Website: http://datasheets.maxim-ic.com/en/ds/DS1963L.pdf. (Accessed on November<br />
17, 2011).<br />
[92] Maxim Integrated Products DS1921G – Thermochron iButton Datasheet, 19-5101,<br />
Revision 5, September 2011. Website: http://datasheets.maximic.com/en/ds/DS1921G.pdf.<br />
(Accessed on November 17, 2011).<br />
[93] Maxim Integrated Products DS1977 – Password-Protected 32Kb EEPROM iButton<br />
Datasheet, 19-4890, Revision 4, November 2009. Website: http://datasheets.maximic.com/en/ds/DS1977.pdf.<br />
(Accessed on November 17, 2011).<br />
[94] Maxim Integrated Products DS1922L, DS1922T – Temperature Logger iButton with 8Kb<br />
Datalog Memory Datasheet, 19-4990, Revision 10, April 2011. Website:<br />
http://datasheets.maxim-ic.com/en/ds/DS1922L-DS1922T.pdf. (Accessed on November<br />
17, 2011).<br />
[95] Freescale Semiconductor, Inc., “Bosch Controller Area Network (CAN) Version 2.0<br />
Protocol Standard”, BCANPSV2.0/D, Revision 3. Website:<br />
http://cache.freescale.com/files/microcontrollers/doc/data_sheet/BCANPSV2.pdf?fsrch=<br />
1&sr=10. (Accessed on November 17, 2011).<br />
[96] K. Terry, Motorola Freescale Semiconductor, Inc., Semiconductor Engineering Bulletin,<br />
“The Motorola MCAN Module,” EB421/D, July 1996. Website:<br />
http://cache.freescale.com/files/microcontrollers/doc/eng_bulletin/EB421.pdf. (Accessed<br />
on November 17, 2011).<br />
226
[97] Freescale Semiconductor, Inc., Motorola Semiconductor Engineering Bulletin,<br />
“Frequently Asked Questions and Answers – M68HC05 Family MCAN Module,”<br />
EB181/D. Website:<br />
http://cache.freescale.com/files/microcontrollers/doc/eng_bulletin/EB181.pdf?fsrch=1&sr<br />
=2. (Accessed on November 17, 2011).<br />
[98] CAN Bosch Controller Area Network Version 2.0 Protocol Standard by Motorola,<br />
BCANPSV2.0/D Rev. 3. Website: http://cst.mi.fuberlin.de/projects/ScatterWeb/moduleComponents/CanBus_CANbook.pdf.<br />
(Accessed on<br />
November 17, 2011).<br />
[99] Maxim Integrated Products DS1986 – 64Kb Add-Only iButton Datasheet, 19-4893,<br />
Revision August 2009. Website: http://datasheets.maxim-ic.com/en/ds/DS1986.pdf.<br />
(Accessed on December 4, 2011).<br />
[100] S. Corrigan, “Improved CAN network security with TI’s SN65HVD1050 transceiver,”<br />
Texas Instruments Incorporated Analog Applications Journal, 3 rd Quarter 2006, page(s):<br />
17 – 19.<br />
[101] Fairchild Semiconductor 54/74F433 – First-In First-Out (FIFO) Buffer Memory<br />
Datasheet, DS009544, Revised August 1999. Website:<br />
http://pdf1.alldatasheet.com/datasheet-pdf/view/50350/FAIRCHILD/74F433.html<br />
(Accessed on February 11, 2012).<br />
227