Example: air traffic controller

AN945, A CANopen Stack for PIC18 ECAN MCUs

2004 Microchip Technology 1AN945 INTRODUCTIONCAN open is a field bus protocol based on the Control-ler Area Network (CAN). As the name implies, it is aopen network standard accepted throughout the created as a field bus protocol for industrialautomation, CANopen finds use in a wide range ofother non-industrial applications. There are so manypossibilities, in fact, that it is possible to write volumeson specialized uses of the than being specific to one narrow application oreven one field, we present here a more generalizedapproach: a generic communication Stack based onCANopen that can be tailored to the user s needs.

2004 Microchip Technology Inc. DS00945A-page 1 AN945 INTRODUCTION CANopen is a field bus protocol based on the Control-ler Area Network (CAN). As the name implies, it is a

Tags:

  Stack, Cane, Canopen, An945, A canopen stack for pic18 ecan, Pic18

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of AN945, A CANopen Stack for PIC18 ECAN MCUs

1 2004 Microchip Technology 1AN945 INTRODUCTIONCAN open is a field bus protocol based on the Control-ler Area Network (CAN). As the name implies, it is aopen network standard accepted throughout the created as a field bus protocol for industrialautomation, CANopen finds use in a wide range ofother non-industrial applications. There are so manypossibilities, in fact, that it is possible to write volumeson specialized uses of the than being specific to one narrow application oreven one field, we present here a more generalizedapproach: a generic communication Stack based onCANopen that can be tailored to the user s needs.

2 Thisarticle focuses only on what is covered in the CAN inAutomation (CiA) standard DS-301. In fact, most of thediscussion is limited to the predefined areas of thespecification, with emphasis on understanding how thecode provided with this application note functions andhow users might develop an application on theCANopen Stack . To help illustrate this, a simple exam-ple application is developed based on the CiA DS-401specification, Generic I/O Modules. The additionalcode provided is solely for demonstration; thus there isno detailed discussion of the demonstration , code examples with comments from thedemo application are frequently used throughout code provided with this application note isdeveloped for the PIC18F8680 and PIC18F4680families of devices, which include ECAN technology aspart of their peripheral set.

3 It is designed to compile withMicrochip s C18 (or greater) compiler. Althoughdeveloped for these specific device families, the codeis adaptable to other PIC18 families with CAN. It is expected that the reader already has someknowledge of CANopen , or has access to the latestCANopen standard (listed in the References section) torefer to for theory and/or critical terminology. The infor-mation covered in this application note leans towardsunderstanding the implementation and developing onthat foundation, rather than discussing the many detailsof OF THE STACKThe CANopen Stack provides the lower layers of theprotocol.

4 Some of the features of this design include: Embedded state machine for handling all communications between all nodes and objects Default Service Data Object (SDO) Server Up to 4 transmit and 4 receive Process Data Objects (TPDOs and RPDOs) Explicit and Segmented Messaging Support Statically-mapped PDO support Structured dictionary for the PDOs and SDO Node Guard/Life Guard SYNC consumer Heartbeat Producer ECAN Driver supportAs this list shows, the CANopen Stack discussed hereis designed for applications that are typically more slave.

5 This design is more static in nature, whichleads to more efficient code with better effective use ofcode space. In addition, the actual CANopen code is broken into aseries of smaller source and header files, all written inC. This allows users to select the appropriate servicesthat they may need for their application and selectivelybuild a project tailored to their specific requirements. Acomplete list of source files is presented in Table course, the actual application and some aspects ofthe communications must still be developed by theuser.

6 The provided CANopen Stack code affords abase on which the application may be :Ross M. FoslerMicrochip Technology IncorporatedA CANopen Stack for PIC18 ECANTM MicrocontrollersAN945DS00945A-page 2 2004 Microchip Technology 1: CANopen SOURCE FILESFile module driver. These files may be replaced by other device-specific drivers, if management services. Required for all specific files. Users must edit this file for their object dictionary. Required for all main services. Required for all copy functions used by the dictionary.

7 Required for all management communications endpoint. Guard, Heartbeat and Boot-up communications PDO object handling endpoints. Provided in a template format that requires development by the user for the specific application. Must be used with the general PDO services server SDO communications synchronization communications for converting Microchip and CANopen CAN identifier formats. For better process performance, all COB IDs are stored internally in the Microchip format. When COB ID is presented due to a request, then the ID is converted to error definitions.

8 Required for all applications. 2004 Microchip Technology 3AN945 CANopen FIRMWARE MODELThe firmware is designed in three levels, as shown inFigure 1. The lowest level is the ECAN driver providinghardware abstracted CAN support. The communica-tions management level is the primary interfacebetween the driver and the individual endpointhandling. Besides the application, there is also the dictionary. Inessence, it resides outside of the communicationobject, and is directly connected to the SDO endpoint.

9 The DriverAt the lowest level is the ECAN driver, which serves asan abstracted hardware interface. It is implemented bythe source files and driver handles all ECAN hardware related function-ality, and conveniently abstracts much of the complexfiltering that is part of the CAN protocol. This isdiscussed in greater detail later in this ManagementThe communications manager is part of the totalcommunications object. It is provided to capture anyevents from the ECAN driver and the higher applicationlevels, and dispatch these to the appropriate handlingcommunications sub-objects and functions.

10 Essen-tially, opening, closing, transmitting to, and receivingfrom an endpoint is all directed by the communicationsmanager. Communications management is provided inthe files and manager has knowledge of what state eachendpoint is in as well as the state of the device it can block messages to endpoints as necessarybased on local or global state. Another feature of the manager is that it uses a single-byte handle method supported by the driver todecode message events. The handle is of a particularstructure designed to accelerate performance; it issignificantly faster that decoding the 11-bit or 29-bitCAN identifier in order to determine the handlingfunction for a particular message.


Related search queries