can-bus logger final presentation jan, 2011 elad barzilay idan cohen-gindi supervisor: boaz mizrahi

21
CAN-Bus Logger CAN-Bus Logger Final Presentation Final Presentation Jan , 2011 Jan , 2011 Elad Barzilay Elad Barzilay Idan Cohen-Gindi Idan Cohen-Gindi Supervisor: Boaz Mizrahi Supervisor: Boaz Mizrahi

Post on 20-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

CAN-Bus LoggerCAN-Bus LoggerFinal PresentationFinal Presentation

Jan , 2011Jan , 2011

Elad BarzilayElad Barzilay

Idan Cohen-GindiIdan Cohen-Gindi

Supervisor: Boaz MizrahiSupervisor: Boaz Mizrahi

Page 2: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

AbstractAbstract

The goal of this project is to produce A Real-The goal of this project is to produce A Real-time Data Logging system which connects to a time Data Logging system which connects to a vehicle’s CAN-Bus, An External GPS device vehicle’s CAN-Bus, An External GPS device and Analog sensors, for reach data storage and and Analog sensors, for reach data storage and analysis. analysis.

Page 3: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

OverviewOverview

• The project continues the PCD project.The project continues the PCD project.• The CAN interface is developed on a designated The CAN interface is developed on a designated

module which integrates to the main PCD platform. module which integrates to the main PCD platform. • The device will posses advanced functions such as:The device will posses advanced functions such as:

– Advanced diagnostic.Advanced diagnostic.– Real time monitoring of the vehicle’s operation.Real time monitoring of the vehicle’s operation.– Access and control of other control units on the Access and control of other control units on the

vehicle. vehicle. • The device will be able to support various The device will be able to support various

applications and will allow analysis on board a PC. applications and will allow analysis on board a PC.

Page 4: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

CAN Protocol - ReminderCAN Protocol - Reminder

Page 5: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

ObjectivesObjectives• Preliminary DesignPreliminary Design

• Block DiagramBlock Diagram• Design ConceptsDesign Concepts• Architecture & Platform Architecture & Platform

• Detailed DesignDetailed Design• Main ComponentsMain Components• Electrical Design – Pin to PinElectrical Design – Pin to Pin• Integration & Platform AdjustmentsIntegration & Platform Adjustments• Mechanical DesignMechanical Design

• Layout , Manufacturing & Electrical TestLayout , Manufacturing & Electrical Test• Software\FirmwareSoftware\Firmware• DebuggingDebugging• Operating Operating

Page 6: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Block DiagramBlock Diagram

Processing Unit

Data Link Layer

Physical Layer

CAN Module

• Physical Layer :

• Maintaining CAN electrical requirements

• Protecting the device

Data Link Layer-

Protocol implementation

Basic message filtering

Processing Unit :

Manage CAN applications

Control peripheral devices

User interface

Page 7: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Block DiagramBlock Diagram

CAN Module

MCU

Analog Devices

On-Board User InterfaceLCD & Key-Pad

Flash Memory

CAN Busnetwork

PC

Page 8: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

CAN Module ComponentsCAN Module Components

CAN Module

CANH

CANL

RX

TX

MCP2551Transceiver

MCP2515Controller

SPI

ToMCU

CAN Controller – MCP2515

• Implementing the CAN protocol engine• Receiving and transmitting buffers.• Filtering and masking capabilities for message analyses and acceptance. • Error detection and handling and bit timing.

CAN Transceiver – MCP2551

• Transform the TX,RX lines to CAN_H , CAN_L required for the connector to the bus. • Supports 1 Mb/s operation• Suitable for 12V and 24V systems• fault-tolerant & high buffering protection

Page 9: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Electrical Design Electrical Design

c a n c t r l_ o s c 1

c a n c t r l_ c a n x r_ R X_ r

J 1

E S Q T-1 0 2 -0 3 -G -S -4 0 1

12

J 2

E S Q T-1 0 2 -0 3 -G -S -4 0 1

12

J 4

E S Q T-1 0 2 -0 3 -G -S -4 0 1

12

J 5

E S Q T-1 0 2 -0 3 -G -S -4 0 1

12

V C C _ 3 p 3

V C C _ 5 p 0

c a n _ m c u _ in t n

m c u _ c a n _ s p i_ c lk

m c u _ c a n _ s p i_ d inc a n _ m c u _ s p i_ d o u t

m c u _ c a n _ s p i_ c s n

V C C _ 3 p 3

c a n _ rx 0 b f n

V C C _ 3 p 3

V C C _ 3 p 3

V C C _ 5 p 0

m c u _ c a n _ s p i_ c s n

c a n _ m c u _ in t n

c a n x r_ c a n h

c a n c t r l_ c a n x r_ TX

c a n x r _ rs

c a n _ m c u _ s o f

canc

trl_

rst

c a n c t r l_ rs t _ r

c a n _ rx 1 b f n _ dc a n _ rx 1 b f n

c a n x r_ c a n l

c a n _ m c u _ s p i_ d o u tm c u _ c a n _ s p i_ d in

TX0 R TS n

c a n c t r l_ c a n x r_ R X

U 1

M C P 2 5 1 5 -I / S O

TXC A N1

R XC A N2

C L K O U T/ S O F3

TX0 R TS4

TX1 R TS5

TX2 R TS6

O S C 27

O S C 18

V S S9

V D D1 8

R E S E T1 7

C S1 6

S O1 5

S I1 4

S C K1 3

I N T1 2

R X0 B F1 1

R X1 B F1 0

C 41 0 0 n F 1 6 V 1 0 %

R 3 3 0 0

TP 3

1

R11

0

D3

LED

D2

LED

R4

300

J 3

H E A D E R -3

123

R 7 4 . 7 k

R2

4.7k

R6

4.7k

C 51 u F 6 . 3 V 1 0 %

TP 4

1

C 11 0 0 n F 1 6 V 1 0 %

M C P 2 5 5 1 -I / S N

U 2

TXD1

V _ S S2

V _ D D3

R XD4

R s8

C A N H7

C A N L6

V _ R E F5

TX1 R TS n

Y 12 4 M H z

R8

300

R1

4.7k

C 3 1 5 p F 5 0 V 5 %

TP 1

1

R10

470

R5

300

C 2 1 5 p F 5 0 V 5 %

m c u _ c a n _ s p i_ c lk

R 91 2 0

TP 5

1

TP 2

1TX2 R TS n

D 1L E D

V C C _ 3 p 3

c a n c t r l_ o s c 2

Page 10: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Pinout DescriptionPinout Description

• Voltage supply –Voltage supply –– 3.3 Volt for the 3.3 Volt for the

operation of the MCP2515 CAN operation of the MCP2515 CAN controller.controller.

– 5 Volt for the5 Volt for the operation of the MCP2551 operation of the MCP2551 CAN transceiver.CAN transceiver.

– GndGnd• SPI Interface –SPI Interface –

– SPI Data InSPI Data In– SPI Data InSPI Data In– SPI ClockSPI Clock– SPI CSnSPI CSn

• CAN Communication –CAN Communication –– MCP2515 Interrupt – MCP2515 Interrupt –

request for attention from the request for attention from the MCU. MCU.

Connectors on-board the PCD board:

Connectors on-board the CAN board:

Page 11: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Integration & Platform

Adjustments Add/Remove HW and fix problems spotted during

the first debugMaking suitable Adjustments for the CAN Module

integration

• Bring up and power up of the new Board –

electrical test were made but bring up and code testing were not – because of un preparedness of the main platform.

Page 12: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Mechanical DesignMechanical Design

• The CAN board is placed on four 100mil

connectors, for robustness. the card’s

outline goes around high components

on the PCD board.

• All large components and

connectors are located on

the bottom side of the CAN

board.

Page 13: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Mechanical DesignMechanical Design

The CAN board dimensions:

length: 22 mm, width: 32 mm, height: 8 mm

Top view: Bottom view:

Page 14: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Layout & ManufacturingLayout & Manufacturing

Top view:Bottom view:

Page 15: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Layout & ManufacturingLayout & Manufacturing

• 30 boards were sent to manufacture, both the revised PCD 30 boards were sent to manufacture, both the revised PCD platform and the CAN board. Date: 20/12/09 Offshore supplier platform and the CAN board. Date: 20/12/09 Offshore supplier (china): MakePCB Ltd. Total cost including tax and shipment: 275 (china): MakePCB Ltd. Total cost including tax and shipment: 275 Euro. Euro.

Page 16: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Software OutlineSoftware Outline

1.1. Operating code changes :Operating code changes :

• Upgrading the Main MenuUpgrading the Main Menu – –

CAN_Menu.cCAN_Menu.c which contains the functions: which contains the functions:

Menu(), Start_Menu() , QS_Menu() Menu(), Start_Menu() , QS_Menu()

example: example:

CAN_MenuCAN_Menu QS_Menu QS_Menu

1. Quick Start2. set test Duration3. set Sampling Rate4. set Output5. Files6. Exit

SPD & RPM & FUEL -------&-------&------- TMP & CO2 & OIL_P-------&-------&------- & & -------&-------&-------* Next & 0 Clr & # Prev

Page 17: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Software OutlineSoftware Outline

2.2. CAN module operating code:CAN module operating code: • MCP OperativeMCP Operative – –

MCP2515.C and MCP2515_Defs.hMCP2515.C and MCP2515_Defs.h which includes all the functions which includes all the functions and definitions for a complete operation of the CAN Module: and definitions for a complete operation of the CAN Module:

void MCP_Reset(void);void MCP_Modify( unsigned char Address, unsigned char Mask, unsigned char Data );void MCP_Write( unsigned char Address, unsigned char Data );unsigned char MCP_Read( unsigned char Address);unsigned char MCP_Read_Status( const unsigned char Address );unsigned char MCP_SetCANCTRL_Mode(const unsigned char newmode);unsigned char MCP_ConfigRate(const unsigned char canSpeed);void MCP_Read_Can_Id( const unsigned char rxb_sidh_addr , bool* ext, unsigned int* can_id );void MCP_Read_CanMsg( const unsigned char rxb_sidh_addr, CanMessage* msg);void MCP_Write_Can_Id( const unsigned char txb_sidh_addr, bool ext, unsigned int can_id );void MCP_Write_CanMsg( const unsigned char rxb_sidh_addr, const CanMessage* msg);void MCP_Start_Transmit(const unsigned char txb_sidh_addr);unsigned char MCP_GetNextFreeTXBuf(unsigned char *txbuf_n);void MCP_InitMCPBuffers(void);unsigned char MCP_Init(const unsigned char canSpeed);

Page 18: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Software OutlineSoftware Outline• PIC – MCP InterfacePIC – MCP Interface - - SPI_MCP.CSPI_MCP.C which includes all the pin-out definitions which includes all the pin-out definitions

and functions for the SPI interface between the MCU and the CAN module’s and functions for the SPI interface between the MCU and the CAN module’s MCP. MCP.

// Enable Pin #define SSPEN SPICON1bits.SSPEN

// Description: The main SPI control register#define SSPCON SSP1CON1// Description: The SPI status register#define SSPSTAT SSP1STAT// Description: The SPI buffer#define SSPBUF SSP1BUF// Description: The bitwise define for the SPI control register (i.e. _____bits)#define SSPCONbits SSP1CON1bits// Description: The write collision detect bit in the SPI control register#define CON_WCOL SSP1CON1bits.WCOL// Description: The write collision detect bit in the SPI control register#define CON_CKP SSP1CON1bits.CKP// Description: The bitwise define for the SPI status register (i.e. _____bits)#define SSPSTATbits SSP1STATbits// Description: The receive buffer full bit in the SPI status register#define STAT_BF SSP1STATbits.BF// Description: The receive buffer full bit in the SPI status register#define STAT_SMP SSP1STATbits.SMP// Description: The receive buffer full bit in the SPI status register#define STAT_CKE SSP1STATbits.CKE

Page 19: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Software OutlineSoftware Outline• CAN Message interface codeCAN Message interface code – – CAN.CCAN.C which includes a complete which includes a complete

set of function the send / receive / store / check errors of can set of function the send / receive / store / check errors of can messages and can message struct : messages and can message struct :

uint8_t can_init(uint8_t speedset);

void can_initMessageStruct(CanMessage* msg);uint8_t can_sendMessage(const CanMessage* msg);uint8_t can_checkReceive(void);uint8_t can_readMessage(CanMessage *msg);uint8_t can_checkError(void);

typedef struct {// identifier CAN_xxxIDuint8_t extended_identifier; // either extended (the 29 LSB) or standard (the 11 LSB)uint32_t identifier; // data length:uint8_t dlc;uint8_t

dta[CAN_MAX_CHAR_IN_MESSAGE];

// used for receive only:// Received Remote Transfer Bit // (0=no... 1=remote transfer request received)uint8_t rtr; // Acceptence Filter that enabled the receptionuint8_t filhit;

} CanMessage;

Page 20: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Done So Far…Done So Far… Preliminary DesignPreliminary Design

Block DiagramBlock Diagram Design ConceptsDesign Concepts Architecture & Platform Architecture & Platform

Detailed DesignDetailed Design Main ComponentsMain Components Electrical Design – Pin to PinElectrical Design – Pin to Pin Integration & Platform AdjustmentsIntegration & Platform Adjustments Mechanical DesignMechanical Design

Layout , Manufacturing & Electrical TestLayout , Manufacturing & Electrical Test• Software\FirmwareSoftware\Firmware• DebuggingDebugging• Operating Operating

Page 21: CAN-Bus Logger Final Presentation Jan, 2011 Elad Barzilay Idan Cohen-Gindi Supervisor: Boaz Mizrahi

Need to be done…Need to be done…• Software\Firmware –Software\Firmware –

90 % of the code is written . 90 % of the code is written . To be written: Oscillator timing for the MCP , small fix-up in the CAN.c To be written: Oscillator timing for the MCP , small fix-up in the CAN.c

code, “envelop functions” and documentation of the code. code, “envelop functions” and documentation of the code.

• DebuggingDebugging Software Debugging.Software Debugging. CAN_H , CAN_L scope analyzeCAN_H , CAN_L scope analyze Transmit and receive testing between 2 devicesTransmit and receive testing between 2 devices

• Operating :Operating : OBD-II Testing : request, receive, validate and store.OBD-II Testing : request, receive, validate and store. GUI on PC.GUI on PC. Final Integration: VEHICLE -> OBD -> MCP -> PIC -> SD > USB -> PC GUIFinal Integration: VEHICLE -> OBD -> MCP -> PIC -> SD > USB -> PC GUI