MikroElektronika PIC Microcontrollers PIC18 Uživatelský manuál

Procházejte online nebo si stáhněte Uživatelský manuál pro Barebones pro PC / pracovní stanice MikroElektronika PIC Microcontrollers PIC18. Advanced PIC18 Projects—CAN Bus Projects Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 40
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 0
CHAPTER 9
Advanced PIC18 Projects—CAN
Bus Projects
The Controller Area Network (CAN) is a serial bus communications protocol developed
by Bosch (an electrical equipment manufacturer in Germany) in the early 1980s.
Thereafter, CAN was standardized as ISO-11898 and ISO-11519, establishing itself as
the standard protocol for in-vehicle networking in the auto industry. In the early days of
the automotive industry, localized stand-alone controllers had been used to manage
various actuators and electromechanical subsystems. By networking the electronics in
vehicles with CAN, however, they could be controlled from a central point, the engine
control unit (ECU), thus increasing functionality, adding modularity, and making
diagnostic processes more efficient.
Early CAN development was mainly supported by the vehicle industry, as it was used in
passenger cars, boats, trucks, and other types of vehicles. Today the CAN protocol is
used in many other fields in applications that call for networked embedded control,
including industrial automation, medical applications, building automation, weaving
machines, and production machinery. CAN offers an efficient communication protocol
between sensors, actuators, controllers, and other nodes in real-time applications, and is
known for its simplicity, reliability, and high performance.
The CAN protocol is based on a bus topology, and only two wires are needed for
communication over a CAN bus. The bus has a multimaster structure where each device
on the bus can send or receive data. Only one device can send data at any time while
all the others listen. If two or more devices attempt to send data at the same time,
the one with the highest priority is allowed to send its data while the others return to
receive mode.
www.newnespress.com
Zobrazit stránku 0
1 2 3 4 5 6 ... 39 40

Shrnutí obsahu

Strany 1 - Bus Projects

CHAPTER 9Advanced PIC18 Projects—CANBus ProjectsThe Controller Area Network (CAN) is a serial bus communications protocol developedby Bosch (an electr

Strany 2

9.1.3 Control FieldThe control field is 6 bits wide, consisting of 2 reserved bits and 4 data length code(DLC) bits, and indicates the number of data

Strany 3 - CAN BUS

9.1.6 ACK FieldThe ACK field indicates that the frame has been received normally. This fieldconsists of 2 bits, one for ACK slot and one for ACK delim

Strany 4

9.5 Bit StuffingThe CAN bus makes use of bit stuffing, a technique to periodically synchronizetransmit-receive operations to prevent timing errors bet

Strany 5

device can have its own different clock frequency. One message bit consists of fournonoverlapping time segments:Synchronization segment (Sync_Seg)Pr

Strany 6

and the nominal bit rate (NMR) isNBR ¼ 1=TBITð9:2ÞThe time quantum is derived from the oscillator frequency and the programmablebaud rate prescaler, w

Strany 7 - 9.1 Data Frame

In order to compensate for phase shifts between the oscillator frequencies of nodeson a bus, each CAN controller must synchronize to the relevant sign

Strany 8 - 9.1.2 Arbitration Field

built-in CAN module. The microcontroller is connected to the CAN bus using anexternal MCP2515 CAN controller chip and an MCP2551 CAN bus transceiver c

Strany 9 - 1234567891011

9.9 PIC18F258 MicrocontrollerLater in this chapter the PIC18F258 microcontroller is used in a CAN bus–basedproject. This section describes this microc

Strany 10 - 9.1.5 CRC Field

The features of the PIC18F258 microcontroller’s CAN module are as follows:Compatible with CAN 1.2, CAN 2.0A, and CAN 2.0BSupports standard and exten

Strany 11 - 9.4 Overload Frame

The CAN module in the PIC18F258 microcontroller has six modes of operation:Configuration modeDisable modeNormal operation modeListen-only modeLoo

Strany 12 - 9.5 Bit Stuffing

As shown in Figure 9.1, in a typical vehicle application there is usually more than oneCAN bus, and they operate at different speeds. Slower devices,

Strany 13

communicating with each other. The baud rate can be determined by testingdifferent values until valid messages are received. The listen-only mode cann

Strany 14

The CAN module uses message acceptance filters and masks to determine if amessage in the MAB should be loaded into a receive buffer. Once a valid mess

Strany 15

the masks and filters to determine if the message should be accepted. If a maskbit is set to 0, that bit in the identifier is automatically accepted r

Strany 16

The Sync_Segment is 1TQ. Choosing 2TQfor the Prop_Seg, and 7TQfor Phase_Seg1leaves 6TQfor Phase_Seg2 and places the sampling point at 10TQat the end o

Strany 17 - 9.9 PIC18F258 Microcontroller

Baud rate prescaler (BRP) ¼ 4Sync_Seg ¼ 1Prop_Seg ¼ 5Phase_Seg1 ¼ 5Phase_Seg2 ¼ 5SJW ¼ 1Sample point ¼ 68%Error ¼ 0%9.10 mikroC CAN FunctionsThe mikro

Strany 18

bus for PIC microcontrollers having no built-in CAN modules. In this section wewill discuss only the library functions available for PIC microcontroll

Strany 19 - 9.9.4 Listen-only Mode

CAN_MODE_LISTEN Listen-only mode of operationCAN_MODE_CONFIG Configuration mode of operation9.10.2 CANGetOperationModeThe CANGetOperationMode functi

Strany 20 - 9.9.8 CAN Message Reception

CAN_CONFIG_SAMPLE_ONCE Sample bus once at sample pointCAN_CONFIG_SAMPLE_THRICE Sample bus three times prior tosample pointCAN_CONFIG_STD_MSG Accept

Strany 21

void CANSetMask(char CAN_MASK, long value, charCAN_CONFIGFLAGS)CAN_MASK can be one of the following:CAN_MASK_B1 Receive buffer 1 mask valueCAN_MASK_

Strany 22

id is the CAN message identifier. Only 11 or 29 bits may be used depending onmessage type (standard or extended). data is an array of bytes up to 8 wh

Strany 23

a random amount of time before trying to send again. CAN protocol, however, solvesthe collision problem using the principle of arbitration, where only

Strany 24 - 9.10 mikroC CAN Functions

CAN_TX_PRIORITY_2 Transmit priority 2CAN_TX_PRIORITY_3 Transmit priority 3CAN_TX_STD_FRAME Standard identifier messageCAN_TX_XTD_FRAME Extended id

Strany 25 - 9.10.1 CANSetOperationMode

The project’s circuit diagram is given in Figure 9.16. Two CAN nodes areconnected together using a two-meter twisted pair cable, terminated with a 120

Strany 26 - 9.10.3 CANInitialize

The DISPLAY ProcessorLike the COLLECTOR processor, the DISPLAY processor consists of a PIC18F258microcontroller with a built-in CAN module and an MCP2

Strany 27 - 9.10.5 CANSetMask

The COLLECTOR processor reads the temperature, formats it, and sends to theDISPLAY processor over the CAN busThe DISPLAY processor reads the tempera

Strany 28 - 9.10.7 CANRead

/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ CAN BUS EXAMPLE - NODE: DISPLAY ======

Strany 29 - 9.10.8 CANWrite

TRISC = 0; // PORTC are outputs (LCD) TRISB = 0x08; // RB2 is output, RB3 is input//// CAN

Strany 30 - Bus Project

Filter 3 for buffer 2 is set to value 3 so that identifiers having values 3 are accepted bythe receive buffer.The operation mode is then set to NORMAL

Strany 31 - Temperature

/∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ CAN BUS EXAMPLE - NODE: COLLECTOR

Strany 32 - The COLLECTOR Processor

//// CAN BUS Timing Parameters// SJW = 1; BRP = 1; Phase_Seg1 = 6; Phase_Seg2 = 7; BRP = 1; Prop_Seg = 6; init_flag = CAN_

Strany 33 - DISPLAY Program

// Program loop. Read the temperature from analog temperature// sensor// for(;;) // Endless

Strany 34 - 508 Chapter 9

removed from the bus, no configuration data needs to be changed (i.e., the bus is“hot pluggable”).CAN bus offers remote transmit request (RTR), which

Strany 35 - Figure 9.17: (Cont’d)

node filter is set to accept identifier 500). This is a request to the COLLECTORnode to send the temperature reading. The program then reads the tempe

Strany 36

dominant bit state always wins out over a recessive bit state. In the recessive state, thedifferential voltage CANH and CANL is less than the minimum

Strany 37 - (Continued)

circuit and a capacitor are used at either end of the bus. This method increases the EMCperformance of the bus (Figure 9.5(c)).Many network protocols

Strany 38 - 512 Chapter 9

There are basically four message frames in CAN: data, remote, error, and overload. Thedata and remote frames need to be set by the user. The other two

Strany 39

CRC field, which checks whether or not the received bit sequence is corrupted.The ACK field is 2 bits and is used by the transmitter to receive acknow

Strany 40 - COLLECTOR Program

The process of arbitration is illustrated in Figure 9.9 by an example consisting of threenodes having identifiers:Node 1: 11100110011 Node 2: 11100111

Komentáře k této Příručce

Žádné komentáře