CANopen

CANfestival Framework Running on mbed

CANfestival is an open source CANopen framework to turn any uC into a CANopen node.

This page documents how to get started with the CANfestival framework on mbed and install the object dictionary editor on a windows PC.

More detailed information about the CANfestival framework can be found here.

Information about CANopen can be found here.

Gathering the Minimum Requirements

The following requirements are necessary for a windows machine.

Setup Details

  • Install Python on your PC
  • Install wxPython on your PC
  • Install TortiseHg on your PC
  • Clone CANfestival repository
    • Open TortiseHg Workbench
    • File - Clone Repository
    • Source = http://dev.automforge.net/CanFestival-3
    • Destination = anywhere on the local drive
  • Install Gnosis Utils on your PC
    • This is installed from the command line.
    • Open a shell and use dos (cd command) to navigate to the directory that contains the unzipped files.
    • Moving the extracted folder close the root drive will make this easier.
    • When at the directory containing setup.py run C:/Python27/python.exe setup.py install

start done

Hardware and Connections

If you are not connecting to a bus with termination resistors - you will need to add them yourself.

  1. mbed with a free CAN peripheral
    • Examples use pins p9 & p10 (rd, td)
  2. CAN physical layer transceiver

CONNECTIONS

Example Projects

Master node

Import programcanopen_masternode

CANfestival - an open source CANopen framework

Slave node

Import programcanopen_slavenode

CANfestival - an open source CANopen framework

Notes about the Framework

The node is configured mostly with the object dictionary and EDS editor. This GUI program is found in the framework repository that was cloned. If the setup steps were executed correctly navigating to .\CanFestival-3\objdictgen will display a ton of *.py files.

Using the Object Dictionary and EDS Editor

Running objdictedit.py will execute the following GUI program. Help and details about the framework can be found under the Help tab (or F2). When an *.od file is created or loaded the parameters can be changed and a new object dictionary can be created.

More detailed information about the object dictionary and EDS files can be found here.

Deviation from the Framework

From the repository there are a few file naming conflicts that need to be resolved when integrating with the mbed api. These are resolved in the example projects as follows:

  • .\CanFestival-3\src\
    • timer.c - renamed canopen_timer.c in the mbed examples
  • .\CanFestival-3\include\
    • timer.h - renamed canopen_timer.h in the mbed examples
    • can.h - renamed canopen_can.h in the mbed examples

Files of Interest

Interaction between the peripherals and the stack take place in:

  • .\CanFestival-3\driver\mbed\
    • can_mbed.cpp - peripheral access to the physical layer
    • timer_mbed.cpp - timer access for the micro scheduler
  • .\CanFestival-3\include\mbed\
    • can_mbed.h - header for can_mbed.cpp
    • applicfg.h - relate data types from the target to the stack defined types


30 comments on CANopen:

13 Jun 2011

Is there any example with using of these libraries? I don't see any example to understand how it work. Could anyone help me?

22 Jan 2012

Has anyone been able to get the objdictedit.py program to run? I've tried running it and all I get is a command line flash and nothing else. Any suggestions would be much appreciated.

23 Jan 2012

There was an installation step missing, the notebook page has been updated. The object dictionary relies on wxPython as well as gnosis utils.

Paul Heslinga wrote:

I've tried running it and all I get is a command line flash and nothing else

If anyone else has this problem make sure wxPython is installed on your machine.

12 Apr 2012

The tutorial / example link has unfortunately been taken down:

http://www.canopenmagic.com/presentations/CANopenHOT.pdf

Do you have a copy of the pdf file, or its name so I can try find a copy hosted elsewhere online? I would be very greatful if so!

12 Apr 2012

I added slides from the tutorial. I cant seem to find the original document. Maybe try their contact page and ask for a copy??

http://www.canopenmagic.com/en/contact-us.html

12 Apr 2012

Not sure if the document in question resides here:

http://www.esacademy.com/en/library/technical-articles-and-documents.html

But it does seem there is a lot of good information on CAN at this site. Hope it helps.

01 May 2012

Hi Sam, I found a copy on a chinese site, but couldn't download! I've just notived your link - many thanks!

02 May 2012

You should be able to access the PDF on the archived version of the website here:

http://web.archive.org/web/20060721042210/http://www.canopenmagic.com/presentations/CANopenHOT.pdf

02 May 2012

g s wrote:

You should be able to access the PDF on the archived version of the website...

Thanks. Stored a copy on mbed.org and updated the link.

25 Sep 2012

Hallo Sam, I try to compile the Canopen Slave but i get a compiler error

"no instance of constructor "mbed::CANMessage::CANMessage" matches the argument list" in file "framework/driver/mbedcan_mbed.cpp", Line: 58, Col: 99

You may have a look for that?

regards

Joerg

26 Sep 2012

Joerg,

Update to the newest revision(6). There was an error in the typecasting of the CANMessage constructor. Not sure when that was injected.

26 Sep 2012

It works now. Thanks a lot :)

05 Oct 2012

Hallo Sam, the Master communicate with the PC via USB? Are there more documentation? regards

Joerg

10 Oct 2012

Joerg,

The only information about the USB commands is in port_helper.cpp (just in source). It was for debugging purposes. The best documentation about the stack will be found when you clone the repository and navigate to

.\canopen\objdictgen\doc

13 Oct 2012

Sam Grove wrote:

Joerg,

The only information about the USB commands is in port_helper.cpp (just in source). It was for debugging purposes. The best documentation about the stack will be found when you clone the repository and navigate to

.\canopen\objdictgen\doc

My question is more I have to use the PCAN-USB from Peak Systems to use the EDS Editor or it works with the mbed Master.

regards

Joerg

03 Nov 2012

Hi Sam,

I have met two problems when using your port of canfestival:

1. After setting the 0x1017 of the OD to 0x3E8 (1s heartbeat), there is no heartbeat when the slave node go into operational state. Am I missing some configuration steps? Or the timer driver is not working properly?

2. The SDO cycle is around 12ms, this is not good enough. I'm using canfestival with a LPC1752 develop board and a Kvaser can-usb cable, the worst SDO cycle is around 5ms. I'm not sure if it's the problem of the mbed driver.

Do you have any ideas about these problems?

Cheers, Simon

05 Nov 2012

Hi Simon,

I haven't worked with this for over a year now but these would be my thoughts on the problems your experiencing...

Quote:

1. After setting the 0x1017 of the OD to 0x3E8 (1s heartbeat), there is no heartbeat when the slave node go into operational state. Am I missing some configuration steps? Or the timer driver is not working properly?

The micro-scheduler is configured in ./framework/driver/mbed/timer_mbed.cpp

Quote:

The SDO cycle is around 12ms, this is not good enough. I'm using canfestival with a LPC1752 develop board and a Kvaser can-usb cable, the worst SDO cycle is around 5ms. I'm not sure if it's the problem of the mbed driver.

The driver should be using the 3 hardware transmit buffers (https://mbed.org/forum/mbed/topic/790/?page=1#comment-4015) but that revision of the mbed library is much older than what is current. Also, I'm sure you are using a different release of the CANfestival stack on your other board. There are hundreds of patches from this port of the stack and where the CANfestival stack currently is.

13 Nov 2012

Hi Sam,

Thank you very much for you reply. I should replay eailier, but I was very busy untill now I can go through your advise. To your first quote, of course I can change the configuration to make it work. However, since we are using mbed, I think the better way is using mbed API to write the timer driver. And I tried by using Timer and osTimer, the result is very good and the timer driver is very accurate (millisecond level) and simplier. If you don't mind, I can contribue my code.

To your second quote, I think the problem is that the canReceive() is in the main while, loop but not in an interrupt. I will write some code to try when I'm free.

Cheers, Simon

25 Apr 2013

Can someone give me an example on how to send data from slave(mbed) to master(mbed)? Definitions:

Message m2 = {0xFF,0,0x8,{0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70}};
CAN_PORT cp = 0;

Neither of these work :

canSend(cp,m2);
canSend(cp,*m2);
canSend(cp,m2*);

Thanks in advance.

28 Jun 2013

HELP ME!

I used LPC 1768

used canopen_mastermode and canopen_slavemode, Master enter state=start Slave have show ID:0x0000 DLC:2 Data(0→1):0x01 0x00 Then Slave enter input=1 or input=5 or input=any number but it not show anything or not send anything (_sendPDOevent not go to status = state5; it can't send PDO)

I want PDO and SDO can send I have only one master node and one slave node please give a examples or teach me help me, thenks.

ps.My English is not good,so sorry.

05 Aug 2013

Hi, I am trying to port the canfestival to LPC 2387.I having problem figuring out where the acceptance filtering configurations are done in the Canfestival driver?Please can anyone help me out. Thanks in Advance!

Regards, Atal

13 Aug 2014

Sam, Or anyone else who might be able to help,

I'm wanting to control some motor controllers via an mbed using CANopen DS 301. So I am only interested in the master node part of CANopen Festival. However, when I rand objdictedit.py and went to create a new node... DS 301 was not an option. (only DS 401 - DS 419 and then DS 302). I wondering how I can implement my mbed as a master node without the CANopen Festival DS 301 profile? Am I missing something?

Thanks

21 Aug 2015

Hi,

I test the slave node but I have the same issue about Heartbeat: I did not ... Is there a solution to this?

Sincerely, JB

30 Sep 2018

/media/uploads/tobhub/unbekannt.jpg I've tried to run the objdictedit.py program with the IDE pycharm. But it does not work. You can find the error message in the Picture. Has anyone been able to get the objdictedit.py program to run? Any suggestions would be much appreciated.

27 Oct 2018

Same problem here if you have any solutions please let us know

Thank you

29 Oct 2018

You need to use "classic" wxPython (in other words, wxPython 3). Get it at: https://sourceforge.net/projects/wxpython/

30 Oct 2018

First of all thank you for your answer.

However i could not solve my problems. There are several reasons and i will be more than happy if you help me out.

When i download .dmg version of 3.0.2.0 and try to run on my OSX i get disk image corrupted error every time i try.

When i encountered this problem i tried to use older packages however the issue is the same. I do not have any idea why this is happening and how i can install this package on OSX.

I tried to switch windows 10 and try to use the given .exe however i was not successful at this either if you have any solutions please guide me.

Thank you for all your help

25 Apr 2019

Is there an EDS file available for use slave node ?

23 Apr 2020

Hello,

is it possible to use this stack for STM32?

I would appreciate any answers.

Thank you and best regards,

15 Jun 2020

I tried compiling on the STM32H745I Discovery, but MBED doesn't seem to be compatible, or at least it doesn't import.

Which MBED version and platform can compile?

Please log in to post comments.