CANopenPIC
CANopenNode on PIC microcontrollers
|
CANopenPIC is a CANopen stack running on PIC microcontrollers.
It is based on CANopenNode, which is free and open source CANopen Stack and is included as a git submodule.
CANopen is the internationally standardized (EN 50325-4) (CiA301) CAN-based higher-layer protocol for embedded control system. For more information on CANopen see http://www.can-cia.org/.
CANopenPIC homepage is https://github.com/CANopenNode/CANopenPIC
Clone the project from git repository and get submodules:
git clone https://github.com/CANopenNode/CANopenPIC.git cd CANopenPIC git submodule init git submodule update
Update the project:
cd CANopenPIC git pull # or: git fetch; inspect the changes (gitk); git merge git submodule update
Visit Microchip and Install MplabX IDE, XC32 C compiler for PIC32 or XC16 C compiler for others. Works on Linux, Mac or Windows.
PIC programmer is required, for example PICkit 4.
Open one of the example projects, build and program your microcontroller.
Program is tested on Explorer16 board from Microchip with devices PIC32MX795F512L and dsPIC33FJ256GP710, and on Max32 board. CAN transciever chip must be soldered to the Explorer16 board.
Program also works on dsPIC30F4011 with basic CANopen functionality (see dsPIC30F/CO_driver_target.h). Device has only 2 Kbytes of RAM.
After connecting the CANopen PIC device into the CAN(open) network, bootup message is visible. By default device uses Object Dictionary from CANopenNode/example
, which contains only communication parameters. With the external CANopen tool all parameters can be accessed and CANopen PIC device can be configured (For example write heartbeat producer time in object 0x1017,0).
For more information and examples see https://github.com/CANopenNode/CANopenDemo
+-------+ +-------------+ +----------------+ | | 5-| VREF RXD |-4-----------45-| C1RX/ETXD1/RF0 | | CAN_L |-2(3)------6-| CAN_L VCC |-3-------+--5V0-| VCC5V0 | | CAN_H |-7(4)------7-| CAN_H GND |-2--+ | | | | | +--8-| RS TXD |-1--|----|---46-| C1TX/ETXD0/RF1 | | | | +-------------+ | | | | | | 47kΩ MCP2551 | 100nF | | | | | | | | | | GND |-3(5)---+------------GND--------+----+--GND-| GND | +-------+ | | DB9 | | | | +-----------------------------+------3V3-| VCC3V3 | | +--------------------------|-------29-| SDI2/RG7 | | | +-----------------------|-------53-| SS2/RG9 | | | | | | | | | | +-------------+ | | | | | +-1-| !CS VCC |-8---+ | | | +----2-| SO !HOLD |-7---+ | | +-------3-| !WP SCK |-6---|-------52-| SCK2/RG6 | +-4-| GND SI |-5---|-------43-| SDO2/RG8 | | +-------------+ | | | | 25LC128 100nF | | | | | | +-----------------------+------GND-| GND | +----------------+ Max32
cocomm "0x30 w 0x1010 1 vs save" "0x30 reset node"
. To see heartbeat messages use: cocomm "0x30 w 0x1017 0 u16 1000"
, etc. See also tutorial in https://github.com/CANopenNode/CANopenDemo-std=gnu99
.;../PIC32;../CANopenNode
DO.h
and OD.c
files to the project or include ../CANopenNode/example
above.CO_USE_GLOBALS
is definded, then heap is not needed.This file is part of CANopenNode, an opensource CANopen Stack. Project home page is https://github.com/CANopenNode/CANopenNode. For more information on CANopen see http://www.can-cia.org/.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.