Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Howto build CAN-devices with CANopen Library

Hi

We're two students working on a project to simulate CAN devices connected to a master. We have to "build" these devices in LabView. We've been working with the CANopen Library and the Channel API.

We would prefer to use the CANopen Library, because it is easier that way to build the device's behaviour as it would be in "real-life". But the problem is, that the CANopen Library has been developed to build a CAN Master. Is there a way to bypass that. So that we could build the other side... a CAN device.

We figured out, that we simply could alter the COB-IDs for de PDOs, that would do it. But the whole SDO and Sync part isn't that easy to bypass.

Would be glad if we could get a tipp

Thank you in advance

Ranil Wijeyratne
0 Kudos
Message 1 of 8
(8,715 Views)

Hi,

I'm a little confused on the master/slave terminology you're using, however, as CAN (also Canopen) is really a peer bus. Any device on the CAN bus can transmit and receive messages as described below (from the NI-CAN User Manual):
"When a CAN device transmits data onto the network, an identifier that is unique throughout the network precedes the data. The identifier defines not only the content of the data, but also the priority. A CAN identifier, along with its associated data, is often referred to as a CAN Object. When a device transmits a message onto the CAN network, all other devices on the network receive that message
. Each receiving device
performs an acceptance test on the identifier to determine if the message is relevant to it. If the received identifier is not relevant to the device (such
as RPM received by an air conditioning controller), the device ignores the message.
When more than one CAN device transmits a message simultaneously, the identifier is used as a priority to determine which device gains access to the network. The lower the numerical value of the identifier, the higher its priority."

As you can see, you can use our CAN interface "slave" to receive commands from any other device on the CAN bus "master".

Also the Canopen Library is just the API for LabVIEW, both CAN and Canopen ends up in Bits which then will be send to the "Listeners"! They´re just on other Layers on the Programming. But both is really easy with LabVIEW

Hope this helps.

Alex Rudolph

NI Switzerland

Message 2 of 8
(8,699 Views)

Hello

Yes i understand the CAN  terminology.
But the problem is, that the LabView CANopen Library is designed to build masters applications.
Which makes sense when we use the library, it sends RxPDOs and receives TxPDOs, you can check Heartbeats of devices and send SDOs and define a timeout for the reply.

This is all fine, but we're working with Products of Selectron and have a running CAN Master (in Hardware) and want to build slave devices in LabView for simulation. Therefore we need the CANopen library the "other way around". We want to send TxPDOs to our Master and receive RxPDOs from the Master. We need to reply with ClientSDO Messages to ServerSDO Messages we get from the CAN Master.

Hope you understand the problem we have here.

Ranil Wijeyratne

 
0 Kudos
Message 3 of 8
(8,687 Views)
You are right the CANopen Library is working in Master mode. It is not possible to change it to Slave mode or bypass something to have it working as a slave, otherwise we would have implemented it as a feature.
The problem is that CANopen works based on CAN but with a Master/Slave communication protocoll. That means the master is sending a command to the slave to enable a specific communication state (NMT) and the Slave waits for this command in order to enable SDO communication for example.
The only chance to write your own Slave software is to use the Frame API. This API has a lot more functions then the Channel API and is able to handle remote frames which are essential for CANopen.
The buttom line: Thats not easy and you should first decide which functions to implement. I would start to write a simple NMT routine and a PDO loop which outputs data if a remote frame receives.
 
good luck.
 
DirkW
Message 4 of 8
(8,686 Views)
Hi

I was afraid to hear that. What i saw yet from the Frame API seemed quiet ... complex.

Actually we need to mainly implement these things:
  • Send TxPDOs if certain buttons in the Front Panel are pressed (Input Modules), and place the data values in the correct bytes of the PDO (according to the Hardware Spec)
  • Receive RxPDOs and read out the data bytes and set signals according to the contained data (Output Modules)

These two things are the most important part, it worked fine with the CANopen Library. But of course only because we bypassed the Rx & Tx problem by changing the COB-ID manually.

  • Set configuration parameters according to the SDO message's object identifier parameters and reply to the SDOs
  • Send heartbeats

It would be a great help if there would be some kind of example code with the Frame API. The problem is that time is getting an critical issue and it would help a lot to understand the frame api if we had an example.

Thank you very much for your quick answers!
That's really great

RanilW

Message Edited by pasln on 12-23-2006 05:41 AM

0 Kudos
Message 5 of 8
(8,679 Views)
Hello Ranil,
 
We are also working on CANopen Protocol Application. We have CAN interface from Adlink. and we have to develop CANopen appplication for this CAN interface. Could you please provide the CANopen library so that we can analyse it and develop for our application.
 
 
Your help is appreciated.
Please reply as soon as possible.
 
Regards
Arif
0 Kudos
Message 6 of 8
(8,614 Views)
Hi,
 
We have a CAN interface. We want to implement CANopen Library for this interface.
Can anybody help us in development of CANopen library.
 
The CAN interface which we are using is a third party card. Can the same CAN APIs be used for creating CANopen Library.
 
Version used: Labview 7.1
 
Regards,
Arif
 
0 Kudos
Message 7 of 8
(8,611 Views)

Hi,

Attached you can find some basic CANopen VIs writing and reading SDO and PDO data. I created them a long time ago and they are written as a Master as well. But you should be able to modify them in order to work as a Slave. A Slave is waiting for a remote frame or a NMT command in order to get operational or send data. Thus you need a continuously running loop checking for incommi9ng requests. The examples should help you dealing with COB IDs and NMT commands.

For Arif:

All this stuff is based on the NI-CAN api, but perhaps you can find the same api functions with your adlink board.

DirkW

0 Kudos
Message 8 of 8
(8,594 Views)