NXP LPC1768/MBED and CanOpen

04 Jan 2011

Hello:

 

I see that the 1768 and MBED (obviously) have a CAN interface and after reading more into it, it seems that there are opensource Can libraries (CanOpen) that will assist with the development of code and sending the data. I have no idea where to start on this one.

Does anyone have experience with this or can point me in the right direction?

 

Thanks!

 

Steve

31 May 2011

I ported the CANfestival framework. Check it out - maybe it will help!

Sam

31 May 2011

Hey,

I was trying out CANFestival a while ago but I didn't get very far. I was trying to somehow hook up the canserial or cansocket driver to the mbed but no succes. Basically I found the CANFestival software to difficult to understand.

Instead I made a simple USB 2 CAN application that allows you to type your canmessages in a terminal. The mbed just converts the stuff you type into canmessages and sends them. The mbed prints back all message it receives to the terminal. This was good enough for simple tests, but for further tests I'll need a working master.

Now that I see this I'm going to have another go with CANFestival.

I've imported your masternode application and took all the steps to install the windows software. Time for some reading.

Thanks in advance Sam, good stuff! I'll let you know how it goes.

Melchior

31 May 2011

Hi,

<<quote Melchiorp>> Instead I made a simple USB 2 CAN application that allows you to type your canmessages in a terminal.<</quote>>

Any chance you publish/share this code? I intent to write something similar for my cmdb command interpreter so the PC can send/receive messages to the CAN bus using an mBed. Any working code is usefull.

31 May 2011

Hello,

Here's the code as it is now.

Import programUSB2CAN

Monitors the CANbus and prints read messages over USB Allows you to send messages via USB to the CANbus Use a terminal application like PuTTY for windows or MoSerial for Ubuntu.

Will do some quick tweaks to it and post it on here later.

Regards,

Melchior

31 May 2011

Hi

Thanks!

31 May 2011

Hey,

The tweaks are minor. Increase the pc_msg a bit so it can take the maximum string length.

Something like !CANStandard CANData 1000 8 ff ff ff ff ff ff ff ff should be the longest. So making pc_msg[60] should do the trick?

Further more you can change the ID to hex if you want.

29bit ID's haven't been implemented yet.

Hope it helps : )

Melchior

Edit: Ah, the format and type need fixing.

Edit: Okay I'm going to leave it at this. It now accepts standard and extended. Seems to be working fine.

Import programUSB2CAN

Monitors the CANbus and prints read messages over USB Allows you to send messages via USB to the CANbus Use a terminal application like PuTTY for windows or MoSerial for Ubuntu.

01 Jun 2011

Hi Sam,

canopen_mastermode is build OK

but

canopen_slavemode gives error :

"No instance of constructor "mbed::CANMessage::CANMessage" matches the argument list (E289) ...in can_mbed.cpp line 58, coll 99

...which should be: Compiler Error 289: The types of your input values do not match the types expected in the declaration of your function.

Any idea, why?

01 Jun 2011

Oops. Change the type cast for m->data from (uint8_t*) to (char*)

This is correct:

CANMessage msg(m->cob_id, (char*)m->data, m->len, static_cast<CANType>(m->rtr), CANStandard);

02 Jun 2011

Thank you,

Yes, now both canopen_mastermode and canopen_slavemode are compiled with no errors.

29 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 And Then Slave enter input=1 or input=5 or input=any number but it 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 help me, thenks.

04 Dec 2015

@Melchior Pau..

Is it Possible for you to upload that USB to CAN code. I am making a project on CAN , and this might help me..Thank you