MikroElektronika PIC Microcontrollers PIC18 Bedienungsanleitung

Stöbern Sie online oder laden Sie Bedienungsanleitung nach PC / Workstation Barebones MikroElektronika PIC Microcontrollers PIC18 herunter. Advanced PIC18 Projects—CAN Bus Projects Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 40
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 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
Seitenansicht 0
1 2 3 4 5 6 ... 39 40

Inhaltsverzeichnis

Seite 1 - Bus Projects

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

Seite 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

Seite 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

Seite 4

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

Seite 5

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

Seite 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

Seite 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

Seite 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

Seite 9 - 1234567891011

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

Seite 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

Seite 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

Seite 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,

Seite 13

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 18

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

Seite 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

Seite 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

Seite 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_

Seite 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

Seite 23

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 28 - 9.10.7 CANRead

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

Seite 29 - 9.10.8 CANWrite

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

Seite 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

Seite 31 - Temperature

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

Seite 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_

Seite 33 - DISPLAY Program

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 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

Kommentare zu diesen Handbüchern

Keine Kommentare